Skip to content

[RFC] Config Overhaul #112

@InusualZ

Description

@InusualZ

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

A config file format for humans.

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 = 9000
Username = ""
Password = ""

[Game]
MaxHunterSlots = 4
Timeout1 = 32767
Timeout2 = 32767
Timeout3 = 32767
Timeout4 = 32767
Timeout5 = 32767
Timeout6 = 32767
Timeout7 = 32767
Timeout8 = 32767

	[[Game.ServerType]]
	Name = "Open" # Max Length 23 
	Description = "Hunters of all Ranks\ncan gather here.NEW" # Max Length 167
	MinimumRank = 0
	MaximumRank = 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 63
				MaxPopulation = 4

				[[Game.ServerType.Server.Gate.City]]
				Name = "City 2" # Max Length 63
				MaxPopulation = 4

				[[Game.ServerType.Server.Gate.City]]
				Name = "City 3" # Max Length 63
				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 = "Valor2"

			[[Game.ServerType.Server.Gate]]
			Name = "City Gate 1" # Max Length 63 

				[[Game.ServerType.Server.Gate.City]]
				Name = "City 1" # Max Length 63
				MaxPopulation = 4

	[[Game.ServerType]]
	Name = "Rookie" # Max Length 23 
	Description = "Only hunters HR 30\nor lower may enter.NEW" # Max Length 167
	MinimumRank = 0
	MaximumRank = 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 = true
	Minimum = 0
	Maximum = 65535

	[[Game.HRLimit]]
	Name = "Low"
	Enabled = true
	Minimum = 0
	Maximum = 30

	# Up to 8 HRLimit

	[[Game.Seeking]]
	Name = "Everyone welcome!"
	Enabled = true
	Flag = 0xff

	[[Game.Seeking]]
	Name = "Casual play"
	Enabled = true
	Flag = 0xff

	# Up to 31 Seeking Types

	[[Game.Goal]]
	Name = "None" 
	Enabled = true
	RestrictionMode = 0 # None - 0, HR Limit - 1, Unknown - 2
	Minimum = 0
	Maximum = 0

	[[Game.Goal]]
	Name = "HR1~" 
	Enabled = true
	RestrictionMode = 1
	Minimum = 1
	Maximum = 8

	[[Game.Goal]]
	Name = "HR9~" 
	Enabled = true
	RestrictionMode = 1
	Minimum = 9
	Maximum = 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions