src/video/win32_v.c
branchcustombridgeheads
changeset 5648 1608018c5ff2
parent 5643 3778051e8095
equal deleted inserted replaced
5647:cbde85c8c878 5648:1608018c5ff2
   784 }
   784 }
   785 
   785 
   786 static void Win32GdiMainLoop(void)
   786 static void Win32GdiMainLoop(void)
   787 {
   787 {
   788 	MSG mesg;
   788 	MSG mesg;
   789 	uint32 next_tick = GetTickCount() + 30, cur_ticks;
   789 	uint32 cur_ticks = GetTickCount();
       
   790 	uint32 next_tick = cur_ticks + 30;
   790 
   791 
   791 	_wnd.running = true;
   792 	_wnd.running = true;
   792 
   793 
   793 	for (;;) {
   794 	for (;;) {
       
   795 		uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
       
   796 
   794 		while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) {
   797 		while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) {
   795 			InteractiveRandom(); // randomness
   798 			InteractiveRandom(); // randomness
   796 			DispatchMessage(&mesg);
   799 			DispatchMessage(&mesg);
   797 		}
   800 		}
   798 		if (_exit_game) return;
   801 		if (_exit_game) return;
   808 		} else if (_fast_forward & 2) {
   811 		} else if (_fast_forward & 2) {
   809 			_fast_forward = 0;
   812 			_fast_forward = 0;
   810 		}
   813 		}
   811 
   814 
   812 		cur_ticks = GetTickCount();
   815 		cur_ticks = GetTickCount();
   813 		if ((_fast_forward && !_pause) || cur_ticks > next_tick)
   816 		if (cur_ticks >= next_tick || (_fast_forward && !_pause) || cur_ticks < prev_cur_ticks) {
   814 			next_tick = cur_ticks;
   817 			next_tick = cur_ticks + 30;
   815 
       
   816 		if (cur_ticks == next_tick) {
       
   817 			next_tick += 30;
       
   818 			_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0;
   818 			_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0;
   819 			_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0;
   819 			_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0;
   820 #ifdef _DEBUG
   820 #ifdef _DEBUG
   821 			_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0;
   821 			_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0;
   822 #endif
   822 #endif