mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
[qw] Count leafs correctly for PHS
This fixes some out-by-one bugs caused by there being an obo bug in the original SV_CalcPHS: space was being allocated for numleafs leafs, but numleafs does not count the world-surrounding solid leaf 0, but SV_CalcPHS generates pvs and phs data (just the "everything" set) for leaf 0, which is later used for broadcasts and the like.
This commit is contained in:
parent
946867c82e
commit
05fa0538ab
1 changed files with 11 additions and 4 deletions
|
@ -217,12 +217,14 @@ SV_SaveSpawnparms (void)
|
|||
static set_t *
|
||||
sv_alloc_vis_array (unsigned numleafs)
|
||||
{
|
||||
unsigned size = SET_SIZE (numleafs);
|
||||
// the passed in numleafs is the true number of leafs in the map and thus
|
||||
// does include leaf 0, but pvs bits do not include leaf 0
|
||||
unsigned size = SET_SIZE (numleafs - 1);
|
||||
|
||||
if (size > SET_DEFMAP_SIZE * SET_BITS) {
|
||||
set_t *sets = Hunk_Alloc (numleafs * (sizeof (set_t) + size / 8));
|
||||
unsigned words = size / SET_BITS;
|
||||
set_bits_t *bits = (set_bits_t *) (&sets[numleafs] + 1);
|
||||
set_bits_t *bits = (set_bits_t *) (&sets[numleafs]);
|
||||
for (unsigned i = 0; i < numleafs; i++) {
|
||||
sets[i].size = size;
|
||||
sets[i].map = bits;
|
||||
|
@ -230,7 +232,7 @@ sv_alloc_vis_array (unsigned numleafs)
|
|||
}
|
||||
return sets;
|
||||
} else {
|
||||
set_t *sets = Hunk_Alloc (numleafs * (sizeof (set_t) + size / 8));
|
||||
set_t *sets = Hunk_Alloc (numleafs * sizeof (set_t));
|
||||
for (unsigned i = 0; i < numleafs; i++) {
|
||||
sets[i].size = size;
|
||||
sets[i].map = sets[i].defmap;
|
||||
|
@ -252,7 +254,12 @@ SV_CalcPHS (void)
|
|||
int num, i;
|
||||
|
||||
SV_Printf ("Building PHS...\n");
|
||||
num = sv.worldmodel->brush.numleafs;
|
||||
//numleafs does NOT include the world-surrounding solid leaf at
|
||||
//brush.leafs[0], so brush.leafs is actually [0]..[numleafs]
|
||||
//however, pvs bits also do not include leaf 0 as it should not be
|
||||
//able to see anything (but instead sees everything)
|
||||
//FIXME make numleafs actual number of leafs?
|
||||
num = sv.worldmodel->brush.numleafs + 1;
|
||||
|
||||
sv.pvs = sv_alloc_vis_array (num);
|
||||
vcount = 0;
|
||||
|
|
Loading…
Reference in a new issue