summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-19 10:35:59 +0000
committerrubidium <rubidium@openttd.org>2010-11-19 10:35:59 +0000
commitab44c91778618147efd12f62fd3b74df872e599d (patch)
treed9ca07e5fd6a7f6ead55dc34eac6c18a53e93ac5 /src
parent43692e514c476923e35d59fc2fe9053e381a4920 (diff)
downloadopenttd-ab44c91778618147efd12f62fd3b74df872e599d.tar.xz
(svn r21252) -Codechange: introduce a constant for the number of milliseconds per game tick and use it
Diffstat (limited to 'src')
-rw-r--r--src/gfx_type.h3
-rw-r--r--src/video/allegro_v.cpp4
-rw-r--r--src/video/cocoa/event.mm4
-rw-r--r--src/video/dedicated_v.cpp4
-rw-r--r--src/video/sdl_v.cpp4
-rw-r--r--src/video/win32_v.cpp4
6 files changed, 13 insertions, 10 deletions
diff --git a/src/gfx_type.h b/src/gfx_type.h
index 8c4bf918f..b1ee21172 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 c4a8341c9..bcec85333 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 bf643955e..7d7fa4cf8 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 2e35f4678..f2ebd0f00 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 9e0a38fa9..f16ca69d7 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 755d6f17a..f411dcdce 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;