hedgewars/uKeys.pas
branchexperimental3D
changeset 4812 f924be23ffb4
parent 4531 4ea193b0e378
child 4744 ecc2c757d0df
--- a/hedgewars/uKeys.pas	Mon Dec 27 23:57:44 2010 +0100
+++ b/hedgewars/uKeys.pas	Tue Jan 04 12:53:46 2011 +0100
@@ -20,10 +20,7 @@
 
 unit uKeys;
 interface
-uses uConsts, SDLh;
-
-type TBinds = array[0..cKeyMaxIndex] of shortstring;
-type TKeyboardState = array[0..cKeyMaxIndex] of Byte;
+uses SDLh, uTypes;
 
 procedure initModule;
 procedure freeModule;
@@ -85,8 +82,7 @@
 {$ENDIF}
 {$ENDIF}
 implementation
-uses uTeams, uConsole, uMisc;
-//const KeyNumber = 1024;
+uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug;
 
 var tkbd, tkbdn: TKeyboardState;
     KeyNames: array [0..cKeyMaxIndex] of string[15];
@@ -175,14 +171,19 @@
 if CurrentBinds[i][0] <> #0 then
     begin
     if (i > 3) and (tkbdn[i] <> 0) and not ((CurrentBinds[i] = 'put') or (CurrentBinds[i] = 'ammomenu') or (CurrentBinds[i] = '+cur_u') or (CurrentBinds[i] = '+cur_d') or (CurrentBinds[i] = '+cur_l') or (CurrentBinds[i] = '+cur_r')) then hideAmmoMenu:= true;
-    if (tkbd[i] = 0) and (tkbdn[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted)
+    if (tkbd[i] = 0) and (tkbdn[i] <> 0) then
+         begin
+         ParseCommand(CurrentBinds[i], Trusted);
+         if (CurrentTeam <> nil) and not CurrentTeam^.ExtDriven and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true)
+         end
     else if (CurrentBinds[i][1] = '+')
             and (tkbdn[i] = 0)
             and (tkbd[i] <> 0) then
             begin
             s:= CurrentBinds[i];
             s[1]:= '-';
-            ParseCommand(s, Trusted)
+            ParseCommand(s, Trusted);
+            if (CurrentTeam <> nil) and not CurrentTeam^.ExtDriven and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true)
             end;
     tkbd[i]:= tkbdn[i]
     end
@@ -196,7 +197,7 @@
 k:= SDL_GetMouseState(nil, nil);
 {$IFNDEF IPHONEOS}pkbd:={$ENDIF}SDL_GetKeyState(@j);
 
-TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(j) + ')', true);
+TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + IntToStr(j) + ')', true);
 
 {$IFNDEF IPHONEOS}
 for i:= 1 to pred(j) do
@@ -265,7 +266,7 @@
 for i:= 6 to cKeyMaxIndex do
     begin
     s:= shortstring(sdl_getkeyname(i));
-    //writeln(stdout,inttostr(i) + ': ' + s);
+    //writeln(stdout,IntToStr(i) + ': ' + s);
     if s = 'unknown key' then KeyNames[i]:= ''
     else 
         begin
@@ -275,7 +276,7 @@
         end;
     end;
 
-//for i:= 0 to cKeyMaxIndex do writeln(stdout,inttostr(i) + ': ' + KeyNames[i]);
+//for i:= 0 to cKeyMaxIndex do writeln(stdout,IntToStr(i) + ': ' + KeyNames[i]);
 
 // get the size of keyboard array
 SDL_GetKeyState(@k);
@@ -285,21 +286,21 @@
     begin
     for i:= 0 to Pred(ControllerNumAxes[j]) do
         begin
-        keynames[k + 0]:= 'j' + inttostr(j) + 'a' + inttostr(i) + 'u';
-        keynames[k + 1]:= 'j' + inttostr(j) + 'a' + inttostr(i) + 'd';
+        keynames[k + 0]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'u';
+        keynames[k + 1]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'd';
         inc(k, 2);
         end;
     for i:= 0 to Pred(ControllerNumHats[j]) do
         begin
-        keynames[k + 0]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'u';
-        keynames[k + 1]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'r';
-        keynames[k + 2]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'd';
-        keynames[k + 3]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'l';
+        keynames[k + 0]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'u';
+        keynames[k + 1]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'r';
+        keynames[k + 2]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'd';
+        keynames[k + 3]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'l';
         inc(k, 4);
         end;
     for i:= 0 to Pred(ControllerNumButtons[j]) do
         begin
-        keynames[k]:= 'j' + inttostr(j) + 'b' + inttostr(i);
+        keynames[k]:= 'j' + IntToStr(j) + 'b' + IntToStr(i);
         inc(k, 1);
         end;
     end;
@@ -350,7 +351,7 @@
 DefaultBinds[KeyNameToCode('left_shift')]:= '+precise';
 {$ENDIF}
 
-for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+inttostr(i))]:= 'slot '+inttostr(i);
+for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i);
 
 SetDefaultBinds();
 end;
@@ -425,7 +426,7 @@
 ControllerNumControllers:= SDL_NumJoysticks();
 if ControllerNumControllers > 6 then ControllerNumControllers:= 6;
 
-WriteLnToConsole('Number of game controllers: ' + inttostr(ControllerNumControllers));
+WriteLnToConsole('Number of game controllers: ' + IntToStr(ControllerNumControllers));
 
 if ControllerNumControllers > 0 then
     begin
@@ -441,10 +442,10 @@
             //ControllerNumBalls[j]:= SDL_JoystickNumBalls(Controller[j]);
             ControllerNumHats[j]:= SDL_JoystickNumHats(Controller[j]);
             ControllerNumButtons[j]:= SDL_JoystickNumButtons(Controller[j]);
-            WriteLnToConsole('* Number of axes: ' + inttostr(ControllerNumAxes[j]));
-            //WriteLnToConsole('* Number of balls: ' + inttostr(ControllerNumBalls[j]));
-            WriteLnToConsole('* Number of hats: ' + inttostr(ControllerNumHats[j]));
-            WriteLnToConsole('* Number of buttons: ' + inttostr(ControllerNumButtons[j]));
+            WriteLnToConsole('* Number of axes: ' + IntToStr(ControllerNumAxes[j]));
+            //WriteLnToConsole('* Number of balls: ' + IntToStr(ControllerNumBalls[j]));
+            WriteLnToConsole('* Number of hats: ' + IntToStr(ControllerNumHats[j]));
+            WriteLnToConsole('* Number of buttons: ' + IntToStr(ControllerNumButtons[j]));
             ControllerEnabled:= 1;
 
             if ControllerNumAxes[j] > 20 then ControllerNumAxes[j]:= 20;