From ce1f1ac362e997513cfad9500d69e7b88ef71814 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 7 Dec 2022 18:02:33 -0800 Subject: [PATCH] Use a dedicated CVar for enabling cutscene skips --- Runtime/Graphics/CTevCombiners.cpp | 6 ++++-- Runtime/World/CScriptSpecialFunction.cpp | 9 +++++++-- Runtime/World/CScriptSpecialFunction.hpp | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Runtime/Graphics/CTevCombiners.cpp b/Runtime/Graphics/CTevCombiners.cpp index bd5319a8b..5afc6e185 100644 --- a/Runtime/Graphics/CTevCombiners.cpp +++ b/Runtime/Graphics/CTevCombiners.cpp @@ -99,8 +99,10 @@ bool SetPassCombiners(ERglTevStage stage, const CTevPass& pass) { } void RecomputePasses() { - sNumEnabledPasses = 1 - static_cast(sValidPasses[maxTevPasses - 1]); - CGX::SetNumTevStages(sNumEnabledPasses); + u8 tmp = static_cast((sValidPasses[maxTevPasses - 1] != 0)); + tmp++; + sNumEnabledPasses = tmp; + CGX::SetNumTevStages(tmp); } void ResetStates() { diff --git a/Runtime/World/CScriptSpecialFunction.cpp b/Runtime/World/CScriptSpecialFunction.cpp index 54c273a24..cb238ab93 100644 --- a/Runtime/World/CScriptSpecialFunction.cpp +++ b/Runtime/World/CScriptSpecialFunction.cpp @@ -51,6 +51,11 @@ CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, std::string_view n if (xe8_function == ESpecialFunction::HUDTarget) { x1c8_touchBounds = {-1.f, 1.f}; } + // Set this as internal archivable so it can be serialized if the player sets it in the configuration + m_cvRef.emplace(&m_canSkipCutscenes, + CVarManager::instance()->findOrMakeCVar( + "enableCutsceneSkip"sv, "Enable skipping of all cutscenes", false, + CVar::EFlags::Cheat | CVar::EFlags::Game | CVar::EFlags::InternalArchivable)); } void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); } @@ -923,7 +928,7 @@ void CScriptSpecialFunction::ThinkSaveStation(float, CStateManager& mgr) { } void CScriptSpecialFunction::ThinkRainSimulator(float, CStateManager& mgr) { - if ((static_cast< float >(mgr.GetInputFrameIdx() % 3600)) / 3600.f < 0.5f) { + if ((static_cast(mgr.GetInputFrameIdx() % 3600)) / 3600.f < 0.5f) { SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None); } else { SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None); @@ -986,7 +991,7 @@ void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) { } bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const { - if (com_developer->toBoolean()) { + if (m_canSkipCutscenes) { return true; } return g_GameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), GetEditorId()); diff --git a/Runtime/World/CScriptSpecialFunction.hpp b/Runtime/World/CScriptSpecialFunction.hpp index d848fe9a6..8a374c350 100644 --- a/Runtime/World/CScriptSpecialFunction.hpp +++ b/Runtime/World/CScriptSpecialFunction.hpp @@ -8,6 +8,8 @@ #include "Runtime/World/CActor.hpp" #include "Runtime/World/CDamageInfo.hpp" +#include "Runtime/ConsoleVariables/CVar.hpp" + #include #include #include @@ -111,6 +113,9 @@ private: bool x1e5_25_playerInArea : 1 = false; bool x1e5_26_displayBillboard : 1 = false; TLockedToken x1e8_; // Used to be optional + std::optional> m_cvRef; + bool m_canSkipCutscenes = false; + public: DEFINE_ENTITY CScriptSpecialFunction(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, ESpecialFunction,