Move doPut into uIO (not a very bad place really)
authorunc0rr
Mon, 22 Nov 2010 21:49:57 +0300
changeset 4414 cb90b7f82cd5
parent 4413 46caab3a8f84
child 4415 941251bad467
Move doPut into uIO (not a very bad place really)
hedgewars/uAIActions.pas
hedgewars/uCommands.pas
hedgewars/uConsole.pas
hedgewars/uIO.pas
--- a/hedgewars/uAIActions.pas	Mon Nov 22 21:43:31 2010 +0300
+++ b/hedgewars/uAIActions.pas	Mon Nov 22 21:49:57 2010 +0300
@@ -62,7 +62,7 @@
 procedure ProcessAction(var Actions: TActions; Me: PGear);
 
 implementation
-uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uDebug;
+uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uDebug, uIO;
 
 const ActionIdToStr: array[0..6] of string[16] = (
 {aia_none}           '',
--- a/hedgewars/uCommands.pas	Mon Nov 22 21:43:31 2010 +0300
+++ b/hedgewars/uCommands.pas	Mon Nov 22 21:49:57 2010 +0300
@@ -13,10 +13,9 @@
 procedure RegisterVariable(Name: shortstring; VType: TVariableType; p: pointer; Trusted: boolean);
 procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
 procedure StopMessages(Message: Longword);
-procedure doPut(putX, putY: LongInt; fromAI: boolean);
 
 implementation
-uses Types, uConsts, uIO, uVariables, uConsole, uUtils, uDebug;
+uses Types, uConsts, uVariables, uConsole, uUtils, uDebug;
 
 type  PVariable = ^TVariable;
       TVariable = record
@@ -114,51 +113,6 @@
 if (Message and gmAttack) <> 0 then ParseCommand('/-attack', true)
 end;
 
-
-procedure doPut(putX, putY: LongInt; fromAI: boolean);
-begin
-if CheckNoTeamOrHH or isPaused then exit;
-if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
-bShowFinger:= false;
-if not CurrentTeam^.ExtDriven and bShowAmmoMenu then
-    begin
-    bSelected:= true;
-    exit
-    end;
-
-with CurrentHedgehog^.Gear^,
-    CurrentHedgehog^ do
-    if (State and gstHHChooseTarget) <> 0 then
-        begin
-        isCursorVisible:= false;
-        if not CurrentTeam^.ExtDriven then
-            begin
-            if fromAI then
-                begin
-                TargetPoint.X:= putX;
-                TargetPoint.Y:= putY
-                end else
-                begin
-                TargetPoint.X:= CursorPoint.X - WorldDx;
-                TargetPoint.Y:= cScreenHeight - CursorPoint.Y - WorldDy;
-                end;
-            SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
-            end
-        else
-            begin
-            TargetPoint.X:= putX;
-            TargetPoint.Y:= putY
-            end;
-        {$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
-        State:= State and not gstHHChooseTarget;
-        if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
-            Message:= Message or gmAttack;
-        end
-    else
-        if CurrentTeam^.ExtDriven then
-            OutError('got /put while not being in choose target mode', false)
-end;
-
 procedure initModule;
 begin
     Variables:= nil;
--- a/hedgewars/uConsole.pas	Mon Nov 22 21:43:31 2010 +0300
+++ b/hedgewars/uConsole.pas	Mon Nov 22 21:49:57 2010 +0300
@@ -28,7 +28,7 @@
 function  GetLastConsoleLine: shortstring;
 
 implementation
-uses uMisc, Types, uVariables, uUtils;
+uses Types, uVariables, uUtils;
 
 const cLineWidth: LongInt = 0;
       cLinesCount = 256;
--- a/hedgewars/uIO.pas	Mon Nov 22 21:43:31 2010 +0300
+++ b/hedgewars/uIO.pas	Mon Nov 22 21:49:57 2010 +0300
@@ -41,6 +41,7 @@
 procedure InitIPC;
 procedure CloseIPC;
 procedure NetGetNextCmd;
+procedure doPut(putX, putY: LongInt; fromAI: boolean);
 
 implementation
 uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug;
@@ -366,6 +367,50 @@
     SendIPC('E' + s);
 end;
 
+procedure doPut(putX, putY: LongInt; fromAI: boolean);
+begin
+if CheckNoTeamOrHH or isPaused then exit;
+if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1;
+bShowFinger:= false;
+if not CurrentTeam^.ExtDriven and bShowAmmoMenu then
+    begin
+    bSelected:= true;
+    exit
+    end;
+
+with CurrentHedgehog^.Gear^,
+    CurrentHedgehog^ do
+    if (State and gstHHChooseTarget) <> 0 then
+        begin
+        isCursorVisible:= false;
+        if not CurrentTeam^.ExtDriven then
+            begin
+            if fromAI then
+                begin
+                TargetPoint.X:= putX;
+                TargetPoint.Y:= putY
+                end else
+                begin
+                TargetPoint.X:= CursorPoint.X - WorldDx;
+                TargetPoint.Y:= cScreenHeight - CursorPoint.Y - WorldDy;
+                end;
+            SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
+            end
+        else
+            begin
+            TargetPoint.X:= putX;
+            TargetPoint.Y:= putY
+            end;
+        {$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
+        State:= State and not gstHHChooseTarget;
+        if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
+            Message:= Message or gmAttack;
+        end
+    else
+        if CurrentTeam^.ExtDriven then
+            OutError('got /put while not being in choose target mode', false)
+end;
+
 procedure initModule;
 begin
     RegisterVariable('fatal', vtCommand, @chFatalError, true );