diff --git a/src/p_setup.c b/src/p_setup.c index b0dd72996..45a5442ff 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2162,6 +2162,30 @@ static void P_LoadReject(lumpnum_t lumpnum) rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); } +// PK3 version +// -- Monster Iestyn 09/01/18 +static void P_LoadRawReject(UINT8 *data, size_t count, const char *lumpname) +{ + // Check if the lump is named "REJECT" + if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) + { + rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadRawReject: No valid REJECT lump found\n"); + return; + } + + if (!count) // zero length, someone probably used ZDBSP + { + rejectmatrix = NULL; + CONS_Debug(DBG_SETUP, "P_LoadRawReject: REJECT lump has size 0, will not be loaded\n"); + } + else + { + rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix + M_Memcpy(rejectmatrix, data, count); // copy the data into it + } +} + #if 0 static char *levellumps[] = { @@ -2848,7 +2872,10 @@ boolean P_SetupLevel(boolean skipprecip) P_LoadRawSegs(wadData + (fileinfo + ML_SEGS)->filepos, (fileinfo + ML_SEGS)->size); if (numlumps > ML_REJECT) // enough room for a REJECT lump at least { - // placeholder + P_LoadRawReject( + wadData + (fileinfo + ML_REJECT)->filepos, + (fileinfo + ML_REJECT)->size, + (fileinfo + ML_REJECT)->name); } // Important: take care of the ordering of the next functions.