[comp.sys.amiga] Warrior Cycles Source

rmariani@watmum.waterloo.edu (Rico Mariani) (03/07/88)

Warrior cycles (source and binary) has been sent to the moderators.
For those of you who already have a copy of it, there is a bug
which can cause you system to thrash or crash...  the cycles server
can sometimes ask timer.device for delays of length zero.  This is
broken...  depending on your machine bad things may or may not happen
(my system always worked fine so I never noticed the problem).  In
any case it is a bad thing to do and the fix is trivial... I believe
that this is whats causing the problems some people have experienced.
Anyways, the source I sent to the moderators has the fix in place
and I'll give just the fix here for those who already have the source.

In the file cycles.c change the body of the if statement for handling
timer requests so that it looks like this:

	    if ((TIMEREQ *)msg == tr) { /* time request reply */
		    if (num_alive) {
		    	move_cycles(&cycle_list);
			Timer_Post(tr,
		    		TIME*num_alive/1000,	       /* seconds */
			    	((num_alive*TIME)%1000)*1000   /* micros  */
		              );
		    }
		    else {
			    Timer_Post(tr,TIME/1000,(TIME%1000)*1000);
		    }
		    continue;
	    }

The old version just did a move_cycles(...) and then a Timer_Post(tr,...)
if num_alive was 0 (as it at the start of the game before and cycles
have registered, a wakeup event for time 0,0 was generated... this is
bad news.  Please make this fix to all versions that are out there...
C-A, why does asking the timer device to send you a message in 0 time
cause so many problems?  

	-Rico

dillon@CORY.BERKELEY.EDU (Matt Dillon) (03/08/88)

>if num_alive was 0 (as it at the start of the game before and cycles
>have registered, a wakeup event for time 0,0 was generated... this is
>bad news.  Please make this fix to all versions that are out there...
>C-A, why does asking the timer device to send you a message in 0 time
>cause so many problems?  
>
>	-Rico
>

	I have never had problems giving the timer.device a 0 time delay.
Delay(0) yes, WaitForChar(fd,0) yes, but not the timer.device .  Are you
sure it is the timer.device??

					-Matt