2017-01-17 01:23:19 +00:00
|
|
|
#include "CStateSetterFlow.hpp"
|
2017-11-05 06:29:22 +00:00
|
|
|
#include "CArchitectureMessage.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
2018-10-18 04:51:59 +00:00
|
|
|
#include "MP1.hpp"
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde::MP1 {
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CStateSetterFlow::CStateSetterFlow() : CIOWin("") {}
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CIOWin::EMessageReturn CStateSetterFlow::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) {
|
|
|
|
if (msg.GetType() == EArchMsgType::TimerTick) {
|
|
|
|
MP1::CMain* m = static_cast<MP1::CMain*>(g_Main);
|
2018-10-18 04:51:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (m->m_warpWorldIdx > -1) {
|
|
|
|
CResLoader* loader = g_ResFactory->GetResLoader();
|
|
|
|
CAssetId worldId;
|
|
|
|
for (const auto& pak : loader->GetPaks()) {
|
|
|
|
if (*(pak->GetPath().end() - 6) == '0' + m->m_warpWorldIdx) {
|
|
|
|
worldId = pak->GetMLVLId();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-10-18 04:51:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (worldId.IsValid()) {
|
|
|
|
m->ResetGameState();
|
2018-10-18 04:51:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
g_GameState->SetCurrentWorldId(worldId);
|
2019-02-10 04:41:35 +00:00
|
|
|
CWorldState& ws = g_GameState->StateForWorld(worldId);
|
|
|
|
CWorldLayerState& layers = *ws.GetLayerState();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (m->m_warpAreaId < layers.GetAreaCount()) {
|
2019-02-10 04:41:35 +00:00
|
|
|
ws.SetAreaId(m->m_warpAreaId);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (m->m_warpLayerBits) {
|
|
|
|
for (u32 i = 0; i < layers.GetAreaLayerCount(m->m_warpAreaId); ++i)
|
|
|
|
layers.SetLayerActive(m->m_warpAreaId, i, ((m->m_warpLayerBits >> i) & 1) != 0);
|
|
|
|
}
|
2019-02-10 04:41:35 +00:00
|
|
|
CRelayTracker& relays = *ws.RelayTracker();
|
|
|
|
for (const auto& r : m->m_warpMemoryRelays)
|
|
|
|
relays.AddRelay(r);
|
2018-10-18 04:51:59 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
g_GameState->GameOptions().ResetToDefaults();
|
|
|
|
g_GameState->WriteBackupBuf();
|
2017-11-05 06:29:22 +00:00
|
|
|
return EMessageReturn::RemoveIOWinAndExit;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-11-05 06:29:22 +00:00
|
|
|
}
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
m->RefreshGameState();
|
|
|
|
return EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
}
|
|
|
|
return EMessageReturn::Exit;
|
2017-01-17 01:23:19 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
} // namespace urde::MP1
|