hedgewars/uTeams.pas
changeset 9464 901e363d5837
parent 9407 860f959f92c9
child 9466 8b48c27201af
equal deleted inserted replaced
9462:4cbc9a8fd559 9464:901e363d5837
   361 
   361 
   362 TeamsArray[TeamsCount]:= team;
   362 TeamsArray[TeamsCount]:= team;
   363 inc(TeamsCount);
   363 inc(TeamsCount);
   364 
   364 
   365 for t:= 0 to cKbdMaxIndex do
   365 for t:= 0 to cKbdMaxIndex do
   366     team^.Binds[t]:= '';
   366     team^.Binds[t]:= DefaultBinds[t];
   367 
   367 
   368 c:= Pred(ClansCount);
   368 c:= Pred(ClansCount);
   369 while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c);
   369 while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c);
   370 if c < 0 then
   370 if c < 0 then
   371     begin
   371     begin
   605                     val(copy(l, i, 3), b);
   605                     val(copy(l, i, 3), b);
   606                     p:= p + char(b);
   606                     p:= p + char(b);
   607                     inc(i, 3)
   607                     inc(i, 3)
   608                     end;
   608                     end;
   609                 end;
   609                 end;
   610             
   610 
   611             if i < length(l) then
   611             if i < length(l) then
   612                 begin
   612                 begin
   613                 l:= copy(l, i + 1, length(l) - i);
   613                 l:= copy(l, i + 1, length(l) - i);
   614                 if l <> 'default' then
   614                 if l <> 'default' then
   615                     begin
   615                     begin
   616                     p:= 'bind ' + l + ' ' + p;
   616                     p:= 'bind ' + l + ' ' + p;
   617                     ParseCommand(p, true)
   617                     ParseCommand(p, true)
   618                     end
   618                     end
   619                 end
   619                 end
   620             end;
   620             end;
   621             
   621 
   622         pfsClose(f)
   622         pfsClose(f)
   623         end
   623         end
   624 end;
   624 end;
   625 
   625 
   626 procedure chAddTeam(var s: shortstring);
   626 procedure chAddTeam(var s: shortstring);
   664     CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   664     CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
   665 end;
   665 end;
   666 
   666 
   667 procedure chBind(var id: shortstring);
   667 procedure chBind(var id: shortstring);
   668 var KeyName, Modifier, tmp: shortstring;
   668 var KeyName, Modifier, tmp: shortstring;
   669     b: LongInt;
   669     i, b: LongInt;
   670 begin
   670 begin
   671 KeyName:= '';
   671 KeyName:= '';
   672 Modifier:= '';
   672 Modifier:= '';
   673 
   673 
   674 if CurrentTeam = nil then
   674 if CurrentTeam = nil then
   689     Delete(KeyName, byte(KeyName[0]), 1);
   689     Delete(KeyName, byte(KeyName[0]), 1);
   690 b:= KeyNameToCode(id, Modifier);
   690 b:= KeyNameToCode(id, Modifier);
   691 if b = 0 then
   691 if b = 0 then
   692     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
   692     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
   693 else
   693 else
       
   694     begin 
       
   695     // add bind: first check if this cmd is already bound, and remove old bind
       
   696     i:= cKbdMaxIndex;
       
   697     repeat
       
   698         dec(i)
       
   699     until (i < 0) or (CurrentTeam^.Binds[i] = KeyName);
       
   700     if (i >= 0) then
       
   701         CurrentTeam^.Binds[i]:= '';
       
   702 
   694     CurrentTeam^.Binds[b]:= KeyName;
   703     CurrentTeam^.Binds[b]:= KeyName;
       
   704     end
   695 end;
   705 end;
   696 
   706 
   697 procedure chTeamGone(var s:shortstring);
   707 procedure chTeamGone(var s:shortstring);
   698 var t: LongInt;
   708 var t: LongInt;
   699 begin
   709 begin