Skip to content

Commit

Permalink
Fixed an issue that ragdoll turned into static model in Day of Defeat.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Dec 8, 2024
1 parent 7e5f4a9 commit cc35125
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions Plugins/BulletPhysics/ClientEntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class CClientEntityManager : public IClientEntityManager
m_PlayerDeathState[entindex].bIsDying = false;
m_PlayerDeathState[entindex].flAnimTime = 0;
m_PlayerDeathState[entindex].iSequence = 0;
m_PlayerDeathState[entindex].iBody = 0;
m_PlayerDeathState[entindex].iModelIndex = 0;
memset(m_PlayerDeathState[entindex].szModelName, 0, sizeof(m_PlayerDeathState[entindex].szModelName));
VectorClear(m_PlayerDeathState[entindex].vecAngles);
Expand Down
2 changes: 2 additions & 0 deletions Plugins/BulletPhysics/exportfuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ cvar_t* sv_cheats = NULL;

bool g_bIsSvenCoop = false;
bool g_bIsCounterStrike = false;
bool g_bIsDayOfDefeat = false;

int g_iRagdollRenderEntIndex = 0;
int g_iRagdollRenderFlags = 0;
bool g_bIsUpdatingRefdef = false;
Expand Down
2 changes: 2 additions & 0 deletions Plugins/BulletPhysics/exportfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ extern cl_entity_t** cl_visedicts;
extern float* g_ChromeOrigin;
extern float* r_origin;

extern bool g_bIsSvenCoop;
extern bool g_bIsCounterStrike;
extern bool g_bIsDayOfDefeat;

extern bool g_bIsUpdatingRefdef;

Expand Down
50 changes: 36 additions & 14 deletions Plugins/BulletPhysics/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,47 @@ pfnUserMsgHook m_pfnClCorpse = NULL;

int __MsgFunc_ClCorpse(const char *pszName, int iSize, void *pbuf)
{
vec3_t vOrigin, vAngles;


BEGIN_READ(pbuf, iSize);

auto model = READ_STRING();

char szModel[64] = { 0 };
strncpy(szModel, model, sizeof(szModel));

vOrigin[0] = 0.0078125f * READ_LONG();
vOrigin[1] = 0.0078125f * READ_LONG();
vOrigin[2] = 0.0078125f * READ_LONG();
vAngles[0] = READ_COORD();
vAngles[1] = READ_COORD();
vAngles[2] = READ_COORD();
auto Delay = READ_LONG();
auto Sequence = READ_BYTE();
auto Body = READ_BYTE();
auto TeamID = READ_BYTE();
auto PlayerID = READ_BYTE();
vec3_t vOrigin, vAngles;
int Delay = -1;
int Sequence = -1;
int Body = -1;
int TeamID = -1;
int PlayerID = -1;

//DOD sucks
if (g_bIsDayOfDefeat)
{
vOrigin[0] = READ_COORD();
vOrigin[1] = READ_COORD();
vOrigin[2] = READ_COORD();
vAngles[0] = READ_ANGLE();
vAngles[1] = READ_ANGLE();
vAngles[2] = READ_ANGLE();
Sequence = READ_BYTE();
Body = READ_SHORT();
}
else
{
vOrigin[0] = 0.0078125f * READ_LONG();
vOrigin[1] = 0.0078125f * READ_LONG();
vOrigin[2] = 0.0078125f * READ_LONG();
vAngles[0] = READ_COORD();
vAngles[1] = READ_COORD();
vAngles[2] = READ_COORD();
Delay = READ_LONG();
Sequence = READ_BYTE();
Body = READ_BYTE();
TeamID = READ_BYTE();
PlayerID = READ_BYTE();
}

char szNewModel[64] = { 0 };
CounterStrike_RedirectPlayerModelPath(szModel, PlayerID, TeamID, szNewModel, sizeof(szNewModel));
Expand All @@ -45,7 +67,7 @@ int __MsgFunc_ClCorpse(const char *pszName, int iSize, void *pbuf)
//pev->framerate = 0;
if (PlayerID <= 0 || PlayerID > gEngfuncs.GetMaxClients())
{
g_iCreatingClCorpsePlayerIndex = ClientEntityManager()->FindDyingPlayer(szModel, vOrigin, vAngles, Sequence, Body);
g_iCreatingClCorpsePlayerIndex = ClientEntityManager()->FindDyingPlayer(szNewModel, vOrigin, vAngles, Sequence, Body);
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions Plugins/BulletPhysics/privatehook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,11 @@ void Client_FillAddress(void)
}
}

if (!strcmp(gEngfuncs.pfnGetGameDirectory(), "dod"))
{
g_bIsDayOfDefeat = true;
}

if (!strcmp(gEngfuncs.pfnGetGameDirectory(), "cstrike") || !strcmp(gEngfuncs.pfnGetGameDirectory(), "czero") || !strcmp(gEngfuncs.pfnGetGameDirectory(), "czeror"))
{
g_bIsCounterStrike = true;
Expand Down
1 change: 1 addition & 0 deletions Plugins/BulletPhysics/privatehook.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ extern private_funcs_t gPrivateFuncs;

extern bool g_bIsSvenCoop;
extern bool g_bIsCounterStrike;
extern bool g_bIsDayOfDefeat;

extern ref_params_t r_params;

Expand Down

0 comments on commit cc35125

Please sign in to comment.