Jump to content


Photo

[2016-08-20] Configuration files converted to libconfig


  • Please log in to reply
15 replies to this topic

#1 Haru

Haru

    Development Administrator

  • Administrators
  • 369 posts
  • Emulator:Hercules
  • Github:MishimaHaruna

Posted 20 August 2016 - 02:36 PM

Rationale:
This changeset updates the syntax of the configuration files, to allow for more flexibility, and get rid of our some times buggy custom parser.

Contents:
All the txt-based configuration files in the conf folder have been replaced with more modular files that use the libconfig syntax. This allows more expressivity in the configuration syntax (i.e it allows to use arrays/lists/groups, especially in settings such as the starting items for players, or the hash check), but, more importantly, it allows to modularize and cross-reference some settings (for example, to change a database username and password, an user only needs to edit one file now, which is in turn included by the other files).

Impact:
Users will need to update their custom configuration. A tool that parses the old configuration and suggests appropriate edits, is included.

Details:
Some highlights about the improvements of the new syntax:

The start items/start point syntax (char-server.conf) is now improved as follows:
// Old syntax
// Start point, Map name followed by coordinates (x,y)
start_point_re: iz_int,97,90
start_point_pre: new_1-1,53,111

// Starting items for new characters
// Format is: id1,quantity1,stackable1,idN,quantityN,stackableN
// stackable:
//             0 - Not stackable (weapon, armor, egg, pet armor)
//             1 - Stackable
start_items: 1201,1,0,2301,1,0

// Starting zeny for new characters
start_zeny: 0
 
 
// New syntax
player: {
    new: {
    // Start point (Renewal)
    start_point_re: {
        map: "iz_int"
        x: 97
        y: 90
    }
    // Start point (Pre-Renewal)
    start_point_pre: {
        map: "new_1-1"
        x: 53
        y: 111
    }
    // Starting items for new characters
    //{
    //    id: Item id
    //    amount: Item amount
    //    loc: Item position, same as in item_db if you want the item to be equipped, otherwise 0 (optional)
    //    stackable: Is stackable? (not stackable item types: weapon, armor, egg, pet armor)
    //},
    start_items: (
    {
        id: 1201 // Knife
        amount: 1
        loc: 2
        stackable: false
    },
    {
        id: 2301 // Cotton_Shirt
        amount: 1
        loc: 16
        stackable: false
    },
    )
    // Starting zeny
    zeny: 0
}
The new format is certainly more verbose, but it's much easier to understand (and allows for new fields, see for example the 'loc' optional field of the starting items.

Another important feature is the 'global configuration' mechanism. There are files in conf/global/, that are included by all three (login, char, map) default configurations. For example, to globally edit the sql connection parameters for all three servers, an user can simply edit the configuration in conf/global/sql_connection.conf:
sql_connection: {
    // [INTER] You can specify the codepage to use in your mySQL tables here.
    // (Note that this feature requires MySQL 4.1+)
    //default_codepage: ""

    // [LOGIN] Is `userid` in account_db case sensitive?
    //case_sensitive: false

    // For IPs, ideally under linux, you want to use localhost instead of 127.0.0.1.
    // Under windows, you want to use 127.0.0.1.  If you see a message like
    // "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"
    // and you have localhost, switch it to 127.0.0.1
    db_hostname: "127.0.0.1"
    db_port: 3306
    db_username: "ragnarok"
    db_password: "ragnarok"
    db_database: "ragnarok"
    //codepage:""
}
In order to migrate the old configuration to the new format, a helper tool is provided in tools/configconverter.pl. The script will parse any existing config files with the old format, and suggest the corresponding new format. The user will need to manually paste the suggestions in the appropriate configuration file (we decided not to automate this, so that the settings are validated by a human, rather than blindly copied over). The helper tool is smart enough to understand which settings were left to their default setting in the old configuration file, and ignore them, only printing the relevant information.
% perl tools/configconverter.pl
=============== Hercules Configuration Migration Helper ===============
=               _   _                     _                           =
=              | | | |                   | |                          =
=              | |_| | ___ _ __ ___ _   _| | ___  ___                 =
=              |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|                =
=              | | | |  __/ | | (__| |_| | |  __/\__ \                =
=              \_| |_/\___|_|  \___|\__,_|_|\___||___/                =
=======================================================================
This tool will assist you through the migration of the old (txt-based)
configuration files to the new (libconfig-based) format.
Please follow the displayed instructions.
=======================================================================
 
Checking conf/char-server.conf... Ok
 
Checking conf/import/char_conf.txt... Old file is still present
1 non-default settings found. Please review and migrate the settings as described, then delete the file 'conf/import/char_conf.txt', as it is no longer used by Hercules.
- Found setting: 'pincode_enabled'.
  Please manually move the setting to 'char-server.conf' as in the following example:
        char_configuration: {
                pincode: {
                        enabled: false
                }
        }
 
Checking conf/inter-server.conf... Ok
 
Checking conf/import/inter_conf.txt... Old file is still present
0 non-default settings found. The file 'conf/import/inter_conf.txt' is no longer used by Hercules and can be deleted.
 
Checking conf/login-server.conf... Ok
 
Checking conf/import/login_conf.txt... Old file is still present
0 non-default settings found. The file 'conf/import/login_conf.txt' is no longer used by Hercules and can be deleted.
 
Checking conf/map-server.conf... Ok
 
Checking conf/import/map_conf.txt... Old file is still present
0 non-default settings found. The file 'conf/import/map_conf.txt' is no longer used by Hercules and can be deleted.
 
Checking conf/logs.conf... Ok
 
Checking conf/import/log_conf.txt... Old file is still present
0 non-default settings found. The file 'conf/import/log_conf.txt' is no longer used by Hercules and can be deleted.
 
Checking conf/script.conf... Ok
 
Checking conf/import/script_conf.txt... Old file is still present
0 non-default settings found. The file 'conf/import/script_conf.txt' is no longer used by Hercules and can be deleted.
 
Checking conf/packet.conf... Ok
 
Checking conf/import/packet_conf.txt... Old file is still present
0 non-default settings found. The file 'conf/import/packet_conf.txt' is no longer used by Hercules and can be deleted.
 
Checking conf/battle.conf... Ok
 
Checking conf/battle/battle.conf... Ok
 
Checking conf/battle/client.conf... Ok
 
Checking conf/battle/drops.conf... Ok
 
Checking conf/battle/exp.conf... Ok
 
Checking conf/battle/gm.conf... Ok
 
Checking conf/battle/guild.conf... Ok
 
Checking conf/battle/battleground.conf... Ok
 
Checking conf/battle/items.conf... Ok
 
Checking conf/battle/monster.conf... Ok
 
Checking conf/battle/party.conf... Ok
 
Checking conf/battle/pet.conf... Ok
 
Checking conf/battle/homunc.conf... Ok
 
Checking conf/battle/player.conf... Ok
 
Checking conf/battle/skill.conf... Ok
 
Checking conf/battle/status.conf... Ok
 
Checking conf/battle/feature.conf... Ok
 
Checking conf/battle/misc.conf... Ok
 
Checking conf/import/battle_conf.txt... Old file is still present
0 non-default settings found. The file 'conf/import/battle_conf.txt' is no longer used by Hercules and can be deleted.
Merge Date:
Sat, 20 Aug 2016 16:27:11 +0300

Related Pull Requests:
- #1399 - https://github.com/H...cules/pull/1399 - Ported the configuration to libconfig format [Haru]

Related Commits:
6be7aab - https://github.com/H.../commit/6be7aab - Mon, 15 Feb 2016 16:19:38 +0100 Renamed some char and inter server variables [Haru]
c84a447 - https://github.com/H.../commit/c84a447 - Sun, 6 Sep 2015 18:08:14 +0200 Ported char-server.conf to libconfig [Haru]
9783ce1 - https://github.com/H.../commit/9783ce1 - Sun, 6 Sep 2015 17:58:28 +0200 HPM Hooks Update [Haru]
ea9ceb1 - https://github.com/H.../commit/ea9ceb1 - Mon, 7 Sep 2015 01:42:31 +0200 Ported inter-server.conf to libconfig [Haru]
3c84a4d - https://github.com/H.../commit/3c84a4d - Mon, 7 Sep 2015 01:39:50 +0200 HPM Hooks Update [Haru]
f56264d - https://github.com/H.../commit/f56264d - Thu, 11 Feb 2016 00:41:54 +0100 Ported login-server.conf to libconfig [Haru]
9d70a6f - https://github.com/H.../commit/9d70a6f - Sun, 21 Feb 2016 01:02:00 +0100 HPM Hooks Update [Haru]
85d1088 - https://github.com/H.../commit/85d1088 - Thu, 11 Feb 2016 13:28:18 +0100 Ported map-server.conf to libconfig [Haru]
e370cc4 - https://github.com/H.../commit/e370cc4 - Thu, 11 Feb 2016 13:39:49 +0100 HPM Hooks Update [Haru]
86dde24 - https://github.com/H.../commit/86dde24 - Thu, 11 Feb 2016 15:15:33 +0100 Improved map list loading [Haru]
654bfa0 - https://github.com/H.../commit/654bfa0 - Thu, 11 Feb 2016 15:29:27 +0100 HPM Hooks Update [Haru]
dc2130b - https://github.com/H.../commit/dc2130b - Sat, 19 Jul 2014 18:17:59 +0200 Updated Travis script to work with the new configuration files [Haru]
5b983fc - https://github.com/H.../commit/5b983fc - Thu, 11 Feb 2016 16:35:08 +0100 Ported npc config to libconfig [Haru]
998b48e - https://github.com/H.../commit/998b48e - Thu, 11 Feb 2016 16:38:26 +0100 HPM Hooks Update [Haru]
1746627 - https://github.com/H.../commit/1746627 - Thu, 11 Feb 2016 18:53:58 +0100 Ported logs.conf to libconfig [Haru]
3f85b17 - https://github.com/H.../commit/3f85b17 - Thu, 11 Feb 2016 18:57:33 +0100 HPM Hooks Update [Haru]
aa3a3f4 - https://github.com/H.../commit/aa3a3f4 - Fri, 12 Feb 2016 12:43:14 +0100 Ported script.conf to libconfig [Haru]
8ecf562 - https://github.com/H.../commit/8ecf562 - Fri, 12 Feb 2016 12:49:19 +0100 HPM Hooks Update [Haru]
445a68f - https://github.com/H.../commit/445a68f - Sun, 14 Feb 2016 01:00:00 +0100 Removed unnecessary typedefs in socket.c [Haru]
a8ca27d - https://github.com/H.../commit/a8ca27d - Sun, 14 Feb 2016 01:09:21 +0100 Changed access_allow and access_deny to VECTORs [Haru]
c0e59c8 - https://github.com/H.../commit/c0e59c8 - Fri, 12 Feb 2016 16:17:30 +0100 Ported socket.conf (was packet.conf) to libconfig [Haru]
6cdb1e5 - https://github.com/H.../commit/6cdb1e5 - Sat, 13 Feb 2016 15:38:23 +0100 Ported battle.conf to libconfig [Haru]
67a84ce - https://github.com/H.../commit/67a84ce - Sun, 17 Apr 2016 03:10:29 +0200 HPM Hooks Update [Haru]
4e5b040 - https://github.com/H.../commit/4e5b040 - Tue, 2 Aug 2016 01:35:41 +0200 Added option to make plugin-defined battle config entries optional [Haru]
9e02b4e - https://github.com/H.../commit/9e02b4e - Sat, 20 Aug 2016 15:18:14 +0200 Updated references to the old config in the documentation [Haru]
af77eec - https://github.com/H.../commit/af77eec - Sat, 20 Aug 2016 16:27:11 +0300 Merge pull request #1399 from HerculesWS/settings_libconfig [Andrei Karas]


Trivia
This change was started by our fellow developer Panikon back in 2014, and never completed until recently (September 2015, February 2016, April 2016, August 2016), when I restarted working on it.

#2 Neo

Neo

    Advanced Member

  • Community Contributors
  • 713 posts
  • LocationThe Mysterious Subcontinent
  • Emulator:Hercules
  • Github:MStr3am

Posted 20 August 2016 - 03:09 PM

:no1: great



#3 Ridley

Ridley

    Advanced Member

  • Script Developers
  • 354 posts
  • IRC Nickname:Ridley
  • LocationGermany
  • Emulator:Hercules
  • Github:ridley8819

Posted 20 August 2016 - 04:17 PM

Awesome

#4 True Zeal

True Zeal

    Advanced Member

  • Members
  • PipPipPip
  • 409 posts
  • LocationAlberta
  • Emulator:Hercules

Posted 20 August 2016 - 05:35 PM

yahoo


I ask a lot of questions. Prepare to be frustrated.


#5 Legend

Legend

    Advanced Member

  • Members
  • PipPipPip
  • 334 posts
  • LocationHeaven ♥
  • Emulator:Hercules
  • Github:Legend95

Posted 21 August 2016 - 06:14 AM

Nice :)

You can use some of my *crappy* request scripts. It may somehow help you.

 

my ♥ belongs here


#6 zenghanbiao

zenghanbiao

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 21 August 2016 - 08:36 AM

Great Changes,Its more readable~



#7 astralprojection

astralprojection

    Advanced Member

  • Members
  • PipPipPip
  • 149 posts

Posted 29 August 2016 - 03:41 AM

how do configure LOG DB to read from log database? i dont see any in the config pointing to log_db sir



#8 Monsieur Panda

Monsieur Panda

    Advanced Member

  • Members
  • PipPipPip
  • 90 posts
  • LocationTokyo
  • Emulator:Hercules

Posted 29 August 2016 - 07:19 AM

Haru knows about this problem... I think ? @haru ?



#9 Haru

Haru

    Development Administrator

  • Administrators
  • 369 posts
  • Emulator:Hercules
  • Github:MishimaHaruna

Posted 29 August 2016 - 08:19 AM

You have to override the global settings from inter-server.conf.

You need to copy the content of global/sql_connections.conf and paste it inside the "log: { }" block that you see in inter-server.conf (and delete the @include directive that you find there).

Please see doc/global_configuration.txt for more details and an example.

#10 Lilori

Lilori

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 16 September 2016 - 06:23 AM

this update make me crazy.

 

i had already changes userid and passw in char_conf, map_conf, and login table,

but when i ran run_server.bat, char-serv disconnected because char-server read USER S1 AND PASSWORD P1 !

i dunno what is wrong, totally changed all S1 AND P1 to my userid and password.



#11 Haru

Haru

    Development Administrator

  • Administrators
  • 369 posts
  • Emulator:Hercules
  • Github:MishimaHaruna

Posted 16 September 2016 - 09:08 AM

- Did you edit them in conf/char/char-server.conf?
- What do you have in your conf/import/char-server.conf?
- Any [Error] or [Warning] messages in the char server console?

#12 chao93

chao93

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • Emulator:Hercules

Posted 16 September 2016 - 10:52 AM

- Did you edit them in conf/char/char-server.conf?
- What do you have in your conf/import/char-server.conf?
- Any [Error] or [Warning] messages in the char server console?

Haru, he already solved.
http://herc.ws/board...ion/#entry76629



#13 Lilori

Lilori

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 17 September 2016 - 03:39 PM

- Did you edit them in conf/char/char-server.conf?
- What do you have in your conf/import/char-server.conf?
- Any [Error] or [Warning] messages in the char server console?

 

 

- Did you edit them in conf/char/char-server.conf?
- What do you have in your conf/import/char-server.conf?
- Any [Error] or [Warning] messages in the char server console?

Haru, he already solved.
http://herc.ws/board...ion/#entry76629

 

and i got this problem.

the problem is in this line :

 



 

// Set the letters/symbols that you want use with the 'char_name_option' option. // Note: Don't add spaces unless you mean to add 'space' to the list.

name_letters: "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"

i got that error if i changed that to this :
 

// Set the letters/symbols that you want use with the 'char_name_option' option. // Note: Don't add spaces unless you mean to add 'space' to the list.

name_letters: "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~`~!@#$%%^&*()_+":?>}"

 

so, in herc, we cannot create a nickname with "

 

sorry Haru, ... rly i feel sorry


Edited by Lilori, 17 September 2016 - 03:39 PM.


#14 Haru

Haru

    Development Administrator

  • Administrators
  • 369 posts
  • Emulator:Hercules
  • Github:MishimaHaruna

Posted 17 September 2016 - 06:53 PM

In order to specify the " character, please prefix it with a backspace (\").

This is from the libconfig documentation at http://www.hyperreal...l#String-Values :

String values consist of arbitrary text delimited by double quotes. Literal double quotes can be escaped by preceding them with a backslash: ‘\"’. The escape sequences ‘\\’, ‘\f’, ‘\n’, ‘\r’, and ‘\t’ are also recognized, and have the usual meaning.

In addition, the ‘\x’ escape sequence is supported; this sequence must be followed by exactly two hexadecimal digits, which represent an 8-bit ASCII value. For example, ‘\xFF’ represents the character with ASCII code 0xFF.

No other escape sequences are currently supported.

Adjacent strings are automatically concatenated, as in C/C++ source code. This is useful for formatting very long strings as sequences of shorter strings. For example, the following constructs are equivalent:

"The quick brown fox jumped over the lazy dog."
"The quick brown fox"
" jumped over the lazy dog."
"The quick" /* comment */ " brown fox " // another comment
"jumped over the lazy dog."



#15 Lilori

Lilori

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 18 September 2016 - 03:28 AM

In order to specify the " character, please prefix it with a backspace (\").

This is from the libconfig documentation at http://www.hyperreal...l#String-Values :

String values consist of arbitrary text delimited by double quotes. Literal double quotes can be escaped by preceding them with a backslash: ‘\"’. The escape sequences ‘\\’, ‘\f’, ‘\n’, ‘\r’, and ‘\t’ are also recognized, and have the usual meaning.

In addition, the ‘\x’ escape sequence is supported; this sequence must be followed by exactly two hexadecimal digits, which represent an 8-bit ASCII value. For example, ‘\xFF’ represents the character with ASCII code 0xFF.

No other escape sequences are currently supported.

Adjacent strings are automatically concatenated, as in C/C++ source code. This is useful for formatting very long strings as sequences of shorter strings. For example, the following constructs are equivalent:

"The quick brown fox jumped over the lazy dog."
"The quick brown fox"
" jumped over the lazy dog."
"The quick" /* comment */ " brown fox " // another comment
"jumped over the lazy dog."

 

 

Supppeeerrrr !!!

thx Haru, ur da best :D

 

sad, i have no experience with programming language :(

sorryyy and thankyou :D



#16 darkasuna

darkasuna

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 03 January 2017 - 02:47 AM

Hello, sorry for make this topic alive again! LOL, but even replacing the @include sql global connection, it's still appearing the SQL loginlog issue, so my question is the following: can i merged ragnarok_log database with my "xxxxxragnarok_rag" database? or i'll make some kind of mess by redundant data. 

 

I'm just kinda newbie in hercules server stuff, so if you guys can help me i'll be thankfully to you a lot! 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


This topic has been visited by 234 user(s)