diff options
author | gumi <git@gumi.ca> | 2018-08-01 15:52:35 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2018-08-01 15:57:42 -0400 |
commit | 3a8705a28c5c9577e5a86584224d6252d0620ed8 (patch) | |
tree | 25dd041289de5912b9d8b004457f02650d271747 /src | |
parent | d77d6b246308308a37d5acca57af7f9d527b306d (diff) | |
download | hercules-3a8705a28c5c9577e5a86584224d6252d0620ed8.tar.gz hercules-3a8705a28c5c9577e5a86584224d6252d0620ed8.tar.bz2 hercules-3a8705a28c5c9577e5a86584224d6252d0620ed8.tar.xz hercules-3a8705a28c5c9577e5a86584224d6252d0620ed8.zip |
reload the zone db on npc reload
Diffstat (limited to 'src')
-rw-r--r-- | src/map/map.c | 28 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/npc.c | 1 |
3 files changed, 30 insertions, 0 deletions
diff --git a/src/map/map.c b/src/map/map.c index ce8f4cdf5..343f219b8 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3690,6 +3690,33 @@ static void do_final_maps(void) map->zone_db_clear(); } + +static void map_zonedb_reload(void) +{ + // first, reset maps to their initial zones: + for (int i = 0; i < map->count; i++) { + map->zone_remove(i); + + if (battle_config.pk_mode) { + map->list[i].flag.pvp = 1; + map->list[i].zone = &map->zone_pk; + } else { + map->list[i].flag.pvp = 0; + map->list[i].zone = &map->zone_all; + } + + map->list[i].prev_zone = map->list[i].zone; + } + + // now it's safe to remove the zones: + map->zone_db_clear(); + + // then reload everything from scratch: + map->zone_db = strdb_alloc(DB_OPT_DUP_KEY | DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); + map->read_zone_db(); +} + + /// Initializes map flags and adjusts them depending on configuration. static void map_flags_init(void) { @@ -6804,6 +6831,7 @@ void map_defaults(void) map->zone_apply = map_zone_apply; map->zone_change = map_zone_change; map->zone_change2 = map_zone_change2; + map->zone_reload = map_zonedb_reload; map->getcell = map_getcell; map->setgatcell = map_setgatcell; diff --git a/src/map/map.h b/src/map/map.h index 207fef2ce..cf3a4e57c 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1216,6 +1216,7 @@ END_ZEROED_BLOCK; void (*zone_apply) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath); void (*zone_change) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath); void (*zone_change2) (int m, struct map_zone_data *zone); + void (*zone_reload) (void); int (*getcell) (int16 m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk); void (*setgatcell) (int16 m, int16 x, int16 y, int gat); diff --git a/src/map/npc.c b/src/map/npc.c index f80f8443a..80ff6ef72 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -4980,6 +4980,7 @@ static int npc_reload(void) instance->reload(); + map->zone_reload(); map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ |