From: Dmitry D. Chernov Date: Sat, 15 Jul 2023 05:35:05 +0000 (+1000) Subject: Fix 'bot_addlist' console command not working X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=ce24e997b94d04fa00b002ab2786cddc060868a9;p=d2df-sdl.git Fix 'bot_addlist' console command not working Regression was introduced in 414f2873efa0cce84499f64774db7000e6268971. --- diff --git a/src/game/g_player.pas b/src/game/g_player.pas index a7afb5c..06176d9 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -1217,90 +1217,91 @@ var path: AnsiString; begin BotNames := nil; + BotList := nil; path := BOTNAMES_FILENAME; - if e_FindResource(DataDirs, path) = false then - Exit; - -// ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà: - AssignFile(F, path); - Reset(F); - - while not EOF(F) do + if e_FindResource(DataDirs, path) then begin - ReadLn(F, s); + // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà: + AssignFile(F, path); + Reset(F); - s := Trim(s); - if s = '' then - Continue; + while not EOF(F) do + begin + ReadLn(F, s); - SetLength(BotNames, Length(BotNames)+1); - BotNames[High(BotNames)] := s; - end; + s := Trim(s); + if s = '' then + Continue; - CloseFile(F); + SetLength(BotNames, Length(BotNames)+1); + BotNames[High(BotNames)] := s; + end; -// Ïåðåìåøèâàåì èõ: - g_Bot_MixNames(); + CloseFile(F); -// ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ: - config := TConfig.CreateFile(path); - BotList := nil; - a := 0; + // Ïåðåìåøèâàåì èõ: + g_Bot_MixNames(); + end; - while config.SectionExists(IntToStr(a)) do + path := BOTLIST_FILENAME; + if e_FindResource(DataDirs, path) then begin - SetLength(BotList, Length(BotList)+1); + // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ: + config := TConfig.CreateFile(path); + a := 0; - with BotList[High(BotList)] do + while config.SectionExists(IntToStr(a)) do begin - // Èìÿ áîòà: - name := config.ReadStr(IntToStr(a), 'name', ''); - // Ìîäåëü: - model := config.ReadStr(IntToStr(a), 'model', ''); - // Êîìàíäà: - if config.ReadStr(IntToStr(a), 'team', 'red') = 'red' then - team := TEAM_RED - else - team := TEAM_BLUE; - // Öâåò ìîäåëè: - sa := parse(config.ReadStr(IntToStr(a), 'color', '')); - color.R := StrToIntDef(sa[0], 0); - color.G := StrToIntDef(sa[1], 0); - color.B := StrToIntDef(sa[2], 0); - // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì: - diag_fire := config.ReadInt(IntToStr(a), 'diag_fire', 0); - // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó: - invis_fire := config.ReadInt(IntToStr(a), 'invis_fire', 0); - // Òî÷íîñòü ñòðåëüáû ïîä óãëîì: - diag_precision := config.ReadInt(IntToStr(a), 'diag_precision', 0); - // Òî÷íîñòü ñòðåëüáû â ïîëåòå: - fly_precision := config.ReadInt(IntToStr(a), 'fly_precision', 0); - // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ: - cover := config.ReadInt(IntToStr(a), 'cover', 0); - // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà: - close_jump := config.ReadInt(IntToStr(a), 'close_jump', 0); - // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ: - sa := parse(config.ReadStr(IntToStr(a), 'w_prior1', '')); - if Length(sa) = 10 then - for b := 0 to 9 do - w_prior1[b] := EnsureRange(StrToInt(sa[b]), 0, 9); - // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ: - sa := parse(config.ReadStr(IntToStr(a), 'w_prior2', '')); - if Length(sa) = 10 then - for b := 0 to 9 do - w_prior2[b] := EnsureRange(StrToInt(sa[b]), 0, 9); - - {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', '')); - if Length(sa) = 10 then - for b := 0 to 9 do - w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);} + SetLength(BotList, Length(BotList)+1); + + with BotList[High(BotList)] do + begin + name := config.ReadStr(IntToStr(a), 'name', ''); // Èìÿ áîòà + model := config.ReadStr(IntToStr(a), 'model', ''); // Ìîäåëü + + // Êîìàíäà + if config.ReadStr(IntToStr(a), 'team', 'red') = 'red' + then team := TEAM_RED + else team := TEAM_BLUE; + + // Öâåò ìîäåëè + sa := parse(config.ReadStr(IntToStr(a), 'color', '')); + color.R := StrToIntDef(sa[0], 0); + color.G := StrToIntDef(sa[1], 0); + color.B := StrToIntDef(sa[2], 0); + + diag_fire := config.ReadInt(IntToStr(a), 'diag_fire', 0); // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì + invis_fire := config.ReadInt(IntToStr(a), 'invis_fire', 0); // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó + diag_precision := config.ReadInt(IntToStr(a), 'diag_precision', 0); // Òî÷íîñòü ñòðåëüáû ïîä óãëîì + fly_precision := config.ReadInt(IntToStr(a), 'fly_precision', 0); // Òî÷íîñòü ñòðåëüáû â ïîëåòå + cover := config.ReadInt(IntToStr(a), 'cover', 0); // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ + close_jump := config.ReadInt(IntToStr(a), 'close_jump', 0); // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà + + // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ + sa := parse(config.ReadStr(IntToStr(a), 'w_prior1', '')); + if Length(sa) = 10 then + for b := 0 to 9 do + w_prior1[b] := EnsureRange(StrToInt(sa[b]), 0, 9); + + // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ + sa := parse(config.ReadStr(IntToStr(a), 'w_prior2', '')); + if Length(sa) = 10 then + for b := 0 to 9 do + w_prior2[b] := EnsureRange(StrToInt(sa[b]), 0, 9); + + {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', '')); + if Length(sa) = 10 then + for b := 0 to 9 do + w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);} + end; + + a += 1; end; - a := a + 1; + config.Free(); end; - config.Free(); SetLength(SavedStates, 0); end;