components/prboom/p_setup.c
//
// P_LoadBlockMap
//
// killough 3/1/98: substantially modified to work
// towards removing blockmap limit (a wad limitation)
//
// killough 3/30/98: Rewritten to remove blockmap limit,
// though current algorithm is brute-force and unoptimal.
//
P_LoadBlockMap
killough 3/1/98: substantially modified to work
towards removing blockmap limit (a wad limitation)

killough 3/30/98: Rewritten to remove blockmap limit,
though current algorithm is brute-force and unoptimal.
P_LoadBlockMap killough 3 / 1 / 98 : substantially modified to work towards removing blockmap limit ( a wad limitation ) killough 3 / 30 / 98 : Rewritten to remove blockmap limit though current algorithm is brute - force and unoptimal .
static void P_LoadBlockMap (int lump)
{
  long count;
  if (M_CheckParm("-blockmap") || W_LumpLength(lump)<8 || (count = W_LumpLength(lump)/2) >= 0x10000) 
    P_CreateBlockMap();
  else
    {
      long i;
      const short *wadblockmaplump = W_CacheLumpNum(lump);
      blockmaplump = Z_Malloc(sizeof(*blockmaplump) * count, PU_LEVEL, 0);
      blockmaplump[0] = SHORT(wadblockmaplump[0]);
      blockmaplump[1] = SHORT(wadblockmaplump[1]);
      blockmaplump[2] = (long)(SHORT(wadblockmaplump[2])) & 0xffff;
      blockmaplump[3] = (long)(SHORT(wadblockmaplump[3])) & 0xffff;
      for (i=4 ; i<count ; i++)
        {
          short t = SHORT(wadblockmaplump[i]);          
          blockmaplump[i] = t == -1 ? -1l : (long) t & 0xffff;
        }
      W_UnlockLumpNum(lump); 
      bmaporgx = blockmaplump[0]<<FRACBITS;
      bmaporgy = blockmaplump[1]<<FRACBITS;
      bmapwidth = blockmaplump[2];
      bmapheight = blockmaplump[3];
    }
  blocklinks = Z_Calloc (bmapwidth*bmapheight,sizeof(*blocklinks),PU_LEVEL,0);
  blockmap = blockmaplump+4;
}
static void P_LoadBlockMap ( int lump ) { long count ; if ( M_CheckParm ( " " ) || W_LumpLength ( lump ) < 8 || ( count = W_LumpLength ( lump ) / 2 ) >= 0x10000 ) P_CreateBlockMap ( ) ; else { long i ; const short * wadblockmaplump = W_CacheLumpNum ( lump ) ; blockmaplump = Z_Malloc ( sizeof ( * blockmaplump ) * count , PU_LEVEL , 0 ) ; blockmaplump [ 0 ] = SHORT ( wadblockmaplump [ 0 ] ) ; blockmaplump [ 1 ] = SHORT ( wadblockmaplump [ 1 ] ) ; blockmaplump [ 2 ] = ( long ) ( SHORT ( wadblockmaplump [ 2 ] ) ) & 0xffff ; blockmaplump [ 3 ] = ( long ) ( SHORT ( wadblockmaplump [ 3 ] ) ) & 0xffff ; for ( i = 4 ; i < count ; i ++ ) { short t = SHORT ( wadblockmaplump [ i ] ) ; blockmaplump [ i ] = t == -1 ? -1l : ( long ) t & 0xffff ; } W_UnlockLumpNum ( lump ) ; bmaporgx = blockmaplump [ 0 ] << FRACBITS ; bmaporgy = blockmaplump [ 1 ] << FRACBITS ; bmapwidth = blockmaplump [ 2 ] ; bmapheight = blockmaplump [ 3 ] ; } blocklinks = Z_Calloc ( bmapwidth * bmapheight , sizeof ( * blocklinks ) , PU_LEVEL , 0 ) ; blockmap = blockmaplump + 4 ; }
P_LoadBlockMap
killough 3/1/98: substantially modified to work
towards removing blockmap limit (a wad limitation)
P_LoadBlockMap killough 3 / 1 / 98 : substantially modified to work towards removing blockmap limit ( a wad limitation )
//e6y // cph - const*, wad lump handling updated // killough 3/1/98: Expand wad blockmap into larger internal one, // by treating all offsets except -1 as unsigned and zero-extending // them. This potentially doubles the size of blockmaps allowed, // because Doom originally considered the offsets as always signed. // killough 3/1/98 // cph - unlock the lump // clear out mobj chains - CPhipps - use calloc