From a65561f0637c8932d840317b48304885e2bf2689 Mon Sep 17 00:00:00 2001 From: Carlos Henrique Date: Sun, 29 Jul 2018 17:46:13 -0400 Subject: add MF_TOWN to atcommand_mapflag --- src/map/atcommand.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index bedb58478..bfbb20177 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -7688,7 +7688,7 @@ ACMD(mapflag) CHECKFLAG(nojobexp); CHECKFLAG(nomobloot); CHECKFLAG(nomvploot); CHECKFLAG(nightenabled); CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent); CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance); - CHECKFLAG(notomb); CHECKFLAG(nocashshop); CHECKFLAG(noviewid); + CHECKFLAG(notomb); CHECKFLAG(nocashshop); CHECKFLAG(noviewid); CHECKFLAG(town); clif->message(sd->fd," "); clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) clif->message(sd->fd,msg_fd(fd,1313)); // Type "@mapflag available" to list the available mapflags. @@ -7730,6 +7730,7 @@ ACMD(mapflag) SETFLAG(nomvploot); SETFLAG(nightenabled); SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent); SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance); SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid); + SETFLAG(town); clif->message(sd->fd, msg_fd(fd, 1314)); // Invalid flag name or flag. -- cgit v1.2.3-60-g2f50 From 07635ce9e2320a4ec22d54a81604439bdf626b71 Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 29 Jul 2018 17:41:04 -0400 Subject: add atcommand_setzone --- src/map/atcommand.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index bfbb20177..02b099742 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1887,6 +1887,63 @@ ACMD(hair_color) return true; } +ACMD(setzone) +{ + char zone_name[MAP_ZONE_MAPFLAG_LENGTH]; + memset(zone_name, '\0', sizeof(zone_name)); + + char fmt_str[8] = ""; + safesnprintf(fmt_str, 8, "%%%ds", MAP_ZONE_MAPFLAG_LENGTH - 1); + + if (*message == '\0' || sscanf(message, fmt_str, zone_name) < 1) { + clif->message(fd, msg_fd(fd, 924)); // usage info + return false; + } + + struct map_zone_data *zone = strdb_get(map->zone_db, zone_name); + const char *prev_zone_name = map->list[sd->bl.m].zone->name; + + // handle special zones: + if (zone == NULL && strcmp(zone_name, MAP_ZONE_NORMAL_NAME) == 0) { + zone = &map->zone_all; + } else if (zone == NULL && strcmp(zone_name, MAP_ZONE_PK_NAME) == 0) { + zone = &map->zone_pk; + } + + if (zone != NULL) { + if (map->list[sd->bl.m].zone != zone) { + if (strcmp(prev_zone_name, MAP_ZONE_PVP_NAME) == 0) { + atcommand_pvpoff(fd, sd, command, message, info); + } else if (strcmp(prev_zone_name, MAP_ZONE_GVG_NAME) == 0) { + atcommand_gvgoff(fd, sd, command, message, info); + } else if (strcmp(prev_zone_name, MAP_ZONE_CVC_NAME) == 0) { + atcommand_cvcoff(fd, sd, command, message, info); + } + } else { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 925), zone_name); + clif->message(fd, atcmd_output); // nothing to do + return false; + } + + if (strcmp(zone_name, MAP_ZONE_PVP_NAME) == 0) { + atcommand_pvpon(fd, sd, command, message, info); + } else if (strcmp(zone_name, MAP_ZONE_GVG_NAME) == 0) { + atcommand_gvgon(fd, sd, command, message, info); + } else if (strcmp(zone_name, MAP_ZONE_CVC_NAME) == 0) { + atcommand_cvcon(fd, sd, command, message, info); + } else { + map->zone_change2(sd->bl.m, zone); + } + } else { + clif->message(fd, msg_fd(fd, 926)); // zone not found + return false; + } + + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 927), prev_zone_name, zone_name); + clif->message(fd, atcmd_output); // changed successfully + return true; +} + /*========================================== * @go [city_number or city_name] - Updated by Harbin *------------------------------------------*/ @@ -10034,6 +10091,7 @@ static void atcommand_basecommands(void) ACMD_DEF(joinclan), ACMD_DEF(leaveclan), ACMD_DEF(reloadclans), + ACMD_DEF(setzone), }; int i; -- cgit v1.2.3-60-g2f50 From 3a8705a28c5c9577e5a86584224d6252d0620ed8 Mon Sep 17 00:00:00 2001 From: gumi Date: Wed, 1 Aug 2018 15:52:35 -0400 Subject: reload the zone db on npc reload --- src/map/map.c | 28 ++++++++++++++++++++++++++++ src/map/map.h | 1 + src/map/npc.c | 1 + 3 files changed, 30 insertions(+) (limited to 'src/map') 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] */ -- cgit v1.2.3-60-g2f50