components/prboom/p_setup.c
//
// P_LoadReject - load the reject table, padding it if it is too short
// totallines must be the number returned by P_GroupLines()
// an underflow will be padded with zeroes, or a doom.exe z_zone header
// 
// this function incorporates e6y's RejectOverrunAddInt code:
// e6y: REJECT overrun emulation code
// It's emulated successfully if the size of overflow no more than 16 bytes.
// No more desync on teeth-32.wad\teeth-32.lmp.
// http://www.doomworld.com/vb/showthread.php?s=&threadid=35214
load the reject table, padding it if it is too short
totallines must be the number returned by P_GroupLines()
an underflow will be padded with zeroes, or a doom.exe z_zone header

this function incorporates e6y's RejectOverrunAddInt code:
e6y: REJECT overrun emulation code
It's emulated successfully if the size of overflow no more than 16 bytes.
load the reject table padding it if it is too short totallines must be the number returned by P_GroupLines () an underflow will be padded with zeroes or a doom . exe z_zone header this function incorporates e6y ' s RejectOverrunAddInt code : e6y : REJECT overrun emulation code It ' s emulated successfully if the size of overflow no more than 16 bytes .
static void P_LoadReject(int lumpnum, int totallines)
{
  unsigned int length, required;
  byte *newreject;
  if (rejectlump != -1)
    W_UnlockLumpNum(rejectlump);
  rejectlump = lumpnum + ML_REJECT;
  rejectmatrix = W_CacheLumpNum(rejectlump);
  required = (numsectors * numsectors + 7) / 8;
  length = W_LumpLength(rejectlump);
  if (length >= required)
    return; 
  newreject = Z_Malloc(required, PU_LEVEL, NULL);
  rejectmatrix = (const byte *)memmove(newreject, rejectmatrix, length);
  memset(newreject + length, 0, required - length);
  W_UnlockLumpNum(rejectlump);
  rejectlump = -1;
  if (demo_compatibility)
  {
    unsigned int rejectpad[4] = {
      0,        
      0,        
      50,       
      0x1d4a11  
    };
    unsigned int i, pad = 0, *src = rejectpad;
    byte *dest = newreject + length;
    rejectpad[0] = ((totallines*4+3)&~3)+24; 
    for (i = 0; i < required - length && i < 16; i++) { 
      if (!(i&3)) 
        pad = *src++;
      *dest++ = pad & 0xff; 
      pad >>= 8; 
    }
  }
  lprintf(LO_WARN, "P_LoadReject: REJECT too short (%u<%u) - padded\n",
          length, required);
}
static void P_LoadReject ( int lumpnum , int totallines ) { unsigned int length , required ; byte * newreject ; if ( rejectlump != -1 ) W_UnlockLumpNum ( rejectlump ) ; rejectlump = lumpnum + ML_REJECT ; rejectmatrix = W_CacheLumpNum ( rejectlump ) ; required = ( numsectors * numsectors + 7 ) / 8 ; length = W_LumpLength ( rejectlump ) ; if ( length >= required ) return ; newreject = Z_Malloc ( required , PU_LEVEL , NULL ) ; rejectmatrix = ( const byte * ) memmove ( newreject , rejectmatrix , length ) ; memset ( newreject + length , 0 , required - length ) ; W_UnlockLumpNum ( rejectlump ) ; rejectlump = -1 ; if ( demo_compatibility ) { unsigned int rejectpad [ 4 ] = { 0 , 0 , 50 , 0x1d4a11 } ; unsigned int i , pad = 0 , * src = rejectpad ; byte * dest = newreject + length ; rejectpad [ 0 ] = ( ( totallines * 4 + 3 ) & ~ 3 ) + 24 ; for ( i = 0 ; i < required - length && i < 16 ; i ++ ) { if ( ! ( i & 3 ) ) pad = * src ++ ; * dest ++ = pad & 0xff ; pad >>= 8 ; } } lprintf ( LO_WARN , " \n " , length , required ) ; }
P_LoadReject - load the reject table, padding it if it is too short
totallines must be the number returned by P_GroupLines()
an underflow will be padded with zeroes, or a doom.exe z_zone header
P_LoadReject - load the reject table padding it if it is too short totallines must be the number returned by P_GroupLines () an underflow will be padded with zeroes or a doom . exe z_zone header
// dump any old cached reject lump, then cache the new one // nothing to do // allocate a new block and copy the reject table into it; zero the rest // PU_LEVEL => will be freed on level exit // unlock the original lump, it is no longer needed // merged in RejectOverrunAddInt(), and the 4 calls to it, here // size, will be filled in using totallines // part of the header of a doom.exe z_zone block // DOOM_CONST_PU_LEVEL // DOOM_CONST_ZONEID // doom.exe zone header size // copy at most 16 bytes from rejectpad // emulating a 32-bit, little-endian architecture (can't memmove) // 16 hard-coded // get the next 4 bytes to copy when i=0,4,8,12 // store lowest-significant byte // rotate the next byte down