From e5f924d1d51bb9ffb522aabf019c34d579559f73 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sat, 12 Mar 2022 16:11:27 -0500 Subject: [PATCH] [Quest API] Allow EVENT_ZONE to be parsed as non-zero to prevent zoning. (#2052) - This will allow server operators to prevent zoning to or from a specific zone based on whatever criteria they want. --- zone/embparser.cpp | 4 +++- zone/lua_parser_events.cpp | 7 ++++++- zone/zoning.cpp | 11 +++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 944ed388d..d77571baf 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -1443,7 +1443,9 @@ void PerlembParser::ExportEventVariables( } case EVENT_ZONE: { - ExportVar(package_name.c_str(), "target_zone_id", data); + Seperator sep(data); + ExportVar(package_name.c_str(), "from_zone_id", sep.arg[0]); + ExportVar(package_name.c_str(), "target_zone_id", sep.arg[1]); break; } diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 5303d5854..973723985 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -406,7 +406,12 @@ void handle_player_task_fail(QuestInterface *parse, lua_State* L, Client* client void handle_player_zone(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector *extra_pointers) { - lua_pushinteger(L, std::stoi(data)); + Seperator sep(data.c_str()); + + lua_pushinteger(L, std::stoi(sep.arg[0])); + lua_setfield(L, -2, "from_zone_id"); + + lua_pushinteger(L, std::stoi(sep.arg[1])); lua_setfield(L, -2, "zone_id"); } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 688d34e2f..385c42668 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -202,8 +202,15 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { return; } - std::string export_string = fmt::format("{}", target_zone_id); - parse->EventPlayer(EVENT_ZONE, this, export_string, 0); + std::string export_string = fmt::format( + "{} {}", + zone->GetZoneID(), + target_zone_id + ); + if (parse->EventPlayer(EVENT_ZONE, this, export_string, 0) != 0) { + SendZoneCancel(zc); + return; + } //handle circumvention of zone restrictions //we need the value when creating the outgoing packet as well.