From c964aa4b43de4e534e1ea421841ee090cc71e6e8 Mon Sep 17 00:00:00 2001 From: gumi Date: Tue, 2 Oct 2018 17:38:22 -0400 Subject: use a dedicated zone remove function when reloading zones --- src/map/map.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index a352d34b0..d4d6e3323 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3707,7 +3707,7 @@ 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); + map->zone_remove_all(i); if (battle_config.pk_mode) { map->list[i].flag.pvp = 1; @@ -4688,6 +4688,27 @@ static void map_zone_remove(int m) map->list[m].zone_mf = NULL; map->list[m].zone_mf_count = 0; } +// this one removes every flag, even if they were previously turned on before +// the current zone was applied +static void map_zone_remove_all(int m) +{ + Assert_retv(m >= 0 && m < map->count); + + for (unsigned short k = 0; k < map->list[m].zone_mf_count; k++) { + char flag[MAP_ZONE_MAPFLAG_LENGTH]; + + memcpy(flag, map->list[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); + strtok(flag, "\t"); + + npc->parse_mapflag(map->list[m].name, "", flag, "off", "", "", "", NULL); + aFree(map->list[m].zone_mf[k]); + map->list[m].zone_mf[k] = NULL; + } + + aFree(map->list[m].zone_mf); + map->list[m].zone_mf = NULL; + map->list[m].zone_mf_count = 0; +} static inline void map_zone_mf_cache_add(int m, char *rflag) { Assert_retv(m >= 0 && m < map->count); @@ -6840,6 +6861,7 @@ void map_defaults(void) /* funcs */ map->zone_init = map_zone_init; map->zone_remove = map_zone_remove; + map->zone_remove_all = map_zone_remove_all; map->zone_apply = map_zone_apply; map->zone_change = map_zone_change; map->zone_change2 = map_zone_change2; -- cgit v1.2.3-70-g09d2