From 51ecac79a072f9dfb63860ac185cad6a3fdfd2e9 Mon Sep 17 00:00:00 2001 From: WPMGPRoSToTeMa Date: Sat, 10 Dec 2016 03:35:08 +0300 Subject: [PATCH] Fixed animation speed when player has attached entities (https://github.com/WPMGPRoSToTeMa/PatchedGoldSrcClient/issues/7) --- rehlds/engine/server.h | 1 + rehlds/engine/sv_main.cpp | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 3f8f29a..aaf0904 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -538,6 +538,7 @@ extern cvar_t sv_rehlds_force_dlmax; extern cvar_t sv_rehlds_hull_centering; extern cvar_t sv_rcon_condebug; extern cvar_t sv_rehlds_userinfo_transmitted_fields; +extern cvar_t sv_rehlds_attachedentities_playeranimationspeed_fix; #endif extern int sv_playermodel; diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index a7ca5aa..07c2c0f 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -307,6 +307,7 @@ cvar_t syserror_logfile = { "syserror_logfile", "sys_error.log", 0, 0.0f, nullpt cvar_t sv_rehlds_hull_centering = { "sv_rehlds_hull_centering", "0", 0, 0.0f, nullptr }; cvar_t sv_rcon_condebug = { "sv_rcon_condebug", "1", 0, 1.0f, nullptr }; cvar_t sv_rehlds_userinfo_transmitted_fields = { "sv_rehlds_userinfo_transmitted_fields", "", 0, 0.0f, nullptr }; +cvar_t sv_rehlds_attachedentities_playeranimationspeed_fix = {"sv_rehlds_attachedentities_playeranimationspeed_fix", "", 0, 0.0f, nullptr}; #endif delta_t *SV_LookupDelta(char *name) @@ -4518,7 +4519,7 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg) for (e = 1; e <= g_psvs.maxclients; e++) { client_t *cl = &g_psvs.clients[e - 1]; - if( ( !cl->active && !cl->spawned ) || cl->proxy ) + if ((!cl->active && !cl->spawned) || cl->proxy) continue; qboolean add = gEntityInterface.pfnAddToFullPack(&curPack->entities[curPack->num_entities], e, &g_psv.edicts[e], host_client->edict, flags, TRUE, pSet); @@ -4552,6 +4553,32 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg) } +#ifdef REHLDS_FIXES + if (sv_rehlds_attachedentities_playeranimationspeed_fix.value != 0) + { + int attachedEntCount[MAX_CLIENTS + 1] = {}; + for (int i = curPack->num_entities - 1; i >= 0; i--) + { + auto &entityState = curPack->entities[i]; + if (entityState.number > MAX_CLIENTS) + { + if (entityState.movetype == MOVETYPE_FOLLOW + && 1 <= entityState.aiment && entityState.aiment <= MAX_CLIENTS) + { + attachedEntCount[entityState.aiment]++; + } + } + else + { + if (attachedEntCount[entityState.number] != 0) + { + entityState.framerate /= (1 + attachedEntCount[entityState.number]); + } + } + } + } +#endif + //for REHLDS_FIXES: Entities are already in the frame's storage, no need to copy them #ifndef REHLDS_OPT_PEDANTIC SV_AllocPacketEntities(frame, fullpack.num_entities); @@ -7692,6 +7719,7 @@ void SV_Init(void) Cvar_RegisterVariable(&sv_rehlds_hull_centering); Cvar_RegisterVariable(&sv_rcon_condebug); Cvar_RegisterVariable(&sv_rehlds_userinfo_transmitted_fields); + Cvar_RegisterVariable(&sv_rehlds_attachedentities_playeranimationspeed_fix); #endif for (int i = 0; i < MAX_MODELS; i++)