Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
authorunc0rr
Sat, 13 Aug 2011 20:44:42 +0400
changeset 5555 38e3d9347910
parent 5554 b27ed6c6f538
child 5556 5b8ca3955834
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
hedgewars/uCommandHandlers.pas
--- a/hedgewars/uCommandHandlers.pas	Fri Aug 12 15:33:07 2011 -0400
+++ b/hedgewars/uCommandHandlers.pas	Sat Aug 13 20:44:42 2011 +0400
@@ -43,16 +43,17 @@
 const prevGState: TGameState = gsConfirm;
 begin
     s:= s; // avoid compiler hint
-    if GameState <> gsConfirm then
-    begin
+    if (GameState = gsGame) or (GameState = gsChat) then
+        begin
         prevGState:= GameState;
         GameState:= gsConfirm;
         SDL_ShowCursor(1)
-    end else
-    begin
-        GameState:= prevGState;
-        SDL_ShowCursor(ord(isPaused))
-    end
+        end else
+        if GameState = gsConfirm then
+            begin
+            GameState:= prevGState;
+            SDL_ShowCursor(ord(isPaused))
+            end
 end;
 
 procedure chForceQuit(var s: shortstring);