mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fix persistence state for s0/s1 builds
CVEngineServer::IsPersistenceAvailable() is inline with Persistence_SetXP in S0 and S1. the virtual function never gets fired. The approach for S0/S1 will call CVEngineServer::IsPersistenceAvailable() when Persistence_SetXP() is ran (the first function to ever use pClient->m_nPersistenceState after the SendServerInfo query).
This commit is contained in:
parent
c4977a39aa
commit
e14934d244
@ -23,5 +23,9 @@ enum class PERSISTENCE : int
|
||||
PERSISTENCE_NONE = 0, // no persistence data for this client yet.
|
||||
PERSISTENCE_PENDING = 1, // pending or processing persistence data.
|
||||
PERSISTENCE_AVAILABLE = 2, // persistence is available for this client.
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
|
||||
PERSISTENCE_READY = 3 // persistence is ready for this client.
|
||||
#else
|
||||
PERSISTENCE_READY = 5 // persistence is ready for this client.
|
||||
#endif
|
||||
};
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "client/vengineclient_impl.h"
|
||||
#ifndef CLIENT_DLL
|
||||
#include "engine/server/server.h"
|
||||
#include "server/persistence.h"
|
||||
#include "server/vengineserver_impl.h"
|
||||
#endif // !CLIENT_DLL
|
||||
#include "squirrel/sqinit.h"
|
||||
@ -188,6 +189,7 @@ void Systems_Init()
|
||||
CKeyValueSystem_Attach();
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
Persistence_Attach();
|
||||
IVEngineServer_Attach();
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
@ -309,6 +311,7 @@ void Systems_Shutdown()
|
||||
CKeyValueSystem_Detach();
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
Persistence_Detach();
|
||||
IVEngineServer_Detach();
|
||||
#endif // !CLIENT_DLL
|
||||
SQAPI_Detach();
|
||||
|
24
r5dev/server/persistence.cpp
Normal file
24
r5dev/server/persistence.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "core/stdafx.h"
|
||||
#include "server/vengineserver_impl.h"
|
||||
#include "server/persistence.h"
|
||||
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
bool Persistence_SetXP(int a1, int* a2)
|
||||
{
|
||||
HIVEngineServer__PersistenceAvailable(nullptr, a1);
|
||||
return v_Persistence_SetXP(a1, a2);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Persistence_Attach()
|
||||
{
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
DetourAttach((LPVOID*)&v_Persistence_SetXP, &Persistence_SetXP);
|
||||
#endif
|
||||
}
|
||||
void Persistence_Detach()
|
||||
{
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
DetourDetach((LPVOID*)&v_Persistence_SetXP, &Persistence_SetXP);
|
||||
#endif
|
||||
}
|
37
r5dev/server/persistence.h
Normal file
37
r5dev/server/persistence.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef PERSISTENCE_H
|
||||
#define PERSISTENCE_H
|
||||
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
inline CMemory p_Persistence_SetXP;
|
||||
inline auto v_Persistence_SetXP = p_Persistence_SetXP.RCast<bool (*)(int a1, int* a2)>();
|
||||
#endif
|
||||
|
||||
void Persistence_Attach();
|
||||
void Persistence_Detach();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class VPersistence : public IDetour
|
||||
{
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
spdlog::debug("| FUN: Persistence_SetXP : {:#18x} |\n", p_Persistence_SetXP.GetPtr());
|
||||
spdlog::debug("+----------------------------------------------------------------+\n");
|
||||
#endif
|
||||
}
|
||||
virtual void GetFun(void) const
|
||||
{
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
p_Persistence_SetXP = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x33\xFF\x48\x8B\xF2\x3B\x0D\x00\x00\x00\x00"), "xxxx?xxxx?xxxxxxxxxxxx????");
|
||||
v_Persistence_SetXP = p_Persistence_SetXP.RCast<bool (*)(int a1, int* a2)>(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 33 FF 48 8B F2 3B 0D ?? ?? ?? ??*/
|
||||
#endif
|
||||
}
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetCon(void) const { }
|
||||
virtual void Attach(void) const { }
|
||||
virtual void Detach(void) const { }
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
REGISTER(VPersistence);
|
||||
#endif // PERSISTENCE_H
|
@ -231,6 +231,7 @@
|
||||
<ClInclude Include="..\rtech\rtech_game.h" />
|
||||
<ClInclude Include="..\rtech\rui\rui.h" />
|
||||
<ClInclude Include="..\rtech\stryder\stryder.h" />
|
||||
<ClInclude Include="..\server\persistence.h" />
|
||||
<ClInclude Include="..\server\vengineserver_impl.h" />
|
||||
<ClInclude Include="..\squirrel\sqapi.h" />
|
||||
<ClInclude Include="..\squirrel\sqinit.h" />
|
||||
@ -523,6 +524,7 @@
|
||||
<ClCompile Include="..\rtech\rtech_utils.cpp" />
|
||||
<ClCompile Include="..\rtech\rtech_game.cpp" />
|
||||
<ClCompile Include="..\rtech\stryder\stryder.cpp" />
|
||||
<ClCompile Include="..\server\persistence.cpp" />
|
||||
<ClCompile Include="..\server\vengineserver_impl.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqapi.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqinit.cpp" />
|
||||
|
@ -1167,6 +1167,9 @@
|
||||
<ClInclude Include="..\mathlib\transform.h">
|
||||
<Filter>sdk\mathlib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\server\persistence.h">
|
||||
<Filter>sdk\server</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\opcodes.cpp">
|
||||
@ -1466,6 +1469,9 @@
|
||||
<ClCompile Include="..\tier0\threadtools.cpp">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\server\persistence.cpp">
|
||||
<Filter>sdk\server</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Dedicated.def" />
|
||||
|
@ -98,6 +98,7 @@
|
||||
<ClCompile Include="..\rtech\rtech_game.cpp" />
|
||||
<ClCompile Include="..\rtech\rui\rui.cpp" />
|
||||
<ClCompile Include="..\rtech\stryder\stryder.cpp" />
|
||||
<ClCompile Include="..\server\persistence.cpp" />
|
||||
<ClCompile Include="..\server\vengineserver_impl.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqapi.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqinit.cpp" />
|
||||
@ -274,6 +275,7 @@
|
||||
<ClInclude Include="..\rtech\rtech_game.h" />
|
||||
<ClInclude Include="..\rtech\rui\rui.h" />
|
||||
<ClInclude Include="..\rtech\stryder\stryder.h" />
|
||||
<ClInclude Include="..\server\persistence.h" />
|
||||
<ClInclude Include="..\server\vengineserver_impl.h" />
|
||||
<ClInclude Include="..\squirrel\sqapi.h" />
|
||||
<ClInclude Include="..\squirrel\sqinit.h" />
|
||||
|
@ -591,6 +591,9 @@
|
||||
<ClCompile Include="..\tier0\threadtools.cpp">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\server\persistence.cpp">
|
||||
<Filter>sdk\server</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1688,6 +1691,9 @@
|
||||
<ClInclude Include="..\mathlib\transform.h">
|
||||
<Filter>sdk\mathlib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\server\persistence.h">
|
||||
<Filter>sdk\server</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
Loading…
x
Reference in New Issue
Block a user