diff --git a/src/server/sv_game.c b/src/server/sv_game.c index 973d56f3..702f4ec5 100644 --- a/src/server/sv_game.c +++ b/src/server/sv_game.c @@ -293,7 +293,10 @@ PF_inPVS(vec3_t p1, vec3_t p2) cluster = CM_LeafCluster(leafnum); area2 = CM_LeafArea(leafnum); - if (mask && (!(mask[cluster >> 3] & (1 << (cluster & 7))))) + // cluster -1 means "not in a visible leaf" or something like that (void?) + // so p1 and p2 probably don't "see" each other. + // either way, we must avoid using a negative index into mask[]! + if (cluster < 0 || (!(mask[cluster >> 3] & (1 << (cluster & 7))))) { return false; } @@ -326,7 +329,10 @@ PF_inPHS(vec3_t p1, vec3_t p2) cluster = CM_LeafCluster(leafnum); area2 = CM_LeafArea(leafnum); - if (mask && (!(mask[cluster >> 3] & (1 << (cluster & 7))))) + // cluster -1 means "not in a visible leaf" or something like that (void?) + // so p1 and p2 probably don't "hear" each other. + // either way, we must avoid using a negative index into mask[]! + if (cluster < 0 || (!(mask[cluster >> 3] & (1 << (cluster & 7))))) { return false; /* more than one bounce away */ } diff --git a/src/server/sv_send.c b/src/server/sv_send.c index da375077..8b934dd0 100644 --- a/src/server/sv_send.c +++ b/src/server/sv_send.c @@ -227,7 +227,9 @@ SV_Multicast(vec3_t origin, multicast_t to) continue; } - if (!(mask[cluster >> 3] & (1 << (cluster & 7)))) + // cluster can be -1 if we're in the void (or sometime just at a wall) + // and using a negative index into mask[] would be invalid + if (cluster < 0 || !(mask[cluster >> 3] & (1 << (cluster & 7)))) { continue; }