2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-27 07:05:43 +03:00

SV_WriteEntitiesToClient: Reset movetype if the aiment index is invalid

This commit is contained in:
s1lentq 2024-02-20 03:18:36 +07:00
parent 498d7e0d18
commit 58391b6ee5

View File

@ -4891,26 +4891,32 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
auto &entityState = curPack->entities[i];
if (entityState.number > MAX_CLIENTS)
{
if (entityState.movetype == MOVETYPE_FOLLOW && entityState.aiment > 0)
if (entityState.movetype == MOVETYPE_FOLLOW)
{
if (sv_rehlds_attachedentities_playeranimationspeed_fix.string[0] == '1' &&
entityState.aiment <= MAX_CLIENTS)
if (entityState.aiment > 0 && entityState.aiment < g_psv.num_edicts)
{
attachedEntCount[entityState.aiment]++;
}
if (sv_rehlds_attachedentities_playeranimationspeed_fix.string[0] == '1' &&
entityState.aiment <= MAX_CLIENTS)
{
attachedEntCount[entityState.aiment]++;
}
// Prevent crash "Cache_UnlinkLRU: NULL link" on client-side
// if aiment with sprite model will be to render as a studio model
if (entityState.aiment < g_psv.num_edicts)
{
// Prevent crash "Cache_UnlinkLRU: NULL link" on client-side
// if aiment with sprite model will be to render as a studio model
edict_t *ent = &g_psv.edicts[entityState.aiment];
if (ent->v.modelindex >= 0 && ent->v.modelindex < MAX_MODELS
&& (!g_psv.models[ent->v.modelindex]
|| g_psv.models[ent->v.modelindex]->type != mod_studio))
{
entityState.aiment = 0;
entityState.movetype = MOVETYPE_NONE;
}
}
else
{
entityState.aiment = 0;
entityState.movetype = MOVETYPE_NONE;
}
}
// Prevent spam "Non-sprite set to glow!" in console on client-side