Added P_LoadReject function to properly check if REJECT lump is valid or not when loading it, so P_CheckSight can avoid accessing it if not.

This should mean that maps built with ZBSDP (no reject) should have less or no problems in netgames compared to the standard ZenNode maps now, hopefully. =)
This commit is contained in:
Monster Iestyn 2016-06-11 18:45:56 +01:00
parent df92dc8d9e
commit a7a7a7ee6d
2 changed files with 32 additions and 4 deletions

View File

@ -1977,6 +1977,31 @@ static void P_GroupLines(void)
}
}
//
// P_LoadReject
//
// Detect if the REJECT lump is valid,
// if not, rejectmatrix will be NULL
static void P_LoadReject(lumpnum_t lumpnum)
{
size_t count;
const char *lumpname = W_CheckNameForNum(lumpnum);
// Check if the lump exists, and if it's named "REJECT"
if (!lumpname || memcmp(lumpname, "REJECT", 8) != 0)
{
rejectmatrix = NULL;
return;
}
count = W_LumpLength(lumpnum);
if (!count) // zero length, someone probably used ZDBSP
rejectmatrix = NULL;
else
rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL);
}
#if 0
static char *levellumps[] =
{
@ -2585,7 +2610,7 @@ boolean P_SetupLevel(boolean skipprecip)
P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS);
P_LoadNodes(lastloadedmaplumpnum + ML_NODES);
P_LoadSegs(lastloadedmaplumpnum + ML_SEGS);
rejectmatrix = W_CacheLumpNum(lastloadedmaplumpnum + ML_REJECT, PU_LEVEL);
P_LoadReject(lastloadedmaplumpnum + ML_REJECT);
P_GroupLines();
numdmstarts = numredctfstarts = numbluectfstarts = 0;

View File

@ -325,9 +325,12 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
s2 = t2->subsector->sector;
pnum = (s1-sectors)*numsectors + (s2-sectors);
// Check in REJECT table.
if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected
return false;
if (rejectmatrix != NULL)
{
// Check in REJECT table.
if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected
return false;
}
// killough 11/98: shortcut for melee situations
// same subsector? obviously visible