From ab44c91778618147efd12f62fd3b74df872e599d Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 19 Nov 2010 10:35:59 +0000 Subject: [PATCH] (svn r21252) -Codechange: introduce a constant for the number of milliseconds per game tick and use it --- src/gfx_type.h | 3 +++ src/video/allegro_v.cpp | 4 ++-- src/video/cocoa/event.mm | 4 ++-- src/video/dedicated_v.cpp | 4 ++-- src/video/sdl_v.cpp | 4 ++-- src/video/win32_v.cpp | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/gfx_type.h b/src/gfx_type.h index 8c4bf918fe..b1ee21172c 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -259,4 +259,7 @@ enum SpriteType { ST_INVALID = 4, ///< Pseudosprite or other unusable sprite, used only internally }; +/** The number of milliseconds per game tick. */ +static const uint MILLISECONDS_PER_TICK = 30; + #endif /* GFX_TYPE_H */ diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index c4a8341c91..bcec853332 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -474,7 +474,7 @@ void VideoDriver_Allegro::MainLoop() { uint32 cur_ticks = GetTime(); uint32 last_cur_ticks = cur_ticks; - uint32 next_tick = cur_ticks + 30; + uint32 next_tick = cur_ticks + MILLISECONDS_PER_TICK; uint32 pal_tick = 0; for (;;) { @@ -501,7 +501,7 @@ void VideoDriver_Allegro::MainLoop() if (cur_ticks >= next_tick || (_fast_forward && !_pause_mode) || cur_ticks < prev_cur_ticks) { _realtime_tick += cur_ticks - last_cur_ticks; last_cur_ticks = cur_ticks; - next_tick = cur_ticks + 30; + next_tick = cur_ticks + MILLISECONDS_PER_TICK; bool old_ctrl_pressed = _ctrl_pressed; diff --git a/src/video/cocoa/event.mm b/src/video/cocoa/event.mm index bf643955e9..7d7fa4cf8f 100644 --- a/src/video/cocoa/event.mm +++ b/src/video/cocoa/event.mm @@ -606,7 +606,7 @@ void QZ_GameLoop() { uint32 cur_ticks = GetTick(); uint32 last_cur_ticks = cur_ticks; - uint32 next_tick = cur_ticks + 30; + uint32 next_tick = cur_ticks + MILLISECONDS_PER_TICK; uint32 pal_tick = 0; #ifdef _DEBUG @@ -655,7 +655,7 @@ void QZ_GameLoop() if (cur_ticks >= next_tick || (_fast_forward && !_pause_mode) || cur_ticks < prev_cur_ticks) { _realtime_tick += cur_ticks - last_cur_ticks; last_cur_ticks = cur_ticks; - next_tick = cur_ticks + 30; + next_tick = cur_ticks + MILLISECONDS_PER_TICK; bool old_ctrl_pressed = _ctrl_pressed; diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index 2e35f4678c..f2ebd0f00c 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -256,7 +256,7 @@ static void DedicatedHandleKeyInput() void VideoDriver_Dedicated::MainLoop() { uint32 cur_ticks = GetTime(); - uint32 next_tick = cur_ticks + 30; + uint32 next_tick = cur_ticks + MILLISECONDS_PER_TICK; /* Signal handlers */ #if defined(UNIX) || defined(PSP) @@ -305,7 +305,7 @@ void VideoDriver_Dedicated::MainLoop() cur_ticks = GetTime(); _realtime_tick += cur_ticks - prev_cur_ticks; if (cur_ticks >= next_tick || cur_ticks < prev_cur_ticks || _ddc_fastforward) { - next_tick = cur_ticks + 30; + next_tick = cur_ticks + MILLISECONDS_PER_TICK; GameLoop(); UpdateWindows(); diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 9e0a38fa99..f16ca69d7f 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -497,7 +497,7 @@ void VideoDriver_SDL::MainLoop() { uint32 cur_ticks = SDL_CALL SDL_GetTicks(); uint32 last_cur_ticks = cur_ticks; - uint32 next_tick = cur_ticks + 30; + uint32 next_tick = cur_ticks + MILLISECONDS_PER_TICK; uint32 pal_tick = 0; uint32 mod; int numkeys; @@ -554,7 +554,7 @@ void VideoDriver_SDL::MainLoop() if (cur_ticks >= next_tick || (_fast_forward && !_pause_mode) || cur_ticks < prev_cur_ticks) { _realtime_tick += cur_ticks - last_cur_ticks; last_cur_ticks = cur_ticks; - next_tick = cur_ticks + 30; + next_tick = cur_ticks + MILLISECONDS_PER_TICK; bool old_ctrl_pressed = _ctrl_pressed; diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 755d6f17a2..f411dcdcec 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -832,7 +832,7 @@ void VideoDriver_Win32::MainLoop() MSG mesg; uint32 cur_ticks = GetTickCount(); uint32 last_cur_ticks = cur_ticks; - uint32 next_tick = cur_ticks + 30; + uint32 next_tick = cur_ticks + MILLISECONDS_PER_TICK; _wnd.running = true; @@ -862,7 +862,7 @@ void VideoDriver_Win32::MainLoop() if (cur_ticks >= next_tick || (_fast_forward && !_pause_mode) || cur_ticks < prev_cur_ticks) { _realtime_tick += cur_ticks - last_cur_ticks; last_cur_ticks = cur_ticks; - next_tick = cur_ticks + 30; + next_tick = cur_ticks + MILLISECONDS_PER_TICK; bool old_ctrl_pressed = _ctrl_pressed;