diff --git a/code/client/App/Settings.h b/code/client/App/Settings.h index c0d5165..be9be26 100644 --- a/code/client/App/Settings.h +++ b/code/client/App/Settings.h @@ -9,6 +9,10 @@ struct Settings static Settings instance; return instance; } + static bool IsDisabled() + { + return !Get().enabled; + } static void Load(); fs::path exePath{}; diff --git a/code/client/App/World/NetworkWorldSystem.cpp b/code/client/App/World/NetworkWorldSystem.cpp index a008482..10f2a94 100644 --- a/code/client/App/World/NetworkWorldSystem.cpp +++ b/code/client/App/World/NetworkWorldSystem.cpp @@ -48,7 +48,7 @@ bool NetworkWorldSystem::Spawn(uint64_t aServerId, const Red::Vector4& aPosition if (!Red::Detail::CallFunctionWithArgs(m_pCreatePuppet, handle, id, aPosition, aRotation, stateHandle.instance->isBodyGenderMale)) return false; - + auto apprSystem = Red::GetGameSystem()->GetAppearanceSystem(); apprSystem->AddEntity(id, aEquipment, aCcstate); @@ -147,7 +147,11 @@ void NetworkWorldSystem::Update(uint64_t aTick) } void NetworkWorldSystem::OnWorldAttached(RED4ext::world::RuntimeScene* aScene) -{ +{ + if (Settings::IsDisabled()) + { + return; + } spdlog::info("[NetworkWorldSystem] OnWorldAttached"); IGameSystem::OnWorldAttached(aScene); @@ -161,6 +165,10 @@ void NetworkWorldSystem::OnWorldAttached(RED4ext::world::RuntimeScene* aScene) void NetworkWorldSystem::OnAfterWorldDetach() { + if (Settings::IsDisabled()) + { + return; + } spdlog::info("[NetworkWorldSystem] OnAfterWorldDetach"); m_ready = false; @@ -175,6 +183,10 @@ void NetworkWorldSystem::OnAfterWorldDetach() void NetworkWorldSystem::OnBeforeWorldDetach(RED4ext::world::RuntimeScene* aScene) { + if (Settings::IsDisabled()) + { + return; + } IGameSystem::OnBeforeWorldDetach(aScene); m_appearanceSystem->OnBeforeWorldDetach(aScene); @@ -192,7 +204,7 @@ void NetworkWorldSystem::HandleCharacterLoad(const PacketEvent(this->GetAllocator()); - for (auto item : aMessage.get_equipment()) + for (auto item : aMessage.get_equipment()) { equipment.EmplaceBack(item); } @@ -219,12 +231,12 @@ void NetworkWorldSystem::HandleSpawnCharacterResponse(const PacketEvent + 1160782872UL, + bool (*)(Red::game::mounting::MountingFacility *, const Red::ent::Entity &, const Red::game::mounting::MountingSlotId &, bool)> IsMountedToObject; static Core::RawFunc< - 3120376212UL, - bool (*)(Red::game::mounting::MountingFacility *, const Red::ent::Entity &, const Red::game::mounting::MountingSlotId &, Red::game::mounting::MountingInfo &)> + 3120376212UL, + bool (*)(Red::game::mounting::MountingFacility *, const Red::ent::Entity &, const Red::game::mounting::MountingSlotId &, Red::game::mounting::MountingInfo &)> GetMountingInfo; void NetworkWorldSystem::UpdatePlayerLocation() const @@ -365,7 +377,7 @@ void NetworkWorldSystem::OnInitialize(const RED4ext::JobHandle& aJob) IGameSystem::OnInitialize(aJob); - if (!Settings::Get().enabled) + if (Settings::IsDisabled()) return; const auto pNetworkService = Core::Container::Get(); diff --git a/code/client/Core/Foundation/Application.cpp b/code/client/Core/Foundation/Application.cpp index 5d1b354..e9c39b1 100644 --- a/code/client/Core/Foundation/Application.cpp +++ b/code/client/Core/Foundation/Application.cpp @@ -1,11 +1,20 @@ #include "Application.hpp" +#include "App/Settings.h" +#include "RED4ext/GameStates.hpp" +#include "RED4ext/Api/Sdk.hpp" + Core::Application::Application(RED4ext::PluginHandle aPlugin, const RED4ext::Sdk* aSdk) + : m_plugin(aPlugin), + m_sdk(aSdk) { - RED4ext::GameState state{nullptr, nullptr, nullptr}; - state.OnUpdate = &RunUpdate; + RED4ext::GameState loadingState{nullptr, nullptr, nullptr}; + RED4ext::GameState runningState{nullptr, nullptr, nullptr}; + loadingState.OnEnter = &RunLoad; + runningState.OnUpdate = &RunUpdate; - aSdk->gameStates->Add(aPlugin, RED4ext::EGameStateType::Running, &state); + aSdk->gameStates->Add(aPlugin, RED4ext::EGameStateType::Initialization, &loadingState); + aSdk->gameStates->Add(aPlugin, RED4ext::EGameStateType::Running, &runningState); s_pApp = this; } @@ -58,8 +67,22 @@ void Core::Application::Shutdown() m_booted = false; } +void Core::Application::Load(RED4ext::CGameApplication* apApp) +{ + Settings::Load(); + + if (Settings::IsDisabled()) + { + m_sdk->logger->Warn(m_plugin, "CyberpunkMP is disabled: \"--online\" flag is missing."); + } +} + void Core::Application::Update(RED4ext::CGameApplication* apApp) const { + if (Settings::IsDisabled()) + { + return; + } for (const auto& feature : GetRegistered()) { feature->OnGameUpdate(apApp); @@ -82,6 +105,13 @@ bool Core::Application::Discover(AutoDiscoveryCallback aCallback) return true; } +bool Core::Application::RunLoad(RED4ext::CGameApplication* apApp) +{ + if (s_pApp) + s_pApp->Load(apApp); + return false; +} + bool Core::Application::RunUpdate(RED4ext::CGameApplication* apApp) { if (s_pApp) diff --git a/code/client/Core/Foundation/Application.hpp b/code/client/Core/Foundation/Application.hpp index b5ffd1e..cf3ec93 100644 --- a/code/client/Core/Foundation/Application.hpp +++ b/code/client/Core/Foundation/Application.hpp @@ -21,12 +21,15 @@ class Application : public Registry virtual ~Application(); void Bootstrap(); void Shutdown(); + + void Load(RED4ext::CGameApplication* apApp); void Update(RED4ext::CGameApplication* apApp) const; static bool Discover(AutoDiscoveryCallback aCallback); protected: + static bool RunLoad(RED4ext::CGameApplication* apApp); static bool RunUpdate(RED4ext::CGameApplication* apApp); void OnRegistered(const SharedPtr& aFeature) override; @@ -37,6 +40,8 @@ class Application : public Registry virtual void OnStopped() {} private: + RED4ext::PluginHandle m_plugin; + const RED4ext::Sdk* m_sdk; bool m_booted = false; inline static Vector s_discoveryCallbacks; diff --git a/code/client/Main.cpp b/code/client/Main.cpp index 8dffcf8..39f991e 100644 --- a/code/client/Main.cpp +++ b/code/client/Main.cpp @@ -47,13 +47,8 @@ RED4EXT_C_EXPORT bool Main(RED4ext::PluginHandle aHandle, RED4ext::EMainReason a { case RED4ext::EMainReason::Load: { - Settings::Load(); - Initialize(); - if (!Settings::Get().enabled) - return false; - App::GApplication = MakeUnique(aHandle, aSdk); App::GApplication->Bootstrap(); @@ -73,7 +68,7 @@ RED4EXT_C_EXPORT bool Main(RED4ext::PluginHandle aHandle, RED4ext::EMainReason a } else { - const auto message = + const auto message = L"The following CyperpunkMP requirements were not met:\n\n* Input Loader v0.2.0\nPlease ensure the mods " L"above are installed/up-to-date."; MessageBoxW(nullptr, message, L"CyperpunkMP requirements could not be found", MB_SYSTEMMODAL | MB_ICONERROR); @@ -92,7 +87,7 @@ RED4EXT_C_EXPORT bool Main(RED4ext::PluginHandle aHandle, RED4ext::EMainReason a } case RED4ext::EMainReason::Unload: { - if (!Settings::Get().enabled) + if (Settings::IsDisabled()) return false; App::GApplication->Shutdown(); diff --git a/vendor/ArchiveXL b/vendor/ArchiveXL index 56a4164..6f649ae 160000 --- a/vendor/ArchiveXL +++ b/vendor/ArchiveXL @@ -1 +1 @@ -Subproject commit 56a416403e52752191005a19b40f4cfe7124962e +Subproject commit 6f649ae931e8c24e0893466c31e54851720dd0bc diff --git a/vendor/Codeware b/vendor/Codeware index 095bb63..a944410 160000 --- a/vendor/Codeware +++ b/vendor/Codeware @@ -1 +1 @@ -Subproject commit 095bb63673ea17ff8f377dadff24abdbf8b789d3 +Subproject commit a94441072bbe4cfb694dff0608d1416238e19ff5 diff --git a/vendor/TweakXL b/vendor/TweakXL index 52b16c3..3b96747 160000 --- a/vendor/TweakXL +++ b/vendor/TweakXL @@ -1 +1 @@ -Subproject commit 52b16c3e087043e82926d131f060622fc05e7354 +Subproject commit 3b96747f45c04ff9fcc3446a5743bf85d65fbdba