Re: SceneDesc extension


06 Nov 1995 11:47:36 GMT

In article <66.3162.1727@tabb.com> joe.mason@tabb.com (Joe Mason) writes:

I'm trying to extend Richard Barnett's "scenery.inf" to allow for more
then one name in a SceneDesc property.

My replacement makes the property like this:

sceneDesc
2 'rock' 'outcrop' "Yep, that's a rock outcrop."
1 'tree' "Straight-trunked and inaccessible."
1 'mud' "It's slimy, dark and malodorous."
1 'rushes' "They're home to insects and swamp birds."

My code:

[ GetScDescAddr loc spWord addr len i j;
! loc is the player's location, passed from the previous routine
addr = loc.&sceneDesc;
len = loc.#sceneDesc;
if (addr-->0 == NULL)
return 0;
for (i = 0 : i < len : i = i + addr-->i + 2)
for (j = i + 1 : j < i + addr-->i + 1: j++)
if (spWord == addr-->j)
return addr-->(i + addr-->i + 1);
return 0;
];

Ok, now my problem: it seems to work fine when I type, say, "look rock",
"look outcrop" or "look mud", but as soon as I type something that's
not there (say, "look birds") the game crashes and returns:

"Fatal error: Game file read error (PC = 9f23)"

Does anybody know what I'm doing wrong?

joe --

glad to see you're using my code; i think the problem is due to a bug
in the original which causes your enhancement to break.

i put some tracing of i and j into your function, and found that (in the
above example) len = 26 and not 13; i realize now that it's the length in
bytes of the property data (and a-->b accesses the bth word offset from a).
thus you need to change the `i < len' condition to `i < (len / 2)'.

(your version fails, whereas the original is ok, because it calculates the
limit for j from the property data; so when addr-->i falls off the end of
the data you get a junk limit for j & the j-loop reads too far...)

i'll be posting an update of the sceneDesc stuff soon, with this fix and a
couple of enhancements.

(can anyone tell me why GetScDescAddr is called twice?)

-- richard

-- 
_______________________________________________________________________________

richard barnett richard@wg.icl.co.uk _______________________________________________________________________________