From f0a4324bd456cfaf648d47ec58b2527df71c1d65 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 3 Feb 2022 22:32:45 -0800 Subject: [PATCH] Fixed an issue where leave-zone was working outside of instanced zones (#431) --- dGame/dUtilities/SlashCommandHandler.cpp | 26 +++++++----------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 66502645..67336eb7 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -304,28 +304,16 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if ((chatCommand == "leave-zone")) { const auto currentZone = dZoneManager::Instance()->GetZone()->GetZoneID().GetMapID(); - auto newZone = 1100; - - switch (currentZone) - { - case 1101: - newZone = 1100; - break; - case 1204: - newZone = 1200; - break; - default: - newZone = 1100; - break; - } - - if (currentZone == newZone) - { + auto newZone = 0; + if (currentZone % 100 == 0) { ChatPackets::SendSystemMessage(sysAddr, u"You are not in an instanced zone."); - return; + } else { + newZone = (currentZone / 100) * 100; } - + // If new zone would be inaccessible, then default to Avant Gardens. + if (!CheckIfAccessibleZone(newZone)) newZone = 1100; + ChatPackets::SendSystemMessage(sysAddr, u"Leaving zone..."); const auto objid = entity->GetObjectID();