From c968dc90287d9d36176fe1199acbdcc140695c64 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 13 Jan 2025 23:28:24 -0800 Subject: [PATCH] fix lego club teleport (#1731) Tested that the lego club teleport and starbase 3001 teleports work now both before and after you visit nexus tower --- dCommon/Amf3.h | 10 ++++- dScripts/02_server/Map/NS/NsLegoClubDoor.cpp | 43 ++++++++------------ dScripts/02_server/Map/NS/NsLegoClubDoor.h | 3 +- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/dCommon/Amf3.h b/dCommon/Amf3.h index 21a3c0c7..67d53c28 100644 --- a/dCommon/Amf3.h +++ b/dCommon/Amf3.h @@ -5,6 +5,7 @@ #include "Logger.h" #include "Game.h" +#include #include #include @@ -257,10 +258,10 @@ public: * * @param key The key to remove from the associative portion */ - void Remove(const std::string& key, const bool deleteValue = true) { + void Remove(const std::string& key) { const AMFAssociative::const_iterator it = m_Associative.find(key); if (it != m_Associative.cend()) { - if (deleteValue) m_Associative.erase(it); + m_Associative.erase(it); } } @@ -343,6 +344,11 @@ public: return index < m_Dense.size() ? m_Dense.at(index).get() : nullptr; } + void Reset() { + m_Associative.clear(); + m_Dense.clear(); + } + private: /** * The associative portion. These values are key'd with strings to an AMFValue. diff --git a/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp b/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp index 959466e9..1cafe67c 100644 --- a/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp +++ b/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp @@ -10,49 +10,38 @@ void NsLegoClubDoor::OnStartup(Entity* self) { self->SetVar(u"teleportString", m_TeleportString); self->SetVar(u"spawnPoint", m_SpawnPoint); - args = {}; + teleportArgs.Reset(); - args.Insert("callbackClient", std::to_string(self->GetObjectID())); - args.Insert("strIdentifier", "choiceDoor"); - args.Insert("title", "%[UI_CHOICE_DESTINATION]"); + teleportArgs.Insert("callbackClient", std::to_string(self->GetObjectID())); + teleportArgs.Insert("strIdentifier", "choiceDoor"); + teleportArgs.Insert("title", "%[UI_CHOICE_DESTINATION]"); - AMFArrayValue* choiceOptions = args.InsertArray("options"); + auto& choiceOptions = *teleportArgs.InsertArray("options"); { - AMFArrayValue* nsArgs = choiceOptions->PushArray(); + auto& nsArgs = *choiceOptions.PushArray(); - nsArgs->Insert("image", "textures/ui/zone_thumnails/Nimbus_Station.dds"); - nsArgs->Insert("caption", "%[UI_CHOICE_NS]"); - nsArgs->Insert("identifier", "zoneID_1200"); - nsArgs->Insert("tooltipText", "%[UI_CHOICE_NS_HOVER]"); + nsArgs.Insert("image", "textures/ui/zone_thumnails/Nimbus_Station.dds"); + nsArgs.Insert("caption", "%[UI_CHOICE_NS]"); + nsArgs.Insert("identifier", "zoneID_1200"); + nsArgs.Insert("tooltipText", "%[UI_CHOICE_NS_HOVER]"); } { - AMFArrayValue* ntArgs = choiceOptions->PushArray(); + auto& ntArgs = *choiceOptions.PushArray(); - ntArgs->Insert("image", "textures/ui/zone_thumnails/Nexus_Tower.dds"); - ntArgs->Insert("caption", "%[UI_CHOICE_NT]"); - ntArgs->Insert("identifier", "zoneID_1900"); - ntArgs->Insert("tooltipText", "%[UI_CHOICE_NT_HOVER]"); + ntArgs.Insert("image", "textures/ui/zone_thumnails/Nexus_Tower.dds"); + ntArgs.Insert("caption", "%[UI_CHOICE_NT]"); + ntArgs.Insert("identifier", "zoneID_1900"); + ntArgs.Insert("tooltipText", "%[UI_CHOICE_NT_HOVER]"); } - - options = choiceOptions; } void NsLegoClubDoor::OnUse(Entity* self, Entity* user) { auto* player = user; if (CheckChoice(self, player)) { - AMFArrayValue multiArgs; - - multiArgs.Insert("callbackClient", std::to_string(self->GetObjectID())); - multiArgs.Insert("strIdentifier", "choiceDoor"); - multiArgs.Insert("title", "%[UI_CHOICE_DESTINATION]"); - multiArgs.Insert("options", static_cast(options)); - - GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "QueueChoiceBox", multiArgs); - - multiArgs.Remove("options", false); // We do not want the local amf to delete the options! + GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "QueueChoiceBox", teleportArgs); } else if (self->GetVar(u"currentZone") != m_ChoiceZoneID) { AMFArrayValue multiArgs; multiArgs.Insert("state", "Lobby"); diff --git a/dScripts/02_server/Map/NS/NsLegoClubDoor.h b/dScripts/02_server/Map/NS/NsLegoClubDoor.h index 5b25ba6d..518ad87c 100644 --- a/dScripts/02_server/Map/NS/NsLegoClubDoor.h +++ b/dScripts/02_server/Map/NS/NsLegoClubDoor.h @@ -19,6 +19,5 @@ private: std::string m_SpawnPoint = "NS_LEGO_Club"; std::u16string m_TeleportAnim = u"lup-teleport"; std::u16string m_TeleportString = u"ROCKET_TOOLTIP_USE_THE_GATEWAY_TO_TRAVEL_TO_LUP_WORLD"; - AMFArrayValue args = {}; - AMFArrayValue* options = {}; + AMFArrayValue teleportArgs{}; };