diff options
author | Haru <haru@dotalux.com> | 2018-08-26 17:01:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-26 17:01:00 +0200 |
commit | 0630ea01ef687ba22f4600a2f32fb4d3e448dcb8 (patch) | |
tree | fc4889ced078a4b11ea5b507ee0b0eee3e7b9942 /src/map/atcommand.c | |
parent | adae3d4518a4eae5424a3bbff40d11d3eb90a52a (diff) | |
parent | 3a8705a28c5c9577e5a86584224d6252d0620ed8 (diff) | |
download | hercules-0630ea01ef687ba22f4600a2f32fb4d3e448dcb8.tar.gz hercules-0630ea01ef687ba22f4600a2f32fb4d3e448dcb8.tar.bz2 hercules-0630ea01ef687ba22f4600a2f32fb4d3e448dcb8.tar.xz hercules-0630ea01ef687ba22f4600a2f32fb4d3e448dcb8.zip |
Merge pull request #2162 from mekolat/setzone
add atcommand_setzone, and fix #2133
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index bedb58478..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 *------------------------------------------*/ @@ -7688,7 +7745,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 +7787,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. @@ -10033,6 +10091,7 @@ static void atcommand_basecommands(void) ACMD_DEF(joinclan), ACMD_DEF(leaveclan), ACMD_DEF(reloadclans), + ACMD_DEF(setzone), }; int i; |