From 4c2b993d1ded0a76ea5de95a98884951cf983d7f Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 10 Jan 2007 15:00:20 +0000 Subject: (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient. --- src/video/cocoa_v.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/video/cocoa_v.m') diff --git a/src/video/cocoa_v.m b/src/video/cocoa_v.m index 8ea16315a..46518445b 100644 --- a/src/video/cocoa_v.m +++ b/src/video/cocoa_v.m @@ -652,8 +652,8 @@ static bool QZ_PollEvent(void) static void QZ_GameLoop(void) { - uint32 next_tick = GetTick() + 30; - uint32 cur_ticks; + uint32 cur_ticks = GetTick(); + uint32 next_tick = cur_ticks + 30; uint32 pal_tick = 0; #ifdef _DEBUG uint32 et0, et, st0, st; @@ -680,6 +680,7 @@ static void QZ_GameLoop(void) CSleep(1); for (;;) { + uint32 prev_cur_ticks; // to check for wrapping InteractiveRandom(); // randomness while (QZ_PollEvent()) {} @@ -698,11 +699,8 @@ static void QZ_GameLoop(void) } cur_ticks = GetTick(); - if ((_fast_forward && !_pause) || cur_ticks > next_tick) - next_tick = cur_ticks; - - if (cur_ticks == next_tick) { - next_tick += 30; + if (cur_ticks >= next_tick || (_fast_forward && !_pause) || cur_ticks < prev_cur_ticks) { + next_tick = cur_ticks + 30; _ctrl_pressed = !!(_cocoa_video_data.current_mods & NSControlKeyMask); _shift_pressed = !!(_cocoa_video_data.current_mods & NSShiftKeyMask); -- cgit v1.2.3-70-g09d2