tweak how timers stored

This commit is contained in:
ehouse 2005-08-21 14:07:29 +00:00
parent a24e7d18b3
commit cca35b28db

View file

@ -553,6 +553,7 @@ ceInitAndStartBoard( CEAppGlobals* globals, XP_Bool newGame, CeGamePrefs* gp,
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
if ( !!addr ) { if ( !!addr ) {
XP_ASSERT( globals->game.comms != NULL );
comms_setAddr( globals->game.comms, addr ); comms_setAddr( globals->game.comms, addr );
} }
#endif #endif
@ -1467,10 +1468,13 @@ debug_saveCurState( CEAppGlobals* globals )
static void static void
ceFireTimer( CEAppGlobals* globals, XWTimerReason why ) ceFireTimer( CEAppGlobals* globals, XWTimerReason why )
{ {
TimerProc proc = globals->timerProcs[why-1]; TimerProc proc;
void* closure = globals->timerClosures[why-1]; void* closure;
proc = globals->timerProcs[why];
closure = globals->timerClosures[why];
(*proc)( closure, why ); (*proc)( closure, why );
} } /* ceFireTimer */
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
static XP_Bool static XP_Bool
@ -1712,11 +1716,11 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|| why == TIMER_HEARTBEAT || why == TIMER_HEARTBEAT
#endif #endif
) { ) {
XP_ASSERT( why < TIMER_NUM_PLUS_ONE ); XP_ASSERT( why < NUM_TIMERS_PLUS_ONE );
/* Kill since they otherwise repeat, but kill before firing /* Kill since they otherwise repeat, but kill before firing
as fired proc may set another. */ as fired proc may set another. */
(void)KillTimer( hWnd, globals->timerIDs[why-1] ); (void)KillTimer( hWnd, globals->timerIDs[why] );
ceFireTimer( globals, why ); ceFireTimer( globals, why );
} }
@ -2239,9 +2243,9 @@ ce_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
XP_U32 timerID; XP_U32 timerID;
XP_U32 howLong; XP_U32 howLong;
XP_ASSERT( why < TIMER_NUM_PLUS_ONE ); XP_ASSERT( why < NUM_TIMERS_PLUS_ONE );
globals->timerProcs[why-1] = proc; globals->timerProcs[why] = proc;
globals->timerClosures[why-1] = closure; globals->timerClosures[why] = closure;
switch ( why ) { switch ( why ) {
case TIMER_PENDOWN: case TIMER_PENDOWN:
@ -2261,7 +2265,7 @@ ce_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
} }
timerID = SetTimer( globals->hWnd, why, howLong, NULL); timerID = SetTimer( globals->hWnd, why, howLong, NULL);
globals->timerIDs[why-1] = timerID; globals->timerIDs[why] = timerID;
} /* ce_util_setTimer */ } /* ce_util_setTimer */
static void static void