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(+) 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-70-g09d2