summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2014-01-18 18:34:21 -0200
committershennetsind <ind@henn.et>2014-01-18 18:34:21 -0200
commita9cc02e1dea69e14a1b1e3d1cf27aaa271ac0b4b (patch)
tree1f8951ab4a7b8d8adc715e00edeb24ab0c492c8e /src/map
parent59662a1656aa1db6f7cd0f92ce10a3ff66a979a4 (diff)
downloadhercules-a9cc02e1dea69e14a1b1e3d1cf27aaa271ac0b4b.tar.gz
hercules-a9cc02e1dea69e14a1b1e3d1cf27aaa271ac0b4b.tar.bz2
hercules-a9cc02e1dea69e14a1b1e3d1cf27aaa271ac0b4b.tar.xz
hercules-a9cc02e1dea69e14a1b1e3d1cf27aaa271ac0b4b.zip
Libconfig Interfaced
Ready for plugin use. Thanks to Haruna Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c40
-rw-r--r--src/map/battleground.c50
-rw-r--r--src/map/clif.c73
-rw-r--r--src/map/itemdb.c178
-rw-r--r--src/map/map.c160
-rw-r--r--src/map/pc.c28
-rw-r--r--src/map/pc_groups.c72
7 files changed, 301 insertions, 300 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index e5d14fc21..3cdfb0e29 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3544,19 +3544,19 @@ ACMD(reloadskilldb)
ACMD(reloadatcommand) {
config_t run_test;
- if (conf_read_file(&run_test, "conf/groups.conf")) {
+ if (libconfig->read_file(&run_test, "conf/groups.conf")) {
clif->message(fd, msg_txt(1036)); // Error reading groups.conf, reload failed.
return false;
}
- config_destroy(&run_test);
+ libconfig->destroy(&run_test);
- if (conf_read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) {
+ if (libconfig->read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) {
clif->message(fd, msg_txt(1037)); // Error reading atcommand.conf, reload failed.
return false;
}
- config_destroy(&run_test);
+ libconfig->destroy(&run_test);
atcommand->doload();
pcg->reload();
@@ -9959,11 +9959,11 @@ void atcommand_config_read(const char* config_filename) {
const char *symbol = NULL;
int num_aliases = 0;
- if (conf_read_file(&atcommand_config, config_filename))
+ if (libconfig->read_file(&atcommand_config, config_filename))
return;
// Command symbols
- if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
+ if (libconfig->lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
if (ISPRINT(*symbol) && // no control characters
*symbol != '/' && // symbol of client commands
*symbol != '%' && // symbol of party chat
@@ -9972,7 +9972,7 @@ void atcommand_config_read(const char* config_filename) {
atcommand->at_symbol = *symbol;
}
- if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
+ if (libconfig->lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
if (ISPRINT(*symbol) && // no control characters
*symbol != '/' && // symbol of client commands
*symbol != '%' && // symbol of party chat
@@ -9982,10 +9982,10 @@ void atcommand_config_read(const char* config_filename) {
}
// Command aliases
- aliases = config_lookup(&atcommand_config, "aliases");
+ aliases = libconfig->lookup(&atcommand_config, "aliases");
if (aliases != NULL) {
int i = 0;
- int count = config_setting_length(aliases);
+ int count = libconfig->setting_length(aliases);
for (i = 0; i < count; ++i) {
config_setting_t *command;
@@ -9993,7 +9993,7 @@ void atcommand_config_read(const char* config_filename) {
int j = 0, alias_count = 0;
AtCommandInfo *commandinfo = NULL;
- command = config_setting_get_elem(aliases, i);
+ command = libconfig->setting_get_elem(aliases, i);
if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
continue;
commandname = config_setting_name(command);
@@ -10001,9 +10001,9 @@ void atcommand_config_read(const char* config_filename) {
ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
continue;
}
- alias_count = config_setting_length(command);
+ alias_count = libconfig->setting_length(command);
for (j = 0; j < alias_count; ++j) {
- const char *alias = config_setting_get_string_elem(command, j);
+ const char *alias = libconfig->setting_get_string_elem(command, j);
if (alias != NULL) {
AliasInfo *alias_info;
if (strdb_exists(atcommand->alias_db, alias)) {
@@ -10020,17 +10020,17 @@ void atcommand_config_read(const char* config_filename) {
}
}
- nolog = config_lookup(&atcommand_config, "nolog");
+ nolog = libconfig->lookup(&atcommand_config, "nolog");
if (nolog != NULL) {
int i = 0;
- int count = config_setting_length(nolog);
+ int count = libconfig->setting_length(nolog);
for (i = 0; i < count; ++i) {
config_setting_t *command;
const char *commandname = NULL;
AtCommandInfo *commandinfo = NULL;
- command = config_setting_get_elem(nolog, i);
+ command = libconfig->setting_get_elem(nolog, i);
commandname = config_setting_name(command);
if ( !( commandinfo = atcommand_exists(commandname) ) ) {
ShowConfigWarning(command, "atcommand_config_read: can not disable logging for non-existent command %s", commandname);
@@ -10042,9 +10042,9 @@ void atcommand_config_read(const char* config_filename) {
// Commands help
// We only check if all commands exist
- help = config_lookup(&atcommand_config, "help");
+ help = libconfig->lookup(&atcommand_config, "help");
if (help != NULL) {
- int count = config_setting_length(help);
+ int count = libconfig->setting_length(help);
int i;
for (i = 0; i < count; ++i) {
@@ -10052,13 +10052,13 @@ void atcommand_config_read(const char* config_filename) {
const char *commandname;
AtCommandInfo *commandinfo = NULL;
- command = config_setting_get_elem(help, i);
+ command = libconfig->setting_get_elem(help, i);
commandname = config_setting_name(command);
if ( !( commandinfo = atcommand_exists(commandname) ) )
ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
else {
if( commandinfo->help == NULL ) {
- const char *str = config_setting_get_string(command);
+ const char *str = libconfig->setting_get_string(command);
size_t len = strlen(str);
commandinfo->help = aMalloc( len * sizeof(char) );
safestrncpy(commandinfo->help, str, len);
@@ -10069,7 +10069,7 @@ void atcommand_config_read(const char* config_filename) {
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
- config_destroy(&atcommand_config);
+ libconfig->destroy(&atcommand_config);
return;
}
diff --git a/src/map/battleground.c b/src/map/battleground.c
index ab44b0953..65f475124 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -257,34 +257,34 @@ void bg_config_read(void) {
config_setting_t *data = NULL;
const char *config_filename = "conf/battlegrounds.conf"; // FIXME hardcoded name
- if (conf_read_file(&bg_conf, config_filename))
+ if (libconfig->read_file(&bg_conf, config_filename))
return;
- data = config_lookup(&bg_conf, "battlegrounds");
+ data = libconfig->lookup(&bg_conf, "battlegrounds");
if (data != NULL) {
- config_setting_t *settings = config_setting_get_elem(data, 0);
+ config_setting_t *settings = libconfig->setting_get_elem(data, 0);
config_setting_t *arenas;
const char *delay_var;
int i, arena_count = 0, offline = 0;
- if( !config_setting_lookup_string(settings, "global_delay_var", &delay_var) )
+ if( !libconfig->setting_lookup_string(settings, "global_delay_var", &delay_var) )
delay_var = "BG_Delay_Tick";
safestrncpy(bg->gdelay_var, delay_var, BG_DELAY_VAR_LENGTH);
- config_setting_lookup_int(settings, "maximum_afk_seconds", &bg->mafksec);
+ libconfig->setting_lookup_int(settings, "maximum_afk_seconds", &bg->mafksec);
- config_setting_lookup_bool(settings, "feature_off", &offline);
+ libconfig->setting_lookup_bool(settings, "feature_off", &offline);
if( offline == 0 )
bg->queue_on = true;
- if( (arenas = config_setting_get_member(settings, "arenas")) != NULL ) {
- arena_count = config_setting_length(arenas);
+ if( (arenas = libconfig->setting_get_member(settings, "arenas")) != NULL ) {
+ arena_count = libconfig->setting_length(arenas);
CREATE( bg->arena, struct bg_arena *, arena_count );
for(i = 0; i < arena_count; i++) {
- config_setting_t *arena = config_setting_get_elem(arenas, i);
+ config_setting_t *arena = libconfig->setting_get_elem(arenas, i);
config_setting_t *reward;
const char *aName, *aEvent, *aDelayVar;
int minLevel = 0, maxLevel = 0;
@@ -295,18 +295,18 @@ void bg_config_read(void) {
bg->arena[i] = NULL;
- if( !config_setting_lookup_string(arena, "name", &aName) ) {
+ if( !libconfig->setting_lookup_string(arena, "name", &aName) ) {
ShowError("bg_config_read: failed to find 'name' for arena #%d\n",i);
continue;
}
- if( !config_setting_lookup_string(arena, "event", &aEvent) ) {
+ if( !libconfig->setting_lookup_string(arena, "event", &aEvent) ) {
ShowError("bg_config_read: failed to find 'event' for arena #%d\n",i);
continue;
}
- config_setting_lookup_int(arena, "minLevel", &minLevel);
- config_setting_lookup_int(arena, "maxLevel", &maxLevel);
+ libconfig->setting_lookup_int(arena, "minLevel", &minLevel);
+ libconfig->setting_lookup_int(arena, "maxLevel", &maxLevel);
if( minLevel < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' minLevel\n",minLevel,aName);
@@ -317,14 +317,14 @@ void bg_config_read(void) {
maxLevel = MAX_LEVEL;
}
- if( !(reward = config_setting_get_member(arena, "reward")) ) {
+ if( !(reward = libconfig->setting_get_member(arena, "reward")) ) {
ShowError("bg_config_read: failed to find 'reward' for arena '%s'/#%d\n",aName,i);
continue;
}
- config_setting_lookup_int(reward, "win", &prizeWin);
- config_setting_lookup_int(reward, "loss", &prizeLoss);
- config_setting_lookup_int(reward, "draw", &prizeDraw);
+ libconfig->setting_lookup_int(reward, "win", &prizeWin);
+ libconfig->setting_lookup_int(reward, "loss", &prizeLoss);
+ libconfig->setting_lookup_int(reward, "draw", &prizeDraw);
if( prizeWin < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:win\n",prizeWin,aName);
@@ -339,9 +339,9 @@ void bg_config_read(void) {
prizeDraw = 0;
}
- config_setting_lookup_int(arena, "minPlayers", &minPlayers);
- config_setting_lookup_int(arena, "maxPlayers", &maxPlayers);
- config_setting_lookup_int(arena, "minTeamPlayers", &minTeamPlayers);
+ libconfig->setting_lookup_int(arena, "minPlayers", &minPlayers);
+ libconfig->setting_lookup_int(arena, "maxPlayers", &maxPlayers);
+ libconfig->setting_lookup_int(arena, "minTeamPlayers", &minTeamPlayers);
if( minPlayers < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' minPlayers\n",minPlayers,aName);
@@ -356,20 +356,20 @@ void bg_config_read(void) {
minTeamPlayers = 0;
}
- if( !config_setting_lookup_string(arena, "delay_var", &aDelayVar) ) {
+ if( !libconfig->setting_lookup_string(arena, "delay_var", &aDelayVar) ) {
ShowError("bg_config_read: failed to find 'delay_var' for arena '%s'/#%d\n",aName,i);
continue;
}
- config_setting_lookup_int(arena, "maxDuration", &maxDuration);
+ libconfig->setting_lookup_int(arena, "maxDuration", &maxDuration);
if( maxDuration < 0 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' maxDuration\n",maxDuration,aName);
maxDuration = 30;
}
- config_setting_lookup_int(arena, "fillDuration", &fillup_duration);
- config_setting_lookup_int(arena, "pGameDuration", &pregame_duration);
+ libconfig->setting_lookup_int(arena, "fillDuration", &fillup_duration);
+ libconfig->setting_lookup_int(arena, "pGameDuration", &pregame_duration);
if( fillup_duration < 20 ) {
ShowWarning("bg_config_read: invalid %d value for arena '%s' fillDuration, minimum has to be 20, defaulting to 20.\n",fillup_duration,aName);
@@ -408,7 +408,7 @@ void bg_config_read(void) {
bg->arenas = arena_count;
}
- config_destroy(&bg_conf);
+ libconfig->destroy(&bg_conf);
}
}
struct bg_arena *bg_name2arena (char *name) {
diff --git a/src/map/clif.c b/src/map/clif.c
index 7157914df..af328e7a7 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2624,13 +2624,13 @@ void read_channels_config(void) {
config_setting_t *chsys = NULL;
const char *config_filename = "conf/channels.conf"; // FIXME hardcoded name
- if (conf_read_file(&channels_conf, config_filename))
+ if (libconfig->read_file(&channels_conf, config_filename))
return;
- chsys = config_lookup(&channels_conf, "chsys");
+ chsys = libconfig->lookup(&channels_conf, "chsys");
if (chsys != NULL) {
- config_setting_t *settings = config_setting_get_elem(chsys, 0);
+ config_setting_t *settings = libconfig->setting_get_elem(chsys, 0);
config_setting_t *channels;
config_setting_t *colors;
int i,k;
@@ -2642,21 +2642,21 @@ void read_channels_config(void) {
allow_user_channel_creation = 0,
irc_enabled = 0;
- if( !config_setting_lookup_string(settings, "map_local_channel_name", &local_name) )
+ if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) )
local_name = "map";
safestrncpy(hChSys.local_name, local_name, HCHSYS_NAME_LENGTH);
- if( !config_setting_lookup_string(settings, "ally_channel_name", &ally_name) )
+ if( !libconfig->setting_lookup_string(settings, "ally_channel_name", &ally_name) )
ally_name = "ally";
safestrncpy(hChSys.ally_name, ally_name, HCHSYS_NAME_LENGTH);
- if( !config_setting_lookup_string(settings, "irc_channel_name", &irc_name) )
+ if( !libconfig->setting_lookup_string(settings, "irc_channel_name", &irc_name) )
irc_name = "irc";
safestrncpy(hChSys.irc_name, irc_name, HCHSYS_NAME_LENGTH);
- config_setting_lookup_bool(settings, "map_local_channel", &local_enabled);
- config_setting_lookup_bool(settings, "ally_channel_enabled", &ally_enabled);
- config_setting_lookup_bool(settings, "irc_channel_enabled", &irc_enabled);
+ libconfig->setting_lookup_bool(settings, "map_local_channel", &local_enabled);
+ libconfig->setting_lookup_bool(settings, "ally_channel_enabled", &ally_enabled);
+ libconfig->setting_lookup_bool(settings, "irc_channel_enabled", &irc_enabled);
if( local_enabled )
hChSys.local = true;
@@ -2671,7 +2671,7 @@ void read_channels_config(void) {
const char *irc_server, *irc_channel,
*irc_nick, *irc_nick_pw;
int irc_use_ghost = 0;
- if( config_setting_lookup_string(settings, "irc_channel_network", &irc_server) ) {
+ if( libconfig->setting_lookup_string(settings, "irc_channel_network", &irc_server) ) {
if( !strstr(irc_server,":") ) {
hChSys.irc = false;
ShowWarning("channels.conf : network port wasn't found in 'irc_channel_network', disabling irc channel...\n");
@@ -2695,13 +2695,13 @@ void read_channels_config(void) {
hChSys.irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_network wasn't found, disabling irc channel...\n");
}
- if( config_setting_lookup_string(settings, "irc_channel_channel", &irc_channel) )
+ if( libconfig->setting_lookup_string(settings, "irc_channel_channel", &irc_channel) )
safestrncpy(hChSys.irc_channel, irc_channel, 50);
else {
hChSys.irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_channel wasn't found, disabling irc channel...\n");
}
- if( config_setting_lookup_string(settings, "irc_channel_nick", &irc_nick) ) {
+ if( libconfig->setting_lookup_string(settings, "irc_channel_nick", &irc_nick) ) {
if( strcmpi(irc_nick,"Hercules_chSysBot") == 0 ) {
sprintf(hChSys.irc_nick, "Hercules_chSysBot%d",rand()%777);
} else
@@ -2710,7 +2710,7 @@ void read_channels_config(void) {
hChSys.irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_nick wasn't found, disabling irc channel...\n");
}
- if( config_setting_lookup_string(settings, "irc_channel_nick_pw", &irc_nick_pw) ) {
+ if( libconfig->setting_lookup_string(settings, "irc_channel_nick_pw", &irc_nick_pw) ) {
safestrncpy(hChSys.irc_nick_pw, irc_nick_pw, 30);
config_setting_lookup_bool(settings, "irc_channel_use_ghost", &irc_use_ghost);
hChSys.irc_use_ghost = irc_use_ghost;
@@ -2718,37 +2718,37 @@ void read_channels_config(void) {
}
- config_setting_lookup_bool(settings, "map_local_channel_autojoin", &local_autojoin);
- config_setting_lookup_bool(settings, "ally_channel_autojoin", &ally_autojoin);
+ libconfig->setting_lookup_bool(settings, "map_local_channel_autojoin", &local_autojoin);
+ libconfig->setting_lookup_bool(settings, "ally_channel_autojoin", &ally_autojoin);
if( local_autojoin )
hChSys.local_autojoin = true;
if( ally_autojoin )
hChSys.ally_autojoin = true;
- config_setting_lookup_bool(settings, "allow_user_channel_creation", &allow_user_channel_creation);
+ libconfig->setting_lookup_bool(settings, "allow_user_channel_creation", &allow_user_channel_creation);
if( allow_user_channel_creation )
hChSys.allow_user_channel_creation = true;
- if( (colors = config_setting_get_member(settings, "colors")) != NULL ) {
- int color_count = config_setting_length(colors);
+ if( (colors = libconfig->setting_get_member(settings, "colors")) != NULL ) {
+ int color_count = libconfig->setting_length(colors);
CREATE( hChSys.colors, unsigned int, color_count );
CREATE( hChSys.colors_name, char *, color_count );
for(i = 0; i < color_count; i++) {
- config_setting_t *color = config_setting_get_elem(colors, i);
+ config_setting_t *color = libconfig->setting_get_elem(colors, i);
CREATE( hChSys.colors_name[i], char, HCHSYS_NAME_LENGTH );
safestrncpy(hChSys.colors_name[i], config_setting_name(color), HCHSYS_NAME_LENGTH);
- hChSys.colors[i] = (unsigned int)strtoul(config_setting_get_string_elem(colors,i),NULL,0);
+ hChSys.colors[i] = (unsigned int)strtoul(libconfig->setting_get_string_elem(colors,i),NULL,0);
hChSys.colors[i] = (hChSys.colors[i] & 0x0000FF) << 16 | (hChSys.colors[i] & 0x00FF00) | (hChSys.colors[i] & 0xFF0000) >> 16;//RGB to BGR
}
hChSys.colors_count = color_count;
}
- config_setting_lookup_string(settings, "map_local_channel_color", &local_color);
+ libconfig->setting_lookup_string(settings, "map_local_channel_color", &local_color);
for (k = 0; k < hChSys.colors_count; k++) {
if( strcmpi(hChSys.colors_name[k],local_color) == 0 )
@@ -2762,7 +2762,7 @@ void read_channels_config(void) {
hChSys.local = false;
}
- config_setting_lookup_string(settings, "ally_channel_color", &ally_color);
+ libconfig->setting_lookup_string(settings, "ally_channel_color", &ally_color);
for (k = 0; k < hChSys.colors_count; k++) {
if( strcmpi(hChSys.colors_name[k],ally_color) == 0 )
@@ -2776,7 +2776,7 @@ void read_channels_config(void) {
hChSys.ally = false;
}
- config_setting_lookup_string(settings, "irc_channel_color", &irc_color);
+ libconfig->setting_lookup_string(settings, "irc_channel_color", &irc_color);
for (k = 0; k < hChSys.colors_count; k++) {
if( strcmpi(hChSys.colors_name[k],irc_color) == 0 )
@@ -2801,13 +2801,13 @@ void read_channels_config(void) {
ircbot->channel = chd;
}
- if( (channels = config_setting_get_member(settings, "default_channels")) != NULL ) {
- int channel_count = config_setting_length(channels);
+ if( (channels = libconfig->setting_get_member(settings, "default_channels")) != NULL ) {
+ int channel_count = libconfig->setting_length(channels);
for(i = 0; i < channel_count; i++) {
- config_setting_t *channel = config_setting_get_elem(channels, i);
+ config_setting_t *channel = libconfig->setting_get_elem(channels, i);
const char *name = config_setting_name(channel);
- const char *color = config_setting_get_string_elem(channels,i);
+ const char *color = libconfig->setting_get_string_elem(channels,i);
struct hChSysCh *chd;
for (k = 0; k < hChSys.colors_count; k++) {
@@ -2833,7 +2833,7 @@ void read_channels_config(void) {
}
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' channels in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(clif->channel_db), config_filename);
- config_destroy(&channels_conf);
+ libconfig->destroy(&channels_conf);
}
}
@@ -17378,32 +17378,33 @@ void clif_cashshop_db(void) {
config_setting_t *cashshop = NULL, *cats = NULL;
const char *config_filename = "db/cashshop_db.conf"; // FIXME hardcoded name
int i, item_count_t = 0;
+
for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
CREATE(clif->cs.data[i], struct hCSData *, 1);
clif->cs.item_count[i] = 0;
}
- if (conf_read_file(&cashshop_conf, config_filename)) {
+ if (libconfig->read_file(&cashshop_conf, config_filename)) {
ShowError("can't read %s\n", config_filename);
return;
}
- cashshop = config_lookup(&cashshop_conf, "cash_shop");
+ cashshop = libconfig->lookup(&cashshop_conf, "cash_shop");
- if( cashshop != NULL && (cats = config_setting_get_elem(cashshop, 0)) != NULL ) {
+ if( cashshop != NULL && (cats = libconfig->setting_get_elem(cashshop, 0)) != NULL ) {
for(i = 0; i < CASHSHOP_TAB_MAX; i++) {
config_setting_t *cat;
char entry_name[10];
sprintf(entry_name,"cat_%d",i);
- if( (cat = config_setting_get_member(cats, entry_name)) != NULL ) {
- int k, item_count = config_setting_length(cat);
+ if( (cat = libconfig->setting_get_member(cats, entry_name)) != NULL ) {
+ int k, item_count = libconfig->setting_length(cat);
for(k = 0; k < item_count; k++) {
- config_setting_t *entry = config_setting_get_elem(cat,k);
+ config_setting_t *entry = libconfig->setting_get_elem(cat,k);
const char *name = config_setting_name(entry);
- int price = config_setting_get_int(entry);
+ int price = libconfig->setting_get_int(entry);
struct item_data * data = NULL;
if( price < 1 ) {
@@ -17434,7 +17435,7 @@ void clif_cashshop_db(void) {
}
}
- config_destroy(&cashshop_conf);
+ libconfig->destroy(&cashshop_conf);
}
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_count_t, config_filename);
}
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 3bed3e03d..6db503214 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -642,18 +642,18 @@ void itemdb_read_groups(void) {
int i = 0, count = 0, c;
unsigned int *gsize = NULL;
- if (conf_read_file(&item_group_conf, config_filename)) {
+ if (libconfig->read_file(&item_group_conf, config_filename)) {
ShowError("can't read %s\n", config_filename);
return;
}
- gsize = aMalloc( config_setting_length(item_group_conf.root) * sizeof(unsigned int) );
+ gsize = aMalloc( libconfig->setting_length(item_group_conf.root) * sizeof(unsigned int) );
- for(i = 0; i < config_setting_length(item_group_conf.root); i++)
+ for(i = 0; i < libconfig->setting_length(item_group_conf.root); i++)
gsize[i] = 0;
i = 0;
- while( (itg = config_setting_get_elem(item_group_conf.root,i++)) ) {
+ while( (itg = libconfig->setting_get_elem(item_group_conf.root,i++)) ) {
const char *name = config_setting_name(itg);
if( !itemdb->name2id(name) ) {
@@ -664,9 +664,9 @@ void itemdb_read_groups(void) {
}
c = 0;
- while( (it = config_setting_get_elem(itg,c++)) ) {
+ while( (it = libconfig->setting_get_elem(itg,c++)) ) {
if( config_setting_is_list(it) )
- gsize[ i - 1 ] += config_setting_get_int_elem(it,1);
+ gsize[ i - 1 ] += libconfig->setting_get_int_elem(it,1);
else
gsize[ i - 1 ] += 1;
}
@@ -674,10 +674,10 @@ void itemdb_read_groups(void) {
}
i = 0;
- CREATE(itemdb->groups, struct item_group, config_setting_length(item_group_conf.root));
- itemdb->group_count = (unsigned short)config_setting_length(item_group_conf.root);
+ CREATE(itemdb->groups, struct item_group, libconfig->setting_length(item_group_conf.root));
+ itemdb->group_count = (unsigned short)libconfig->setting_length(item_group_conf.root);
- while( (itg = config_setting_get_elem(item_group_conf.root,i++)) ) {
+ while( (itg = libconfig->setting_get_elem(item_group_conf.root,i++)) ) {
struct item_data *data = itemdb->name2id(config_setting_name(itg));
int ecount = 0;
@@ -688,13 +688,13 @@ void itemdb_read_groups(void) {
CREATE(itemdb->groups[count].nameid, unsigned short, gsize[ count ] + 1);
c = 0;
- while( (it = config_setting_get_elem(itg,c++)) ) {
+ while( (it = libconfig->setting_get_elem(itg,c++)) ) {
int repeat = 1;
if( config_setting_is_list(it) ) {
- itname = config_setting_get_string_elem(it,0);
- repeat = config_setting_get_int_elem(it,1);
+ itname = libconfig->setting_get_string_elem(it,0);
+ repeat = libconfig->setting_get_int_elem(it,1);
} else
- itname = config_setting_get_string_elem(itg,c - 1);
+ itname = libconfig->setting_get_string_elem(itg,c - 1);
if( itname[0] == 'I' && itname[1] == 'D' && strlen(itname) < 8 ) {
if( !( data = itemdb->exists(atoi(itname+2)) ) )
@@ -716,7 +716,7 @@ void itemdb_read_groups(void) {
count++;
}
- config_destroy(&item_group_conf);
+ libconfig->destroy(&item_group_conf);
aFree(gsize);
ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
@@ -934,18 +934,18 @@ void itemdb_read_packages(void) {
return;
}
- if (conf_read_file(&item_packages_conf, config_filename)) {
+ if (libconfig->read_file(&item_packages_conf, config_filename)) {
ShowError("can't read %s\n", config_filename);
return;
}
- must = aMalloc( config_setting_length(item_packages_conf.root) * sizeof(unsigned int) );
- random = aMalloc( config_setting_length(item_packages_conf.root) * sizeof(unsigned int) );
- rgroup = aMalloc( config_setting_length(item_packages_conf.root) * sizeof(unsigned int) );
- rgroups = aMalloc( config_setting_length(item_packages_conf.root) * sizeof(unsigned int *) );
+ must = aMalloc( libconfig->setting_length(item_packages_conf.root) * sizeof(unsigned int) );
+ random = aMalloc( libconfig->setting_length(item_packages_conf.root) * sizeof(unsigned int) );
+ rgroup = aMalloc( libconfig->setting_length(item_packages_conf.root) * sizeof(unsigned int) );
+ rgroups = aMalloc( libconfig->setting_length(item_packages_conf.root) * sizeof(unsigned int *) );
- for(i = 0; i < config_setting_length(item_packages_conf.root); i++) {
+ for(i = 0; i < libconfig->setting_length(item_packages_conf.root); i++) {
must[i] = 0;
random[i] = 0;
rgroup[i] = 0;
@@ -954,22 +954,22 @@ void itemdb_read_packages(void) {
/* validate tree, drop poisonous fruits! */
i = 0;
- while( (itg = config_setting_get_elem(item_packages_conf.root,i++)) ) {
+ while( (itg = libconfig->setting_get_elem(item_packages_conf.root,i++)) ) {
const char *name = config_setting_name(itg);
if( !itemdb->name2id(name) ) {
ShowWarning("itemdb_read_packages: unknown package item '%s', skipping..\n",name);
- config_setting_remove(item_packages_conf.root, name);
+ libconfig->setting_remove(item_packages_conf.root, name);
--i;
continue;
}
c = 0;
- while( (it = config_setting_get_elem(itg,c++)) ) {
+ while( (it = libconfig->setting_get_elem(itg,c++)) ) {
int rval = 0;
- if( !( t = config_setting_get_member(it, "Random") ) || (rval = config_setting_get_int(t)) < 0 ) {
+ if( !( t = libconfig->setting_get_member(it, "Random") ) || (rval = libconfig->setting_get_int(t)) < 0 ) {
ShowWarning("itemdb_read_packages: invalid 'Random' value (%d) for item '%s' in package '%s', defaulting to must!\n",rval,config_setting_name(it),name);
- config_setting_remove(it, config_setting_name(it));
+ libconfig->setting_remove(it, config_setting_name(it));
--c;
continue;
}
@@ -991,7 +991,7 @@ void itemdb_read_packages(void) {
prev[i] = NULL;
}
- for(i = 0; i < config_setting_length(item_packages_conf.root); i++ ) {
+ for(i = 0; i < libconfig->setting_length(item_packages_conf.root); i++ ) {
rgroups[i] = aMalloc( rgroup[i] * sizeof(unsigned int) );
for( c = 0; c < rgroup[i]; c++ ) {
rgroups[i][c] = 0;
@@ -1000,22 +1000,22 @@ void itemdb_read_packages(void) {
/* grab the known sizes */
i = 0;
- while( (itg = config_setting_get_elem(item_packages_conf.root,i++)) ) {
+ while( (itg = libconfig->setting_get_elem(item_packages_conf.root,i++)) ) {
c = 0;
- while( (it = config_setting_get_elem(itg,c++)) ) {
+ while( (it = libconfig->setting_get_elem(itg,c++)) ) {
int rval = 0;
- if( ( t = config_setting_get_member(it, "Random")) && ( rval = config_setting_get_int(t) ) > 0 ) {
+ if( ( t = libconfig->setting_get_member(it, "Random")) && ( rval = libconfig->setting_get_int(t) ) > 0 ) {
rgroups[i - 1][rval - 1] += 1;
}
}
}
- CREATE(itemdb->packages, struct item_package, config_setting_length(item_packages_conf.root));
- itemdb->package_count = (unsigned short)config_setting_length(item_packages_conf.root);
+ CREATE(itemdb->packages, struct item_package, libconfig->setting_length(item_packages_conf.root));
+ itemdb->package_count = (unsigned short)libconfig->setting_length(item_packages_conf.root);
/* write */
i = 0;
- while( (itg = config_setting_get_elem(item_packages_conf.root,i++)) ) {
+ while( (itg = libconfig->setting_get_elem(item_packages_conf.root,i++)) ) {
struct item_data *data = itemdb->name2id(config_setting_name(itg));
int r = 0, m = 0;
@@ -1045,7 +1045,7 @@ void itemdb_read_packages(void) {
CREATE(itemdb->packages[count].must_items, struct item_package_must_entry, itemdb->packages[count].must_qty);
c = 0;
- while( (it = config_setting_get_elem(itg,c++)) ) {
+ while( (it = libconfig->setting_get_elem(itg,c++)) ) {
int icount = 1, expire = 0, rate = 10000, gid = 0;
bool announce = false, named = false;
@@ -1057,30 +1057,30 @@ void itemdb_read_packages(void) {
} else if( !( data = itemdb->name2id(itname) ) )
ShowWarning("itemdb_read_packages: unknown item '%s' in package '%s'!\n",itname,config_setting_name(itg));
- if( ( t = config_setting_get_member(it, "Count")) )
- icount = config_setting_get_int(t);
+ if( ( t = libconfig->setting_get_member(it, "Count")) )
+ icount = libconfig->setting_get_int(t);
- if( ( t = config_setting_get_member(it, "Expire")) )
- expire = config_setting_get_int(t);
+ if( ( t = libconfig->setting_get_member(it, "Expire")) )
+ expire = libconfig->setting_get_int(t);
- if( ( t = config_setting_get_member(it, "Rate")) ) {
- if( (rate = (unsigned short)config_setting_get_int(t)) > 10000 ) {
+ if( ( t = libconfig->setting_get_member(it, "Rate")) ) {
+ if( (rate = (unsigned short)libconfig->setting_get_int(t)) > 10000 ) {
ShowWarning("itemdb_read_packages: invalid rate (%d) for item '%s' in package '%s'!\n",rate,itname,config_setting_name(itg));
rate = 10000;
}
}
- if( ( t = config_setting_get_member(it, "Announce")) && config_setting_get_bool(t) )
+ if( ( t = libconfig->setting_get_member(it, "Announce")) && libconfig->setting_get_bool(t) )
announce = true;
- if( ( t = config_setting_get_member(it, "Named")) && config_setting_get_bool(t) )
+ if( ( t = libconfig->setting_get_member(it, "Named")) && libconfig->setting_get_bool(t) )
named = true;
- if( !( t = config_setting_get_member(it, "Random") ) ) {
+ if( !( t = libconfig->setting_get_member(it, "Random") ) ) {
ShowWarning("itemdb_read_packages: missing 'Random' field for item '%s' in package '%s', defaulting to must!\n",itname,config_setting_name(itg));
gid = 0;
} else
- gid = config_setting_get_int(t);
+ gid = libconfig->setting_get_int(t);
if( gid == 0 ) {
itemdb->packages[count].must_items[m].id = data ? data->nameid : 0;
@@ -1131,14 +1131,14 @@ void itemdb_read_packages(void) {
aFree(must);
aFree(random);
- for(i = 0; i < config_setting_length(item_packages_conf.root); i++ ) {
+ for(i = 0; i < libconfig->setting_length(item_packages_conf.root); i++ ) {
aFree(rgroups[i]);
}
aFree(rgroups);
aFree(rgroup);
aFree(prev);
- config_destroy(&item_packages_conf);
+ libconfig->destroy(&item_packages_conf);
if( HCache->enabled )
itemdb->write_cached_packages(config_filename);
@@ -1156,26 +1156,26 @@ void itemdb_read_chains(void) {
#endif
int i = 0, count = 0;
- if (conf_read_file(&item_chain_conf, config_filename)) {
+ if (libconfig->read_file(&item_chain_conf, config_filename)) {
ShowError("can't read %s\n", config_filename);
return;
}
- CREATE(itemdb->chains, struct item_chain, config_setting_length(item_chain_conf.root));
- itemdb->chain_count = (unsigned short)config_setting_length(item_chain_conf.root);
+ CREATE(itemdb->chains, struct item_chain, libconfig->setting_length(item_chain_conf.root));
+ itemdb->chain_count = (unsigned short)libconfig->setting_length(item_chain_conf.root);
- while( (itc = config_setting_get_elem(item_chain_conf.root,i++)) ) {
+ while( (itc = libconfig->setting_get_elem(item_chain_conf.root,i++)) ) {
struct item_data *data = NULL;
struct item_chain_entry *prev = NULL;
const char *name = config_setting_name(itc);
int c = 0;
script->set_constant2(name,i-1,0);
- itemdb->chains[count].qty = (unsigned short)config_setting_length(itc);
+ itemdb->chains[count].qty = (unsigned short)libconfig->setting_length(itc);
- CREATE(itemdb->chains[count].items, struct item_chain_entry, config_setting_length(itc));
+ CREATE(itemdb->chains[count].items, struct item_chain_entry, libconfig->setting_length(itc));
- while( (entry = config_setting_get_elem(itc,c++)) ) {
+ while( (entry = libconfig->setting_get_elem(itc,c++)) ) {
const char *itname = config_setting_name(entry);
if( itname[0] == 'I' && itname[1] == 'D' && strlen(itname) < 8 ) {
if( !( data = itemdb->exists(atoi(itname+2)) ) )
@@ -1187,7 +1187,7 @@ void itemdb_read_chains(void) {
prev->next = &itemdb->chains[count].items[c - 1];
itemdb->chains[count].items[c - 1].id = data ? data->nameid : 0;
- itemdb->chains[count].items[c - 1].rate = data ? config_setting_get_int(entry) : 0;
+ itemdb->chains[count].items[c - 1].rate = data ? libconfig->setting_get_int(entry) : 0;
prev = &itemdb->chains[count].items[c - 1];
}
@@ -1198,7 +1198,7 @@ void itemdb_read_chains(void) {
count++;
}
- config_destroy(&item_chain_conf);
+ libconfig->destroy(&item_chain_conf);
if( !script->get_constant("ITMCHAIN_ORE",&i) )
ShowWarning("itemdb_read_chains: failed to find 'ITMCHAIN_ORE' chain to link to cache!\n");
@@ -1781,13 +1781,13 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
* OnUnequipScript: <" OnUnequip Script ">
* Inherit: inherit or override
*/
- if( !config_setting_lookup_int(it, "Id", &i32) ) {
+ if( !libconfig->setting_lookup_int(it, "Id", &i32) ) {
ShowWarning("itemdb_readdb_libconfig_sub: Invalid or missing id in \"%s\", entry #%d, skipping.\n", source, n);
return 0;
}
id.nameid = (uint16)i32;
- if( (t = config_setting_get_member(it, "Inherit")) && (inherit = config_setting_get_bool(t)) ) {
+ if( (t = libconfig->setting_get_member(it, "Inherit")) && (inherit = libconfig->setting_get_bool(t)) ) {
if( !itemdb->exists(id.nameid) ) {
ShowWarning("itemdb_readdb_libconfig_sub: Trying to inherit nonexistent item %d, default values will be used instead.\n", id.nameid);
inherit = false;
@@ -1798,7 +1798,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
}
}
- if( !config_setting_lookup_string(it, "AegisName", &str) || !*str ) {
+ if( !libconfig->setting_lookup_string(it, "AegisName", &str) || !*str ) {
if( !inherit ) {
ShowWarning("itemdb_readdb_libconfig_sub: Missing AegisName in item %d of \"%s\", skipping.\n", id.nameid, source);
return 0;
@@ -1807,7 +1807,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
safestrncpy(id.name, str, sizeof(id.name));
}
- if( !config_setting_lookup_string(it, "Name", &str) || !*str ) {
+ if( !libconfig->setting_lookup_string(it, "Name", &str) || !*str ) {
if( !inherit ) {
ShowWarning("itemdb_readdb_libconfig_sub: Missing Name in item %d of \"%s\", skipping.\n", id.nameid, source);
return 0;
@@ -1816,86 +1816,86 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
safestrncpy(id.jname, str, sizeof(id.jname));
}
- if( config_setting_lookup_int(it, "Type", &i32) )
+ if( libconfig->setting_lookup_int(it, "Type", &i32) )
id.type = i32;
else if( !inherit )
id.type = IT_UNKNOWN;
- if( config_setting_lookup_int(it, "Buy", &i32) )
+ if( libconfig->setting_lookup_int(it, "Buy", &i32) )
id.value_buy = i32;
else if( !inherit )
id.value_buy = -1;
- if( config_setting_lookup_int(it, "Sell", &i32) )
+ if( libconfig->setting_lookup_int(it, "Sell", &i32) )
id.value_sell = i32;
else if( !inherit )
id.value_sell = -1;
- if( config_setting_lookup_int(it, "Weight", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Weight", &i32) && i32 >= 0 )
id.weight = i32;
- if( config_setting_lookup_int(it, "Atk", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Atk", &i32) && i32 >= 0 )
id.atk = i32;
- if( config_setting_lookup_int(it, "Matk", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Matk", &i32) && i32 >= 0 )
id.matk = i32;
- if( config_setting_lookup_int(it, "Def", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Def", &i32) && i32 >= 0 )
id.def = i32;
- if( config_setting_lookup_int(it, "Range", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Range", &i32) && i32 >= 0 )
id.range = i32;
- if( config_setting_lookup_int(it, "Slots", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Slots", &i32) && i32 >= 0 )
id.slot = i32;
- if( config_setting_lookup_int(it, "Job", &i32) ) // This is an unsigned value, do not check for >= 0
+ if( libconfig->setting_lookup_int(it, "Job", &i32) ) // This is an unsigned value, do not check for >= 0
itemdb->jobid2mapid(id.class_base, (unsigned int)i32);
else if( !inherit )
itemdb->jobid2mapid(id.class_base, UINT_MAX);
- if( config_setting_lookup_int(it, "Upper", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Upper", &i32) && i32 >= 0 )
id.class_upper = (unsigned int)i32;
else if( !inherit )
id.class_upper = ITEMUPPER_ALL;
- if( config_setting_lookup_int(it, "Gender", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Gender", &i32) && i32 >= 0 )
id.sex = i32;
else if( !inherit )
id.sex = 2;
- if( config_setting_lookup_int(it, "Loc", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "Loc", &i32) && i32 >= 0 )
id.equip = i32;
- if( config_setting_lookup_int(it, "WeaponLv", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "WeaponLv", &i32) && i32 >= 0 )
id.wlv = i32;
- if( (t = config_setting_get_member(it, "EquipLv")) ) {
+ if( (t = libconfig->setting_get_member(it, "EquipLv")) ) {
if( config_setting_is_aggregate(t) ) {
- if( config_setting_length(t) >= 2 )
- id.elvmax = config_setting_get_int_elem(t, 1);
- if( config_setting_length(t) >= 1 )
- id.elv = config_setting_get_int_elem(t, 0);
+ if( libconfig->setting_length(t) >= 2 )
+ id.elvmax = libconfig->setting_get_int_elem(t, 1);
+ if( libconfig->setting_length(t) >= 1 )
+ id.elv = libconfig->setting_get_int_elem(t, 0);
} else {
- id.elv = config_setting_get_int(t);
+ id.elv = libconfig->setting_get_int(t);
}
}
- if( (t = config_setting_get_member(it, "Refine")) )
- id.flag.no_refine = config_setting_get_bool(t) ? 0 : 1;
+ if( (t = libconfig->setting_get_member(it, "Refine")) )
+ id.flag.no_refine = libconfig->setting_get_bool(t) ? 0 : 1;
- if( config_setting_lookup_int(it, "View", &i32) && i32 >= 0 )
+ if( libconfig->setting_lookup_int(it, "View", &i32) && i32 >= 0 )
id.look = i32;
- if( (t = config_setting_get_member(it, "BindOnEquip")) )
- id.flag.bindonequip = config_setting_get_bool(t) ? 1 : 0;
+ if( (t = libconfig->setting_get_member(it, "BindOnEquip")) )
+ id.flag.bindonequip = libconfig->setting_get_bool(t) ? 1 : 0;
- if( config_setting_lookup_string(it, "Script", &str) )
+ if( libconfig->setting_lookup_string(it, "Script", &str) )
id.script = *str ? script->parse(str, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS) : NULL;
- if( config_setting_lookup_string(it, "OnEquipScript", &str) )
+ if( libconfig->setting_lookup_string(it, "OnEquipScript", &str) )
id.equip_script = *str ? script->parse(str, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS) : NULL;
- if( config_setting_lookup_string(it, "OnUnequipScript", &str) )
+ if( libconfig->setting_lookup_string(it, "OnUnequipScript", &str) )
id.unequip_script = *str ? script->parse(str, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS) : NULL;
return itemdb->validate_entry(&id, n, source);
@@ -1917,12 +1917,12 @@ int itemdb_readdb_libconfig(const char *filename) {
sprintf(filepath, "%s/%s", map->db_path, filename);
memset(&duplicate,0,sizeof(duplicate));
- if( conf_read_file(&item_db_conf, filepath) || !(itdb = config_setting_get_member(item_db_conf.root, "item_db")) ) {
+ if( libconfig->read_file(&item_db_conf, filepath) || !(itdb = libconfig->setting_get_member(item_db_conf.root, "item_db")) ) {
ShowError("can't read %s\n", filepath);
return 0;
}
- while( (it = config_setting_get_elem(itdb,i++)) ) {
+ while( (it = libconfig->setting_get_elem(itdb,i++)) ) {
int nameid = itemdb->readdb_libconfig_sub(it, i-1, filename);
if( !nameid )
@@ -1936,7 +1936,7 @@ int itemdb_readdb_libconfig(const char *filename) {
} else
duplicate[nameid] = true;
}
- config_destroy(&item_db_conf);
+ libconfig->destroy(&item_db_conf);
ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
return count;
diff --git a/src/map/map.c b/src/map/map.c
index 5344d11bf..052d589b4 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -4577,10 +4577,10 @@ void read_map_zone_db(void) {
#else
const char *config_filename = "db/pre-re/map_zone_db.conf"; // FIXME hardcoded name
#endif
- if (conf_read_file(&map_zone_db, config_filename))
+ if (libconfig->read_file(&map_zone_db, config_filename))
return;
- zones = config_lookup(&map_zone_db, "zones");
+ zones = libconfig->lookup(&map_zone_db, "zones");
if (zones != NULL) {
struct map_zone_data *zone;
@@ -4597,16 +4597,16 @@ void read_map_zone_db(void) {
disabled_commands_count = 0, capped_skills_count = 0;
enum map_zone_skill_subtype subtype;
- zone_count = config_setting_length(zones);
+ zone_count = libconfig->setting_length(zones);
for (i = 0; i < zone_count; ++i) {
bool is_all = false;
- zone_e = config_setting_get_elem(zones, i);
+ zone_e = libconfig->setting_get_elem(zones, i);
- if (!config_setting_lookup_string(zone_e, "name", &zonename)) {
+ if (!libconfig->setting_lookup_string(zone_e, "name", &zonename)) {
ShowError("map_zone_db: missing zone name, skipping... (%s:%d)\n",
config_setting_source_file(zone_e), config_setting_source_line(zone_e));
- config_setting_remove_elem(zones,i);/* remove from the tree */
+ libconfig->setting_remove_elem(zones,i);/* remove from the tree */
--zone_count;
--i;
continue;
@@ -4614,7 +4614,7 @@ void read_map_zone_db(void) {
if( strdb_exists(map->zone_db, zonename) ) {
ShowError("map_zone_db: duplicate zone name '%s', skipping...\n",zonename);
- config_setting_remove_elem(zones,i);/* remove from the tree */
+ libconfig->setting_remove_elem(zones,i);/* remove from the tree */
--zone_count;
--i;
continue;
@@ -4634,31 +4634,31 @@ void read_map_zone_db(void) {
}
safestrncpy(zone->name, zonename, MAP_ZONE_NAME_LENGTH);
- if( (skills = config_setting_get_member(zone_e, "disabled_skills")) != NULL ) {
- disabled_skills_count = config_setting_length(skills);
+ if( (skills = libconfig->setting_get_member(zone_e, "disabled_skills")) != NULL ) {
+ disabled_skills_count = libconfig->setting_length(skills);
/* validate */
- for(h = 0; h < config_setting_length(skills); h++) {
- config_setting_t *skillinfo = config_setting_get_elem(skills, h);
+ for(h = 0; h < libconfig->setting_length(skills); h++) {
+ config_setting_t *skillinfo = libconfig->setting_get_elem(skills, h);
name = config_setting_name(skillinfo);
if( !map->zone_str2skillid(name) ) {
ShowError("map_zone_db: unknown skill (%s) in disabled_skills for zone '%s', skipping skill...\n",name,zone->name);
- config_setting_remove_elem(skills,h);
+ libconfig->setting_remove_elem(skills,h);
--disabled_skills_count;
--h;
continue;
}
- if( !map->zone_bl_type(config_setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */
+ if( !map->zone_bl_type(libconfig->setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */
--disabled_skills_count;
}
/* all ok, process */
CREATE( zone->disabled_skills, struct map_zone_disabled_skill_entry *, disabled_skills_count );
- for(h = 0, v = 0; h < config_setting_length(skills); h++) {
- config_setting_t *skillinfo = config_setting_get_elem(skills, h);
+ for(h = 0, v = 0; h < libconfig->setting_length(skills); h++) {
+ config_setting_t *skillinfo = libconfig->setting_get_elem(skills, h);
struct map_zone_disabled_skill_entry * entry;
enum bl_type type;
name = config_setting_name(skillinfo);
- if( (type = map->zone_bl_type(config_setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */
+ if( (type = map->zone_bl_type(libconfig->setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */
CREATE( entry, struct map_zone_disabled_skill_entry, 1 );
entry->nameid = map->zone_str2skillid(name);
@@ -4672,28 +4672,28 @@ void read_map_zone_db(void) {
zone->disabled_skills_count = disabled_skills_count;
}
- if( (items = config_setting_get_member(zone_e, "disabled_items")) != NULL ) {
- disabled_items_count = config_setting_length(items);
+ if( (items = libconfig->setting_get_member(zone_e, "disabled_items")) != NULL ) {
+ disabled_items_count = libconfig->setting_length(items);
/* validate */
- for(h = 0; h < config_setting_length(items); h++) {
- config_setting_t *item = config_setting_get_elem(items, h);
+ for(h = 0; h < libconfig->setting_length(items); h++) {
+ config_setting_t *item = libconfig->setting_get_elem(items, h);
name = config_setting_name(item);
if( !map->zone_str2itemid(name) ) {
ShowError("map_zone_db: unknown item (%s) in disabled_items for zone '%s', skipping item...\n",name,zone->name);
- config_setting_remove_elem(items,h);
+ libconfig->setting_remove_elem(items,h);
--disabled_items_count;
--h;
continue;
}
- if( !config_setting_get_bool(item) )/* we dont remove it from the three due to inheritance */
+ if( !libconfig->setting_get_bool(item) )/* we dont remove it from the three due to inheritance */
--disabled_items_count;
}
/* all ok, process */
CREATE( zone->disabled_items, int, disabled_items_count );
- for(h = 0, v = 0; h < config_setting_length(items); h++) {
- config_setting_t *item = config_setting_get_elem(items, h);
+ for(h = 0, v = 0; h < libconfig->setting_length(items); h++) {
+ config_setting_t *item = libconfig->setting_get_elem(items, h);
- if( config_setting_get_bool(item) ) { /* only add if enabled */
+ if( libconfig->setting_get_bool(item) ) { /* only add if enabled */
name = config_setting_name(item);
zone->disabled_items[v++] = map->zone_str2itemid(name);
}
@@ -4702,14 +4702,14 @@ void read_map_zone_db(void) {
zone->disabled_items_count = disabled_items_count;
}
- if( (mapflags = config_setting_get_member(zone_e, "mapflags")) != NULL ) {
- mapflags_count = config_setting_length(mapflags);
+ if( (mapflags = libconfig->setting_get_member(zone_e, "mapflags")) != NULL ) {
+ mapflags_count = libconfig->setting_length(mapflags);
/* mapflags are not validated here, so we save all anyway */
CREATE( zone->mapflags, char *, mapflags_count );
for(h = 0; h < mapflags_count; h++) {
CREATE( zone->mapflags[h], char, MAP_ZONE_MAPFLAG_LENGTH );
- name = config_setting_get_string_elem(mapflags, h);
+ name = libconfig->setting_get_string_elem(mapflags, h);
safestrncpy(zone->mapflags[h], name, MAP_ZONE_MAPFLAG_LENGTH);
@@ -4717,31 +4717,31 @@ void read_map_zone_db(void) {
zone->mapflags_count = mapflags_count;
}
- if( (commands = config_setting_get_member(zone_e, "disabled_commands")) != NULL ) {
- disabled_commands_count = config_setting_length(commands);
+ if( (commands = libconfig->setting_get_member(zone_e, "disabled_commands")) != NULL ) {
+ disabled_commands_count = libconfig->setting_length(commands);
/* validate */
- for(h = 0; h < config_setting_length(commands); h++) {
- config_setting_t *command = config_setting_get_elem(commands, h);
+ for(h = 0; h < libconfig->setting_length(commands); h++) {
+ config_setting_t *command = libconfig->setting_get_elem(commands, h);
name = config_setting_name(command);
if( !atcommand->exists(name) ) {
ShowError("map_zone_db: unknown command '%s' in disabled_commands for zone '%s', skipping entry...\n",name,zone->name);
- config_setting_remove_elem(commands,h);
+ libconfig->setting_remove_elem(commands,h);
--disabled_commands_count;
--h;
continue;
}
- if( !config_setting_get_int(command) )/* we dont remove it from the three due to inheritance */
+ if( !libconfig->setting_get_int(command) )/* we dont remove it from the three due to inheritance */
--disabled_commands_count;
}
/* all ok, process */
CREATE( zone->disabled_commands, struct map_zone_disabled_command_entry *, disabled_commands_count );
- for(h = 0, v = 0; h < config_setting_length(commands); h++) {
- config_setting_t *command = config_setting_get_elem(commands, h);
+ for(h = 0, v = 0; h < libconfig->setting_length(commands); h++) {
+ config_setting_t *command = libconfig->setting_get_elem(commands, h);
struct map_zone_disabled_command_entry * entry;
int group_lv;
name = config_setting_name(command);
- if( (group_lv = config_setting_get_int(command)) ) { /* only add if enabled */
+ if( (group_lv = libconfig->setting_get_int(command)) ) { /* only add if enabled */
CREATE( entry, struct map_zone_disabled_command_entry, 1 );
entry->cmd = atcommand->exists(name)->func;
@@ -4753,35 +4753,35 @@ void read_map_zone_db(void) {
zone->disabled_commands_count = disabled_commands_count;
}
- if( (caps = config_setting_get_member(zone_e, "skill_damage_cap")) != NULL ) {
- capped_skills_count = config_setting_length(caps);
+ if( (caps = libconfig->setting_get_member(zone_e, "skill_damage_cap")) != NULL ) {
+ capped_skills_count = libconfig->setting_length(caps);
/* validate */
- for(h = 0; h < config_setting_length(caps); h++) {
- config_setting_t *cap = config_setting_get_elem(caps, h);
+ for(h = 0; h < libconfig->setting_length(caps); h++) {
+ config_setting_t *cap = libconfig->setting_get_elem(caps, h);
name = config_setting_name(cap);
if( !map->zone_str2skillid(name) ) {
ShowError("map_zone_db: unknown skill (%s) in skill_damage_cap for zone '%s', skipping skill...\n",name,zone->name);
- config_setting_remove_elem(caps,h);
+ libconfig->setting_remove_elem(caps,h);
--capped_skills_count;
--h;
continue;
}
- if( !map->zone_bl_type(config_setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */
+ if( !map->zone_bl_type(libconfig->setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */
--capped_skills_count;
}
/* all ok, process */
CREATE( zone->capped_skills, struct map_zone_skill_damage_cap_entry *, capped_skills_count );
- for(h = 0, v = 0; h < config_setting_length(caps); h++) {
- config_setting_t *cap = config_setting_get_elem(caps, h);
+ for(h = 0, v = 0; h < libconfig->setting_length(caps); h++) {
+ config_setting_t *cap = libconfig->setting_get_elem(caps, h);
struct map_zone_skill_damage_cap_entry * entry;
enum bl_type type;
name = config_setting_name(cap);
- if( (type = map->zone_bl_type(config_setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */
+ if( (type = map->zone_bl_type(libconfig->setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */
CREATE( entry, struct map_zone_skill_damage_cap_entry, 1 );
entry->nameid = map->zone_str2skillid(name);
- entry->cap = config_setting_get_int_elem(cap,0);
+ entry->cap = libconfig->setting_get_int_elem(cap,0);
entry->type = type;
entry->subtype = subtype;
zone->capped_skills[v++] = entry;
@@ -4801,24 +4801,24 @@ void read_map_zone_db(void) {
config_setting_t *new_entry = NULL;
int inherit_count;
- zone_e = config_setting_get_elem(zones, i);
- config_setting_lookup_string(zone_e, "name", &zonename);
+ zone_e = libconfig->setting_get_elem(zones, i);
+ libconfig->setting_lookup_string(zone_e, "name", &zonename);
if( strncmpi(zonename,MAP_ZONE_ALL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
continue;/* all zone doesn't inherit anything (if it did, everything would link to each other and boom endless loop) */
}
- if( (inherit_tree = config_setting_get_member(zone_e, "inherit")) != NULL ) {
+ if( (inherit_tree = libconfig->setting_get_member(zone_e, "inherit")) != NULL ) {
/* append global zone to this */
- new_entry = config_setting_add(inherit_tree,MAP_ZONE_ALL_NAME,CONFIG_TYPE_STRING);
- config_setting_set_string(new_entry,MAP_ZONE_ALL_NAME);
+ new_entry = libconfig->setting_add(inherit_tree,MAP_ZONE_ALL_NAME,CONFIG_TYPE_STRING);
+ libconfig->setting_set_string(new_entry,MAP_ZONE_ALL_NAME);
} else {
/* create inherit member and add global zone to it */
- inherit_tree = config_setting_add(zone_e, "inherit",CONFIG_TYPE_ARRAY);
- new_entry = config_setting_add(inherit_tree,MAP_ZONE_ALL_NAME,CONFIG_TYPE_STRING);
- config_setting_set_string(new_entry,MAP_ZONE_ALL_NAME);
+ inherit_tree = libconfig->setting_add(zone_e, "inherit",CONFIG_TYPE_ARRAY);
+ new_entry = libconfig->setting_add(inherit_tree,MAP_ZONE_ALL_NAME,CONFIG_TYPE_STRING);
+ libconfig->setting_set_string(new_entry,MAP_ZONE_ALL_NAME);
}
- inherit_count = config_setting_length(inherit_tree);
+ inherit_count = libconfig->setting_length(inherit_tree);
for(h = 0; h < inherit_count; h++) {
struct map_zone_data *izone; /* inherit zone */
int disabled_skills_count_i = 0; /* disabled skill count from inherit zone */
@@ -4828,8 +4828,8 @@ void read_map_zone_db(void) {
int capped_skills_count_i = 0; /* skill capped count from inherit zone */
int j;
- name = config_setting_get_string_elem(inherit_tree, h);
- config_setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */
+ name = libconfig->setting_get_string_elem(inherit_tree, h);
+ libconfig->setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */
if( !(izone = strdb_get(map->zone_db, name)) ) {
ShowError("map_zone_db: Unknown zone '%s' being inherit by zone '%s', skipping...\n",name,zonename);
@@ -4851,13 +4851,13 @@ void read_map_zone_db(void) {
/* process everything to override, paying attention to config_setting_get_bool */
if( disabled_skills_count_i ) {
- if( (skills = config_setting_get_member(zone_e, "disabled_skills")) == NULL )
- skills = config_setting_add(zone_e, "disabled_skills",CONFIG_TYPE_GROUP);
- disabled_skills_count = config_setting_length(skills);
+ if( (skills = libconfig->setting_get_member(zone_e, "disabled_skills")) == NULL )
+ skills = libconfig->setting_add(zone_e, "disabled_skills",CONFIG_TYPE_GROUP);
+ disabled_skills_count = libconfig->setting_length(skills);
for(j = 0; j < disabled_skills_count_i; j++) {
int k;
for(k = 0; k < disabled_skills_count; k++) {
- config_setting_t *skillinfo = config_setting_get_elem(skills, k);
+ config_setting_t *skillinfo = libconfig->setting_get_elem(skills, k);
if( map->zone_str2skillid(config_setting_name(skillinfo)) == izone->disabled_skills[j]->nameid ) {
break;
}
@@ -4874,18 +4874,18 @@ void read_map_zone_db(void) {
}
if( disabled_items_count_i ) {
- if( (items = config_setting_get_member(zone_e, "disabled_items")) == NULL )
- items = config_setting_add(zone_e, "disabled_items",CONFIG_TYPE_GROUP);
- disabled_items_count = config_setting_length(items);
+ if( (items = libconfig->setting_get_member(zone_e, "disabled_items")) == NULL )
+ items = libconfig->setting_add(zone_e, "disabled_items",CONFIG_TYPE_GROUP);
+ disabled_items_count = libconfig->setting_length(items);
for(j = 0; j < disabled_items_count_i; j++) {
int k;
for(k = 0; k < disabled_items_count; k++) {
- config_setting_t *item = config_setting_get_elem(items, k);
+ config_setting_t *item = libconfig->setting_get_elem(items, k);
name = config_setting_name(item);
if( map->zone_str2itemid(name) == izone->disabled_items[j] ) {
- if( config_setting_get_bool(item) )
+ if( libconfig->setting_get_bool(item) )
continue;
break;
}
@@ -4898,13 +4898,13 @@ void read_map_zone_db(void) {
}
if( mapflags_count_i ) {
- if( (mapflags = config_setting_get_member(zone_e, "mapflags")) == NULL )
- mapflags = config_setting_add(zone_e, "mapflags",CONFIG_TYPE_ARRAY);
- mapflags_count = config_setting_length(mapflags);
+ if( (mapflags = libconfig->setting_get_member(zone_e, "mapflags")) == NULL )
+ mapflags = libconfig->setting_add(zone_e, "mapflags",CONFIG_TYPE_ARRAY);
+ mapflags_count = libconfig->setting_length(mapflags);
for(j = 0; j < mapflags_count_i; j++) {
int k;
for(k = 0; k < mapflags_count; k++) {
- name = config_setting_get_string_elem(mapflags, k);
+ name = libconfig->setting_get_string_elem(mapflags, k);
if( strcmpi(name,izone->mapflags[j]) == 0 ) {
break;
@@ -4919,14 +4919,14 @@ void read_map_zone_db(void) {
}
if( disabled_commands_count_i ) {
- if( (commands = config_setting_get_member(zone_e, "disabled_commands")) == NULL )
- commands = config_setting_add(zone_e, "disabled_commands",CONFIG_TYPE_GROUP);
+ if( (commands = libconfig->setting_get_member(zone_e, "disabled_commands")) == NULL )
+ commands = libconfig->setting_add(zone_e, "disabled_commands",CONFIG_TYPE_GROUP);
- disabled_commands_count = config_setting_length(commands);
+ disabled_commands_count = libconfig->setting_length(commands);
for(j = 0; j < disabled_commands_count_i; j++) {
int k;
for(k = 0; k < disabled_commands_count; k++) {
- config_setting_t *command = config_setting_get_elem(commands, k);
+ config_setting_t *command = libconfig->setting_get_elem(commands, k);
if( atcommand->exists(config_setting_name(command))->func == izone->disabled_commands[j]->cmd ) {
break;
}
@@ -4943,14 +4943,14 @@ void read_map_zone_db(void) {
}
if( capped_skills_count_i ) {
- if( (caps = config_setting_get_member(zone_e, "skill_damage_cap")) == NULL )
- caps = config_setting_add(zone_e, "skill_damage_cap",CONFIG_TYPE_GROUP);
+ if( (caps = libconfig->setting_get_member(zone_e, "skill_damage_cap")) == NULL )
+ caps = libconfig->setting_add(zone_e, "skill_damage_cap",CONFIG_TYPE_GROUP);
- capped_skills_count = config_setting_length(caps);
+ capped_skills_count = libconfig->setting_length(caps);
for(j = 0; j < capped_skills_count_i; j++) {
int k;
for(k = 0; k < capped_skills_count; k++) {
- config_setting_t *cap = config_setting_get_elem(caps, k);
+ config_setting_t *cap = libconfig->setting_get_elem(caps, k);
if( map->zone_str2skillid(config_setting_name(cap)) == izone->capped_skills[j]->nameid ) {
break;
}
@@ -4972,7 +4972,7 @@ void read_map_zone_db(void) {
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' zones in '"CL_WHITE"%s"CL_RESET"'.\n", zone_count, config_filename);
/* not supposed to go in here but in skill_final whatever */
- config_destroy(&map_zone_db);
+ libconfig->destroy(&map_zone_db);
}
}
diff --git a/src/map/pc.c b/src/map/pc.c
index cc2566a6e..f96b70cdb 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -9746,14 +9746,14 @@ void pc_read_skill_tree(void) {
{ "Rebellion", JOB_REBELLION },
};
- if (conf_read_file(&skill_tree_conf, config_filename)) {
+ if (libconfig->read_file(&skill_tree_conf, config_filename)) {
ShowError("can't read %s\n", config_filename);
return;
}
jnamelen = ARRAYLENGTH(jnames);
- while( (skt = config_setting_get_elem(skill_tree_conf.root,i++)) ) {
+ while( (skt = libconfig->setting_get_elem(skill_tree_conf.root,i++)) ) {
int k, idx;
const char *name = config_setting_name(skt);
@@ -9765,12 +9765,12 @@ void pc_read_skill_tree(void) {
}
- if( ( skills = config_setting_get_member(skt,"skills") ) ) {
+ if( ( skills = libconfig->setting_get_member(skt,"skills") ) ) {
int c = 0;
idx = pc->class2idx(jnames[k].id);
- while( ( sk = config_setting_get_elem(skills,c++) ) ) {
+ while( ( sk = libconfig->setting_get_elem(skills,c++) ) ) {
const char *sk_name = config_setting_name(sk);
int skill_id;
@@ -9790,23 +9790,23 @@ void pc_read_skill_tree(void) {
if( config_setting_is_group(sk) ) {
int max = 0, jlevel = 0;
- config_setting_lookup_int(sk, "MaxLevel", &max);
- config_setting_lookup_int(sk, "MinJobLevel", &jlevel);
+ libconfig->setting_lookup_int(sk, "MaxLevel", &max);
+ libconfig->setting_lookup_int(sk, "MinJobLevel", &jlevel);
pc->skill_tree[idx][skidx].max = (unsigned char)max;
pc->skill_tree[idx][skidx].joblv = (unsigned char)jlevel;
- rlen = config_setting_length(sk);
+ rlen = libconfig->setting_length(sk);
offset += jlevel ? 2 : 1;
} else {
- pc->skill_tree[idx][skidx].max = (unsigned char)config_setting_get_int(sk);
+ pc->skill_tree[idx][skidx].max = (unsigned char)libconfig->setting_get_int(sk);
pc->skill_tree[idx][skidx].joblv = 0;
}
for( h = offset; h < rlen && h < MAX_PC_SKILL_REQUIRE; h++ ) {
- config_setting_t *rsk = config_setting_get_elem(sk,h);
+ config_setting_t *rsk = libconfig->setting_get_elem(sk,h);
if( rsk && ( rskid = skill->name2id(config_setting_name(rsk)) ) ) {
pc->skill_tree[idx][skidx].need[h].id = rskid;
pc->skill_tree[idx][skidx].need[h].idx = skill->get_index(rskid);
- pc->skill_tree[idx][skidx].need[h].lv = (unsigned char)config_setting_get_int(rsk);
+ pc->skill_tree[idx][skidx].need[h].lv = (unsigned char)libconfig->setting_get_int(rsk);
} else if( rsk ) {
ShowWarning("pc_read_skill_tree: unknown requirement '%s' for '%s' in '%s'\n",config_setting_name(rsk),sk_name,name);
} else {
@@ -9822,7 +9822,7 @@ void pc_read_skill_tree(void) {
}
i = 0;
- while( (skt = config_setting_get_elem(skill_tree_conf.root,i++)) ) {
+ while( (skt = libconfig->setting_get_elem(skill_tree_conf.root,i++)) ) {
int k, idx, v = 0;
const char *name = config_setting_name(skt);
const char *iname;
@@ -9836,8 +9836,8 @@ void pc_read_skill_tree(void) {
}
idx = pc->class2idx(jnames[k].id);
- if( ( inherit = config_setting_get_member(skt,"inherit") ) ) {
- while( ( iname = config_setting_get_string_elem(inherit, v++) ) ) {
+ if( ( inherit = libconfig->setting_get_member(skt,"inherit") ) ) {
+ while( ( iname = libconfig->setting_get_string_elem(inherit, v++) ) ) {
int b = 0, a, d, f, fidx;
ARR_FIND(0, jnamelen, b, strcmpi(jnames[b].name,iname) == 0 );
@@ -9869,7 +9869,7 @@ void pc_read_skill_tree(void) {
}
- config_destroy(&skill_tree_conf);
+ libconfig->destroy(&skill_tree_conf);
/* lets update all players skill tree */
iter = mapit_getallusers();
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 4ddb95c9b..906462c7e 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -49,26 +49,26 @@ static void read_config(void) {
const char *config_filename = "conf/groups.conf"; // FIXME hardcoded name
int group_count = 0;
- if (conf_read_file(&pc_group_config, config_filename))
+ if (libconfig->read_file(&pc_group_config, config_filename))
return;
- groups = config_lookup(&pc_group_config, "groups");
+ groups = libconfig->lookup(&pc_group_config, "groups");
if (groups != NULL) {
GroupSettings *group_settings = NULL;
DBIterator *iter = NULL;
int i, loop = 0;
- group_count = config_setting_length(groups);
+ group_count = libconfig->setting_length(groups);
for (i = 0; i < group_count; ++i) {
int id = 0, level = 0;
const char *groupname = NULL;
int log_commands = 0;
- config_setting_t *group = config_setting_get_elem(groups, i);
+ config_setting_t *group = libconfig->setting_get_elem(groups, i);
- if (!config_setting_lookup_int(group, "id", &id)) {
+ if (!libconfig->setting_lookup_int(group, "id", &id)) {
ShowConfigWarning(group, "pc_groups:read_config: \"groups\" list member #%d has undefined id, removing...", i);
- config_setting_remove_elem(groups, i);
+ libconfig->setting_remove_elem(groups, i);
--i;
--group_count;
continue;
@@ -76,16 +76,16 @@ static void read_config(void) {
if (pcg->exists(id)) {
ShowConfigWarning(group, "pc_groups:read_config: duplicate group id %d, removing...", i);
- config_setting_remove_elem(groups, i);
+ libconfig->setting_remove_elem(groups, i);
--i;
--group_count;
continue;
}
- config_setting_lookup_int(group, "level", &level);
- config_setting_lookup_bool(group, "log_commands", &log_commands);
+ libconfig->setting_lookup_int(group, "level", &level);
+ libconfig->setting_lookup_bool(group, "log_commands", &log_commands);
- if (!config_setting_lookup_string(group, "name", &groupname)) {
+ if (!libconfig->setting_lookup_string(group, "name", &groupname)) {
char temp[20];
config_setting_t *name = NULL;
snprintf(temp, sizeof(temp), "Group %d", id);
@@ -97,12 +97,12 @@ static void read_config(void) {
--group_count;
continue;
}
- config_setting_lookup_string(group, "name", &groupname); // Retrieve the pointer
+ libconfig->setting_lookup_string(group, "name", &groupname); // Retrieve the pointer
}
if (name2group(groupname) != NULL) {
ShowConfigWarning(group, "pc_groups:read_config: duplicate group name %s, removing...", groupname);
- config_setting_remove_elem(groups, i);
+ libconfig->setting_remove_elem(groups, i);
--i;
--group_count;
continue;
@@ -113,9 +113,9 @@ static void read_config(void) {
group_settings->level = level;
group_settings->name = aStrdup(groupname);
group_settings->log_commands = (bool)log_commands;
- group_settings->inherit = config_setting_get_member(group, "inherit");
- group_settings->commands = config_setting_get_member(group, "commands");
- group_settings->permissions = config_setting_get_member(group, "permissions");
+ group_settings->inherit = libconfig->setting_get_member(group, "inherit");
+ group_settings->commands = libconfig->setting_get_member(group, "commands");
+ group_settings->permissions = libconfig->setting_get_member(group, "permissions");
group_settings->inheritance_done = false;
group_settings->root = group;
group_settings->index = i;
@@ -124,7 +124,7 @@ static void read_config(void) {
idb_put(pcg->db, id, group_settings);
}
- group_count = config_setting_length(groups); // Save number of groups
+ group_count = libconfig->setting_length(groups); // Save number of groups
assert(group_count == db_size(pcg->db));
// Check if all commands and permissions exist
@@ -135,15 +135,15 @@ static void read_config(void) {
// Make sure there is "commands" group
if (commands == NULL)
- commands = group_settings->commands = config_setting_add(group_settings->root, "commands", CONFIG_TYPE_GROUP);
- count = config_setting_length(commands);
+ commands = group_settings->commands = libconfig->setting_add(group_settings->root, "commands", CONFIG_TYPE_GROUP);
+ count = libconfig->setting_length(commands);
for (i = 0; i < count; ++i) {
- config_setting_t *command = config_setting_get_elem(commands, i);
+ config_setting_t *command = libconfig->setting_get_elem(commands, i);
const char *name = config_setting_name(command);
if (!atcommand->exists(name)) {
ShowConfigWarning(command, "pc_groups:read_config: non-existent command name '%s', removing...", name);
- config_setting_remove(commands, name);
+ libconfig->setting_remove(commands, name);
--i;
--count;
}
@@ -151,18 +151,18 @@ static void read_config(void) {
// Make sure there is "permissions" group
if (permissions == NULL)
- permissions = group_settings->permissions = config_setting_add(group_settings->root, "permissions", CONFIG_TYPE_GROUP);
- count = config_setting_length(permissions);
+ permissions = group_settings->permissions = libconfig->setting_add(group_settings->root, "permissions", CONFIG_TYPE_GROUP);
+ count = libconfig->setting_length(permissions);
for(i = 0; i < count; ++i) {
- config_setting_t *permission = config_setting_get_elem(permissions, i);
+ config_setting_t *permission = libconfig->setting_get_elem(permissions, i);
const char *name = config_setting_name(permission);
int j;
ARR_FIND(0, pcg->permission_count, j, strcmp(pcg->permissions[j].name, name) == 0);
if (j == pcg->permission_count) {
ShowConfigWarning(permission, "pc_groups:read_config: non-existent permission name '%s', removing...", name);
- config_setting_remove(permissions, name);
+ libconfig->setting_remove(permissions, name);
--i;
--count;
}
@@ -184,7 +184,7 @@ static void read_config(void) {
continue;
if ((inherit = group_settings->inherit) == NULL ||
- (inherit_count = config_setting_length(inherit)) <= 0) { // this group does not inherit from others
+ (inherit_count = libconfig->setting_length(inherit)) <= 0) { // this group does not inherit from others
++i;
group_settings->inheritance_done = true;
continue;
@@ -192,16 +192,16 @@ static void read_config(void) {
for (j = 0; j < inherit_count; ++j) {
GroupSettings *inherited_group = NULL;
- const char *groupname = config_setting_get_string_elem(inherit, j);
+ const char *groupname = libconfig->setting_get_string_elem(inherit, j);
if (groupname == NULL) {
ShowConfigWarning(inherit, "pc_groups:read_config: \"inherit\" array member #%d is not a name, removing...", j);
- config_setting_remove_elem(inherit,j);
+ libconfig->setting_remove_elem(inherit,j);
continue;
}
if ((inherited_group = name2group(groupname)) == NULL) {
ShowConfigWarning(inherit, "pc_groups:read_config: non-existent group name \"%s\", removing...", groupname);
- config_setting_remove_elem(inherit,j);
+ libconfig->setting_remove_elem(inherit,j);
continue;
}
if (!inherited_group->inheritance_done)
@@ -209,15 +209,15 @@ static void read_config(void) {
// Copy settings (commands/permissions) that are not defined yet
if (inherited_group->commands != NULL) {
- int k = 0, commands_count = config_setting_length(inherited_group->commands);
+ int k = 0, commands_count = libconfig->setting_length(inherited_group->commands);
for (k = 0; k < commands_count; ++k)
- config_setting_copy(commands, config_setting_get_elem(inherited_group->commands, k));
+ libconfig->setting_copy(commands, libconfig->setting_get_elem(inherited_group->commands, k));
}
if (inherited_group->permissions != NULL) {
- int k = 0, permissions_count = config_setting_length(inherited_group->permissions);
+ int k = 0, permissions_count = libconfig->setting_length(inherited_group->permissions);
for (k = 0; k < permissions_count; ++k)
- config_setting_copy(permissions, config_setting_get_elem(inherited_group->permissions, k));
+ libconfig->setting_copy(permissions, libconfig->setting_get_elem(inherited_group->permissions, k));
}
++done; // copied commands and permissions from one of inherited groups
@@ -241,12 +241,12 @@ static void read_config(void) {
iter = db_iterator(pcg->db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
config_setting_t *permissions = group_settings->permissions;
- int count = config_setting_length(permissions);
+ int count = libconfig->setting_length(permissions);
for (i = 0; i < count; ++i) {
- config_setting_t *perm = config_setting_get_elem(permissions, i);
+ config_setting_t *perm = libconfig->setting_get_elem(permissions, i);
const char *name = config_setting_name(perm);
- int val = config_setting_get_bool(perm);
+ int val = libconfig->setting_get_bool(perm);
int j;
if (val == 0) // does not have this permission
@@ -282,7 +282,7 @@ static void read_config(void) {
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' groups in '"CL_WHITE"%s"CL_RESET"'.\n", group_count, config_filename);
// All data is loaded now, discard config
- config_destroy(&pc_group_config);
+ libconfig->destroy(&pc_group_config);
}
/**