diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 768fc04..4578c95 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -66,6 +66,7 @@ float EV_HLDM_PlayTextureSound(int idx, pmtrace_t* ptr, float* vecSrc, float* ve { // hit the world, try to play sound based on texture material type char chTextureType = CHAR_TEX_CONCRETE; + cl_entity_t* cl_entity = NULL; float fvol; float fvolbar; const char* rgsz[4]; @@ -84,12 +85,7 @@ float EV_HLDM_PlayTextureSound(int idx, pmtrace_t* ptr, float* vecSrc, float* ve chTextureType = 0; // Player - if (entity >= 1 && entity <= gEngfuncs.GetMaxClients()) - { - // hit body - chTextureType = CHAR_TEX_FLESH; - } - else if (entity == 0) + if (entity == 0) { // get texture from entity or world (world is ent(0)) pTextureName = (char*)gEngfuncs.pEventAPI->EV_TraceTexture(ptr->ent, vecSrc, vecEnd); @@ -118,6 +114,20 @@ float EV_HLDM_PlayTextureSound(int idx, pmtrace_t* ptr, float* vecSrc, float* ve chTextureType = PM_FindTextureType(szbuffer); } } + else + { + // JoshA: Look up the entity and find the EFLAG_FLESH_SOUND flag. + // This broke at some point then TF:C added prediction. + // + // It used to use Classify of pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE + // to determine what sound to play, but that's server side and isn't available on the client + // and got lost in the translation to that. + // Now the server will replicate that state via an eflag. + cl_entity = gEngfuncs.GetEntityByIndex(entity); + + if (cl_entity && !!(cl_entity->curstate.eflags & EFLAG_FLESH_SOUND)) + chTextureType = CHAR_TEX_FLESH; + } switch (chTextureType) { diff --git a/common/const.h b/common/const.h index 9f6472f..1abfe77 100644 --- a/common/const.h +++ b/common/const.h @@ -117,6 +117,7 @@ // entity flags #define EFLAG_SLERP 1 // do studio interpolation of this entity +#define EFLAG_FLESH_SOUND 2 // JoshA: Whether this entity should sound like flesh. (ie. pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) // // temp entity events diff --git a/dlls/client.cpp b/dlls/client.cpp index 597f1b4..e13b42c 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1418,6 +1418,12 @@ int AddToFullPack(struct entity_state_s* state, int e, edict_t* ent, edict_t* ho state->health = ent->v.health; } + CBaseEntity* pEntity = static_cast(GET_PRIVATE(ent)); + if (pEntity && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) + state->eflags |= EFLAG_FLESH_SOUND; + else + state->eflags &= ~EFLAG_FLESH_SOUND; + return 1; }