Skip to content

Commit

Permalink
Merge pull request #48 from rayshader/fix/support-2.2
Browse files Browse the repository at this point in the history
fix(Client): support patch 2.2
  • Loading branch information
maximegmd authored Dec 20, 2024
2 parents 5e4004c + 98b4130 commit 995c767
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 21 deletions.
4 changes: 4 additions & 0 deletions code/client/App/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ struct Settings
static Settings instance;
return instance;
}
static bool IsDisabled()
{
return !Get().enabled;
}
static void Load();

fs::path exePath{};
Expand Down
28 changes: 20 additions & 8 deletions code/client/App/World/NetworkWorldSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NetworkWorldSystem>()->GetAppearanceSystem();
apprSystem->AddEntity(id, aEquipment, aCcstate);

Expand Down Expand Up @@ -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);

Expand All @@ -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;

Expand All @@ -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);
Expand All @@ -192,7 +204,7 @@ void NetworkWorldSystem::HandleCharacterLoad(const PacketEvent<server::NotifyCha
const Red::Quaternion rotation{quat.x, quat.y, quat.z, quat.w};

auto equipment = Red::DynArray<Red::TweakDBID>(this->GetAllocator());
for (auto item : aMessage.get_equipment())
for (auto item : aMessage.get_equipment())
{
equipment.EmplaceBack(item);
}
Expand All @@ -219,12 +231,12 @@ void NetworkWorldSystem::HandleSpawnCharacterResponse(const PacketEvent<server::
}

static Core::RawFunc<
1160782872UL,
bool (*)(Red::game::mounting::MountingFacility *, const Red::ent::Entity &, const Red::game::mounting::MountingSlotId &, bool)>
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
Expand Down Expand Up @@ -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<NetworkService>();
Expand Down
36 changes: 33 additions & 3 deletions code/client/Core/Foundation/Application.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions code/client/Core/Foundation/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ class Application : public Registry<Feature>
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<Feature>& aFeature) override;
Expand All @@ -37,6 +40,8 @@ class Application : public Registry<Feature>
virtual void OnStopped() {}

private:
RED4ext::PluginHandle m_plugin;
const RED4ext::Sdk* m_sdk;
bool m_booted = false;

inline static Vector<AutoDiscoveryCallback> s_discoveryCallbacks;
Expand Down
9 changes: 2 additions & 7 deletions code/client/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<App::Application>(aHandle, aSdk);
App::GApplication->Bootstrap();

Expand All @@ -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);
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion vendor/ArchiveXL
Submodule ArchiveXL updated 260 files
2 changes: 1 addition & 1 deletion vendor/Codeware
Submodule Codeware updated 112 files
2 changes: 1 addition & 1 deletion vendor/TweakXL
Submodule TweakXL updated 95 files
+3 −0 .gitignore
+5 −5 .gitmodules
+3 −3 README.md
+286 −0 THIRD_PARTY_LICENSES
+3 −0 config/Project.hpp.in
+ data/ExtraFlats.dat
+ data/InheritanceMap.dat
+30 −30 lib/Core/Facades/Hook.hpp
+10 −0 lib/Core/Facades/Runtime.cpp
+3 −0 lib/Core/Facades/Runtime.hpp
+52 −12 lib/Core/Hooking/Detail.hpp
+56 −56 lib/Core/Hooking/HookingAgent.hpp
+76 −15 lib/Core/Raw.hpp
+47 −0 lib/Core/Runtime/HostImage.cpp
+22 −0 lib/Core/Runtime/HostImage.hpp
+14 −0 lib/Core/Stl.hpp
+1 −0 lib/Red/Engine.hpp
+9 −5 lib/Red/Engine/LogChannel.hpp
+1 −0 lib/Red/TypeInfo.hpp
+3 −0 lib/Red/TypeInfo/Common.hpp
+31 −6 lib/Red/TypeInfo/Definition.hpp
+77 −37 lib/Red/TypeInfo/Invocation.hpp
+3 −0 lib/Red/TypeInfo/Macros/Definition.hpp
+3 −0 lib/Red/TypeInfo/Mappings.hpp
+24 −13 lib/Red/TypeInfo/Parameters.hpp
+56 −40 lib/Red/TypeInfo/Resolving.hpp
+13 −1 lib/Red/Utils/Handles.hpp
+17 −6 lib/Red/Utils/JobQueues.hpp
+6 −0 lib/Support/RED4ext/RED4extProvider.hpp
+1 −0 scripts/Module.reds
+0 −0 scripts/ScriptableTweak.reds
+1 −0 scripts/TweakDBBatch.reds
+0 −0 scripts/TweakDBInterface.reds
+1 −0 scripts/TweakDBManager.reds
+0 −0 scripts/TweakXL.reds
+14 −4 src/App/Application.cpp
+43 −3 src/App/Environment.hpp
+5 −0 src/App/Facade.cpp
+2 −0 src/App/Facade.hpp
+13 −0 src/App/Migration.hpp
+0 −16 src/App/Project.hpp
+16 −11 src/App/Stats/StatService.cpp
+2 −0 src/App/Stats/StatService.hpp
+13 −4 src/App/Tweaks/Batch/TweakChangelog.cpp
+292 −33 src/App/Tweaks/Batch/TweakChangeset.cpp
+33 −6 src/App/Tweaks/Batch/TweakChangeset.hpp
+47 −25 src/App/Tweaks/Declarative/Red/RedReader.cpp
+7 −4 src/App/Tweaks/Declarative/Red/RedReader.hpp
+69 −14 src/App/Tweaks/Declarative/TweakImporter.cpp
+11 −3 src/App/Tweaks/Declarative/TweakImporter.hpp
+14 −30 src/App/Tweaks/Declarative/TweakReader.cpp
+7 −4 src/App/Tweaks/Declarative/TweakReader.hpp
+157 −68 src/App/Tweaks/Declarative/Yaml/YamlReader.Template.cpp
+80 −12 src/App/Tweaks/Declarative/Yaml/YamlReader.cpp
+2 −1 src/App/Tweaks/Declarative/Yaml/YamlReader.hpp
+11 −0 src/App/Tweaks/Executable/Scriptable/ScriptBatch.cpp
+2 −0 src/App/Tweaks/Executable/Scriptable/ScriptBatch.hpp
+8 −0 src/App/Tweaks/Executable/Scriptable/ScriptManager.cpp
+2 −0 src/App/Tweaks/Executable/Scriptable/ScriptManager.hpp
+390 −0 src/App/Tweaks/Metadata/MetadataExporter.cpp
+33 −0 src/App/Tweaks/Metadata/MetadataExporter.hpp
+196 −0 src/App/Tweaks/Metadata/MetadataImporter.cpp
+19 −0 src/App/Tweaks/Metadata/MetadataImporter.hpp
+37 −0 src/App/Tweaks/TweakContext.hpp
+69 −17 src/App/Tweaks/TweakService.cpp
+14 −1 src/App/Tweaks/TweakService.hpp
+0 −37 src/App/Version.rc
+0 −25 src/Red/Addresses/Direct.hpp
+3 −0 src/Red/Addresses/Library.hpp
+0 −774 src/Red/TweakDB/Generated/ExtraFlats.cpp
+41 −7 src/Red/TweakDB/Manager.cpp
+6 −1 src/Red/TweakDB/Manager.hpp
+4 −0 src/Red/TweakDB/Raws.hpp
+66 −21 src/Red/TweakDB/Reflection.cpp
+16 −1 src/Red/TweakDB/Reflection.hpp
+5 −0 src/Red/TweakDB/Source/Grammar.hpp
+21 −1 src/Red/TweakDB/Source/Parser.cpp
+13 −5 src/Red/TweakDB/Source/Source.hpp
+5 −0 src/Red/Value.hpp
+1 −1 src/main.cpp
+2 −1 src/pch.hpp
+0 −10 tools/dist/install-mod.ps1
+6 −3 tools/dist/package-mod.ps1
+0 −13 tools/dist/readme.md
+6 −0 tools/dist/steps/compose-data.ps1
+7 −0 tools/dist/steps/compose-licenses.ps1
+0 −6 tools/dist/steps/compose-plugin-asi.ps1
+0 −0 tools/dist/steps/compose-red4ext.ps1
+50 −3 tools/dist/steps/compose-redscripts.ps1
+1 −0 tools/dist/steps/get-version.ps1
+0 −208 tools/ida/cp77ida.py
+0 −4 tools/ida/readme.md
+0 −47 tools/ida/scan.py
+1 −1 vendor/RED4ext.SDK
+1 −1 xmake.lua

0 comments on commit 995c767

Please sign in to comment.