hedgewars/uTeams.pas
changeset 10665 b57c328c6794
parent 10646 0be6442946b1
child 10883 294ef49efdd2
equal deleted inserted replaced
10663:9bbb29d2bd68 10665:b57c328c6794
   647     isSynced:= s[1] = 's';
   647     isSynced:= s[1] = 's';
   648 
   648 
   649     Delete(s, 1, 1);
   649     Delete(s, 1, 1);
   650 
   650 
   651     t:= 0;
   651     t:= 0;
   652     while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do
   652     while (t < TeamsCount) and (TeamsArray[t]^.TeamName <> s) do
   653         inc(t);
   653         inc(t);
   654     if (t = cMaxTeams) or (TeamsArray[t] = nil) then
   654     if t = TeamsCount then
   655         exit;
   655         exit;
   656 
   656 
   657     TeamsArray[t]^.isGoneFlagPendingToBeSet:= true;
   657     TeamsArray[t]^.isGoneFlagPendingToBeSet:= true;
   658 
   658 
   659     if isSynced then
   659     if isSynced then
   660     begin
   660         begin
   661     for i:= 0 to Pred(cMaxTeams) do
   661         for i:= 0 to Pred(TeamsCount) do
   662         with TeamsArray[i]^ do
   662             with TeamsArray[i]^ do
   663             begin
       
   664             if (not hasGone) and isGoneFlagPendingToBeSet then
       
   665                 begin
   663                 begin
   666                 AddChatString('** '+ TeamName + ' is gone'); // TODO: localize
   664                 if (not hasGone) and isGoneFlagPendingToBeSet then
   667                 if not CurrentTeam^.ExtDriven then SendIPC(_S'f' + s);
   665                     begin
   668                 hasGone:= true;
   666                     AddChatString('** '+ TeamName + ' is gone'); // TODO: localize
   669                 skippedTurns:= 0;
   667                     if not CurrentTeam^.ExtDriven then SendIPC(_S'f' + s);
   670                 isGoneFlagPendingToBeSet:= false;
   668                     hasGone:= true;
   671                 RecountTeamHealth(TeamsArray[i])
   669                     skippedTurns:= 0;
   672                 end;
   670                     isGoneFlagPendingToBeSet:= false;
   673             if hasGone and isGoneFlagPendingToBeUnset then
   671                     RecountTeamHealth(TeamsArray[i])
   674                 ParseCommand('/teamback s' + s, true);
   672                     end;
   675             end;
   673                 if hasGone and isGoneFlagPendingToBeUnset then
   676     end
   674                     ParseCommand('/teamback s' + s, true)
       
   675                 end
       
   676         end
   677     else
   677     else
   678     begin
   678         begin
   679         TeamsArray[t]^.isGoneFlagPendingToBeSet:= true;
   679         TeamsArray[t]^.isGoneFlagPendingToBeSet:= true;
   680 
   680 
   681         if (not CurrentTeam^.ExtDriven) or (CurrentTeam^.TeamName = s) or (CurrentTeam^.hasGone) then
   681         if (not CurrentTeam^.ExtDriven) or (CurrentTeam^.TeamName = s) or (CurrentTeam^.hasGone) then
   682             ParseCommand('/teamgone s' + s, true);
   682             ParseCommand('/teamgone s' + s, true)
   683     end;
   683         end;
   684 end;
   684 end;
   685 
   685 
   686 procedure chTeamBack(var s:shortstring);
   686 procedure chTeamBack(var s:shortstring);
   687 var t: LongInt;
   687 var t: LongInt;
   688     isSynced: boolean;
   688     isSynced: boolean;
   690     isSynced:= s[1] = 's';
   690     isSynced:= s[1] = 's';
   691 
   691 
   692     Delete(s, 1, 1);
   692     Delete(s, 1, 1);
   693 
   693 
   694     t:= 0;
   694     t:= 0;
   695     while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do
   695     while (t < TeamsCount) and (TeamsArray[t]^.TeamName <> s) do
   696         inc(t);
   696         inc(t);
   697     if (t = cMaxTeams) or (TeamsArray[t] = nil) then
   697     if t = TeamsCount then
   698         exit;
   698         exit;
   699 
   699 
   700     if isSynced then
   700     if isSynced then
   701         begin
   701         begin
   702         with TeamsArray[t]^ do
   702         with TeamsArray[t]^ do
   713 
   713 
   714                 isGoneFlagPendingToBeUnset:= false;
   714                 isGoneFlagPendingToBeUnset:= false;
   715                 end;
   715                 end;
   716         end
   716         end
   717     else
   717     else
   718     begin
   718         begin
   719         TeamsArray[t]^.isGoneFlagPendingToBeUnset:= true;
   719         TeamsArray[t]^.isGoneFlagPendingToBeUnset:= true;
   720 
   720 
   721         if not CurrentTeam^.ExtDriven then
   721         if not CurrentTeam^.ExtDriven then
   722             ParseCommand('/teamback s' + s, true);
   722             ParseCommand('/teamback s' + s, true);
   723     end;
   723         end;
   724 end;
   724 end;
   725 
   725 
   726 
   726 
   727 procedure chFinish(var s:shortstring);
   727 procedure chFinish(var s:shortstring);
   728 var t: LongInt;
   728 var t: LongInt;
   729 begin
   729 begin
   730 // avoid compiler hint
   730 // avoid compiler hint
   731 s:= s;
   731 s:= s;
   732 
   732 
   733 t:= 0;
   733 t:= 0;
   734 while (t < cMaxTeams) and (TeamsArray[t] <> nil) do
   734 while t < TeamsCount do
   735     begin
   735     begin
   736     TeamsArray[t]^.hasGone:= true;
   736     TeamsArray[t]^.hasGone:= true;
   737     inc(t);
   737     inc(t)
   738     end;
   738     end;
   739 
   739 
   740 AddChatString('** Good-bye!');
   740 AddChatString('** Good-bye!');
   741 RecountAllTeamsHealth();
   741 RecountAllTeamsHealth();
   742 end;
   742 end;