On Mon, 3 Sep 2001, Luca wrote: > PULSE_VIOLENCE and i noticed that PULSE_VIOLENCE was (2 RL_SECOND) and (2 > RL_SECOND) => * PASSES_PER_SEC => (1000000 / OPT_USEC) > and OPT_USEC => 100000 /* 10 passes per sec */. RL_SECOND: A real (RL) second. PASSES_PER_SEC: The number of times the main loop is executed in a second. OPT_USEC: The amount of time (microseconds) spent sleeping in the loop. It's generally fairly obvious if you know how the loop works, but it can be a bit confusing for newbies. In general, the main loop works by doing: * Scan for I/O on server socket. * Dispatch I/O events. * Sleep for a short time (OPT_USEC). * Handle events at this interval. The sleep prevents the code from being executed as fast as possible over and over and over again, which would be CPU-intensive. The sleep also helps in timing when world events should happen (such as fight rounds). If we're sleeping OPT_USEC per loop, then, obviously, there's only so many times per second the loop can be executed. In this case, we determine this using the PASSES_PER_SEC macro. The constant 1000000 is the number of microseconds per second. Since OPT_USEC is in microseconds (which is what a usec is; u is meant to represent the Greek character mu), dividing the number of microseconds per second by the number of milliseconds to sleep gives, obviously, the number of times per second we're going to loop (PASSES_PER_SEC). If you're sleeping two real seconds, then you need to sleep 2 * the number of passes per second (10) or for 20 passes. It's that simple. -dak -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/06/01 PST