components/prboom/p_setup.c
// modified to return totallines (needed by P_LoadReject)
modified to return totallines (needed by P_LoadReject)
modified to return totallines ( needed by P_LoadReject )
static int P_GroupLines (void)
{
  line_t *li;
  sector_t *sector;
  int i,j, total = numlines;
  for (i=0 ; i<numsubsectors ; i++)
  {
    seg_t *seg = &segs[subsectors[i].firstline];
    subsectors[i].sector = NULL;
    for(j=0; j<subsectors[i].numlines; j++)
    {
      if(seg->sidedef)
      {
        subsectors[i].sector = seg->sidedef->sector;
        break;
      }
      seg++;
    }
    if(subsectors[i].sector == NULL)
      I_Error("P_GroupLines: Subsector a part of no sector!\n");
  }
  for (i=0,li=lines; i<numlines; i++, li++)
    {
      li->frontsector->linecount++;
      if (li->backsector && li->backsector != li->frontsector)
        {
          li->backsector->linecount++;
          total++;
        }
    }
  {  
    line_t **linebuffer = Z_Malloc(total*sizeof(line_t *), PU_LEVEL, 0);
    for (i=0, sector = sectors; i<numsectors; i++, sector++)
    {
      sector->lines = linebuffer;
      linebuffer += sector->linecount;
      sector->linecount = 0;
      M_ClearBox(sector->blockbox);
    }
  }
  for (i=0,li=lines; i<numlines; i++, li++)
  {
    P_AddLineToSector(li, li->frontsector);
    if (li->backsector && li->backsector != li->frontsector)
      P_AddLineToSector(li, li->backsector);
  }
  for (i=0, sector = sectors; i<numsectors; i++, sector++)
  {
    fixed_t *bbox = (void*)sector->blockbox; 
    int block;
    if (comp[comp_sound])
    {
      sector->soundorg.x = (bbox[BOXRIGHT]+bbox[BOXLEFT])/2;
      sector->soundorg.y = (bbox[BOXTOP]+bbox[BOXBOTTOM])/2;
    }
    else
    {
      sector->soundorg.x = bbox[BOXRIGHT]/2+bbox[BOXLEFT]/2;
      sector->soundorg.y = bbox[BOXTOP]/2+bbox[BOXBOTTOM]/2;
    }
    block = (bbox[BOXTOP]-bmaporgy+MAXRADIUS)>>MAPBLOCKSHIFT;
    block = block >= bmapheight ? bmapheight-1 : block;
    sector->blockbox[BOXTOP]=block;
    block = (bbox[BOXBOTTOM]-bmaporgy-MAXRADIUS)>>MAPBLOCKSHIFT;
    block = block < 0 ? 0 : block;
    sector->blockbox[BOXBOTTOM]=block;
    block = (bbox[BOXRIGHT]-bmaporgx+MAXRADIUS)>>MAPBLOCKSHIFT;
    block = block >= bmapwidth ? bmapwidth-1 : block;
    sector->blockbox[BOXRIGHT]=block;
    block = (bbox[BOXLEFT]-bmaporgx-MAXRADIUS)>>MAPBLOCKSHIFT;
    block = block < 0 ? 0 : block;
    sector->blockbox[BOXLEFT]=block;
  }
  return total; 
}
static int P_GroupLines ( void ) { line_t * li ; sector_t * sector ; int i , j , total = numlines ; for ( i = 0 ; i < numsubsectors ; i ++ ) { seg_t * seg = & segs [ subsectors [ i ] . firstline ] ; subsectors [ i ] . sector = NULL ; for ( j = 0 ; j < subsectors [ i ] . numlines ; j ++ ) { if ( seg -> sidedef ) { subsectors [ i ] . sector = seg -> sidedef -> sector ; break ; } seg ++ ; } if ( subsectors [ i ] . sector == NULL ) I_Error ( " \n " ) ; } for ( i = 0 , li = lines ; i < numlines ; i ++ , li ++ ) { li -> frontsector -> linecount ++ ; if ( li -> backsector && li -> backsector != li -> frontsector ) { li -> backsector -> linecount ++ ; total ++ ; } } { line_t * * linebuffer = Z_Malloc ( total * sizeof ( line_t * ) , PU_LEVEL , 0 ) ; for ( i = 0 , sector = sectors ; i < numsectors ; i ++ , sector ++ ) { sector -> lines = linebuffer ; linebuffer += sector -> linecount ; sector -> linecount = 0 ; M_ClearBox ( sector -> blockbox ) ; } } for ( i = 0 , li = lines ; i < numlines ; i ++ , li ++ ) { P_AddLineToSector ( li , li -> frontsector ) ; if ( li -> backsector && li -> backsector != li -> frontsector ) P_AddLineToSector ( li , li -> backsector ) ; } for ( i = 0 , sector = sectors ; i < numsectors ; i ++ , sector ++ ) { fixed_t * bbox = ( void * ) sector -> blockbox ; int block ; if ( comp [ comp_sound ] ) { sector -> soundorg . x = ( bbox [ BOXRIGHT ] + bbox [ BOXLEFT ] ) / 2 ; sector -> soundorg . y = ( bbox [ BOXTOP ] + bbox [ BOXBOTTOM ] ) / 2 ; } else { sector -> soundorg . x = bbox [ BOXRIGHT ] / 2 + bbox [ BOXLEFT ] / 2 ; sector -> soundorg . y = bbox [ BOXTOP ] / 2 + bbox [ BOXBOTTOM ] / 2 ; } block = ( bbox [ BOXTOP ] - bmaporgy + MAXRADIUS ) >> MAPBLOCKSHIFT ; block = block >= bmapheight ? bmapheight - 1 : block ; sector -> blockbox [ BOXTOP ] = block ; block = ( bbox [ BOXBOTTOM ] - bmaporgy - MAXRADIUS ) >> MAPBLOCKSHIFT ; block = block < 0 ? 0 : block ; sector -> blockbox [ BOXBOTTOM ] = block ; block = ( bbox [ BOXRIGHT ] - bmaporgx + MAXRADIUS ) >> MAPBLOCKSHIFT ; block = block >= bmapwidth ? bmapwidth - 1 : block ; sector -> blockbox [ BOXRIGHT ] = block ; block = ( bbox [ BOXLEFT ] - bmaporgx - MAXRADIUS ) >> MAPBLOCKSHIFT ; block = block < 0 ? 0 : block ; sector -> blockbox [ BOXLEFT ] = block ; } return total ; }
modified to return totallines (needed by P_LoadReject)
modified to return totallines ( needed by P_LoadReject )
// figgi // count number of lines in each sector // allocate line tables for each sector // e6y: REJECT overrun emulation code // moved to P_LoadReject // Enter those lines // cph - For convenience, so // I can sue the old code unchanged // set the degenmobj_t to the middle of the bounding box //e6y: fix sound origin for large levels // adjust bounding box to map blocks // this value is needed by the reject overrun emulation code