diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/genworld_gui.cpp | 8 | ||||
-rw-r--r-- | src/gfx.cpp | 12 | ||||
-rw-r--r-- | src/misc.cpp | 1 | ||||
-rw-r--r-- | src/openttd.cpp | 2 | ||||
-rw-r--r-- | src/variables.h | 3 | ||||
-rw-r--r-- | src/video/cocoa_v.mm | 3 | ||||
-rw-r--r-- | src/video/sdl_v.cpp | 3 | ||||
-rw-r--r-- | src/video/win32_v.cpp | 3 | ||||
-rw-r--r-- | src/window.cpp | 8 |
9 files changed, 26 insertions, 17 deletions
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 4163d168a..43b204161 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -875,14 +875,12 @@ static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total _tp.percent = percent_table[cls]; } - /* Don't update the screen too often. So update it once in every 200ms. - * However, the _tick_counter increases by 8 every 30ms, so compensate - * for that. */ - if (!_network_dedicated && _tp.timer != 0 && _timer_counter - _tp.timer < (200 * 8 / 30)) return; + /* Don't update the screen too often. So update it once in every 200ms */ + if (!_network_dedicated && _tp.timer != 0 && _realtime_tick - _tp.timer < 200) return; /* Percentage is about the number of completed tasks, so 'current - 1' */ _tp.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_tp.current == 0 ? 0 : _tp.current - 1) / _tp.total; - _tp.timer = _timer_counter; + _tp.timer = _realtime_tick; if (_network_dedicated) { static uint last_percent = 0; diff --git a/src/gfx.cpp b/src/gfx.cpp index 3028f444a..a60c4b9b7 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -665,8 +665,8 @@ void GfxInitPalettes() _pal_count_dirty = 255; } -#define EXTR(p, q) (((uint16)(_timer_counter * (p)) * (q)) >> 16) -#define EXTR2(p, q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16) +#define EXTR(p, q) (((uint16)(_palette_animation_counter * (p)) * (q)) >> 16) +#define EXTR2(p, q) (((uint16)(~_palette_animation_counter * (p)) * (q)) >> 16) void DoPaletteAnimations() { @@ -681,10 +681,10 @@ void DoPaletteAnimations() Colour old_val[38]; uint i; uint j; - uint old_tc = _timer_counter; + uint old_tc = _palette_animation_counter; if (blitter != NULL && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) { - _timer_counter = 0; + _palette_animation_counter = 0; } d = &_cur_palette[217]; @@ -727,7 +727,7 @@ void DoPaletteAnimations() /* Radio tower blinking */ { - byte i = (_timer_counter >> 1) & 0x7F; + byte i = (_palette_animation_counter >> 1) & 0x7F; byte v; (v = 255, i < 0x3f) || @@ -779,7 +779,7 @@ void DoPaletteAnimations() } if (blitter != NULL && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) { - _timer_counter = old_tc; + _palette_animation_counter = old_tc; } else { if (memcmp(old_val, &_cur_palette[217], c * sizeof(*old_val)) != 0) { _pal_first_dirty = 217; diff --git a/src/misc.cpp b/src/misc.cpp index 8c80e6035..802b6aabc 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -110,6 +110,7 @@ void InitializeGame(int mode, uint size_x, uint size_y) _pause_game = 0; _fast_forward = 0; _tick_counter = 0; + _realtime_tick = 0; _date_fract = 0; _cur_tileloop_tile = 0; diff --git a/src/openttd.cpp b/src/openttd.cpp index 359f2e0b6..13ce248aa 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1099,7 +1099,7 @@ void GameLoop() } _caret_timer += 3; - _timer_counter += 8; + _palette_animation_counter += 8; CursorTick(); #ifdef ENABLE_NETWORK diff --git a/src/variables.h b/src/variables.h index 8a4067ba9..b3aec9f29 100644 --- a/src/variables.h +++ b/src/variables.h @@ -270,10 +270,11 @@ struct Cheats { VARDEF Cheats _cheats; /* NOSAVE: Used in palette animations only, not really important. */ -VARDEF int _timer_counter; +VARDEF int _palette_animation_counter; VARDEF uint32 _frame_counter; +VARDEF uint32 _realtime_tick; VARDEF bool _is_old_ai_player; // current player is an oldAI player? (enables a lot of cheats..) diff --git a/src/video/cocoa_v.mm b/src/video/cocoa_v.mm index f4dfc5b77..8e13605d8 100644 --- a/src/video/cocoa_v.mm +++ b/src/video/cocoa_v.mm @@ -685,6 +685,7 @@ static bool QZ_PollEvent() static void QZ_GameLoop() { uint32 cur_ticks = GetTick(); + uint32 last_cur_ticks = cur_ticks; uint32 next_tick = cur_ticks + 30; uint32 pal_tick = 0; #ifdef _DEBUG @@ -731,6 +732,8 @@ static void QZ_GameLoop() } cur_ticks = GetTick(); + _realtime_tick += cur_ticks - last_cur_ticks; + last_cur_ticks = cur_ticks; if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) { next_tick = cur_ticks + 30; diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 1e11b32c3..782ac1521 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -442,6 +442,7 @@ static void SdlVideoStop() static void SdlVideoMainLoop() { uint32 cur_ticks = SDL_CALL SDL_GetTicks(); + uint32 last_cur_ticks = cur_ticks; uint32 next_tick = cur_ticks + 30; uint32 pal_tick = 0; uint32 mod; @@ -471,6 +472,8 @@ static void SdlVideoMainLoop() } cur_ticks = SDL_CALL SDL_GetTicks(); + _realtime_tick += cur_ticks - last_cur_ticks; + last_cur_ticks = cur_ticks; if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) { next_tick = cur_ticks + 30; diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 1508e1ebd..583f7f84b 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -795,6 +795,7 @@ static void Win32GdiMainLoop() { MSG mesg; uint32 cur_ticks = GetTickCount(); + uint32 last_cur_ticks = cur_ticks; uint32 next_tick = cur_ticks + 30; _wnd.running = true; @@ -822,6 +823,8 @@ static void Win32GdiMainLoop() } cur_ticks = GetTickCount(); + _realtime_tick += cur_ticks - last_cur_ticks; + last_cur_ticks = cur_ticks; if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) { next_tick = cur_ticks + 30; _ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0; diff --git a/src/window.cpp b/src/window.cpp index b00e02230..24e2cbec8 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1639,8 +1639,8 @@ enum MouseClick { MC_RIGHT, MC_DOUBLE_LEFT, - MAX_OFFSET_DOUBLE_CLICK = 5, - TIME_BETWEEN_DOUBLE_CLICK = 50, + MAX_OFFSET_DOUBLE_CLICK = 5, ///< How much the mouse is allowed to move to call it a double click + TIME_BETWEEN_DOUBLE_CLICK = 500, ///< Time between 2 left clicks before it becoming a double click, in ms }; void MouseLoop(MouseClick click, int mousewheel) @@ -1759,12 +1759,12 @@ void HandleMouseEvents() click = MC_NONE; if (_left_button_down && !_left_button_clicked) { click = MC_LEFT; - if (double_click_time != 0 && _tick_counter - double_click_time < TIME_BETWEEN_DOUBLE_CLICK && + if (double_click_time != 0 && _realtime_tick - double_click_time < TIME_BETWEEN_DOUBLE_CLICK && double_click_x != 0 && abs(_cursor.pos.x - double_click_x) < MAX_OFFSET_DOUBLE_CLICK && double_click_y != 0 && abs(_cursor.pos.y - double_click_y) < MAX_OFFSET_DOUBLE_CLICK) { click = MC_DOUBLE_LEFT; } - double_click_time = _tick_counter; + double_click_time = _realtime_tick; double_click_x = _cursor.pos.x; double_click_y = _cursor.pos.y; _left_button_clicked = true; |