@@ -15,7 +15,6 @@ public static class Fields
1515 public const string RlBotLauncher = "launcher" ;
1616 public const string RlBotLauncherArg = "launcher_arg" ;
1717 public const string RlBotAutoStartAgents = "auto_start_agents" ;
18- public const string RlBotAutoStartAgentsOld = "auto_start_bots" ;
1918 public const string RlBotWaitForAgents = "wait_for_agents" ;
2019
2120 public const string MatchTable = "match" ;
@@ -70,7 +69,6 @@ public static class Fields
7069 public const string AgentName = "name" ;
7170 public const string AgentLoadoutFile = "loadout_file" ;
7271 public const string AgentConfigFile = "config_file" ;
73- public const string AgentConfigFileOld = "config" ;
7472 public const string AgentSettingsTable = "settings" ;
7573 public const string AgentAgentId = "agent_id" ;
7674 public const string AgentRootDir = "root_dir" ;
@@ -270,100 +268,155 @@ private PlayerConfigurationT ParseCarTable(TomlTable table, string matchConfigPa
270268 }
271269
272270 PlayerClass playerClass = GetEnum ( table , Fields . AgentType , PlayerClass . CustomBot ) ;
273-
274- ( PlayerClassUnion variety , bool useConfig ) = playerClass switch
271+ if ( playerClass == PlayerClass . Human )
275272 {
276- PlayerClass . CustomBot => ( PlayerClassUnion . FromCustomBot ( new CustomBotT ( ) ) , true ) ,
277- PlayerClass . Psyonix => (
278- PlayerClassUnion . FromPsyonix (
279- new PsyonixT
280- {
281- BotSkill = GetEnum ( table , Fields . AgentSkill , PsyonixSkill . AllStar ) ,
282- }
283- ) ,
284- true
285- ) ,
286- PlayerClass . Human => ( PlayerClassUnion . FromHuman ( new HumanT ( ) ) , false ) ,
287- PlayerClass . PartyMember => throw new NotImplementedException (
288- "PartyMember not implemented"
289- ) ,
290- _ => throw new ConfigParserException (
291- $ "{ _context . ToStringWithEnd ( Fields . AgentType ) } is out of range."
292- ) ,
293- } ;
273+ return new PlayerConfigurationT
274+ {
275+ Variety = PlayerClassUnion . FromHuman ( new HumanT ( ) ) ,
276+ Team = team ,
277+ PlayerId = 0 ,
278+ } ;
279+ }
294280
295- string configPath = useConfig ? GetValue ( table , Fields . AgentConfigFile , "" ) : "" ;
296- // FIXME: Remove in v5.beta.6.0+
297- if ( configPath == "" && table . ContainsKey ( Fields . AgentConfigFileOld ) )
281+ string configPath = GetValue ( table , Fields . AgentConfigFile , "" ) ;
282+ if ( configPath != "" )
298283 {
299- Logger . LogError (
300- $ "In { _context } : '{ Fields . AgentConfigFileOld } ' has been removed. Use '{ Fields . AgentConfigFile } ' instead."
301- ) ;
284+ string absoluteConfigPath = Path . Combine ( matchConfigDir , configPath ) ;
285+ using ( _context . Begin ( Fields . AgentConfigFile , ConfigContextTracker . Type . Link ) )
286+ {
287+ switch ( playerClass )
288+ {
289+ case PlayerClass . PsyonixBot :
290+ return LoadPsyonixConfig (
291+ absoluteConfigPath ,
292+ team ,
293+ nameOverride ,
294+ loadoutFileOverride
295+ ) ;
296+ case PlayerClass . CustomBot :
297+ return LoadPlayerConfig (
298+ absoluteConfigPath ,
299+ team ,
300+ nameOverride ,
301+ loadoutFileOverride ,
302+ GetValue ( table , Fields . AgentAutoStart , true )
303+ ) ;
304+ default :
305+ throw new ConfigParserException (
306+ $ "{ _context . ToStringWithEnd ( Fields . AgentType ) } is out of range."
307+ ) ;
308+ }
309+ }
302310 }
303311
304- PlayerConfigurationT player ;
305- if ( useConfig && configPath == "" && variety . Type == PlayerClass . CustomBot )
312+ PlayerLoadoutT ? loadout = null ;
313+ if ( loadoutFileOverride is not null )
306314 {
307- throw new FileNotFoundException (
308- $ " { _context } has type \" rlbot \" but { _context . ToStringWithEnd ( Fields . AgentConfigFile ) } is empty. "
309- + $ "RLBot bots must specify a config file."
310- ) ;
315+ using ( _context . Begin ( Fields . AgentLoadoutFile , ConfigContextTracker . Type . Link ) )
316+ {
317+ loadout = LoadPlayerLoadout ( loadoutFileOverride , team ) ;
318+ }
311319 }
312320
313- if ( useConfig && configPath != "" )
321+ PlayerClassUnion variety ;
322+ switch ( playerClass )
314323 {
315- string absoluteConfigPath = Path . Combine ( matchConfigDir , configPath ) ;
316- using ( _context . Begin ( Fields . AgentConfigFile , ConfigContextTracker . Type . Link ) )
317- {
318- player = LoadPlayerConfig (
319- absoluteConfigPath ,
320- variety ,
321- team ,
322- nameOverride ,
323- loadoutFileOverride
324+ case PlayerClass . PsyonixBot :
325+ variety = PlayerClassUnion . FromPsyonixBot (
326+ new PsyonixBotT
327+ {
328+ BotSkill = GetEnum ( table , Fields . AgentSkill , PsyonixSkill . AllStar ) ,
329+ Loadout = loadout ,
330+ Name = nameOverride ,
331+ }
332+ ) ;
333+ break ;
334+ case PlayerClass . CustomBot :
335+ variety = PlayerClassUnion . FromPsyonixBot (
336+ new PsyonixBotT
337+ {
338+ BotSkill = GetEnum ( table , Fields . AgentSkill , PsyonixSkill . AllStar ) ,
339+ Loadout = loadout ,
340+ Name = nameOverride ,
341+ }
342+ ) ;
343+ break ;
344+ default :
345+ throw new ConfigParserException (
346+ $ "{ _context . ToStringWithEnd ( Fields . AgentType ) } is out of range."
324347 ) ;
325- }
326348 }
327- else
349+
350+ return new PlayerConfigurationT
328351 {
329- PlayerLoadoutT ? loadout = null ;
330- if ( loadoutFileOverride is not null )
352+ Variety = variety ,
353+ Team = team ,
354+ PlayerId = 0 ,
355+ } ;
356+ }
357+
358+ private PlayerConfigurationT LoadPsyonixConfig (
359+ string configPath ,
360+ uint team ,
361+ string ? nameOverride ,
362+ string ? loadoutFileOverride
363+ )
364+ {
365+ TomlTable table = LoadTomlFile ( configPath ) ;
366+ string configDir = Path . GetDirectoryName ( configPath ) ! ;
367+
368+ TomlTable settings = GetValue < TomlTable > ( table , Fields . AgentSettingsTable , [ ] ) ;
369+ using ( _context . Begin ( Fields . AgentSettingsTable ) )
370+ {
371+ string rootDir = Path . Combine (
372+ configDir ,
373+ GetValue < string > ( settings , Fields . AgentRootDir , "" )
374+ ) ;
375+
376+ // Override is null, "", or an absolute path.
377+ // Null implies no override and "" implies we should not load the loadout.
378+ string ? loadoutPath = loadoutFileOverride ;
379+ if ( loadoutFileOverride is null )
331380 {
332- using ( _context . Begin ( Fields . AgentLoadoutFile , ConfigContextTracker . Type . Link ) )
381+ if ( settings . TryGetValue ( Fields . AgentLoadoutFile , out var loadoutPathRel ) )
333382 {
334- loadout = LoadPlayerLoadout ( loadoutFileOverride , team ) ;
383+ loadoutPath = Path . Combine ( configDir , ( string ) loadoutPathRel ) ;
384+ }
385+ else
386+ {
387+ _missingValues . Add ( _context . ToStringWithEnd ( Fields . AgentLoadoutFile ) ) ;
335388 }
336389 }
337390
338- player = new PlayerConfigurationT
391+ PlayerLoadoutT ? loadout ;
392+ using ( _context . Begin ( Fields . AgentLoadoutFile , ConfigContextTracker . Type . Link ) )
339393 {
340- AgentId = "" ,
341- Variety = variety ,
342- Name = nameOverride ,
343- Team = team ,
394+ loadout =
395+ ( loadoutPath ?? "" ) != "" ? LoadPlayerLoadout ( loadoutPath ! , team ) : null ;
396+ }
397+
398+ PsyonixBotT variety = new ( )
399+ {
400+ BotSkill = GetEnum ( table , Fields . AgentSkill , PsyonixSkill . AllStar ) ,
344401 Loadout = loadout ,
345- Hivemind = false ,
346- RootDir = "" ,
347- RunCommand = "" ,
348- PlayerId = 0 ,
402+ Name = nameOverride ?? GetValue < string > ( settings , Fields . AgentName , "" ) ,
349403 } ;
350- }
351404
352- bool autoStart = GetValue ( table , Fields . AgentAutoStart , true ) ;
353- if ( ! autoStart )
354- {
355- player . RunCommand = "" ;
405+ return new PlayerConfigurationT
406+ {
407+ Variety = PlayerClassUnion . FromPsyonixBot ( variety ) ,
408+ Team = team ,
409+ PlayerId = 0 ,
410+ } ;
356411 }
357-
358- return player ;
359412 }
360413
361414 private PlayerConfigurationT LoadPlayerConfig (
362415 string configPath ,
363- PlayerClassUnion variety ,
364416 uint team ,
365417 string ? nameOverride ,
366- string ? loadoutFileOverride
418+ string ? loadoutFileOverride ,
419+ bool autoStart
367420 )
368421 {
369422 TomlTable table = LoadTomlFile ( configPath ) ;
@@ -399,17 +452,21 @@ private PlayerConfigurationT LoadPlayerConfig(
399452 ( loadoutPath ?? "" ) != "" ? LoadPlayerLoadout ( loadoutPath ! , team ) : null ;
400453 }
401454
402- return new PlayerConfigurationT
455+ CustomBotT variety = new ( )
403456 {
404457 AgentId = GetValue < string > ( settings , Fields . AgentAgentId , "" ) ,
405458 Name = nameOverride ?? GetValue < string > ( settings , Fields . AgentName , "" ) ,
406- Team = team ,
407459 Loadout = loadout ,
408- RunCommand = GetRunCommand ( settings ) ,
460+ RunCommand = autoStart ? GetRunCommand ( settings ) : "" ,
409461 Hivemind = GetValue ( settings , Fields . AgentHivemind , false ) ,
410462 RootDir = rootDir ,
463+ } ;
464+
465+ return new PlayerConfigurationT
466+ {
467+ Variety = PlayerClassUnion . FromCustomBot ( variety ) ,
468+ Team = team ,
411469 PlayerId = 0 ,
412- Variety = variety ,
413470 } ;
414471 }
415472 }
@@ -656,21 +713,6 @@ public MatchConfigurationT LoadMatchConfig(string path)
656713 Fields . RlBotWaitForAgents ,
657714 true
658715 ) ;
659- // TODO: Remove in future version
660- if ( rlbotTable . ContainsKey ( Fields . RlBotAutoStartAgentsOld ) )
661- {
662- bool autoStartBots = GetValue (
663- rlbotTable ,
664- Fields . RlBotAutoStartAgentsOld ,
665- true
666- ) ;
667- matchConfig . AutoStartAgents = autoStartBots ;
668- matchConfig . WaitForAgents = autoStartBots ;
669- Logger . LogWarning (
670- $ "'{ Fields . RlBotAutoStartAgentsOld } ' is deprecated. Please use "
671- + $ "'{ Fields . RlBotAutoStartAgents } ' and '{ Fields . RlBotWaitForAgents } ' instead."
672- ) ;
673- }
674716 }
675717
676718 TomlTableArray players = GetValue < TomlTableArray > ( outerTable , Fields . CarsList , [ ] ) ;
@@ -749,10 +791,10 @@ public MatchConfigurationT LoadMatchConfig(string path)
749791 Fields . MatchStartWithoutCountdown ,
750792 false
751793 ) ;
752- matchConfig . EnableRendering = GetValue (
794+ matchConfig . EnableRendering = GetEnum (
753795 matchTable ,
754796 Fields . MatchRendering ,
755- false
797+ DebugRendering . OffByDefault
756798 ) ;
757799 matchConfig . EnableStateSetting = GetValue (
758800 matchTable ,
0 commit comments