1
0
Fork 0

(svn r8174) -Backport from trunk (r8027, r8028, r8043, r8132):

- (FS#486) pause command issues with shift-pressed did not pause the game, interference with pause_on_join (r8027)
 - overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient (r8028, r8043)
 - The game could crash when the chat key (<ENTER>) is pressed too quickly during join (r8132)
release/0.5
Darkvater 2007-01-17 00:20:23 +00:00
parent f08141ae48
commit 06367834c6
6 changed files with 32 additions and 30 deletions

View File

@ -463,7 +463,11 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
_docommand_recursive = 1; _docommand_recursive = 1;
// cost estimation only? // cost estimation only?
if (!IsGeneratingWorld() && _shift_pressed && IsLocalPlayer() && !(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR))) { if (!IsGeneratingWorld() &&
_shift_pressed &&
IsLocalPlayer() &&
!(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR)) &&
(cmd & 0xFF) != CMD_PAUSE) {
// estimate the cost. // estimate the cost.
res = proc(tile, flags, p1, p2); res = proc(tile, flags, p1, p2);
if (CmdFailed(res)) { if (CmdFailed(res)) {

View File

@ -2308,6 +2308,8 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index); const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
bool teamchat = false; bool teamchat = false;
if (cio == NULL) break;
/* Only players actually playing can speak to team. Eg spectators cannot */ /* Only players actually playing can speak to team. Eg spectators cannot */
if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) { if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
const NetworkClientInfo *ci; const NetworkClientInfo *ci;
@ -2329,8 +2331,10 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates
if (_networking) { if (_networking) {
const NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index); const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
ShowNetworkChatQueryWindow(DESTTYPE_TEAM, ci->client_playas); if (cio == NULL) break;
ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas);
} }
break; break;
#endif #endif

View File

@ -652,8 +652,8 @@ static bool QZ_PollEvent(void)
static void QZ_GameLoop(void) static void QZ_GameLoop(void)
{ {
uint32 next_tick = GetTick() + 30; uint32 cur_ticks = GetTick();
uint32 cur_ticks; uint32 next_tick = cur_ticks + 30;
uint32 pal_tick = 0; uint32 pal_tick = 0;
#ifdef _DEBUG #ifdef _DEBUG
uint32 et0, et, st0, st; uint32 et0, et, st0, st;
@ -682,6 +682,7 @@ static void QZ_GameLoop(void)
CSleep(1); CSleep(1);
for (;;) { for (;;) {
uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
InteractiveRandom(); // randomness InteractiveRandom(); // randomness
while (QZ_PollEvent()) {} while (QZ_PollEvent()) {}
@ -700,11 +701,8 @@ static void QZ_GameLoop(void)
} }
cur_ticks = GetTick(); cur_ticks = GetTick();
if ((_fast_forward && !_pause) || cur_ticks > next_tick) if (cur_ticks >= next_tick || (_fast_forward && !_pause) || cur_ticks < prev_cur_ticks) {
next_tick = cur_ticks; next_tick = cur_ticks + 30;
if (cur_ticks == next_tick) {
next_tick += 30;
_ctrl_pressed = !!(_cocoa_video_data.current_mods & NSControlKeyMask); _ctrl_pressed = !!(_cocoa_video_data.current_mods & NSControlKeyMask);
_shift_pressed = !!(_cocoa_video_data.current_mods & NSShiftKeyMask); _shift_pressed = !!(_cocoa_video_data.current_mods & NSShiftKeyMask);

View File

@ -224,10 +224,8 @@ static void DedicatedHandleKeyInput(void)
static void DedicatedVideoMainLoop(void) static void DedicatedVideoMainLoop(void)
{ {
uint32 next_tick; uint32 cur_ticks = GetTime();
uint32 cur_ticks; uint32 next_tick = cur_ticks + 30;
next_tick = GetTime() + 30;
/* Signal handlers */ /* Signal handlers */
#ifdef UNIX #ifdef UNIX
@ -269,15 +267,15 @@ static void DedicatedVideoMainLoop(void)
} }
while (!_exit_game) { while (!_exit_game) {
uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
InteractiveRandom(); // randomness InteractiveRandom(); // randomness
if (!_dedicated_forks) if (!_dedicated_forks)
DedicatedHandleKeyInput(); DedicatedHandleKeyInput();
cur_ticks = GetTime(); cur_ticks = GetTime();
if (cur_ticks >= next_tick || cur_ticks < prev_cur_ticks) {
if (cur_ticks >= next_tick) { next_tick = cur_ticks + 30;
next_tick += 30;
GameLoop(); GameLoop();
_screen.dst_ptr = _dedicated_video_mem; _screen.dst_ptr = _dedicated_video_mem;

View File

@ -422,14 +422,15 @@ static void SdlVideoStop(void)
static void SdlVideoMainLoop(void) static void SdlVideoMainLoop(void)
{ {
uint32 next_tick = SDL_CALL SDL_GetTicks() + 30; uint32 cur_ticks = SDL_CALL SDL_GetTicks();
uint32 cur_ticks; uint32 next_tick = cur_ticks + 30;
uint32 pal_tick = 0; uint32 pal_tick = 0;
uint32 mod; uint32 mod;
int numkeys; int numkeys;
Uint8 *keys; Uint8 *keys;
for (;;) { for (;;) {
uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
InteractiveRandom(); // randomness InteractiveRandom(); // randomness
while (PollEvent() == -1) {} while (PollEvent() == -1) {}
@ -451,11 +452,8 @@ static void SdlVideoMainLoop(void)
} }
cur_ticks = SDL_CALL SDL_GetTicks(); cur_ticks = SDL_CALL SDL_GetTicks();
if ((_fast_forward && !_pause) || cur_ticks > next_tick) if (cur_ticks >= next_tick || (_fast_forward && !_pause) || cur_ticks < prev_cur_ticks) {
next_tick = cur_ticks; next_tick = cur_ticks + 30;
if (cur_ticks == next_tick) {
next_tick += 30;
_ctrl_pressed = !!(mod & KMOD_CTRL); _ctrl_pressed = !!(mod & KMOD_CTRL);
_shift_pressed = !!(mod & KMOD_SHIFT); _shift_pressed = !!(mod & KMOD_SHIFT);

View File

@ -786,11 +786,14 @@ static void CheckPaletteAnim(void)
static void Win32GdiMainLoop(void) static void Win32GdiMainLoop(void)
{ {
MSG mesg; MSG mesg;
uint32 next_tick = GetTickCount() + 30, cur_ticks; uint32 cur_ticks = GetTickCount();
uint32 next_tick = cur_ticks + 30;
_wnd.running = true; _wnd.running = true;
for (;;) { for (;;) {
uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) { while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) {
InteractiveRandom(); // randomness InteractiveRandom(); // randomness
DispatchMessage(&mesg); DispatchMessage(&mesg);
@ -810,11 +813,8 @@ static void Win32GdiMainLoop(void)
} }
cur_ticks = GetTickCount(); cur_ticks = GetTickCount();
if ((_fast_forward && !_pause) || cur_ticks > next_tick) if (cur_ticks >= next_tick || (_fast_forward && !_pause) || cur_ticks < prev_cur_ticks) {
next_tick = cur_ticks; next_tick = cur_ticks + 30;
if (cur_ticks == next_tick) {
next_tick += 30;
_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0; _ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0;
_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0; _shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0;
#ifdef _DEBUG #ifdef _DEBUG