compujuckel / AssettoServer

Custom Assetto Corsa server with focus on freeroam
https://assettoserver.org
GNU Affero General Public License v3.0
282 stars 66 forks source link

No support for # in config files #8

Open gijs007 opened 2 years ago

gijs007 commented 2 years ago

Some Assetto Corsa configuration files contain comments, to help server admins guide certain settings. When using such a config file the "AssettoServer" will fail to startup with the following message:

[01:18:22 FTL] Unhandled exception occurred

IniParser.Exceptions.ParsingException: Unknown file format. Couldn't parse the line: '#Race over time specifies the time in seconds that is left to finish the race, from the moment the first driver passes the finish line'. while parsing line number 0 with value '' - IniParser version: 2.5.2.0 while parsing line number 12 with value '#Race over time specifies the time in seconds that is left to finish the race, from the moment the first driver passes the finish line' - IniParser version: 2.5.2.0

 ---> IniParser.Exceptions.ParsingException: Unknown file format. Couldn't parse the line: '#Race over time specifies the time in seconds that is left to finish the race, from the moment the first driver passes the finish line'. while parsing line number 0 with value '' - IniParser version: 2.5.2.0

   at IniParser.Parser.IniDataParser.ProcessLine(String currentLine, IniData currentIniData)

   at IniParser.Parser.IniDataParser.Parse(String iniDataString)

   --- End of inner exception stack trace ---

   at IniParser.Parser.IniDataParser.Parse(String iniDataString)

   at IniParser.StreamIniDataParser.ReadData(StreamReader reader)

   at IniParser.FileIniDataParser.ReadFile(String filePath, Encoding fileEncoding)

   at AssettoServer.Server.Configuration.ACServerConfiguration.FromFiles(String preset, String serverCfgPath, String entryListPath, ACPluginLoader loader) in /home/runner/work/AssettoServer/AssettoServer/AssettoServer/Server/Configuration/ACServerConfiguration.cs:line 85

   at AssettoServer.Program.Main(String[] args) in /home/runner/work/AssettoServer/AssettoServer/AssettoServer/Program.cs:line 56

   at AssettoServer.Program.
(String[] args)
compujuckel commented 2 years ago

you need to use ";" for comments in ini files: https://en.wikipedia.org/wiki/INI_file#Comments

gijs007 commented 2 years ago

Thanks! That works for comments, however only if they start on a new line. If we use the official example config from Kunos Simulazioni: https://www.assettocorsa.net/forum/index.php?faq/assetto-corsa-dedicated-server-manual.28/

The mod still fails to load. One could argue that Assetto Corsa Server config files do not strictly follow the ini file format. However is this plugin not supposed to be a drop in replacement for the official Assetto Corsa Server?

For example this section contains two issues:

------ UPDATE ------
TIME_OF_DAY_MULT=1  ; multiplier for the time of day
------------------------
  1. The line's with the ------ UPDATE ------ are not recognized as comments, and thus fail to parse.
  2. TIME_OF_DAY_MULT=1 ; multiplier for the time of day The ";" semicolon later in the line is not recognized as comments. Resulting in this vague error message:
[14:25:23 FTL] Unhandled exception occurred

System.FormatException: Input string was not in a correct format.

   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)

   at System.Single.Parse(String s)

   at AssettoServer.Server.Configuration.ACServerConfiguration.FromFiles(String preset, String serverCfgPath, String entryListPath, ACPluginLoader loader) in /home/runner/work/AssettoServer/AssettoServer/AssettoServer/Server/Configuration/ACServerConfiguration.cs:line 121

   at AssettoServer.Program.Main(String[] args) in /home/runner/work/AssettoServer/AssettoServer/AssettoServer/Program.cs:line 56

   at AssettoServer.Program.
(String[] args)
compujuckel commented 2 years ago

this server is far from being a drop-in replacement for the original server and currently mainly serves the purpose of creating freeroam traffic servers.

If having inline comments is important to you, feel free to create a PR.

gijs007 commented 2 years ago

It's not an important feature for me. It's just that as a new user I spend several hours troubleshooting this mod, wondering why my old config wasn't working where as a new config from the content manager worked fine immediately.

If being a drop-in replacement is not a project goal, then it would be helpful to make this a "known issue" or step in the installation/migration process and improve the error reporting on the inline comments.

compujuckel commented 2 years ago

well it wasn't a known issue before :D I usually just export my configs from CM and they'll work fine, didn't even know that the Kunos example config is such a mess.

If you want faster help than creating Github issues you could visit the #server-troubleshooting channel on our Discord.

gijs007 commented 2 years ago

Makes sense.

I can't seem to find the #server-troubleshooting channel in Discord. I do have one quick question, does the mod support Stracker and other mods which use Assetto Corsa's UDP plugin interface?

compujuckel commented 2 years ago

ah, you need to read the #welcome channel then to get full access to the server.

the UDP plugin interface is not supported.