--- a/hedgewars/uTeams.pas Sat Jun 28 14:51:45 2014 +0400
+++ b/hedgewars/uTeams.pas Sun Jun 29 22:50:21 2014 +0400
@@ -629,7 +629,7 @@
end;
procedure chTeamGone(var s:shortstring);
-var t: LongInt;
+var t, i: LongInt;
isSynced: boolean;
begin
isSynced:= s[1] = 's';
@@ -642,24 +642,31 @@
if (t = cMaxTeams) or (TeamsArray[t] = nil) then
exit;
+ TeamsArray[t]^.isGoneFlagPengingToBeSet:= true;
+
if isSynced then
- begin
- with TeamsArray[t]^ do
- if not hasGone then
+ begin
+ for i:= 0 to Pred(cMaxTeams) do
+ with TeamsArray[i]^ do
+ begin
+ if (not hasGone) and isGoneFlagPengingToBeSet then
begin
- AddChatString('** '+ TeamName + ' is gone');
+ AddChatString('** '+ TeamName + ' is gone'); // TODO: localize
+ if not CurrentTeam^.ExtDriven then SendIPC(_S'f' + s);
hasGone:= true;
-
- RecountTeamHealth(TeamsArray[t])
+ isGoneFlagPengingToBeSet:= false;
+ RecountTeamHealth(TeamsArray[i])
end;
- end
+ if hasGone and isGoneFlagPengingToBeUnset then
+ ParseCommand('/teamback s' + s, true);
+ end;
+ end
else
begin
- if not CurrentTeam^.ExtDriven then
- begin
- SendIPC(_S'f' + s);
+ TeamsArray[t]^.isGoneFlagPengingToBeSet:= true;
+
+ if (not CurrentTeam^.ExtDriven) or (CurrentTeam^.TeamName = s) then
ParseCommand('/teamgone s' + s, true);
- end;
end;
end;
@@ -683,7 +690,9 @@
if hasGone then
begin
AddChatString('** '+ TeamName + ' is back');
+ if not CurrentTeam^.ExtDriven then SendIPC(_S'g' + s);
hasGone:= false;
+ isGoneFlagPengingToBeUnset:= false;
RecountTeamHealth(TeamsArray[t]);
@@ -693,11 +702,10 @@
end
else
begin
+ TeamsArray[t]^.isGoneFlagPengingToBeUnset:= true;
+
if not CurrentTeam^.ExtDriven then
- begin
- SendIPC(_S'g' + s);
ParseCommand('/teamback s' + s, true);
- end;
end;
end;