mirror of https://github.com/AxioDL/metaforce.git
Rename CRelayTracker back to CScriptMailbox
This commit is contained in:
parent
4df59e3e39
commit
0f92b8d8c5
|
@ -75,7 +75,7 @@ void CWorldLayerState::InitializeWorldLayers(const std::vector<CWorldLayers::Are
|
|||
}
|
||||
|
||||
CWorldState::CWorldState(CAssetId id) : x0_mlvlId(id), x4_areaId(0) {
|
||||
x8_relayTracker = std::make_shared<CRelayTracker>();
|
||||
x8_relayTracker = std::make_shared<CScriptMailbox>();
|
||||
xc_mapWorldInfo = std::make_shared<CMapWorldInfo>();
|
||||
x10_desiredAreaAssetId = {};
|
||||
x14_layerState = std::make_shared<CWorldLayerState>();
|
||||
|
@ -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<CRelayTracker>(reader, saveWorld);
|
||||
x8_relayTracker = std::make_shared<CScriptMailbox>(reader, saveWorld);
|
||||
xc_mapWorldInfo = std::make_shared<CMapWorldInfo>(reader, saveWorld, mlvlId);
|
||||
x14_layerState = std::make_shared<CWorldLayerState>(reader, saveWorld);
|
||||
}
|
||||
|
|
|
@ -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<CRelayTracker> x8_relayTracker;
|
||||
std::shared_ptr<CScriptMailbox> x8_relayTracker;
|
||||
std::shared_ptr<CMapWorldInfo> xc_mapWorldInfo;
|
||||
CAssetId x10_desiredAreaAssetId;
|
||||
std::shared_ptr<CWorldLayerState> 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<CRelayTracker>& RelayTracker() const { return x8_relayTracker; }
|
||||
const std::shared_ptr<CScriptMailbox>& RelayTracker() const { return x8_relayTracker; }
|
||||
const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return xc_mapWorldInfo; }
|
||||
const std::shared_ptr<CWorldLayerState>& GetLayerState() const { return x14_layerState; }
|
||||
void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<bool> 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<bool> 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;
|
|
@ -24,16 +24,16 @@ struct CMailMessage
|
|||
};
|
||||
#endif
|
||||
|
||||
class CRelayTracker {
|
||||
std::vector<TEditorId> x0_relayStates;
|
||||
class CScriptMailbox {
|
||||
std::vector<TEditorId> 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);
|
||||
};
|
|
@ -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<CRelayTracker>& relayTracker,
|
||||
CStateManager::CStateManager(const std::weak_ptr<CScriptMailbox>& relayTracker,
|
||||
const std::weak_ptr<CMapWorldInfo>& mwInfo, const std::weak_ptr<CPlayerState>& playerState,
|
||||
const std::weak_ptr<CWorldTransManager>& wtMgr,
|
||||
const std::weak_ptr<CWorldLayerState>& layerState)
|
||||
|
|
|
@ -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<TEditorId, SScriptObjectStream> x8a4_loadedScriptObjects;
|
||||
|
||||
std::shared_ptr<CPlayerState> x8b8_playerState;
|
||||
std::shared_ptr<CRelayTracker> x8bc_relayTracker;
|
||||
std::shared_ptr<CScriptMailbox> x8bc_relayTracker;
|
||||
std::shared_ptr<CMapWorldInfo> x8c0_mapWorldInfo;
|
||||
std::shared_ptr<CWorldTransManager> x8c4_worldTransManager;
|
||||
std::shared_ptr<CWorldLayerState> x8c8_worldLayerState;
|
||||
|
@ -220,7 +220,7 @@ private:
|
|||
static void RendererDrawCallback(void*, void*, int);
|
||||
|
||||
public:
|
||||
CStateManager(const std::weak_ptr<CRelayTracker>&, const std::weak_ptr<CMapWorldInfo>&,
|
||||
CStateManager(const std::weak_ptr<CScriptMailbox>&, const std::weak_ptr<CMapWorldInfo>&,
|
||||
const std::weak_ptr<CPlayerState>&, const std::weak_ptr<CWorldTransManager>&,
|
||||
const std::weak_ptr<CWorldLayerState>&);
|
||||
~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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue