diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 7600b7b58..078ef018a 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -2099,7 +2099,10 @@ void CStateManager::UpdateAreaSounds() { CSfxManager::SetActiveAreas(areas); } -void CStateManager::FrameEnd() { g_SimplePool->Flush(); } +void CStateManager::FrameEnd() { + CModel::FrameDone(); + g_SimplePool->Flush(); +} void CStateManager::ProcessPlayerInput() { if (x84c_player) { diff --git a/Runtime/CToken.cpp b/Runtime/CToken.cpp index 9c22125ca..8d0637496 100644 --- a/Runtime/CToken.cpp +++ b/Runtime/CToken.cpp @@ -102,6 +102,8 @@ IObj* CToken::GetObj() { return x0_objRef->GetObject(); } CToken& CToken::operator=(const CToken& other) { + if (this == &other) + return *this; Unlock(); RemoveRef(); x0_objRef = other.x0_objRef; diff --git a/Runtime/Graphics/CModel.cpp b/Runtime/Graphics/CModel.cpp index 10e675b1c..87b1d11be 100644 --- a/Runtime/Graphics/CModel.cpp +++ b/Runtime/Graphics/CModel.cpp @@ -133,6 +133,11 @@ CModel::CModel(std::unique_ptr in, u32 dataLen, IObjectStore* store) // DCFlushRange(x0_data, dataLen); } +CModel::~CModel() { + RemoveFromList(); + sTotalMemory -= x4_dataLen; +} + void CModel::UpdateLastFrame() { x38_lastFrame = CGraphics::GetFrameCounter(); } void CModel::MoveToThisFrameList() { diff --git a/Runtime/Graphics/CModel.hpp b/Runtime/Graphics/CModel.hpp index cc61894d9..04547fcaa 100644 --- a/Runtime/Graphics/CModel.hpp +++ b/Runtime/Graphics/CModel.hpp @@ -92,6 +92,7 @@ private: public: CModel(std::unique_ptr in, u32 dataLen, IObjectStore* store); + ~CModel(); void UpdateLastFrame(); void MoveToThisFrameList(); diff --git a/Runtime/MP1/CInGameGuiManager.cpp b/Runtime/MP1/CInGameGuiManager.cpp index abbedf44b..da78c5a01 100644 --- a/Runtime/MP1/CInGameGuiManager.cpp +++ b/Runtime/MP1/CInGameGuiManager.cpp @@ -168,7 +168,10 @@ void CInGameGuiManager::DoStateTransition(CStateManager& stateMgr) { } } -void CInGameGuiManager::DestroyAreaTextures(CStateManager& stateMgr) {} +void CInGameGuiManager::DestroyAreaTextures(CStateManager& stateMgr) { + // TODO + CModel::DisableTextureTimeout(); +} void CInGameGuiManager::TryReloadAreaTextures() {} @@ -270,6 +273,7 @@ void CInGameGuiManager::OnNewPauseScreenState(CArchitectureQueue& archQueue) { if (x1c0_nextState >= EInGameGuiState::Zero && x1c0_nextState <= EInGameGuiState::InGame) { if (x44_messageScreen) x44_messageScreen.reset(); + CModel::EnableTextureTimeout(); RefreshHudOptions(); } x1bc_prevState = x1c0_nextState; diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index d7dd43277..e83515080 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -255,6 +255,7 @@ void CMFGame::EnterMapScreen() { } CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") { + CModel::DisableTextureTimeout(); auto* m = static_cast(g_Main); switch (m->GetFlowState()) { case EClientFlowStates::Default: @@ -357,6 +358,7 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, if (x2c_25_transitionFinished) { queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000, std::make_shared(x14_stateMgr, x18_guiMgr, queue))); + CModel::EnableTextureTimeout(); return EMessageReturn::RemoveIOWinAndExit; } break;