From 498d7e0d18060f53a65286fcbf91e772f42c5611 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Wed, 14 Feb 2024 19:23:16 +0700 Subject: [PATCH] Fix crash when the entity with aiment doesn't have a model --- rehlds/engine/sv_main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 14321da..411ca39 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -4904,8 +4904,9 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg) if (entityState.aiment < g_psv.num_edicts) { edict_t *ent = &g_psv.edicts[entityState.aiment]; - if ((ent->v.modelindex >= 0 && ent->v.modelindex < MAX_MODELS) - && g_psv.models[ent->v.modelindex]->type != mod_studio) + 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; } @@ -4915,6 +4916,7 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg) // Prevent spam "Non-sprite set to glow!" in console on client-side if (entityState.rendermode == kRenderGlow && (entityState.modelindex >= 0 && entityState.modelindex < MAX_MODELS) + && g_psv.models[entityState.modelindex] && g_psv.models[entityState.modelindex]->type != mod_sprite) { entityState.rendermode = kRenderNormal;