]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
snd: fix a hard-to-repro segfault when joining a server
authorbones_was_here <bones_was_here@xonotic.au>
Wed, 7 Feb 2024 15:11:27 +0000 (01:11 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 7 Feb 2024 15:11:27 +0000 (01:11 +1000)
Closes https://gitlab.com/xonotic/darkplaces/-/issues/356

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
snd_main.c

index 53e4da999445bab2e4516f062afe1dcb8d7d0527..821ed7b403dcf955e367bb09ef6e50aab16cf74f 100644 (file)
@@ -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]);