From 77b61b0e68ff059e31add73dd6422142098155ea Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 5 Nov 2019 09:18:14 -0800 Subject: [PATCH] Fix saves sending you to incorrect rooms, fix triggers --- Runtime/CGameState.cpp | 4 ++-- Runtime/Input/CInputGenerator.hpp | 4 +++- Runtime/MP1/CMFGame.cpp | 4 +++- Runtime/World/CScriptTrigger.cpp | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index a6b99b840..8ad5a942e 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -83,7 +83,7 @@ CWorldState::CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CSaveW void CWorldState::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const { writer.WriteEncoded(x4_areaId, 32); - writer.WriteEncoded(x10_desiredAreaAssetId.Value(), 32); + writer.WriteEncoded(u32(x10_desiredAreaAssetId.Value()), 32); x8_relayTracker->PutTo(writer, savw); xc_mapWorldInfo->PutTo(writer, savw, x0_mlvlId); x14_layerState->PutTo(writer); @@ -209,7 +209,7 @@ void CGameState::PutTo(CBitStreamWriter& writer) const { writer.WriteEncoded(CBasics::ToWiiTime(std::chrono::system_clock::now()) / CBasics::TICKS_PER_SECOND, 32); writer.WriteEncoded(x228_24_hardMode, 1); writer.WriteEncoded(x228_25_initPowerupsAtFirstSpawn, 1); - writer.WriteEncoded(x84_mlvlId.Value(), 32); + writer.WriteEncoded(u32(x84_mlvlId.Value()), 32); BitsToDouble conv; conv.doub = xa0_playTime; diff --git a/Runtime/Input/CInputGenerator.hpp b/Runtime/Input/CInputGenerator.hpp index e67d43cbc..0126102d0 100644 --- a/Runtime/Input/CInputGenerator.hpp +++ b/Runtime/Input/CInputGenerator.hpp @@ -38,8 +38,10 @@ public: : boo::DeviceFinder({dev_typeid(DolphinSmashAdapter)}), m_leftDiv(leftDiv), m_rightDiv(rightDiv) {} ~CInputGenerator() override { - if (smashAdapter) + if (smashAdapter) { smashAdapter->setCallback(nullptr); + smashAdapter->closeDevice(); + } } /* Keyboard and mouse events are delivered on the main game diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index 22755120d..885cd0802 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -332,8 +332,10 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, return EMessageReturn::Exit; } - if (!x18_guiMgr) + if (!x18_guiMgr) { + g_GameState->CurrentWorldState().SetDesiredAreaAssetId(CAssetId()); x18_guiMgr = std::make_shared(*x14_stateMgr, queue); + } if (!x18_guiMgr->CheckLoadComplete(*x14_stateMgr)) return EMessageReturn::Exit; diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index 39c78be22..84c54e2a3 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -179,18 +179,18 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) { x148_25_camSubmerged = true; if (True(x12c_flags & ETriggerFlags::DetectCamera)) { InhabitantAdded(*cam, mgr); - SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::Activate); + SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None); } } } } if (sendInside) { - SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::Activate); + SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None); } if (sendExited) { - SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::Activate); + SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None); if (x148_27_deactivateOnExited) { mgr.SendScriptMsg(GetUniqueId(), mgr.GetEditorIdForUniqueId(GetUniqueId()), EScriptObjectMessage::Deactivate, EScriptObjectState::Exited);