Changeset - r7018:50bc56022ec1
[Not reviewed]
master
0 9 0
truelight - 17 years ago 2007-06-22 20:04:21
truelight@openttd.org
(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
9 files changed with 26 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/genworld_gui.cpp
Show inline comments
 
@@ -875,14 +875,12 @@ static void _SetGeneratingWorldProgress(
 
		_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;
src/gfx.cpp
Show inline comments
 
@@ -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;
src/misc.cpp
Show inline comments
 
@@ -110,6 +110,7 @@ void InitializeGame(int mode, uint size_
 
	_pause_game = 0;
 
	_fast_forward = 0;
 
	_tick_counter = 0;
 
	_realtime_tick = 0;
 
	_date_fract = 0;
 
	_cur_tileloop_tile = 0;
 

	
src/openttd.cpp
Show inline comments
 
@@ -1099,7 +1099,7 @@ void GameLoop()
 
	}
 

	
 
	_caret_timer += 3;
 
	_timer_counter += 8;
 
	_palette_animation_counter += 8;
 
	CursorTick();
 

	
 
#ifdef ENABLE_NETWORK
src/variables.h
Show inline comments
 
@@ -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..)
 

	
src/video/cocoa_v.mm
Show inline comments
 
@@ -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;
 

	
src/video/sdl_v.cpp
Show inline comments
 
@@ -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;
 

	
src/video/win32_v.cpp
Show inline comments
 
@@ -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;
src/window.cpp
Show inline comments
 
@@ -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;
0 comments (0 inline, 0 general)