summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 06ce403)
raw | patch | inline | side by side (parent: 06ce403)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Mon, 2 May 2022 14:05:08 +0000 (17:05 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Mon, 2 May 2022 14:05:08 +0000 (17:05 +0300) |
src/game/g_console.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history | |
src/game/g_player.pas | patch | blob | history |
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 7ae8166192d7c16994c1855083076335fbf88d3a..64b08642029b320c93a0377ae8a56526b94eb821 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
AddCommand('g_throw_flag', GameCVars);
AddCommand('g_bot_vsmonsters', GameCVars);
AddCommand('g_bot_vsplayers', GameCVars);
+ AddCommand('g_max_bots', GameCVars); // intentionally not whitelisted
AddCommand('g_scorelimit', GameCVars);
AddCommand('g_timelimit', GameCVars);
AddCommand('g_maxlives', GameCVars);
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index d1246ba0c7dabdc027035501fe4fee5bd9bfc6a7..5822952a5e8383595a747ebfd831ac19bdc4e06c 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
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
(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
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 23be583051a8a69d66adac8c96af8ae2a4e2ca23..19d6be55027fbad4ea488a2915b2d034f5a464e0 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure g_Bot_AddList(Team: Byte; lname: ShortString; num: Integer = -1; Handicap: Integer = 100);
procedure g_Bot_MixNames();
procedure g_Bot_RemoveAll();
+function g_Bot_GetCount(): Integer;
implementation
begin
if not g_Game_IsServer then Exit;
+// Íå äîáàâëÿåì áîòîâ åñëè ëèìèò óæå äîñòèãíóò
+ if (g_Bot_GetCount() >= gMaxBots) then Exit;
+
// Ñïèñîê íàçâàíèé ìîäåëåé:
m := g_PlayerModel_GetNames();
if m = nil then
begin
if not g_Game_IsServer then Exit;
+// Íå äîáàâëÿåì áîòîâ åñëè ëèìèò óæå äîñòèãíóò
+ if (g_Bot_GetCount() >= gMaxBots) then Exit;
+
// Ñïèñîê íàçâàíèé ìîäåëåé:
m := g_PlayerModel_GetNames();
if m = nil then
Result := Result + 1;
end;
+function g_Bot_GetCount(): Integer;
+var
+ a: Integer;
+begin
+ Result := 0;
+
+ if gPlayers = nil then
+ Exit;
+
+ for a := 0 to High(gPlayers) do
+ if (gPlayers[a] <> nil) and (gPlayers[a] is TBot) then
+ Result := Result + 1;
+end;
+
function g_Player_GetStats(): TPlayerStatArray;
var
a: Integer;