hedgewars/uTeams.pas
changeset 9464 901e363d5837
parent 9407 860f959f92c9
child 9466 8b48c27201af
--- a/hedgewars/uTeams.pas	Sat Sep 21 22:32:01 2013 +0400
+++ b/hedgewars/uTeams.pas	Sat Sep 21 23:54:57 2013 +0400
@@ -363,7 +363,7 @@
 inc(TeamsCount);
 
 for t:= 0 to cKbdMaxIndex do
-    team^.Binds[t]:= '';
+    team^.Binds[t]:= DefaultBinds[t];
 
 c:= Pred(ClansCount);
 while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c);
@@ -607,7 +607,7 @@
                     inc(i, 3)
                     end;
                 end;
-            
+
             if i < length(l) then
                 begin
                 l:= copy(l, i + 1, length(l) - i);
@@ -618,7 +618,7 @@
                     end
                 end
             end;
-            
+
         pfsClose(f)
         end
 end;
@@ -666,7 +666,7 @@
 
 procedure chBind(var id: shortstring);
 var KeyName, Modifier, tmp: shortstring;
-    b: LongInt;
+    i, b: LongInt;
 begin
 KeyName:= '';
 Modifier:= '';
@@ -691,7 +691,17 @@
 if b = 0 then
     OutError(errmsgUnknownVariable + ' "' + id + '"', false)
 else
+    begin 
+    // add bind: first check if this cmd is already bound, and remove old bind
+    i:= cKbdMaxIndex;
+    repeat
+        dec(i)
+    until (i < 0) or (CurrentTeam^.Binds[i] = KeyName);
+    if (i >= 0) then
+        CurrentTeam^.Binds[i]:= '';
+
     CurrentTeam^.Binds[b]:= KeyName;
+    end
 end;
 
 procedure chTeamGone(var s:shortstring);