Remove some more circular dependencies
authorunc0rr
Sun, 21 Nov 2010 19:51:33 +0300
changeset 4404 6bae4e9461aa
parent 4403 0dfe26f48ec1
child 4405 ed78465973f6
Remove some more circular dependencies
hedgewars/uChat.pas
hedgewars/uIO.pas
hedgewars/uRenderUtils.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
--- a/hedgewars/uChat.pas	Sun Nov 21 19:41:19 2010 +0300
+++ b/hedgewars/uChat.pas	Sun Nov 21 19:51:33 2010 +0300
@@ -308,6 +308,11 @@
     end
 end;
 
+procedure chChatMessage(var s: shortstring);
+begin
+    AddChatString(s)
+end;
+
 procedure chSay(var s: shortstring);
 begin
     SendIPC('s' + s);
@@ -355,6 +360,7 @@
 
 procedure initModule;
 begin
+    RegisterVariable('chatmsg', vtCommand, @chChatMessage, true);
     RegisterVariable('say', vtCommand, @chSay, true);
     RegisterVariable('team', vtCommand, @chTeamSay, true);
     RegisterVariable('history', vtCommand, @chHistory, true );
--- a/hedgewars/uIO.pas	Sun Nov 21 19:41:19 2010 +0300
+++ b/hedgewars/uIO.pas	Sun Nov 21 19:51:33 2010 +0300
@@ -43,7 +43,7 @@
 procedure NetGetNextCmd;
 
 implementation
-uses uConsole, uConsts, uChat, uTeams, uVariables, uCommands, uUtils, uDebug;
+uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug;
 
 type PCmd = ^TCmd;
      TCmd = packed record
@@ -309,15 +309,16 @@
         ',': ParseCommand('skip', true);
         's': begin
             s:= copy(headcmd^.str, 2, Pred(headcmd^.len));
-            AddChatString(s);
+            ParseCommand('chatmsg' + s, true);
             WriteLnToConsole(s)
             end;
         'b': begin
             s:= copy(headcmd^.str, 2, Pred(headcmd^.len));
-            AddChatString(#4 + s);
+            ParseCommand('chatmsg'#4 + s, true);
             WriteLnToConsole(s)
             end;
-        'F': TeamGone(copy(headcmd^.str, 2, Pred(headcmd^.len)));
+// TODO: deprecate 'F'
+        'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
         'N': begin
             tmpflag:= false;
             {$IFDEF DEBUGFILE}AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime)){$ENDIF}
--- a/hedgewars/uRenderUtils.pas	Sun Nov 21 19:41:19 2010 +0300
+++ b/hedgewars/uRenderUtils.pas	Sun Nov 21 19:51:33 2010 +0300
@@ -12,7 +12,7 @@
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 
 implementation
-uses uIO, uUtils, uVariables, uConsts, uTextures, sysutils, uDebug;
+uses uUtils, uVariables, uConsts, uTextures, sysutils, uDebug;
 
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 var r: TSDL_Rect;
--- a/hedgewars/uSound.pas	Sun Nov 21 19:41:19 2010 +0300
+++ b/hedgewars/uSound.pas	Sun Nov 21 19:51:33 2010 +0300
@@ -46,7 +46,7 @@
 
 
 implementation
-uses uMisc, uVariables, uConsole, uUtils, uIO, uCommands, uDebug;
+uses uVariables, uConsole, uUtils, uCommands, uDebug;
 
 const chanTPU = 32;
 var Volume: LongInt;
--- a/hedgewars/uStore.pas	Sun Nov 21 19:41:19 2010 +0300
+++ b/hedgewars/uStore.pas	Sun Nov 21 19:51:33 2010 +0300
@@ -39,7 +39,7 @@
 procedure FreeWeaponTooltip;
 
 implementation
-uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uIO, uRender, uRenderUtils, uCommands, uDebug;
+uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug;
 
 type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
 
--- a/hedgewars/uTeams.pas	Sun Nov 21 19:41:19 2010 +0300
+++ b/hedgewars/uTeams.pas	Sun Nov 21 19:51:33 2010 +0300
@@ -33,7 +33,6 @@
 procedure RecountTeamHealth(team: PTeam);
 procedure RestoreTeamsFromSave;
 function  CheckForWin: boolean;
-procedure TeamGone(s: shortstring);
 procedure TeamGoneEffect(var Team: TTeam);
 function  GetTeamStatString(p: PTeam): shortstring;
 
@@ -394,24 +393,6 @@
    TeamsArray[t]^.ExtDriven:= false
 end;
 
-procedure TeamGone(s: shortstring);
-var t: LongInt;
-begin
-t:= 0;
-while (t < cMaxTeams)
-    and (TeamsArray[t] <> nil)
-    and (TeamsArray[t]^.TeamName <> s) do inc(t);
-if (t = cMaxTeams) or (TeamsArray[t] = nil) then exit;
-
-with TeamsArray[t]^ do
-    begin
-    AddChatString('** '+ TeamName + ' is gone');
-    hasGone:= true
-    end;
-
-RecountTeamHealth(TeamsArray[t])
-end;
-
 procedure TeamGoneEffect(var Team: TTeam);
 var i: LongInt;
 begin
@@ -515,12 +496,32 @@
         else CurrentTeam^.Binds[b]:= s
 end;
 
+procedure chTeamGone(var s:shortstring);
+var t: LongInt;
+begin
+t:= 0;
+while (t < cMaxTeams)
+    and (TeamsArray[t] <> nil)
+    and (TeamsArray[t]^.TeamName <> s) do inc(t);
+if (t = cMaxTeams) or (TeamsArray[t] = nil) then exit;
+
+with TeamsArray[t]^ do
+    begin
+    AddChatString('** '+ TeamName + ' is gone');
+    hasGone:= true
+    end;
+
+RecountTeamHealth(TeamsArray[t])
+end;
+
+
 procedure initModule;
 begin
     RegisterVariable('addhh', vtCommand, @chAddHH, false);
     RegisterVariable('addteam', vtCommand, @chAddTeam, false);
     RegisterVariable('hhcoords', vtCommand, @chSetHHCoords, false);
     RegisterVariable('bind', vtCommand, @chBind, true );
+    RegisterVariable('teamgone', vtCommand, @chTeamGone, true );
 
     CurrentTeam:= nil;
     PreviousTeam:= nil;