DEADSOFTWARE

Fix handicap specifying in the 'bot_addlist' console command
[d2df-sdl.git] / src / game / g_game.pas
index b8c69a1cf396b26dd41d88dd9625393cd6b2afdf..4fbede48721b20714b43ca74026b6d2683a21efc 100644 (file)
@@ -728,6 +728,17 @@ begin
   CloseFile(s);
 end;
 
+procedure ClearDebugCvars();
+begin
+  g_debug_Sounds := False;
+  g_debug_Frames := False;
+  g_debug_WinMsgs := False;
+  g_debug_MonsterOff := False;
+  g_debug_BotAIOff := 0;
+  g_debug_HealthBar := False;
+  g_Debug_Player := False;
+end;
+
 function g_Game_ModeToText(Mode: Byte): string;
 begin
   Result := '';
@@ -4673,6 +4684,8 @@ begin
 
   g_Game_ClearLoading();
 
+  ClearDebugCvars();
+
 // Íàñòðîéêè èãðû:
   gGameSettings.GameType := GT_SERVER;
   gGameSettings.GameMode := GameMode;
@@ -4806,6 +4819,8 @@ begin
 
   g_Game_ClearLoading();
 
+  ClearDebugCvars();
+
 // Íàñòðîéêè èãðû:
   gGameSettings.GameType := GT_CLIENT;
 
@@ -4821,15 +4836,6 @@ begin
 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
   g_Game_SetupScreenSize();
 
-// set debug options to false to avoid cheaters
-  g_debug_Sounds := False;
-  g_debug_Frames := False;
-  g_debug_WinMsgs := False;
-  g_debug_MonsterOff := False;
-  g_debug_BotAIOff := 0;
-  g_debug_HealthBar := False;
-  g_Debug_Player := False;
-
   NetState := NET_STATE_AUTH;
 
   g_Game_SetLoadingText(_lc[I_LOAD_CONNECT], 0, False);
@@ -5776,6 +5782,34 @@ begin
     begin
       a := StrToIntDef(p[1], 0);
       g_Force_Model_Set(a);
+      if (g_Force_Model_Get() <> 0) and (gPlayers <> nil) then
+      begin
+        for a := Low(gPlayers) to High(gPlayers) do
+        begin
+          if (gPlayers[a] <> nil) then
+          begin
+            if (gPlayers[a].UID = gPlayer1.UID) then
+              continue
+            else if (gPlayer2 <> nil) and (gPlayers[a].UID = gPlayer2.UID) then
+              continue;
+            gPlayers[a].setModel(g_Forced_Model_GetName());
+          end;
+        end
+      end
+      else if (g_Force_Model_Get() = 0) and (gPlayers <> nil) then
+      begin
+        for a := Low(gPlayers) to High(gPlayers) do
+        begin
+          if (gPlayers[a] <> nil) then
+          begin
+            if (gPlayers[a].UID = gPlayer1.UID) then
+              continue
+            else if (gPlayer2 <> nil) and (gPlayers[a].UID = gPlayer2.UID) then
+              continue;
+            gPlayers[a].setModel(gPlayers[a].FActualModelName);
+          end;
+        end
+      end
     end
   end
   else if cmd = 'g_force_model_name' then
@@ -5784,7 +5818,7 @@ begin
     begin
       cmd := b_Text_Unformat(P[1]);
       g_Forced_Model_SetName(cmd);
-      if (gGameSettings.GameType <> GT_SINGLE) and (g_Force_Model_Get() <> 0) and (gPlayers <> nil) then
+      if (g_Force_Model_Get() <> 0) and (gPlayers <> nil) then
       begin
         for a := Low(gPlayers) to High(gPlayers) do
         begin
@@ -6525,6 +6559,7 @@ var
   nm: Boolean;
   listen: LongWord;
   found: Boolean;
+  t: Byte;
 begin
 // Îáùèå êîìàíäû:
   cmd := LowerCase(P[0]);
@@ -6569,7 +6604,7 @@ begin
       if (pl <> nil) then
       begin
         s := g_Net_ClientName_ByID(pl^.ID);
-        enet_peer_disconnect(pl^.Peer, NET_DISC_KICK);
+        g_Net_Host_Kick(pl^.ID, NET_DISC_KICK);
         g_Console_Add(Format(_lc[I_PLAYER_KICK], [s]));
         MH_SEND_GameEvent(NET_EV_PLAYER_KICK, 0, s);
         g_Net_Slist_ServerPlayerLeaves();
@@ -6613,7 +6648,7 @@ begin
         if NetClients[a].Used and (NetClients[a].Peer <> nil) then
         begin
           s := g_Net_ClientName_ByID(NetClients[a].ID);
-          enet_peer_disconnect(NetClients[a].Peer, NET_DISC_KICK);
+          g_Net_Host_Kick(NetClients[a].ID, NET_DISC_KICK);
           g_Console_Add(Format(_lc[I_PLAYER_KICK], [s]));
           MH_SEND_GameEvent(NET_EV_PLAYER_KICK, 0, s);
           g_Net_Slist_ServerPlayerLeaves();
@@ -6642,7 +6677,7 @@ begin
       if (pl <> nil) and pl^.Used and (pl^.Peer <> nil) then
       begin
         s := g_Net_ClientName_ByID(pl^.ID);
-        enet_peer_disconnect(pl^.Peer, NET_DISC_KICK);
+        g_Net_Host_Kick(pl^.ID, NET_DISC_KICK);
         g_Console_Add(Format(_lc[I_PLAYER_KICK], [s]));
         MH_SEND_GameEvent(NET_EV_PLAYER_KICK, 0, s);
         g_Net_Slist_ServerPlayerLeaves();
@@ -6670,7 +6705,7 @@ begin
       begin
         s := g_Net_ClientName_ByID(pl^.ID);
         g_Net_BanHost(pl^.Peer^.address.host, False);
-        enet_peer_disconnect(pl^.Peer, NET_DISC_TEMPBAN);
+        g_Net_Host_Kick(pl^.ID, NET_DISC_TEMPBAN);
         g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
         MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
         g_Net_Slist_ServerPlayerLeaves();
@@ -6700,7 +6735,7 @@ begin
         begin
           s := g_Net_ClientName_ByID(NetClients[a].ID);
           g_Net_BanHost(NetClients[a].Peer^.address.host, False);
-          enet_peer_disconnect(NetClients[a].Peer, NET_DISC_TEMPBAN);
+          g_Net_Host_Kick(NetClients[a].ID, NET_DISC_TEMPBAN);
           g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
           MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
           g_Net_Slist_ServerPlayerLeaves();
@@ -6729,7 +6764,7 @@ begin
       begin
         s := g_Net_ClientName_ByID(pl^.ID);
         g_Net_BanHost(pl^.Peer^.address.host, False);
-        enet_peer_disconnect(pl^.Peer, NET_DISC_TEMPBAN);
+        g_Net_Host_Kick(pl^.ID, NET_DISC_TEMPBAN);
         g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
         MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
         g_Net_Slist_ServerPlayerLeaves();
@@ -6757,7 +6792,7 @@ begin
       begin
         s := g_Net_ClientName_ByID(pl^.ID);
         g_Net_BanHost(pl^.Peer^.address.host);
-        enet_peer_disconnect(pl^.Peer, NET_DISC_BAN);
+        g_Net_Host_Kick(pl^.ID, NET_DISC_BAN);
         g_Net_SaveBanList();
         g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
         MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
@@ -6788,7 +6823,7 @@ begin
         begin
           s := g_Net_ClientName_ByID(NetClients[a].ID);
           g_Net_BanHost(NetClients[a].Peer^.address.host);
-          enet_peer_disconnect(NetClients[a].Peer, NET_DISC_BAN);
+          g_Net_Host_Kick(NetClients[a].ID, NET_DISC_BAN);
           g_Net_SaveBanList();
           g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
           MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
@@ -6818,7 +6853,7 @@ begin
       begin
         s := g_Net_ClientName_ByID(pl^.ID);
         g_Net_BanHost(pl^.Peer^.address.host);
-        enet_peer_disconnect(pl^.Peer, NET_DISC_BAN);
+        g_Net_Host_Kick(pl^.ID, NET_DISC_TEMPBAN);
         g_Net_SaveBanList();
         g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
         MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
@@ -6956,10 +6991,19 @@ begin
     begin
       if Length(P) = 2 then
         g_Bot_AddList(TEAM_NONE, P[1], StrToIntDef(P[1], -1))
-      else if Length(P) = 3 then
-        g_Bot_AddList(TEAM_NONE, P[1], StrToIntDef(P[1], -1), StrToIntDef(P[2], 100))
       else
-        g_Bot_AddList(IfThen(P[2] = 'red', TEAM_RED, TEAM_BLUE), P[1], StrToIntDef(P[1], -1));
+      begin
+        if P[2] = 'red' then
+          t := TEAM_RED
+        else if P[2] = 'blue' then
+          t := TEAM_BLUE
+        else 
+          t := TEAM_NONE;
+
+        if Length(P) = 3
+          then g_Bot_AddList(t, P[1], StrToIntDef(P[1], -1))
+          else g_Bot_AddList(t, P[1], StrToIntDef(P[1], -1), StrToIntDef(P[3], 100));
+      end;
     end;
   end
   else if cmd = 'bot_removeall' then
@@ -7177,6 +7221,10 @@ begin
         g_Console_Add(_lc[I_MSG_GM_UNAVAIL])
       end
     end
+    else if not e_IsValidResourceName(P[1]) then
+    begin
+      g_Console_Add('wad name must not be absolute or relative');
+    end
     else
     begin
       if g_Game_IsServer and (gGameSettings.GameType <> GT_SINGLE) then
@@ -7304,6 +7352,10 @@ begin
           g_Console_Add(_lc[I_MSG_GM_UNAVAIL]);
         end;
       end
+      else if not e_IsValidResourceName(P[1]) then
+      begin
+        g_Console_Add('wad name must not be absolute or relative');
+      end
       else
       begin
         nm := False;