From 954fcc4fae8e18e4cb50a7dfafd9446eb239ec39 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Thu, 8 Feb 2024 01:11:27 +1000 Subject: [PATCH] snd: fix a hard-to-repro segfault when joining a server Closes https://gitlab.com/xonotic/darkplaces/-/issues/356 Signed-off-by: bones_was_here --- snd_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snd_main.c b/snd_main.c index 53e4da99..821ed7b4 100644 --- a/snd_main.c +++ b/snd_main.c @@ -1226,7 +1226,7 @@ static void SND_Spatialize_WithSfx(channel_t *ch, qbool isstatic, sfx_t *sfx) { //Con_Printf("-- entnum %i origin %f %f %f neworigin %f %f %f\n", ch->entnum, ch->origin[0], ch->origin[1], ch->origin[2], cl.entities[ch->entnum].state_current.origin[0], cl.entities[ch->entnum].state_current.origin[1], cl.entities[ch->entnum].state_current.origin[2]); - if (ch->entnum > MAX_EDICTS) + if (CLVM_prog->loaded && ch->entnum > MAX_EDICTS) if (!CL_VM_GetEntitySoundOrigin(ch->entnum, ch->origin)) ch->entnum = MAX_EDICTS; // entity was removed, disown sound } @@ -1240,7 +1240,7 @@ static void SND_Spatialize_WithSfx(channel_t *ch, qbool isstatic, sfx_t *sfx) else Matrix4x4_OriginFromMatrix(&cl.entities[ch->entnum].render.matrix, ch->origin); } - else if (cl.csqc_server2csqcentitynumber[ch->entnum]) + else if (CLVM_prog->loaded && cl.csqc_server2csqcentitynumber[ch->entnum]) { //Con_Printf("-- entnum %i (client %i) origin %f %f %f neworigin %f %f %f\n", ch->entnum, cl.csqc_server2csqcentitynumber[ch->entnum], ch->origin[0], ch->origin[1], ch->origin[2], cl.entities[ch->entnum].state_current.origin[0], cl.entities[ch->entnum].state_current.origin[1], cl.entities[ch->entnum].state_current.origin[2]); -- 2.39.2