From 7aae740983238044ce9104e3a50f130bc753462b Mon Sep 17 00:00:00 2001 From: Justin <95296300+Toodles2You@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:20:58 -0700 Subject: [PATCH] Fix weapon events not treating pushable objects as BSP models --- CHANGELOG.md | 1 + FULL_UPDATED_CHANGELOG.md | 1 + cl_dll/ev_hldm.cpp | 29 ++++++++++++++++------------- cl_dll/hud.cpp | 2 ++ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8040a16c2..a35d1b7f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Fixed potential buffer overflows in text localization (Thanks OMAM) * Reset frame to 0 when grenade bounces [#238](https://github.com/twhl-community/halflife-updated/issues/238) (thanks FreeSlave) +* Fix weapon events not treating pushable objects as BSP models [#220](https://github.com/twhl-community/halflife-updated/pull/220) (Thanks Toodles2You) ## Changes in V1.0.0 diff --git a/FULL_UPDATED_CHANGELOG.md b/FULL_UPDATED_CHANGELOG.md index c9995625a..2b12c34d5 100644 --- a/FULL_UPDATED_CHANGELOG.md +++ b/FULL_UPDATED_CHANGELOG.md @@ -43,6 +43,7 @@ Fixes for bugs introduced in beta builds are not included in this list. * Fixed player weapons still receiving input when starting to use a func_tank (halflife issue [#3345](https://github.com/ValveSoftware/halflife/issues/3345)) (Thanks Oxofemple.) * Fixed limit in world weapons (e.g. Hand Grenade) respawning at wrong time if server is near edict limit * Disabled fall think function for weapons when the player picks it up to prevent possible double-pickup which removes the weapon and crashes the game +* Fix weapon events not treating pushable objects as BSP models [#220](https://github.com/twhl-community/halflife-updated/pull/220) (Thanks Toodles2You) ### Crowbar diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 38efd2f05..768fc04e0 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -52,6 +52,12 @@ void V_PunchAxis(int axis, float punch); void VectorAngles(const float* forward, float* angles); extern cvar_t* cl_lw; +extern cvar_t* r_decals; + +static inline bool EV_HLDM_IsBSPModel(physent_t* pe) +{ + return pe != nullptr && (pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP); +} // play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the // original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture. @@ -209,6 +215,9 @@ char* EV_HLDM_DamageDecal(physent_t* pe) static char decalname[32]; int idx; + if (pe->rendermode == kRenderTransAlpha) + return nullptr; + if (pe->classnumber == 1) { idx = gEngfuncs.pfnRandomLong(0, 2); @@ -229,7 +238,6 @@ char* EV_HLDM_DamageDecal(physent_t* pe) void EV_HLDM_GunshotDecalTrace(pmtrace_t* pTrace, char* decalName) { int iRand; - physent_t* pe; gEngfuncs.pEfxAPI->R_BulletImpactParticles(pTrace->endpos); @@ -256,17 +264,12 @@ void EV_HLDM_GunshotDecalTrace(pmtrace_t* pTrace, char* decalName) } } - pe = gEngfuncs.pEventAPI->EV_GetPhysent(pTrace->ent); - // Only decal brush models such as the world etc. - if (decalName && '\0' != decalName[0] && pe && (pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP)) + if (decalName && '\0' != decalName[0] && r_decals->value > 0) { - if (CVAR_GET_FLOAT("r_decals")) - { - gEngfuncs.pEfxAPI->R_DecalShoot( - gEngfuncs.pEfxAPI->Draw_DecalIndex(gEngfuncs.pEfxAPI->Draw_DecalIndexFromName(decalName)), - gEngfuncs.pEventAPI->EV_IndexFromTrace(pTrace), 0, pTrace->endpos, 0); - } + gEngfuncs.pEfxAPI->R_DecalShoot( + gEngfuncs.pEfxAPI->Draw_DecalIndex(gEngfuncs.pEfxAPI->Draw_DecalIndexFromName(decalName)), + gEngfuncs.pEventAPI->EV_IndexFromTrace(pTrace), 0, pTrace->endpos, 0); } } @@ -276,7 +279,7 @@ void EV_HLDM_DecalGunshot(pmtrace_t* pTrace, int iBulletType) pe = gEngfuncs.pEventAPI->EV_GetPhysent(pTrace->ent); - if (pe && pe->solid == SOLID_BSP) + if (EV_HLDM_IsBSPModel(pe)) { switch (iBulletType) { @@ -926,7 +929,7 @@ void EV_FireGauss(event_args_t* args) if (pEntity == NULL) break; - if (pEntity->solid == SOLID_BSP) + if (EV_HLDM_IsBSPModel(pEntity)) { float n; @@ -1177,7 +1180,7 @@ void EV_FireCrossbow2(event_args_t* args) physent_t* pe = gEngfuncs.pEventAPI->EV_GetPhysent(tr.ent); //Not the world, let's assume we hit something organic ( dog, cat, uncle joe, etc ). - if (pe->solid != SOLID_BSP) + if (!EV_HLDM_IsBSPModel(pe)) { switch (gEngfuncs.pfnRandomLong(0, 1)) { diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 415cd6648..6aca7a65b 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -85,6 +85,7 @@ cvar_t* cl_lw = NULL; cvar_t* cl_rollangle = nullptr; cvar_t* cl_rollspeed = nullptr; cvar_t* cl_bobtilt = nullptr; +cvar_t* r_decals = nullptr; void ShutdownInput(); @@ -334,6 +335,7 @@ void CHud::Init() cl_rollangle = CVAR_CREATE("cl_rollangle", "2.0", FCVAR_ARCHIVE); cl_rollspeed = CVAR_CREATE("cl_rollspeed", "200", FCVAR_ARCHIVE); cl_bobtilt = CVAR_CREATE("cl_bobtilt", "0", FCVAR_ARCHIVE); + r_decals = gEngfuncs.pfnGetCvarPointer("r_decals"); m_pSpriteList = NULL;