hedgewars/uFLGameConfig.pas
branchqmlfrontend
changeset 11446 321d0ce43568
parent 11444 91f8c6ff5bab
child 11447 2572afe532af
--- a/hedgewars/uFLGameConfig.pas	Sun Dec 06 20:07:35 2015 +0300
+++ b/hedgewars/uFLGameConfig.pas	Sun Dec 06 20:20:09 2015 +0300
@@ -239,9 +239,9 @@
 
 
 procedure tryRemoveTeam(teamName: PChar); cdecl;
-var msg: shortstring;
-    i: Longword;
+var i: Longword;
     tn: shortstring;
+    isLocal: boolean;
 begin
     with currentConfig do
     begin
@@ -253,6 +253,11 @@
         // team not found???
         if (i > 7) then exit;
 
+        isLocal:= not teams[i].extDriven;
+
+        if isConnected and not isLocal then
+            exit; // we cannot remove this team
+
         while (i < 7) and (teams[i + 1].hogsNumber > 0) do
         begin
             teams[i]:= teams[i + 1];
@@ -262,10 +267,11 @@
         teams[i].hogsNumber:= 0
     end;
 
-    msg:= teamName;
-
-    sendUI(mtRemovePlayingTeam, @msg[1], length(msg));
-    sendUI(mtAddTeam, @msg[1], length(msg))
+    sendUI(mtRemovePlayingTeam, @tn[1], length(tn));
+    if isConnected then
+        removeTeam(tn);
+    if isLocal then
+        sendUI(mtAddTeam, @tn[1], length(tn))
 end;