summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2018-07-29 17:41:04 -0400
committergumi <git@gumi.ca>2018-07-29 22:50:43 -0400
commit07635ce9e2320a4ec22d54a81604439bdf626b71 (patch)
treebafd664d0b6923207f75434e0a527c5c72f7b893
parenta65561f0637c8932d840317b48304885e2bf2689 (diff)
downloadhercules-07635ce9e2320a4ec22d54a81604439bdf626b71.tar.gz
hercules-07635ce9e2320a4ec22d54a81604439bdf626b71.tar.bz2
hercules-07635ce9e2320a4ec22d54a81604439bdf626b71.tar.xz
hercules-07635ce9e2320a4ec22d54a81604439bdf626b71.zip
add atcommand_setzone
-rw-r--r--src/map/atcommand.c58
1 files changed, 58 insertions, 0 deletions
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;