[net.sources.bugs] Spell Casting Bug in LARN 12.0

wolenty@inuxj.UUCP (R Wolenty) (08/29/86)

I ran into a bug that has been mentioned before: when casting
lightening I experienced total lockup.  Needless to say, I was
having my best game ever when this unfortunate event occurred.
After some experimentation in wizard mode I noticed that this
only occurred when casting lightening not balls of fire, cones
of cold or the like.  The difference was in the call to display
the spell: lightening(being the fast stuff it is) only had a delay of
1 ms as opposed to the 20 to 30 ms in other spells.  Looking
into 'nap.c' there is a routine to generate millisecond delays.
This routine gets a time value and assigns it to the variable
matchclock:
		matchclock = times(some_arg).
		
Then matchclock is incremented by the amount of time you want to
delay:
		matchclock += (time/x)
	Where x = 17 for DEC systems and 10 for AT&T systems.
	
Then the crucial loop is then:
		while(matchclock < times(some_arg));

Note that this loop condition is immediately false because we just added
some time interval to matchclock so the function returns.

The problem is when this routine is called with a delay of 1 ms 1/x is
0 as far as integers are concerned so no time gets added to matchclock.
Now if you are so unfortunate as to have the system clock increment
between matchclock = times() and the while statement, matchclock will
be less than the system time for one very long while!
So in short go into nap.c and make the while statement read:
		while(matchclock > times(some_arg));

Sorry to be so long with this but after losing that wonderful game 
I needed the therapy!

					Ron Wolenty
					AT&T Information Systems
					Indianapolis, IN