summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-18 16:19:36 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-18 16:19:36 +0300
commit5b74faa8afd04771af7acb918072ea71a3db475f (patch)
tree47d24a43925e95aea6acb8ff321cb9543600fda4 /src/map/script.c
parent1bfb8c1283a0c662902cc8cb94d30159a9bc1183 (diff)
parent1d2eb6d23519a971db0646a146152fc6f79350f1 (diff)
downloadhercules-5b74faa8afd04771af7acb918072ea71a3db475f.tar.gz
hercules-5b74faa8afd04771af7acb918072ea71a3db475f.tar.bz2
hercules-5b74faa8afd04771af7acb918072ea71a3db475f.tar.xz
hercules-5b74faa8afd04771af7acb918072ea71a3db475f.zip
Merge pull request #1160 from MishimaHaruna/libconfig
Libconfig: update to 1.5 and various improvements
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/map/script.c b/src/map/script.c
index f3c839555..4b3bf960c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -55,6 +55,7 @@
#include "map/storage.h"
#include "map/unit.h"
#include "common/cbasetypes.h"
+#include "common/conf.h"
#include "common/memmgr.h"
#include "common/md5calc.h"
#include "common/mmo.h" // NEW_CARTS
@@ -2289,15 +2290,18 @@ void script_set_constant2(const char *name, int value, bool is_parameter, bool i
*/
void read_constdb(void)
{
- config_t constants_conf;
+ struct config_t constants_conf;
char filepath[256];
- config_setting_t *cdb;
- config_setting_t *t;
+ struct config_setting_t *cdb;
+ struct config_setting_t *t;
int i = 0;
sprintf(filepath, "%s/constants.conf", map->db_path);
- if (libconfig->read_file(&constants_conf, filepath) || !(cdb = libconfig->setting_get_member(constants_conf.root, "constants_db"))) {
+ if (!libconfig->load_file(&constants_conf, filepath))
+ return;
+
+ if ((cdb = libconfig->setting_get_member(constants_conf.root, "constants_db")) == NULL) {
ShowError("can't read %s\n", filepath);
return;
}
@@ -4800,9 +4804,9 @@ uint8 script_add_language(const char *name) {
* Goes thru db/translations.conf file
**/
void script_load_translations(void) {
- config_t translations_conf;
+ struct config_t translations_conf;
const char *config_filename = "db/translations.conf"; // FIXME hardcoded name
- config_setting_t *translations = NULL;
+ struct config_setting_t *translations = NULL;
int i, size;
uint32 total = 0;
uint8 lang_id = 0, k;
@@ -4822,12 +4826,10 @@ void script_load_translations(void) {
script->add_language("English");/* 0 is default, which is whatever is in the npc files hardcoded (in our case, English) */
- if (libconfig->read_file(&translations_conf, config_filename)) {
- ShowError("load_translations: can't read '%s'\n", config_filename);
+ if (!libconfig->load_file(&translations_conf, config_filename))
return;
- }
- if( !(translations = libconfig->lookup(&translations_conf, "translations")) ) {
+ if ((translations = libconfig->lookup(&translations_conf, "translations")) == NULL) {
ShowError("load_translations: invalid format on '%s'\n",config_filename);
return;
}