hedgewars/uTeams.pas
changeset 10343 fe9853dea6c4
parent 10193 d7cd5b43588f
child 10344 cceabf9628bb
equal deleted inserted replaced
10342:16122539d2ea 10343:fe9853dea6c4
   628     addBind(CurrentTeam^.Binds, id)
   628     addBind(CurrentTeam^.Binds, id)
   629 end;
   629 end;
   630 
   630 
   631 procedure chTeamGone(var s:shortstring);
   631 procedure chTeamGone(var s:shortstring);
   632 var t: LongInt;
   632 var t: LongInt;
   633 begin
   633     isSynced: boolean;
   634 t:= 0;
   634 begin
   635 while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do
   635     isSynced:= s[1] = 's';
   636     inc(t);
   636 
   637 if (t = cMaxTeams) or (TeamsArray[t] = nil) then
   637     Delete(s, 1, 1);
   638     exit;
   638 
   639 
   639     t:= 0;
   640 with TeamsArray[t]^ do
   640     while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do
   641     if not hasGone then
   641         inc(t);
   642         begin
   642     if (t = cMaxTeams) or (TeamsArray[t] = nil) then
   643         AddChatString('** '+ TeamName + ' is gone');
   643         exit;
   644         hasGone:= true;
   644 
   645 
   645     if isSynced then
   646         RecountTeamHealth(TeamsArray[t])
   646         begin
   647         end;
   647         with TeamsArray[t]^ do
       
   648             if not hasGone then
       
   649                 begin
       
   650                 AddChatString('** '+ TeamName + ' is gone');
       
   651                 hasGone:= true;
       
   652 
       
   653                 RecountTeamHealth(TeamsArray[t])
       
   654                 end;
       
   655         end
       
   656     else
       
   657     begin
       
   658         if not CurrentTeam^.ExtDriven then
       
   659         begin
       
   660             SendIPC(_S'f' + s);
       
   661             ParseCommand('/teamgone s' + s, true);
       
   662         end;
       
   663     end;
       
   664 end;
       
   665 
       
   666 procedure chTeamBack(var s:shortstring);
       
   667 var t: LongInt;
       
   668     isSynced: boolean;
       
   669 begin
       
   670     isSynced:= s[1] = 's';
       
   671 
       
   672     Delete(s, 1, 1);
       
   673 
       
   674     t:= 0;
       
   675     while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do
       
   676         inc(t);
       
   677     if (t = cMaxTeams) or (TeamsArray[t] = nil) then
       
   678         exit;
       
   679 
       
   680     if isSynced then
       
   681         begin
       
   682         with TeamsArray[t]^ do
       
   683             if hasGone then
       
   684                 begin
       
   685                 AddChatString('** '+ TeamName + ' is back');
       
   686                 hasGone:= false;
       
   687 
       
   688                 RecountTeamHealth(TeamsArray[t]);
       
   689 
       
   690                 if Owner = UserNick then
       
   691                     ExtDriven:= false
       
   692                 end;
       
   693         end
       
   694     else
       
   695     begin
       
   696         if not CurrentTeam^.ExtDriven then
       
   697         begin
       
   698             SendIPC(_S'g' + s);
       
   699             ParseCommand('/teamback s' + s, true);
       
   700         end;
       
   701     end;
   648 end;
   702 end;
   649 
   703 
   650 
   704 
   651 procedure chFinish(var s:shortstring);
   705 procedure chFinish(var s:shortstring);
   652 var t: LongInt;
   706 var t: LongInt;
   745 RegisterVariable('addhh', @chAddHH, false);
   799 RegisterVariable('addhh', @chAddHH, false);
   746 RegisterVariable('addteam', @chAddTeam, false);
   800 RegisterVariable('addteam', @chAddTeam, false);
   747 RegisterVariable('hhcoords', @chSetHHCoords, false);
   801 RegisterVariable('hhcoords', @chSetHHCoords, false);
   748 RegisterVariable('bind', @chBind, true );
   802 RegisterVariable('bind', @chBind, true );
   749 RegisterVariable('teamgone', @chTeamGone, true );
   803 RegisterVariable('teamgone', @chTeamGone, true );
       
   804 RegisterVariable('teamback', @chTeamBack, true );
   750 RegisterVariable('finish', @chFinish, true ); // all teams gone
   805 RegisterVariable('finish', @chFinish, true ); // all teams gone
   751 RegisterVariable('fort'    , @chFort         , false);
   806 RegisterVariable('fort'    , @chFort         , false);
   752 RegisterVariable('grave'   , @chGrave        , false);
   807 RegisterVariable('grave'   , @chGrave        , false);
   753 RegisterVariable('hat'     , @chSetHat       , false);
   808 RegisterVariable('hat'     , @chSetHat       , false);
   754 RegisterVariable('flag'    , @chFlag         , false);
   809 RegisterVariable('flag'    , @chFlag         , false);