diff options
author | rubidium <rubidium@openttd.org> | 2007-01-10 15:00:20 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-01-10 15:00:20 +0000 |
commit | 4c2b993d1ded0a76ea5de95a98884951cf983d7f (patch) | |
tree | 19fd2d766e78e387fca929a0a80d245f456b373f /src/video/win32_v.c | |
parent | f3b4cf10b651e131ea37d8bdf0d1aa6e74405029 (diff) | |
download | openttd-4c2b993d1ded0a76ea5de95a98884951cf983d7f.tar.xz |
(svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
Diffstat (limited to 'src/video/win32_v.c')
-rw-r--r-- | src/video/win32_v.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/video/win32_v.c b/src/video/win32_v.c index 7588653f0..eab832ae5 100644 --- a/src/video/win32_v.c +++ b/src/video/win32_v.c @@ -786,11 +786,14 @@ static void CheckPaletteAnim(void) static void Win32GdiMainLoop(void) { MSG mesg; - uint32 next_tick = GetTickCount() + 30, cur_ticks; + uint32 cur_ticks = GetTickCount(); + uint32 next_tick = cur_ticks + 30; _wnd.running = true; for (;;) { + uint32 prev_cur_ticks = cur_ticks; // to check for wrapping + while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) { InteractiveRandom(); // randomness DispatchMessage(&mesg); @@ -810,11 +813,8 @@ static void Win32GdiMainLoop(void) } cur_ticks = GetTickCount(); - 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 = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0; _shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0; #ifdef _DEBUG |