summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-18 03:10:37 +0300
committerGitHub <noreply@github.com>2016-09-18 03:10:37 +0300
commit90c4f0f2087e9895bcca0257fd9500c29d7c1790 (patch)
treed6132f5dcbcc8b5caae346169f9b1e26b76c6405 /src/map/map.c
parentfc9b897f73fd94afb1ab2c57fe05e9f541136800 (diff)
parent9068ec7dc0e85cd3f7f8f9a11a3b7f06dc24f4f6 (diff)
downloadhercules-90c4f0f2087e9895bcca0257fd9500c29d7c1790.tar.gz
hercules-90c4f0f2087e9895bcca0257fd9500c29d7c1790.tar.bz2
hercules-90c4f0f2087e9895bcca0257fd9500c29d7c1790.tar.xz
hercules-90c4f0f2087e9895bcca0257fd9500c29d7c1790.zip
Merge pull request #1435 from HerculesWS/npc_removed_list
Fixes for npc_removed_list and map_removed
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/map/map.c b/src/map/map.c
index d22b28689..47e22fa9b 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3996,7 +3996,7 @@ bool map_config_read_map_list(const char *filename, struct config_t *config, boo
nullpo_retr(false, filename);
nullpo_retr(false, config);
- deleted_maps = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY|DB_OPT_ALLOW_NULL_DATA, MAP_NAME_LENGTH);
+ deleted_maps = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA, MAP_NAME_LENGTH);
// Remove maps
if ((setting = libconfig->lookup(config, "map_configuration/map_removed")) != NULL) {
@@ -4128,6 +4128,7 @@ bool map_read_npclist(const char *filename, bool imported)
struct config_setting_t *setting = NULL;
const char *import = NULL;
bool retval = true;
+ bool remove_all = false;
struct DBMap *deleted_npcs;
@@ -4136,9 +4137,9 @@ bool map_read_npclist(const char *filename, bool imported)
if (!libconfig->load_file(&config, filename))
return false;
- deleted_npcs = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY, MAP_NAME_LENGTH);
+ deleted_npcs = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA, MAP_NAME_LENGTH);
- // Remove maps
+ // Remove NPCs
if ((setting = libconfig->lookup(&config, "npc_removed_list")) != NULL) {
int i, del_count = libconfig->setting_length(setting);
for (i = 0; i < del_count; i++) {
@@ -4147,10 +4148,13 @@ bool map_read_npclist(const char *filename, bool imported)
if ((scriptname = libconfig->setting_get_string_elem(setting, i)) == NULL || scriptname[0] == '\0')
continue;
- strdb_put(deleted_npcs, scriptname, NULL);
-
- if (imported) // Map list is empty on the first run, only do this for imported files.
+ if (strcmp(scriptname, "all") == 0) {
+ remove_all = true;
+ npc->clearsrcfile();
+ } else {
+ strdb_put(deleted_npcs, scriptname, NULL);
npc->delsrcfile(scriptname);
+ }
}
}
@@ -4168,7 +4172,7 @@ bool map_read_npclist(const char *filename, bool imported)
if ((scriptname = libconfig->setting_get_string_elem(setting, i)) == NULL || scriptname[0] == '\0')
continue;
- if (strdb_exists(deleted_npcs, scriptname))
+ if (remove_all || strdb_exists(deleted_npcs, scriptname))
continue;
npc->addsrcfile(scriptname);
@@ -4208,7 +4212,7 @@ bool map_read_npclist(const char *filename, bool imported)
void map_reloadnpc(bool clear) {
int i;
if (clear)
- npc->addsrcfile("clear"); // this will clear the current script list
+ npc->clearsrcfile();
#ifdef RENEWAL
map->read_npclist("npc/re/scripts_main.conf", false);