# HG changeset patch # User truelight # Date 1182542661 0 # Node ID 71e174292e42e124f025a7591d380826e1e2915b # Parent ea1d1e2fc80c5a1256318710b58a876715970670 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on -Codechange: renamed _timer_counter to _palette_animation_counter, as that is what it is diff -r ea1d1e2fc80c -r 71e174292e42 src/genworld_gui.cpp --- a/src/genworld_gui.cpp Fri Jun 22 19:42:00 2007 +0000 +++ b/src/genworld_gui.cpp Fri Jun 22 20:04:21 2007 +0000 @@ -875,14 +875,12 @@ _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 -r ea1d1e2fc80c -r 71e174292e42 src/gfx.cpp --- a/src/gfx.cpp Fri Jun 22 19:42:00 2007 +0000 +++ b/src/gfx.cpp Fri Jun 22 20:04:21 2007 +0000 @@ -665,8 +665,8 @@ _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 @@ 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 @@ /* 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 @@ } 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 -r ea1d1e2fc80c -r 71e174292e42 src/misc.cpp --- a/src/misc.cpp Fri Jun 22 19:42:00 2007 +0000 +++ b/src/misc.cpp Fri Jun 22 20:04:21 2007 +0000 @@ -110,6 +110,7 @@ _pause_game = 0; _fast_forward = 0; _tick_counter = 0; + _realtime_tick = 0; _date_fract = 0; _cur_tileloop_tile = 0; diff -r ea1d1e2fc80c -r 71e174292e42 src/openttd.cpp --- a/src/openttd.cpp Fri Jun 22 19:42:00 2007 +0000 +++ b/src/openttd.cpp Fri Jun 22 20:04:21 2007 +0000 @@ -1099,7 +1099,7 @@ } _caret_timer += 3; - _timer_counter += 8; + _palette_animation_counter += 8; CursorTick(); #ifdef ENABLE_NETWORK diff -r ea1d1e2fc80c -r 71e174292e42 src/variables.h --- a/src/variables.h Fri Jun 22 19:42:00 2007 +0000 +++ b/src/variables.h Fri Jun 22 20:04:21 2007 +0000 @@ -270,10 +270,11 @@ 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 -r ea1d1e2fc80c -r 71e174292e42 src/video/cocoa_v.mm --- a/src/video/cocoa_v.mm Fri Jun 22 19:42:00 2007 +0000 +++ b/src/video/cocoa_v.mm Fri Jun 22 20:04:21 2007 +0000 @@ -685,6 +685,7 @@ 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 @@ } 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 -r ea1d1e2fc80c -r 71e174292e42 src/video/sdl_v.cpp --- a/src/video/sdl_v.cpp Fri Jun 22 19:42:00 2007 +0000 +++ b/src/video/sdl_v.cpp Fri Jun 22 20:04:21 2007 +0000 @@ -442,6 +442,7 @@ 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 @@ } 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 -r ea1d1e2fc80c -r 71e174292e42 src/video/win32_v.cpp --- a/src/video/win32_v.cpp Fri Jun 22 19:42:00 2007 +0000 +++ b/src/video/win32_v.cpp Fri Jun 22 20:04:21 2007 +0000 @@ -795,6 +795,7 @@ { 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 @@ } 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 -r ea1d1e2fc80c -r 71e174292e42 src/window.cpp --- a/src/window.cpp Fri Jun 22 19:42:00 2007 +0000 +++ b/src/window.cpp Fri Jun 22 20:04:21 2007 +0000 @@ -1639,8 +1639,8 @@ 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 @@ 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;