Add server movehelper to SDK

Initial implementation of server movehelper. IMoveHelper interface class is fully reversed and aligns with implementation in engine. CMoveHelperServer is also reversed, excect for CGameTrace, though this isn't necessary for now.
This commit is contained in:
Kawe Mazidjatari 2023-01-19 18:52:46 +01:00
parent afe8efbc2a
commit 754c986e3d
10 changed files with 179 additions and 0 deletions

View File

@ -108,6 +108,7 @@
#include "game/server/detour_impl.h"
#include "game/server/fairfight_impl.h"
#include "game/server/gameinterface.h"
#include "game/server/movehelper_server.h"
#endif // !CLIENT_DLL
#ifndef DEDICATED
#include "game/client/viewrender.h"

View File

@ -0,0 +1,18 @@
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "core/stdafx.h"
#include "movehelper_server.h"
//-----------------------------------------------------------------------------
// Purpose: Gets the server movehelper
//-----------------------------------------------------------------------------
IMoveHelper* MoveHelperServer()
{
return s_MoveHelperServer;
}
CMoveHelperServer* s_MoveHelperServer = nullptr;

View File

@ -0,0 +1,54 @@
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef MOVEHELPER_SERVER_H
#define MOVEHELPER_SERVER_H
#include "game/shared/imovehelper.h"
#include "tier1/utlvector.h"
class CMoveHelperServer : public IMoveHelper
{
CBaseEntity* m_pHost;
// results, tallied on client and server, but only used by server to run SV_Impact.
// we store off our velocity in the trace_t structure so that we can determine results
// of shoving boxes etc. around.
struct touchlist_t
{
Vector3D deltavelocity;
//trace_t trace; // !TODO: Reverse CGameTrace!
};
CUtlVector<touchlist_t> m_TouchList;
};
IMoveHelper* MoveHelperServer();
extern CMoveHelperServer* s_MoveHelperServer;
///////////////////////////////////////////////////////////////////////////////
class VMoveHelperServer : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: s_MoveHelperServer : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_MoveHelperServer));
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const { }
virtual void GetVar(void) const
{
CMemory pFunc = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 85 C0 0F 84 ?? ?? ?? ?? 48 8B 47 10").FollowNearCallSelf();
s_MoveHelperServer = pFunc.FindPattern("48 8D 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CMoveHelperServer*>();
}
virtual void GetCon(void) const { }
virtual void Attach(void) const { }
virtual void Detach(void) const { }
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(VMoveHelperServer);
#endif // MOVEHELPER_SERVER_H

View File

@ -0,0 +1,78 @@
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IMOVEHELPER_H
#define IMOVEHELPER_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/annotations.h"
#include "public/baseentity.h"
typedef CBaseHandle EntityHandle_t;
class IPhysicsSurfaceProps; // !TODO: reverse vtable.
//-----------------------------------------------------------------------------
// Functions the engine provides to IGameMovement to assist in its movement.
//-----------------------------------------------------------------------------
abstract_class IMoveHelper
{
public:
// Call this to set the singleton
static IMoveHelper * GetSingleton() { return sm_pSingleton; }
// Methods associated with a particular entity
virtual char const* GetName(EntityHandle_t handle) const = 0;
// sets the entity being moved
virtual void SetHost(CBaseEntity* host) = 0;
virtual CBaseEntity* GetHost(void) = 0;
virtual void ResetTouchList(void) = 0;
virtual bool AddToTouched(const /*CGameTrace&*/void* tr, const Vector3D& impactvelocity) = 0;
// Adds the trace result to touch list, if contact is not already in list.
virtual void ProcessImpacts(void) = 0;
// Numbered line printf
virtual void Con_NPrintf(int idx, PRINTF_FORMAT_STRING char const* fmt, ...) = 0;
virtual IPhysicsSurfaceProps* GetSurfaceProps(void) = 0;
virtual bool IsWorldEntity(const CBaseHandle& handle) = 0;
// These has separate server vs client implementations
virtual void StartSound(const Vector3D& origin, const char* soundname) = 0;
protected:
// Inherited classes can call this to set the singleton
static void SetSingleton(IMoveHelper* pMoveHelper) { sm_pSingleton = pMoveHelper; }
// The global instance
static IMoveHelper* sm_pSingleton;
};
//-----------------------------------------------------------------------------
// Add this to the CPP file that implements the IMoveHelper
//-----------------------------------------------------------------------------
#define IMPLEMENT_MOVEHELPER() \
IMoveHelper* IMoveHelper::sm_pSingleton = 0
//-----------------------------------------------------------------------------
// Call this to set the singleton
//-----------------------------------------------------------------------------
inline IMoveHelper* MoveHelper()
{
return IMoveHelper::GetSingleton();
}
#endif // IMOVEHELPER_H

View File

@ -236,6 +236,7 @@
<ClInclude Include="..\game\shared\collisionproperty.h" />
<ClInclude Include="..\game\shared\ehandle.h" />
<ClInclude Include="..\game\shared\entitylist_base.h" />
<ClInclude Include="..\game\shared\imovehelper.h" />
<ClInclude Include="..\game\shared\playernet_vars.h" />
<ClInclude Include="..\game\shared\predictioncopy.h" />
<ClInclude Include="..\game\shared\shareddefs.h" />

View File

@ -1934,6 +1934,9 @@
<ClInclude Include="..\game\shared\usercmd.h">
<Filter>sdk\game\shared</Filter>
</ClInclude>
<ClInclude Include="..\game\shared\imovehelper.h">
<Filter>sdk\game\shared</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">

View File

@ -185,6 +185,7 @@
<ClInclude Include="..\game\server\detour_impl.h" />
<ClInclude Include="..\game\server\fairfight_impl.h" />
<ClInclude Include="..\game\server\gameinterface.h" />
<ClInclude Include="..\game\server\movehelper_server.h" />
<ClInclude Include="..\game\server\networkproperty.h" />
<ClInclude Include="..\game\server\player.h" />
<ClInclude Include="..\game\server\playerlocaldata.h" />
@ -192,6 +193,7 @@
<ClInclude Include="..\game\shared\collisionproperty.h" />
<ClInclude Include="..\game\shared\ehandle.h" />
<ClInclude Include="..\game\shared\entitylist_base.h" />
<ClInclude Include="..\game\shared\imovehelper.h" />
<ClInclude Include="..\game\shared\playernet_vars.h" />
<ClInclude Include="..\game\shared\predictioncopy.h" />
<ClInclude Include="..\game\shared\shareddefs.h" />
@ -552,6 +554,7 @@
<ClCompile Include="..\game\server\ai_networkmanager.cpp" />
<ClCompile Include="..\game\server\ai_utility.cpp" />
<ClCompile Include="..\game\server\gameinterface.cpp" />
<ClCompile Include="..\game\server\movehelper_server.cpp" />
<ClCompile Include="..\game\server\networkproperty.cpp" />
<ClCompile Include="..\game\server\player.cpp" />
<ClCompile Include="..\game\shared\animation.cpp" />

View File

@ -1365,6 +1365,12 @@
<ClInclude Include="..\game\shared\usercmd.h">
<Filter>sdk\game\shared</Filter>
</ClInclude>
<ClInclude Include="..\game\server\movehelper_server.h">
<Filter>sdk\game\server</Filter>
</ClInclude>
<ClInclude Include="..\game\shared\imovehelper.h">
<Filter>sdk\game\shared</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\opcodes.cpp">
@ -1721,6 +1727,9 @@
<ClCompile Include="..\public\baseentity.cpp">
<Filter>sdk\public</Filter>
</ClCompile>
<ClCompile Include="..\game\server\movehelper_server.cpp">
<Filter>sdk\game\server</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\Dedicated.def" />

View File

@ -69,6 +69,7 @@
<ClCompile Include="..\game\server\ai_networkmanager.cpp" />
<ClCompile Include="..\game\server\ai_utility.cpp" />
<ClCompile Include="..\game\server\gameinterface.cpp" />
<ClCompile Include="..\game\server\movehelper_server.cpp" />
<ClCompile Include="..\game\server\networkproperty.cpp" />
<ClCompile Include="..\game\server\player.cpp" />
<ClCompile Include="..\game\shared\ai_utility_shared.cpp" />
@ -260,6 +261,7 @@
<ClInclude Include="..\game\server\detour_impl.h" />
<ClInclude Include="..\game\server\fairfight_impl.h" />
<ClInclude Include="..\game\server\gameinterface.h" />
<ClInclude Include="..\game\server\movehelper_server.h" />
<ClInclude Include="..\game\server\networkproperty.h" />
<ClInclude Include="..\game\server\player.h" />
<ClInclude Include="..\game\server\playerlocaldata.h" />
@ -268,6 +270,7 @@
<ClInclude Include="..\game\shared\collisionproperty.h" />
<ClInclude Include="..\game\shared\ehandle.h" />
<ClInclude Include="..\game\shared\entitylist_base.h" />
<ClInclude Include="..\game\shared\imovehelper.h" />
<ClInclude Include="..\game\shared\playernet_vars.h" />
<ClInclude Include="..\game\shared\predictioncopy.h" />
<ClInclude Include="..\game\shared\shareddefs.h" />

View File

@ -711,6 +711,9 @@
<ClCompile Include="..\public\baseentity.cpp">
<Filter>sdk\public</Filter>
</ClCompile>
<ClCompile Include="..\game\server\movehelper_server.cpp">
<Filter>sdk\game\server</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -2078,6 +2081,12 @@
<ClInclude Include="..\game\shared\usercmd.h">
<Filter>sdk\game\shared</Filter>
</ClInclude>
<ClInclude Include="..\game\server\movehelper_server.h">
<Filter>sdk\game\server</Filter>
</ClInclude>
<ClInclude Include="..\game\shared\imovehelper.h">
<Filter>sdk\game\shared</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">