DEADSOFTWARE

game: add g_max_bots
[d2df-sdl.git] / src / game / g_game.pas
index 7e30028766f9080332d9568345b134bb3fa3b812..5822952a5e8383595a747ebfd831ac19bdc4e06c 100644 (file)
@@ -350,6 +350,7 @@ var
   gWeaponAction: Array [0..1, WP_FACT..WP_LACT] of Boolean; // [player, weapon_action]
   gSelectWeapon: Array [0..1, WP_FIRST..WP_LAST] of Boolean; // [player, weapon]
   gInterReadyCount: Integer = 0;
+  gMaxBots: Integer = 127;
 
   g_dbg_ignore_bounds: Boolean = false;
   r_smallmap_h: Integer = 0; // 0: left; 1: center; 2: right
@@ -5701,7 +5702,7 @@ begin
   begin
     if Length(p) = 2 then
     begin
-      a := Max(0, StrToInt(p[1]));
+      a := Max(0, StrToIntDef(p[1], 0));
       g_GFX_SetMax(a)
     end
     else if Length(p) = 1 then
@@ -5717,7 +5718,7 @@ begin
   begin
     if Length(p) = 2 then
     begin
-      a := Max(0, StrToInt(p[1]));
+      a := Max(0, StrToIntDef(p[1], 0));
       g_Shells_SetMax(a)
     end
     else if Length(p) = 1 then
@@ -5733,7 +5734,7 @@ begin
   begin
     if Length(p) = 2 then
     begin
-      a := Max(0, StrToInt(p[1]));
+      a := Max(0, StrToIntDef(p[1], 0));
       g_Gibs_SetMax(a)
     end
     else if Length(p) = 1 then
@@ -5749,7 +5750,7 @@ begin
   begin
     if Length(p) = 2 then
     begin
-      a := Max(0, StrToInt(p[1]));
+      a := Max(0, StrToIntDef(p[1], 0));
       g_Corpses_SetMax(a)
     end
     else if Length(p) = 1 then
@@ -5807,6 +5808,12 @@ begin
                          (gsTimeLimit div 60) mod 60,
                           gsTimeLimit mod 60]));
   end
+  else if cmd = 'g_max_bots' then
+  begin
+    if Length(P) > 1 then
+      gMaxBots := nclamp(StrToIntDef(P[1], gMaxBots), 0, 127);
+    g_Console_Add('g_max_bots = ' + IntToStr(gMaxBots));
+  end
   else if cmd = 'g_maxlives' then
   begin
     if Length(P) > 1 then
@@ -6976,6 +6983,34 @@ begin
     end else
       g_Console_Add(_lc[I_MSG_GM_UNAVAIL]);
   end
+  else if (cmd = 'an') or (cmd = 'announce') then
+  begin
+    if g_Game_IsNet then
+    begin
+      if Length(P) > 1 then
+      begin
+        for a := 1 to High(P) do
+          chstr := chstr + P[a] + ' ';
+
+        if Length(chstr) > 200 then SetLength(chstr, 200);
+
+        if Length(chstr) < 1 then
+        begin
+          g_Console_Add('announce <text>');
+          Exit;
+        end;
+
+        chstr := 'centerprint 100 ' + b_Text_Format(chstr);
+        if g_Game_IsClient then
+          MC_SEND_RCONCommand(chstr)
+        else
+          g_Console_Process(chstr, True);
+      end
+      else
+        g_Console_Add('announce <text>');
+    end else
+      g_Console_Add(_lc[I_MSG_GM_UNAVAIL]);
+  end
   else if cmd = 'game' then
   begin
     if gGameSettings.GameType <> GT_NONE then
@@ -7432,7 +7467,7 @@ begin
   begin
     if Length(p) = 2 then
     begin
-      a := WP_FIRST + StrToInt(p[1]) - 1;
+      a := WP_FIRST + StrToIntDef(p[1], 0) - 1;
       if (a >= WP_FIRST) and (a <= WP_LAST) then
         gSelectWeapon[0, a] := True
     end
@@ -7451,7 +7486,7 @@ begin
   begin
     if Length(p) = 2 then
     begin
-      a := WP_FIRST + StrToInt(p[1]) - 1;
+      a := WP_FIRST + StrToIntDef(p[1], 0) - 1;
       b := ord(cmd[2]) - ord('1');
       if (a >= WP_FIRST) and (a <= WP_LAST) then
         gSelectWeapon[b, a] := True
@@ -7775,7 +7810,7 @@ begin
     name := e_CatPath(dir, Filename + '.png');
     s := createDiskFile(name);
     try
-      e_MakeScreenshot(s, gScreenWidth, gScreenHeight);
+      e_MakeScreenshot(s, gWinSizeX, gWinSizeX);
       s.Free;
       g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name]))
     except