From 157946810a42335059a67621afa06169b90ea608 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 3 Feb 2019 13:20:05 -0800 Subject: [PATCH] Minor fixes to CFrontEndUI, add elapsed seconds to save selection --- Runtime/CStateManager.cpp | 12 ++++----- Runtime/MP1/CFrontEndUI.cpp | 21 +++++++++++++-- Runtime/World/CScriptSpecialFunction.cpp | 34 ++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index c01f3e18e..a07e59683 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -417,12 +417,12 @@ void CStateManager::SetupParticleHook(const CActor& actor) const { void CStateManager::MurderScriptInstanceNames() { xb40_uniqueInstanceNames.clear(); } std::string CStateManager::HashInstanceName(CInputStream& in) { -#ifdef NDEBUG - while (in.readByte() != 0) {}; - return ""; -#else - return in.readString(); -#endif + if (hecl::com_developer && hecl::com_developer->toBoolean()) { + return in.readString(); + } else { + while (in.readByte() != 0) {}; + return ""; + } } void CStateManager::SetActorAreaId(CActor& actor, TAreaId aid) { diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index 78c2c82b9..0a4369f57 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -26,6 +26,8 @@ namespace urde::MP1 { +#define FE_USE_SECONDS_IN_ELAPSED 1 + /* Music volume constants */ static const float FE1_VOL = 0.7421875f; static const float FE2_VOL = 0.7421875f; @@ -455,7 +457,7 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() { case 0: // Completion percent if (data) { - std::u16string fileStr = g_MainStringTable->GetString(data->x20_hardMode ? 106 : 39); + std::u16string fileStr = g_MainStringTable->GetString((data->x20_hardMode ? 106 : 39) + i); str = fileStr + hecl::Char16Format(L" %02d%%", data->x18_itemPercent); break; } @@ -473,7 +475,21 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() { } str = g_MainStringTable->GetString(51); break; - +#if FE_USE_SECONDS_IN_ELAPSED + case 2: + // Formatted time + if (data) { + auto pt = std::div(data->x0_playTime, 3600); + str = hecl::Char16Format(L"%02d:%02d:%02d", pt.quot, pt.rem / 60, pt.rem % 60); + break; + } + str = g_MainStringTable->GetString(52); + break; + case 3: + // "Elapsed" + str = std::u16string(u" ") + std::u16string(g_MainStringTable->GetString(data ? 54 : 53)); + break; +#else case 2: // Formatted time if (data) { @@ -488,6 +504,7 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() { // "Elapsed" str = g_MainStringTable->GetString(data ? 54 : 53); break; +#endif default: break; diff --git a/Runtime/World/CScriptSpecialFunction.cpp b/Runtime/World/CScriptSpecialFunction.cpp index ecbd9545e..7a76da790 100644 --- a/Runtime/World/CScriptSpecialFunction.cpp +++ b/Runtime/World/CScriptSpecialFunction.cpp @@ -464,7 +464,33 @@ void CScriptSpecialFunction::ThinkPlayerFollowLocator(float, CStateManager&) {} void CScriptSpecialFunction::ThinkSpinnerController(float, CStateManager&, CScriptSpecialFunction::ESpinnerControllerMode) {} -void CScriptSpecialFunction::ThinkObjectFollowLocator(float, CStateManager&) {} +void CScriptSpecialFunction::ThinkObjectFollowLocator(float, CStateManager& mgr) { + TUniqueId followerAct = kInvalidUniqueId; + TUniqueId followedAct = kInvalidUniqueId; + for (const SConnection& conn : x20_conns) { + if (conn.x0_state != EScriptObjectState::Play) + continue; + + auto search = mgr.GetIdListForScript(conn.x8_objId); + for (auto it = search.first; it != search.second; ++it) { + if (TCastToConstPtr act = mgr.GetObjectById(it->second)) { + if (conn.x4_msg == EScriptObjectMessage::Activate && + (act->HasModelData() && act->GetModelData()->HasAnimData()) && act->GetActive()) { + followedAct = it->second; + } else if (conn.x4_msg == EScriptObjectMessage::Deactivate) { + followerAct = it->second; + } + } + } + } + + if (followerAct == kInvalidUniqueId || followedAct == kInvalidUniqueId) + return; + + TCastToConstPtr fromAct = mgr.GetObjectById(followedAct); + TCastToPtr toAct = mgr.ObjectById(followerAct); + toAct->SetTransform(fromAct->GetTransform() * fromAct->GetScaledLocatorTransform(xec_locatorName)); +} void CScriptSpecialFunction::ThinkObjectFollowObject(float, CStateManager&) {} @@ -509,7 +535,11 @@ void CScriptSpecialFunction::ThinkRainSimulator(float, CStateManager& mgr) { SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None); } -void CScriptSpecialFunction::ThinkAreaDamage(float, CStateManager&) {} +void CScriptSpecialFunction::ThinkAreaDamage(float, CStateManager& mgr) { + const auto& playerState = mgr.GetPlayerState(); + const CPlayer& player = mgr.GetPlayer(); + +} void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) { if (mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {