From 7e4c82a013d4621f09b4aec765dddb23f2bb5c04 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 8 Feb 2017 23:37:00 -0800 Subject: [PATCH 1/2] Fix SCAN state saving, clean up MLVL, add support for newer CRasterFont versions --- DataSpec/DNAMP1/MLVL.cpp | 7 ++----- Runtime/CMemoryCardSys.cpp | 4 ++++ Runtime/CPlayerState.cpp | 23 ++++++++++++++++++++--- Runtime/CPlayerState.hpp | 4 ++-- Runtime/GuiSys/CRasterFont.cpp | 34 +++++++++++++++++++++++++--------- Runtime/MP1/CFrontEndUI.cpp | 1 + 6 files changed, 54 insertions(+), 19 deletions(-) diff --git a/DataSpec/DNAMP1/MLVL.cpp b/DataSpec/DNAMP1/MLVL.cpp index 00dc130c4..0b04f968b 100644 --- a/DataSpec/DNAMP1/MLVL.cpp +++ b/DataSpec/DNAMP1/MLVL.cpp @@ -20,13 +20,10 @@ bool MLVL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: MLVL mlvl; mlvl.read(rs); const nod::Node* node; - const typename PAKRouter::EntryType* texEntry = pakRouter.lookupEntry(mlvl.saveWorldId, &node); - hecl::ProjectPath savwPath = pakRouter.getWorking(texEntry); + const typename PAKRouter::EntryType* savwEntry = pakRouter.lookupEntry(mlvl.saveWorldId, &node); SAVW savw; - if (!savwPath.isNone()) { - savwPath.makeDirChain(false); - PAKEntryReadStream rs = texEntry->beginReadStream(*node); + PAKEntryReadStream rs = savwEntry->beginReadStream(*node); savw.read(rs); } diff --git a/Runtime/CMemoryCardSys.cpp b/Runtime/CMemoryCardSys.cpp index 4975304b9..0b8d91941 100644 --- a/Runtime/CMemoryCardSys.cpp +++ b/Runtime/CMemoryCardSys.cpp @@ -157,6 +157,10 @@ bool CMemoryCardSys::InitializePump() x20_scanStates.emplace_back(scan.x0_id, scan.x4_category); } + std::sort(x20_scanStates.begin(), x20_scanStates.end(), [&](const auto& a, const auto& b) ->bool{ + return g_ResFactory->TranslateNewToOriginal(a.first) < g_ResFactory->TranslateNewToOriginal(b.first); + }); + wldMemOut.x3c_saveWorld = std::move(world.x34_saveWorld); wldMemOut.x2c_worldName = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), wldMemOut.x0_strgId}); } diff --git a/Runtime/CPlayerState.cpp b/Runtime/CPlayerState.cpp index cd0009121..ee42c5370 100644 --- a/Runtime/CPlayerState.cpp +++ b/Runtime/CPlayerState.cpp @@ -203,8 +203,8 @@ CPlayerState::EPlayerSuit CPlayerState::GetCurrentSuit() const bool CPlayerState::CanVisorSeeFog(const CStateManager& stateMgr) const { - u32 activeVisor = u32(GetActiveVisor(stateMgr)); - if (activeVisor == 0 || activeVisor == 2) + EPlayerVisor activeVisor = GetActiveVisor(stateMgr); + if (activeVisor == EPlayerVisor::Combat || activeVisor == EPlayerVisor::Scan) return true; return true; } @@ -222,9 +222,26 @@ void CPlayerState::UpdateStaticInterference(CStateManager& stateMgr, const float x188_staticIntf.Update(stateMgr, dt); } -void CPlayerState::IncreaseScanTime(u32 time, float val) +void CPlayerState::SetScanTime(ResId res, float time) { + auto it = std::find_if(x170_scanTimes.begin(), x170_scanTimes.end(), [&](const auto& test) -> bool{ + return test.first == res; + }); + if (it != x170_scanTimes.end()) + it->second = time; +} + +float CPlayerState::GetScanTime(ResId res) const +{ + const auto it = std::find_if(x170_scanTimes.cbegin(), x170_scanTimes.cend(), [&](const auto& test) -> bool{ + return test.first == res; + }); + + if (it == x170_scanTimes.end()) + return 0.f; + + return it->second; } bool CPlayerState::GetIsVisorTransitioning() const diff --git a/Runtime/CPlayerState.hpp b/Runtime/CPlayerState.hpp index c11836867..25459615e 100644 --- a/Runtime/CPlayerState.hpp +++ b/Runtime/CPlayerState.hpp @@ -145,8 +145,8 @@ public: EPlayerVisor GetActiveVisor(const CStateManager& stateMgr) const; void UpdateStaticInterference(CStateManager& stateMgr, const float& dt); void IncreaseScanTime(u32 time, float val); - void SetScanTime(u32 time, float val); - float GetScanTime(u32 time, float val); + void SetScanTime(ResId time, float val); + float GetScanTime(ResId time) const; bool GetIsVisorTransitioning() const; float GetVisorTransitionFactor() const; void UpdateVisorTransition(float dt); diff --git a/Runtime/GuiSys/CRasterFont.cpp b/Runtime/GuiSys/CRasterFont.cpp index 083bdafe3..c4e133cad 100644 --- a/Runtime/GuiSys/CRasterFont.cpp +++ b/Runtime/GuiSys/CRasterFont.cpp @@ -31,7 +31,7 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) u32 tmp3 = in.readUint32Big(); u32 tmp4 = in.readUint32Big(); std::string name= in.readString(); - u32 txtrId = in.readUint32Big(); + u32 txtrId = (version == 5 ? in.readUint64Big() : in.readUint32Big()); x30_fontInfo = CFontInfo(tmp1, tmp2, tmp3, tmp4, name.c_str()); x80_texture = store.GetObj({FOURCC('TXTR'), txtrId}); x2c_mode = EColorType(in.readUint32Big()); @@ -46,15 +46,31 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) float startV = in.readFloatBig(); float endU = in.readFloatBig(); float endV = in.readFloatBig(); - s32 a = in.readInt32Big(); - s32 b = in.readInt32Big(); - s32 c = in.readInt32Big(); - s32 cellWidth = in.readInt32Big(); - s32 cellHeight = in.readInt32Big(); - s32 baseline = in.readInt32Big(); - s32 kernStart = in.readInt32Big(); + s32 layer = 0; + s32 a, b, c, cellWidth, cellHeight, baseline, kernStart; + if (version < 4) + { + a = in.readInt32Big(); + b = in.readInt32Big(); + c = in.readInt32Big(); + cellWidth = in.readInt32Big(); + cellHeight = in.readInt32Big(); + baseline = in.readInt32Big(); + kernStart = in.readInt32Big(); + } + else + { + layer = in.readByte(); + a = in.readByte(); + b = in.readByte(); + c = in.readByte(); + cellWidth = in.readByte(); + cellHeight = in.readByte(); + baseline = in.readByte(); + kernStart = in.readInt16Big(); + } xc_glyphs.push_back(std::make_pair(chr, CGlyph(a, b, c, startU, startV, endU, endV, - cellWidth, cellHeight, baseline, kernStart))); + cellWidth, cellHeight, baseline, kernStart, layer))); } std::sort(xc_glyphs.begin(), xc_glyphs.end(), [=](auto& a, auto& b) -> bool{ diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index c1a41fd16..9a04fc29b 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -481,6 +481,7 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() { auto pt = std::div(data->x0_playTime, 3600); str = hecl::Char16Format(L"%02d:%02d", pt.quot, pt.rem / 60); + break; } str = g_MainStringTable->GetString(52); break; From 48c295f9d833d9e045dc367589d297d770b29918 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 9 Feb 2017 00:17:10 -0800 Subject: [PATCH 2/2] Fix sort placement derp --- Runtime/CMemoryCardSys.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Runtime/CMemoryCardSys.cpp b/Runtime/CMemoryCardSys.cpp index 0b8d91941..42b8d6f97 100644 --- a/Runtime/CMemoryCardSys.cpp +++ b/Runtime/CMemoryCardSys.cpp @@ -157,10 +157,6 @@ bool CMemoryCardSys::InitializePump() x20_scanStates.emplace_back(scan.x0_id, scan.x4_category); } - std::sort(x20_scanStates.begin(), x20_scanStates.end(), [&](const auto& a, const auto& b) ->bool{ - return g_ResFactory->TranslateNewToOriginal(a.first) < g_ResFactory->TranslateNewToOriginal(b.first); - }); - wldMemOut.x3c_saveWorld = std::move(world.x34_saveWorld); wldMemOut.x2c_worldName = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), wldMemOut.x0_strgId}); } @@ -169,7 +165,12 @@ bool CMemoryCardSys::InitializePump() } if (done) + { + std::sort(x20_scanStates.begin(), x20_scanStates.end(), [&](const auto& a, const auto& b) ->bool{ + return g_ResFactory->TranslateNewToOriginal(a.first) < g_ResFactory->TranslateNewToOriginal(b.first); + }); x1c_worldInter = std::experimental::nullopt; + } return false; }