From 0f92b8d8c5be45be8bf9cb02a1bc56d3b7d148a1 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 3 Jun 2021 14:39:49 -0700 Subject: [PATCH] Rename CRelayTracker back to CScriptMailbox --- Runtime/CGameState.cpp | 4 +-- Runtime/CGameState.hpp | 6 ++-- Runtime/CMakeLists.txt | 2 +- .../{CRelayTracker.cpp => CScriptMailbox.cpp} | 34 +++++++++---------- .../{CRelayTracker.hpp => CScriptMailbox.hpp} | 14 ++++---- Runtime/CStateManager.cpp | 2 +- Runtime/CStateManager.hpp | 10 +++--- Runtime/MP1/CStateSetterFlow.cpp | 4 +-- Runtime/World/CScriptMemoryRelay.cpp | 6 ++-- 9 files changed, 41 insertions(+), 41 deletions(-) rename Runtime/{CRelayTracker.cpp => CScriptMailbox.cpp} (64%) rename Runtime/{CRelayTracker.hpp => CScriptMailbox.hpp} (75%) diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index 743f446f2..0cc358e84 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -75,7 +75,7 @@ void CWorldLayerState::InitializeWorldLayers(const std::vector(); + x8_relayTracker = std::make_shared(); xc_mapWorldInfo = std::make_shared(); x10_desiredAreaAssetId = {}; x14_layerState = std::make_shared(); @@ -84,7 +84,7 @@ CWorldState::CWorldState(CAssetId id) : x0_mlvlId(id), x4_areaId(0) { CWorldState::CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CSaveWorld& saveWorld) : x0_mlvlId(mlvlId) { x4_areaId = TAreaId(reader.ReadEncoded(32)); x10_desiredAreaAssetId = u32(reader.ReadEncoded(32)); - x8_relayTracker = std::make_shared(reader, saveWorld); + x8_relayTracker = std::make_shared(reader, saveWorld); xc_mapWorldInfo = std::make_shared(reader, saveWorld, mlvlId); x14_layerState = std::make_shared(reader, saveWorld); } diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 610d906ca..0cacfeaac 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -9,7 +9,7 @@ #include "Runtime/CBasics.hpp" #include "Runtime/CGameOptions.hpp" #include "Runtime/CPlayerState.hpp" -#include "Runtime/CRelayTracker.hpp" +#include "Runtime/CScriptMailbox.hpp" #include "Runtime/AutoMapper/CMapWorldInfo.hpp" #include "Runtime/World/CWorld.hpp" #include "Runtime/World/CWorldTransManager.hpp" @@ -46,7 +46,7 @@ public: class CWorldState { CAssetId x0_mlvlId; TAreaId x4_areaId = kInvalidAreaId; - std::shared_ptr x8_relayTracker; + std::shared_ptr x8_relayTracker; std::shared_ptr xc_mapWorldInfo; CAssetId x10_desiredAreaAssetId; std::shared_ptr x14_layerState; @@ -59,7 +59,7 @@ public: TAreaId GetCurrentAreaId() const { return x4_areaId; } CAssetId GetDesiredAreaAssetId() const { return x10_desiredAreaAssetId; } void SetDesiredAreaAssetId(CAssetId id) { x10_desiredAreaAssetId = id; } - const std::shared_ptr& RelayTracker() const { return x8_relayTracker; } + const std::shared_ptr& RelayTracker() const { return x8_relayTracker; } const std::shared_ptr& MapWorldInfo() const { return xc_mapWorldInfo; } const std::shared_ptr& GetLayerState() const { return x14_layerState; } void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const; diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 71324d383..3f5062f68 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -83,7 +83,7 @@ set(RUNTIME_SOURCES_B CIOWinManager.hpp CIOWinManager.cpp CStateManager.hpp CStateManager.cpp CGameState.hpp CGameState.cpp - CRelayTracker.hpp CRelayTracker.cpp + CScriptMailbox.hpp CScriptMailbox.cpp CPlayerState.hpp CPlayerState.cpp CRandom16.hpp CRandom16.cpp CResFactory.hpp CResFactory.cpp diff --git a/Runtime/CRelayTracker.cpp b/Runtime/CScriptMailbox.cpp similarity index 64% rename from Runtime/CRelayTracker.cpp rename to Runtime/CScriptMailbox.cpp index 2485bc66d..5638e1b7e 100644 --- a/Runtime/CRelayTracker.cpp +++ b/Runtime/CScriptMailbox.cpp @@ -1,4 +1,4 @@ -#include "Runtime/CRelayTracker.hpp" +#include "Runtime/CScriptMailbox.hpp" #include "Runtime/CSaveWorld.hpp" #include "Runtime/CStateManager.hpp" @@ -8,7 +8,7 @@ namespace metaforce { -CRelayTracker::CRelayTracker(CBitStreamReader& in, const CSaveWorld& saveWorld) { +CScriptMailbox::CScriptMailbox(CBitStreamReader& in, const CSaveWorld& saveWorld) { const u32 relayCount = saveWorld.GetRelayCount(); if (saveWorld.GetRelayCount()) { std::vector relayStates(saveWorld.GetRelayCount()); @@ -20,32 +20,32 @@ CRelayTracker::CRelayTracker(CBitStreamReader& in, const CSaveWorld& saveWorld) if (!relayStates[i]) { continue; } - x0_relayStates.push_back(saveWorld.GetRelayEditorId(i)); + x0_relays.push_back(saveWorld.GetRelayEditorId(i)); } } } -bool CRelayTracker::HasRelay(TEditorId id) const { - return std::find(x0_relayStates.cbegin(), x0_relayStates.cend(), id) != x0_relayStates.cend(); +bool CScriptMailbox::HasMsg(TEditorId id) const { + return std::find(x0_relays.cbegin(), x0_relays.cend(), id) != x0_relays.cend(); } -void CRelayTracker::AddRelay(TEditorId id) { - if (HasRelay(id)) { +void CScriptMailbox::AddMsg(TEditorId id) { + if (HasMsg(id)) { return; } - x0_relayStates.push_back(id); + x0_relays.push_back(id); } -void CRelayTracker::RemoveRelay(TEditorId id) { - if (!HasRelay(id)) { +void CScriptMailbox::RemoveMsg(TEditorId id) { + if (!HasMsg(id)) { return; } - std::erase(x0_relayStates, id); + std::erase(x0_relays, id); } -void CRelayTracker::SendMsgs(TAreaId areaId, CStateManager& stateMgr) { +void CScriptMailbox::SendMsgs(TAreaId areaId, CStateManager& stateMgr) { const CWorld* world = stateMgr.GetWorld(); u32 relayCount = world->GetRelayCount(); @@ -55,7 +55,7 @@ void CRelayTracker::SendMsgs(TAreaId areaId, CStateManager& stateMgr) { if (relay.GetTargetId().AreaNum() != areaId) continue; - if (!HasRelay(relay.GetRelayId())) + if (!HasMsg(relay.GetRelayId())) continue; stateMgr.SendScriptMsg(kInvalidUniqueId, relay.GetTargetId(), EScriptObjectMessage(relay.GetMessage()), @@ -72,18 +72,18 @@ void CRelayTracker::SendMsgs(TAreaId areaId, CStateManager& stateMgr) { if (relay.GetTargetId().AreaNum() != areaId) continue; - if (!HasRelay(relay.GetRelayId()) || !relay.GetActive()) + if (!HasMsg(relay.GetRelayId()) || !relay.GetActive()) continue; - RemoveRelay(relay.GetRelayId()); + RemoveMsg(relay.GetRelayId()); } } -void CRelayTracker::PutTo(CBitStreamWriter& out, const CSaveWorld& saveWorld) { +void CScriptMailbox::PutTo(CBitStreamWriter& out, const CSaveWorld& saveWorld) { const u32 relayCount = saveWorld.GetRelayCount(); std::vector relays(relayCount); - for (const TEditorId& id : x0_relayStates) { + for (const TEditorId& id : x0_relays) { const s32 idx = saveWorld.GetRelayIndex(id); if (idx >= 0) { relays[idx] = true; diff --git a/Runtime/CRelayTracker.hpp b/Runtime/CScriptMailbox.hpp similarity index 75% rename from Runtime/CRelayTracker.hpp rename to Runtime/CScriptMailbox.hpp index 980a5b6a1..69e7f3dae 100644 --- a/Runtime/CRelayTracker.hpp +++ b/Runtime/CScriptMailbox.hpp @@ -24,16 +24,16 @@ struct CMailMessage }; #endif -class CRelayTracker { - std::vector x0_relayStates; +class CScriptMailbox { + std::vector x0_relays; public: - CRelayTracker() = default; - CRelayTracker(CBitStreamReader& in, const CSaveWorld& saveWorld); + CScriptMailbox() = default; + CScriptMailbox(CBitStreamReader& in, const CSaveWorld& saveWorld); - bool HasRelay(TEditorId id) const; - void AddRelay(TEditorId id); - void RemoveRelay(TEditorId id); + bool HasMsg(TEditorId id) const; + void AddMsg(TEditorId id); + void RemoveMsg(TEditorId id); void SendMsgs(TAreaId areaId, CStateManager& stateMgr); void PutTo(CBitStreamWriter& out, const CSaveWorld& saveWorld); }; diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index b88c24bb8..ae4c7c280 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -62,7 +62,7 @@ hecl::CVar* debugToolDrawPlatformCollision = nullptr; hecl::CVar* sm_logScripting = nullptr; } // namespace logvisor::Module LogModule("metaforce::CStateManager"); -CStateManager::CStateManager(const std::weak_ptr& relayTracker, +CStateManager::CStateManager(const std::weak_ptr& relayTracker, const std::weak_ptr& mwInfo, const std::weak_ptr& playerState, const std::weak_ptr& wtMgr, const std::weak_ptr& layerState) diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 51696462e..a78caa9ed 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -47,7 +47,7 @@ class CObjectList; class CPlayer; class CPlayerState; class CProjectedShadow; -class CRelayTracker; +class CScriptMailbox; class CRumbleManager; class CSortedListManager; class CTexture; @@ -140,7 +140,7 @@ private: std::map x8a4_loadedScriptObjects; std::shared_ptr x8b8_playerState; - std::shared_ptr x8bc_relayTracker; + std::shared_ptr x8bc_relayTracker; std::shared_ptr x8c0_mapWorldInfo; std::shared_ptr x8c4_worldTransManager; std::shared_ptr x8c8_worldLayerState; @@ -220,7 +220,7 @@ private: static void RendererDrawCallback(void*, void*, int); public: - CStateManager(const std::weak_ptr&, const std::weak_ptr&, + CStateManager(const std::weak_ptr&, const std::weak_ptr&, const std::weak_ptr&, const std::weak_ptr&, const std::weak_ptr&); ~CStateManager(); @@ -396,8 +396,8 @@ public: const CEnvFxManager* GetEnvFxManager() const { return x880_envFxManager; } CWorld* GetWorld() { return x850_world.get(); } const CWorld* GetWorld() const { return x850_world.get(); } - CRelayTracker* GetRelayTracker() { return x8bc_relayTracker.get(); } - const CRelayTracker* GetRelayTracker() const { return x8bc_relayTracker.get(); } + CScriptMailbox* GetRelayTracker() { return x8bc_relayTracker.get(); } + const CScriptMailbox* GetRelayTracker() const { return x8bc_relayTracker.get(); } CCameraManager* GetCameraManager() const { return x870_cameraManager; } CFluidPlaneManager* GetFluidPlaneManager() const { return x87c_fluidPlaneManager; } CActorModelParticles* GetActorModelParticles() const { return x884_actorModelParticles; } diff --git a/Runtime/MP1/CStateSetterFlow.cpp b/Runtime/MP1/CStateSetterFlow.cpp index 6a9e69870..75a6a308d 100644 --- a/Runtime/MP1/CStateSetterFlow.cpp +++ b/Runtime/MP1/CStateSetterFlow.cpp @@ -34,9 +34,9 @@ CIOWin::EMessageReturn CStateSetterFlow::OnMessage(const CArchitectureMessage& m for (u32 i = 0; i < layers.GetAreaLayerCount(m->m_warpAreaId); ++i) layers.SetLayerActive(m->m_warpAreaId, i, ((m->m_warpLayerBits >> i) & 1) != 0); } - CRelayTracker& relays = *ws.RelayTracker(); + CScriptMailbox& relays = *ws.RelayTracker(); for (const auto& r : m->m_warpMemoryRelays) - relays.AddRelay(r); + relays.AddMsg(r); } g_GameState->GameOptions().ResetToDefaults(); g_GameState->WriteBackupBuf(); diff --git a/Runtime/World/CScriptMemoryRelay.cpp b/Runtime/World/CScriptMemoryRelay.cpp index 44909e364..5848962f2 100644 --- a/Runtime/World/CScriptMemoryRelay.cpp +++ b/Runtime/World/CScriptMemoryRelay.cpp @@ -1,6 +1,6 @@ #include "Runtime/World/CScriptMemoryRelay.hpp" -#include "Runtime/CRelayTracker.hpp" +#include "Runtime/CScriptMailbox.hpp" #include "Runtime/CStateManager.hpp" #include "TCastTo.hpp" // Generated file, do not modify include path @@ -22,10 +22,10 @@ void CScriptMemoryRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj } if (msg == EScriptObjectMessage::Deactivate) { - stateMgr.GetRelayTracker()->RemoveRelay(xc_editorId); + stateMgr.GetRelayTracker()->RemoveMsg(xc_editorId); return; } else if (msg == EScriptObjectMessage::Activate) { - stateMgr.GetRelayTracker()->AddRelay(xc_editorId); + stateMgr.GetRelayTracker()->AddMsg(xc_editorId); if (!x34_25_skipSendActive) { SendScriptMsgs(EScriptObjectState::Active, stateMgr, EScriptObjectMessage::None); }