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 | |
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
-rw-r--r-- | conf/messages.conf | 9 | ||||
-rw-r--r-- | doc/atcommands.txt | 38 | ||||
-rw-r--r-- | src/map/atcommand.c | 61 | ||||
-rw-r--r-- | src/map/map.c | 28 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/npc.c | 1 |
6 files changed, 120 insertions, 18 deletions
diff --git a/conf/messages.conf b/conf/messages.conf index a7a11b969..f986e4649 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -711,7 +711,14 @@ // @jobchange 923: You can not change to this job by command. -//924-979 FREE + +// atcommand_setzone +924: Usage: @setzone <zone name> +925: The zone is already set to '%s'. +926: Zone not found. Keep in mind that the names are CaSe SenSitiVe. +927: Zone successfully changed from '%s' to '%s'. + +//928-979 FREE // @kami 980: Please enter a message (usage: @kami <message>). diff --git a/doc/atcommands.txt b/doc/atcommands.txt index 18d3de4e4..fb3628e00 100644 --- a/doc/atcommands.txt +++ b/doc/atcommands.txt @@ -50,7 +50,7 @@ Other Drop Rates: MvP 1.00x / Card-Based 1.00x / Treasure 1.00x @time Displays the local server time, along with day/night information. - + --------------------------------------- @uptime @@ -192,6 +192,12 @@ Sets a mapflag for the current map (1 = On, 0 = Off). --------------------------------------- +@setzone <new zone> + +Changes the zone of the current map. + +--------------------------------------- + @addwarp <map> <x> <y> <npc name> Creates a warp portal on the character's current coordinates that lasts until the next reboot. @@ -256,13 +262,13 @@ Map Name: prontera | Players In Map: 1 | NPCs In Map: 127 | Chats In Map: 0 ------ Map Flags ------ Town Map Autotrade Enabled -PvP Flags: -GvG Flags: -Teleport Flags: +PvP Flags: +GvG Flags: +Teleport Flags: No Exp Penalty: On | No Zeny Penalty: On -Weather Flags: Displays Night | -Other Flags: NoBranch | Reset | -Other Flags: +Weather Flags: Displays Night | +Other Flags: NoBranch | Reset | +Other Flags: --------------------------------------- @@ -270,7 +276,7 @@ Other Flags: Gives information about terrain/area (debug function). -Output Example: +Output Example: prontera (x= 165, y= 202) 00 00 00 00 00 prontera (x= 165, y= 201) 01 00 00 00 00 prontera (x= 165, y= 200) 01 00 00 00 00 @@ -297,7 +303,7 @@ DEF:2 MDEF:5 STR:6 AGI:1 VIT:1 INT:1 DEX:6 LUK:5 ATK:8~9 Range:1~10~12 Size:Medium Race:Plant Element:Water (Lv:1) Drops: - Jellopy 70.00% - Knife[4] 1.00% etc... - + --------------------------------------- @iteminfo <item name/ID> @@ -317,7 +323,7 @@ NPC Buy:6z, Sell:3z | Weight: 1.0 @whodrops <item name/ID> Displays a list of mobs which drop the specified item. -Only the highest drop rates are shown. +Only the highest drop rates are shown. --------------------------------------- @@ -557,7 +563,7 @@ Using the command without a message will enable or disable main chat. @storage Opens your Kafra storage. - + --------------------------------------- @mail @@ -636,7 +642,7 @@ identify_flag: 0 = unidentified, 1 = identified attribute: 0 = not broken, 1 = broken --------------------------------------- - + @itembound <item name/ID> <amount> <bound_type> Creates the specified item and bounds it to the account. @@ -951,7 +957,7 @@ Some options can be found in 'conf/map/battle/misc.conf'. @heal -Fully heals HP and SP. +Fully heals HP and SP. --------------------------------------- @@ -1247,7 +1253,7 @@ Example: @party <party_name> Organizes a new party, with the attached character as leader. - + --------------------------------------- @partyoption <pickup share: yes/no> <item distribution: yes/no> @@ -1317,7 +1323,7 @@ Changes guild level by the specified amount. @undisguiseguild Disguises or undisguises all online characters of a guild. - + --------------------------------------- @sizeguild <size> <guild name> @@ -1334,7 +1340,7 @@ Warps all online characters of a guild to your location. @guildspy <guild name> -Allows you to spy on any guild's Guild Chat. +Allows you to spy on any guild's Guild Chat. At least one member of that guild must be online. NOTE: map server needs to be configured to enable spying to use this command (enable_spy: true) 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; 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 a49fb08eb..b93b2b6f4 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] */ |