DEADSOFTWARE

Allow duplicated names for bots added by the 'bot_addlist' console command
authorDmitry D. Chernov <blackdoomer@yandex.ru>
Sat, 15 Jul 2023 11:17:42 +0000 (21:17 +1000)
committerDmitry D. Chernov <blackdoomer@yandex.ru>
Sat, 15 Jul 2023 11:17:42 +0000 (21:17 +1000)
Let's trust the user. This also fixes frequent fallback names when selecting preset randomly.

src/game/g_player.pas

index cda360c1006e6ad066964625442ae568e12fac86..82ce13054db7fb141c6468f3c5b01b9c74c861d3 100644 (file)
@@ -623,7 +623,7 @@ procedure g_Player_ResetAll(Force, Silent: Boolean);
 function  g_Player_Get(UID: Word): TPlayer;
 function  g_Player_GetCount(): Byte;
 function  g_Player_GetStats(): TPlayerStatArray;
-function  g_Player_ValidName(Name: String): Boolean;
+function  g_Player_ExistingName(Name: String): Boolean;
 function  g_Player_CreateCorpse(Player: TPlayer): Integer;
 procedure g_Player_CreateGibs(fX, fY: Integer; ModelName: String; fColor: TRGB);
 procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
@@ -1024,7 +1024,7 @@ begin
   _name := '';
   if BotNames <> nil then
     for a := 0 to High(BotNames) do
-      if g_Player_ValidName(BotNames[a]) then
+      if g_Player_ExistingName(BotNames[a]) then
       begin
         _name := BotNames[a];
         Break;
@@ -1116,11 +1116,6 @@ begin
 
 // Èìÿ áîòà:
   _name := BotList[num].name;
-// Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
-  if not g_Player_ValidName(_name) then
-  repeat
-    _name := Format('DFBOT%.2d', [Random(100)]);
-  until g_Player_ValidName(_name);
 
 // Ìîäåëü:
   _model := BotList[num].model;
@@ -5559,7 +5554,7 @@ begin
             (y >= 0) and (y <= PLAYER_RECT.Height);
 end;
 
-function g_Player_ValidName(Name: string): Boolean;
+function g_Player_ExistingName(Name: string): Boolean;
 var
   a: Integer;
 begin