- Fixed co-op issues related to Player and Weapon options, such as God Mode, Player Health, Player Immunity, Weapon Durability sliders not working

This commit is contained in:
EricPlayZ
2024-09-07 16:14:59 +03:00
parent 4961177ef7
commit 4803e3b5ce
16 changed files with 37 additions and 81 deletions

View File

@ -35,7 +35,6 @@
<ClCompile Include="source\game\GamePH\FreeCamera.cpp" />
<ClCompile Include="source\game\GamePH\GameDI_PH.cpp" />
<ClCompile Include="source\game\GamePH\GameDI_PH2.cpp" />
<ClCompile Include="source\game\GamePH\gen_TPPModel.cpp" />
<ClCompile Include="source\game\GamePH\game_hooks.cpp" />
<ClCompile Include="source\game\GamePH\InventoryContainerDI.cpp" />
<ClCompile Include="source\game\GamePH\InventoryItem.cpp" />
@ -140,7 +139,6 @@
<ClInclude Include="source\game\GamePH\FreeCamera.h" />
<ClInclude Include="source\game\GamePH\GameDI_PH.h" />
<ClInclude Include="source\game\GamePH\GameDI_PH2.h" />
<ClInclude Include="source\game\GamePH\gen_TPPModel.h" />
<ClInclude Include="source\game\GamePH\InventoryContainerDI.h" />
<ClInclude Include="source\game\GamePH\InventoryItem.h" />
<ClInclude Include="source\game\GamePH\InventoryMoney.h" />

View File

@ -133,9 +133,6 @@
<ClCompile Include="source\game\GamePH\GameDI_PH2.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\gen_TPPModel.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\game_hooks.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
@ -364,9 +361,6 @@
<ClInclude Include="source\game\GamePH\GameDI_PH2.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\gen_TPPModel.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\LevelDI.h">
<Filter>game\GamePH</Filter>
</ClInclude>

View File

@ -143,6 +143,8 @@ If anyone is looking to help with development, I'm all eyes and ears! Thank you!
I have some things planned for the next updates, but time will decide when I'll be able to work on the updates. I'm almost done with my exams!)" },
{ "v1.2.2",
R"(- Added compatibility with v1.18.0 "Community QoL" update
- Fixed an issue with classes not always getting detected correctly for everyone (Debug tab; if you still run into issues, please open a bug report!))" }
- Fixed an issue with classes not always getting detected correctly for everyone (Debug tab; if you still run into issues, please open a bug report!))" },
{ "v1.2.3",
R"(- Fixed co-op issues related to Player and Weapon options, such as God Mode, Player Health, Player Immunity, Weapon Durability sliders not working (if you still run into issues, please open a bug report!)" }
};
}

View File

@ -2,7 +2,6 @@
#include "..\GamePH\GameDI_PH.h"
#include "..\GamePH\LevelDI.h"
#include "..\GamePH\gameph_misc.h"
#include "..\GamePH\gen_TPPModel.h"
#include "..\core.h"
#include "..\menu\camera.h"
#include "..\menu\misc.h"

View File

@ -11,10 +11,6 @@ namespace GamePH {
class LevelDI {
public:
union {
buffer<0x160, PlayerDI_PH*> pPlayerDI_PH;
};
bool IsLoading();
bool IsLoaded();
LPVOID GetViewCamera();

View File

@ -2,12 +2,12 @@
#include "..\buffer.h"
namespace GamePH {
class gen_TPPModel;
class PlayerDI_PH;
class LocalClientDI {
public:
union {
buffer<0x90, gen_TPPModel*> pgen_TPPModel;
buffer<0x90, PlayerDI_PH*> pPlayerDI_PH;
};
static LocalClientDI* Get();

View File

@ -2,17 +2,17 @@
#include "..\offsets.h"
#include "InventoryContainerDI.h"
#include "InventoryItem.h"
#include "LevelDI.h"
#include "LocalClientDI.h"
#include "PlayerDI_PH.h"
namespace GamePH {
PlayerDI_PH* PlayerDI_PH::Get() {
__try {
LevelDI* iLevel = LevelDI::Get();
if (!iLevel)
LocalClientDI* localClient = LocalClientDI::Get();
if (!localClient)
return nullptr;
PlayerDI_PH* ptr = iLevel->pPlayerDI_PH;
PlayerDI_PH* ptr = localClient->pPlayerDI_PH;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
if (*reinterpret_cast<DWORD64**>(ptr) != Offsets::GetVT_PlayerDI_PH())
@ -41,7 +41,6 @@ namespace GamePH {
return nullptr;
}
}
InventoryContainerDI* PlayerDI_PH::GetInventoryContainer() {
__try {
InventoryContainerDI* ptr = reinterpret_cast<InventoryContainerDI*>(*reinterpret_cast<DWORD64*>(reinterpret_cast<DWORD64>(this) + 0x470));

View File

@ -6,6 +6,11 @@
namespace GamePH {
class PlayerDI_PH {
public:
union {
buffer<0x35E1, bool> enableTPPModel1;
buffer<0x35E2, bool> enableTPPModel2;
};
static PlayerDI_PH* Get();
InventoryItem* GetCurrentWeapon(UINT indexMaybe);

View File

@ -1,5 +1,5 @@
#include <pch.h>
#include "LevelDI.h"
#include "PlayerDI_PH.h"
#include "PlayerHealthModule.h"
namespace GamePH {
@ -23,14 +23,14 @@ namespace GamePH {
void PlayerHealthModule::Set(LPVOID instance) { pPlayerHealthModule = reinterpret_cast<PlayerHealthModule*>(instance); }
void PlayerHealthModule::UpdateClassAddr() {
LevelDI* iLevel = LevelDI::Get();
if (!iLevel)
PlayerDI_PH* pPlayerDI_PH = PlayerDI_PH::Get();
if (!pPlayerDI_PH)
return;
if (PlayerHealthModule::Get() && PlayerHealthModule::Get()->pPlayerDI_PH == iLevel->pPlayerDI_PH)
if (PlayerHealthModule::Get() && PlayerHealthModule::Get()->pPlayerDI_PH == pPlayerDI_PH)
return;
for (auto& pPlayerHealthModule : PlayerHealthModule::playerHealthModulePtrList) {
if (pPlayerHealthModule->pPlayerDI_PH == iLevel->pPlayerDI_PH) {
if (pPlayerHealthModule->pPlayerDI_PH == pPlayerDI_PH) {
PlayerHealthModule::Set(pPlayerHealthModule);
PlayerHealthModule::playerHealthModulePtrList.clear();
PlayerHealthModule::playerHealthModulePtrList.emplace_back(pPlayerHealthModule);

View File

@ -1,5 +1,5 @@
#include <pch.h>
#include "LevelDI.h"
#include "PlayerDI_PH.h"
#include "PlayerInfectionModule.h"
namespace GamePH {
@ -23,14 +23,14 @@ namespace GamePH {
void PlayerInfectionModule::Set(LPVOID instance) { pPlayerInfectionModule = reinterpret_cast<PlayerInfectionModule*>(instance); }
void PlayerInfectionModule::UpdateClassAddr() {
LevelDI* iLevel = LevelDI::Get();
if (!iLevel)
PlayerDI_PH* pPlayerDI_PH = PlayerDI_PH::Get();
if (!pPlayerDI_PH)
return;
if (PlayerInfectionModule::Get() && PlayerInfectionModule::Get()->pPlayerDI_PH == iLevel->pPlayerDI_PH)
if (PlayerInfectionModule::Get() && PlayerInfectionModule::Get()->pPlayerDI_PH == pPlayerDI_PH)
return;
for (auto& pPlayerInfectionModule : PlayerInfectionModule::playerInfectionModulePtrList) {
if (pPlayerInfectionModule->pPlayerDI_PH == iLevel->pPlayerDI_PH) {
if (pPlayerInfectionModule->pPlayerDI_PH == pPlayerDI_PH) {
PlayerInfectionModule::Set(pPlayerInfectionModule);
PlayerInfectionModule::playerInfectionModulePtrList.clear();
PlayerInfectionModule::playerInfectionModulePtrList.emplace_back(pPlayerInfectionModule);

View File

@ -11,7 +11,7 @@
#include "LevelDI.h"
#include "PlayerHealthModule.h"
#include "PlayerInfectionModule.h"
#include "gen_TPPModel.h"
#include "PlayerDI_PH.h"
namespace GamePH {
namespace Hooks {
@ -161,20 +161,20 @@ namespace GamePH {
static Utils::Hook::MHook<LPVOID, void(*)(DWORD64, bool)> ShowTPPModelFunc3Hook{ "ShowTPPModelFunc3", &Offsets::Get_ShowTPPModelFunc3, &detourShowTPPModelFunc3 };
static void detourShowTPPModelFunc3(DWORD64 tppFunc2Addr, bool showTPPModel) {
gen_TPPModel* pgen_TPPModel = gen_TPPModel::Get();
if (!pgen_TPPModel) {
PlayerDI_PH* pPlayerDI_PH = PlayerDI_PH::Get();
if (!pPlayerDI_PH) {
ShowTPPModelFunc3Hook.pOriginal(tppFunc2Addr, showTPPModel);
return;
}
if (!showTPPModel && prevUseTPPModel) {
pgen_TPPModel->enableTPPModel2 = true;
pgen_TPPModel->enableTPPModel1 = true;
pPlayerDI_PH->enableTPPModel2 = true;
pPlayerDI_PH->enableTPPModel1 = true;
}
ShowTPPModelFunc3Hook.pOriginal(tppFunc2Addr, showTPPModel);
if (showTPPModel && prevUseTPPModel) {
pgen_TPPModel->enableTPPModel2 = false;
pgen_TPPModel->enableTPPModel1 = false;
pPlayerDI_PH->enableTPPModel2 = false;
pPlayerDI_PH->enableTPPModel1 = false;
} else
prevUseTPPModel = showTPPModel;
}

View File

@ -1,7 +1,7 @@
#include <pch.h>
#include "..\offsets.h"
#include "GameDI_PH.h"
#include "gen_TPPModel.h"
#include "PlayerDI_PH.h"
namespace GamePH {
const DWORD GetCurrentGameVersion() {
@ -59,8 +59,8 @@ namespace GamePH {
void(*pShowTPPModelFunc3)(DWORD64 tppFunc2Addr, bool showTPPModel) = (decltype(pShowTPPModelFunc3))Offsets::Get_ShowTPPModelFunc3();
if (!pShowTPPModelFunc3)
return;
gen_TPPModel* pgen_TPPModel = gen_TPPModel::Get();
if (!pgen_TPPModel)
PlayerDI_PH* pPlayerDI_PH = PlayerDI_PH::Get();
if (!pPlayerDI_PH)
return;
pShowTPPModelFunc3(tppFunc2Addr, showTPPModel);

View File

@ -1,21 +0,0 @@
#include <pch.h>
#include "LocalClientDI.h"
#include "gen_TPPModel.h"
namespace GamePH {
gen_TPPModel* gen_TPPModel::Get() {
__try {
LocalClientDI* pLocalClientDI = LocalClientDI::Get();
if (!pLocalClientDI)
return nullptr;
gen_TPPModel* ptr = pLocalClientDI->pgen_TPPModel;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -1,14 +0,0 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class gen_TPPModel {
public:
union {
buffer<0x35E1, bool> enableTPPModel1;
buffer<0x35E2, bool> enableTPPModel2;
};
static gen_TPPModel* Get();
};
}

View File

@ -5,9 +5,9 @@
#include "..\game\GamePH\FreeCamera.h"
#include "..\game\GamePH\GameDI_PH.h"
#include "..\game\GamePH\LevelDI.h"
#include "..\game\GamePH\PlayerDI_PH.h"
#include "..\game\GamePH\PlayerVariables.h"
#include "..\game\GamePH\gameph_misc.h"
#include "..\game\GamePH\gen_TPPModel.h"
#include "..\offsets.h"
#include "camera.h"
#include "menu.h"
@ -149,8 +149,8 @@ namespace Menu {
if (!iLevel || !iLevel->IsLoaded())
return;
GamePH::gen_TPPModel* pgen_TPPModel = GamePH::gen_TPPModel::Get();
if (pgen_TPPModel) {
GamePH::PlayerDI_PH* pPlayerDI_PH = GamePH::PlayerDI_PH::Get();
if (pPlayerDI_PH) {
if (Menu::Camera::freeCam.GetValue() && !iLevel->IsTimerFrozen())
GamePH::ShowTPPModel(true);
else if (Menu::Camera::freeCam.GetValue() && iLevel->IsTimerFrozen() && !photoMode.GetValue())

View File

@ -16,7 +16,6 @@
#include "..\game\GamePH\SessionCooperativeDI.h"
#include "..\game\GamePH\TPPCameraDI.h"
#include "..\game\GamePH\TimeWeather\CSystem.h"
#include "..\game\GamePH\gen_TPPModel.h"
#include "..\game\Engine\CBulletPhysicsCharacter.h"
#include "..\game\Engine\CGSObject.h"
@ -37,7 +36,6 @@ namespace Menu {
{ "FreeCamera", reinterpret_cast<LPVOID(*)()>(&GamePH::FreeCamera::Get) },
{ "GameDI_PH", reinterpret_cast<LPVOID(*)()>(&GamePH::GameDI_PH::Get) },
{ "GameDI_PH2", reinterpret_cast<LPVOID(*)()>(&GamePH::GameDI_PH2::Get) },
{ "gen_TPPModel", reinterpret_cast<LPVOID(*)()>(&GamePH::gen_TPPModel::Get) },
{ "LevelDI", reinterpret_cast<LPVOID(*)()>(&GamePH::LevelDI::Get) },
{ "LocalClientDI", reinterpret_cast<LPVOID(*)()>(&GamePH::LocalClientDI::Get) },
{ "LogicalPlayer", reinterpret_cast<LPVOID(*)()>(&GamePH::LogicalPlayer::Get) },