Don't abort ready phase for moving camera with keys
authorWuzzy <Wuzzy2@mail.ru>
Sat, 18 May 2019 19:33:49 +0200
changeset 15012 9d00a873bbcc
parent 15011 f81b46f584c7
child 15013 fdf646e3e083
Don't abort ready phase for moving camera with keys Rationale: The keys are equivalent to moving the mouse, but boving the mouse doesn't abort the ready phase. So this is only fair: Players should not be punished for using different controls.
hedgewars/uInputHandler.pas
--- a/hedgewars/uInputHandler.pas	Sat May 18 19:20:54 2019 +0200
+++ b/hedgewars/uInputHandler.pas	Sat May 18 19:33:49 2019 +0200
@@ -188,6 +188,7 @@
 var
     Trusted: boolean;
     curBind, s: shortstring;
+    readyAborter: boolean;
 begin
 if not(tkbd[code] xor KeyDown) then exit;
 tkbd[code]:= KeyDown;
@@ -228,6 +229,12 @@
 if CurrentBinds.indices[code] > 0 then
     begin
     curBind:= CurrentBinds.binds[CurrentBinds.indices[code]];
+
+    // Check if the keypress should end the ready phase.
+    // Camera movement keys are "safe" since its equivalent to moving the mouse,
+    // which also does not end the ready phase.
+    readyAborter:= (curBind <> '+cur_u') and (curBind <> '+cur_d') and (curBind <> '+cur_l') and (curBind <> '+cur_r');
+
     if (code < cKeyMaxIndex - 2) // means not mouse buttons
         and KeyDown
         and (not ((curBind = 'put')
@@ -255,7 +262,8 @@
             end;
 
         ParseCommand(curBind, Trusted);
-        if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
+        // End ready phase
+        if (readyAborter) and (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
             ParseCommand('gencmd R', true)
         end
     else if (curBind[1] = '+') then
@@ -270,7 +278,8 @@
         s:= curBind;
         s[1]:= '-';
         ParseCommand(s, Trusted);
-        if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
+        // End ready phase
+        if (readyAborter) and (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
             ParseCommand('gencmd R', true)
         end
     else