X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=1468551a3c29fcd0ee26e32bc564ed7800559c2d;hb=f628f55ae39e87c3a8e0c6204e3e8a847d683618;hp=06176d94272587199f1e6c7f910cb046fc5565f4;hpb=ce24e997b94d04fa00b002ab2786cddc060868a9;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 06176d9..1468551 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -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; @@ -1096,26 +1096,33 @@ begin Team := BotList[num].team; // CTF / TDM // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè: - lName := AnsiLowerCase(lName); - if (num < 0) or (num > Length(BotList)-1) then - num := -1; - if (num = -1) and (lName <> '') and (BotList <> nil) then - for a := 0 to High(BotList) do - if AnsiLowerCase(BotList[a].name) = lName then - begin - num := a; - Break; - end; - if num = -1 then - Exit; + if lName = '' then + num := Random(Length(BotList)) + else + begin + if (num < 0) or (num > Length(BotList)-1) then + num := -1; + if (num = -1) and (BotList <> nil) then + lName := AnsiLowerCase(lName); + for a := 0 to High(BotList) do + if AnsiLowerCase(BotList[a].name) = lName then + begin + num := a; + Break; + end; + if num = -1 then + Exit; + end; // Èìÿ áîòà: _name := BotList[num].name; -// Çàíÿòî - âûáèðàåì ñëó÷àéíîå: - if not g_Player_ValidName(_name) then - repeat - _name := Format('DFBOT%.2d', [Random(100)]); - until g_Player_ValidName(_name); + if (_name = '') and (BotNames <> nil) then + for a := 0 to High(BotNames) do + if g_Player_ExistingName(BotNames[a]) then + begin + _name := BotNames[a]; + Break; + end; // Ìîäåëü: _model := BotList[num].model; @@ -1126,7 +1133,10 @@ begin // Ñîçäàåì áîòà: with g_Player_Get(g_Player_Create(_model, BotList[num].color, Team, True)) as TBot do begin - Name := _name; + // Åñëè èìåíè íåò, äåëàåì åãî èç UID áîòà + if _name = '' + then Name := Format('DFBOT%.5d', [UID]) + else Name := _name; FDifficult.DiagFire := BotList[num].diag_fire; FDifficult.InvisFire := BotList[num].invis_fire; @@ -1261,12 +1271,17 @@ begin model := config.ReadStr(IntToStr(a), 'model', ''); // Ìîäåëü // Êîìàíäà - if config.ReadStr(IntToStr(a), 'team', 'red') = 'red' - then team := TEAM_RED - else team := TEAM_BLUE; + s := config.ReadStr(IntToStr(a), 'team', ''); + if s = 'red' then + team := TEAM_RED + else if s = 'blue' then + team := TEAM_BLUE + else + team := TEAM_NONE; // Öâåò ìîäåëè sa := parse(config.ReadStr(IntToStr(a), 'color', '')); + SetLength(sa, 3); color.R := StrToIntDef(sa[0], 0); color.G := StrToIntDef(sa[1], 0); color.B := StrToIntDef(sa[2], 0); @@ -5554,7 +5569,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