You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seeming that we have reach a limit to the bare bone config system that the server have today (#111). I think it's a good time to introduce TOML to the software.
TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics. TOML is designed to map unambiguously to a hash table. TOML should be easy to parse into data structures in a wide variety of languages.
Why TOML
Human readable
Useful natives type
Key/Value Pairs
Arrays
Tables
Inline tables
Arrays of tables
Integers & Floats
Booleans
Dates & Times, with optional offsets
Comments
Multi Line String
Numerical Notations
Integers (1,2)
Hex (0x)
Octal (0o)
Binary (0b)
Floats (1.1)
Exponent
Scientific Notation
Separators (2_100)
Infinity
NaN
Date and Time
Example
[OpnServer]
CertificatePath = "server.cer"CertificatePassphrase = "server.key"Address = "127.0.0.1"Port = 8200
[LmpServer]
Address = "127.0.0.1"Port = 8210
[FmpServer]
Address = "127.0.0.1"Port = 8220
[Database]
Host = "127.0.0.1"Port = 9000Username = ""Password = ""
[Game]
MaxHunterSlots = 4Timeout1 = 32767Timeout2 = 32767Timeout3 = 32767Timeout4 = 32767Timeout5 = 32767Timeout6 = 32767Timeout7 = 32767Timeout8 = 32767
[[Game.ServerType]]
Name = "Open"# Max Length 23 Description = "Hunters of all Ranks\ncan gather here.NEW"# Max Length 167MinimumRank = 0MaximumRank = 65535
[[Game.ServerType.Server]]
Name = "Valor1"
[[Game.ServerType.Server.Gate]]
Name = "City Gate 1"# Max Length 63
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"# Max Length 63MaxPopulation = 4
[[Game.ServerType.Server.Gate.City]]
Name = "City 2"# Max Length 63MaxPopulation = 4
[[Game.ServerType.Server.Gate.City]]
Name = "City 3"# Max Length 63MaxPopulation = 4
[[Game.ServerType.Server.Gate]]
Name = "City Gate 2"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4
[[Game.ServerType.Server.Gate]]
Name = "City Gate 3"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4
[[Game.ServerType.Server.Gate]]
Name = "City Gate 4"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4
[[Game.ServerType.Server]]
Name = "Valor2"
[[Game.ServerType.Server.Gate]]
Name = "City Gate 1"# Max Length 63
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"# Max Length 63MaxPopulation = 4
[[Game.ServerType]]
Name = "Rookie"# Max Length 23 Description = "Only hunters HR 30\nor lower may enter.NEW"# Max Length 167MinimumRank = 0MaximumRank = 30
[[Game.ServerType.Server]]
Name = "Rookies1"
[[Game.ServerType.Server.Gate]]
Name = "City Gate 1"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4
[[Game.ServerType.Server.Gate]]
Name = "City Gate 2"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4
[[Game.ServerType.Server.Gate]]
Name = "City Gate 3"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4
[[Game.ServerType.Server.Gate]]
Name = "City Gate 4"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4
[[Game.ServerType.Server]]
Name = "Rookies2"
[[Game.ServerType.Server.Gate]]
Name = "City Gate 1"
[[Game.ServerType.Server.Gate.City]]
Name = "City 1"MaxPopulation = 4# Up to 4 Server Type
[[Game.HRLimit]]
Name = "None"Enabled = trueMinimum = 0Maximum = 65535
[[Game.HRLimit]]
Name = "Low"Enabled = trueMinimum = 0Maximum = 30# Up to 8 HRLimit
[[Game.Seeking]]
Name = "Everyone welcome!"Enabled = trueFlag = 0xff
[[Game.Seeking]]
Name = "Casual play"Enabled = trueFlag = 0xff# Up to 31 Seeking Types
[[Game.Goal]]
Name = "None"Enabled = trueRestrictionMode = 0# None - 0, HR Limit - 1, Unknown - 2Minimum = 0Maximum = 0
[[Game.Goal]]
Name = "HR1~"Enabled = trueRestrictionMode = 1Minimum = 1Maximum = 8
[[Game.Goal]]
Name = "HR9~"Enabled = trueRestrictionMode = 1Minimum = 9Maximum = 17# Up to 63 Goals
[[Game.Event]]
File = "/path/to/quest/event.bin"
[[Game.Event]]
File = "/path/to/quest/event2.bin"# Up to 10 Event
From my example you can see that even the most complex relationship can be expressed with this config format. I'm a little bit bias since I have always loved this config format (But not without reason)
The text was updated successfully, but these errors were encountered:
I have nothing against TOML, I have been thinking of YAML and JSON too but without a strong preference. Ideally, if we can integrate this dependency in externals without doing anything fancy (to support Python2/3), that would be great.
Regardless of the chosen format, we can take advantage of python format string and named arguments to write:
[[Game.ServerType.Server]]
Name = "Valor {server_index}"Name_FR = "Valeur {server_index}"
[[Game.ServerType.Server.Gate]]
Name = "City Gate {gate_index}"Name_FR = "Porte {gate_index}"
[[Game.ServerType.Server.Gate.City]]
Name = "City {city_index}"Name_FR = "Ville {city_index}"
We can also try to implement i18n by appending a language suffix (_FR in the above example), if the language isn't available we can fallback to the regular value.
I also would like to have some kind of inheritance and/or default values. So we have a way to define, for instance, 40 cities without writing 40 entries but still allow to define specialization. Something like this or similar:
[[Game.ServerType.Server.Gate.City]]
Name = "City {city_index}"Name_FR = "Ville {city_index}"Count = 40
[Game.ServerType.Server.Gate.City40]
Name = "Last city"Name_FR = "Dernière ville"
Having a way to "split" the config file into several parts could be interesting to organize things such as event/arena quests, network/ssl/db config, server name/ip/settings, etc.
Seeming that we have reach a limit to the bare bone config system that the server have today (#111). I think it's a good time to introduce
TOML
to the software.TOML
TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics. TOML is designed to map unambiguously to a hash table. TOML should be easy to parse into data structures in a wide variety of languages.
Why
TOML
Example
From my example you can see that even the most complex relationship can be expressed with this config format. I'm a little bit bias since I have always loved this config format (But not without reason)
The text was updated successfully, but these errors were encountered: