components/prboom/p_setup.c
//
// P_LoadLineDefs
// Also counts secret lines for intermissions.
//        ^^^
// ??? killough ???
// Does this mean secrets used to be linedef-based, rather than sector-based?
//
// killough 4/4/98: split into two functions, to allow sidedef overloading
//
// killough 5/3/98: reformatted, cleaned up
P_LoadLineDefs
Also counts secret lines for intermissions.

killough 4/4/98: split into two functions, to allow sidedef overloading

killough 5/3/98: reformatted, cleaned up
P_LoadLineDefs Also counts secret lines for intermissions . killough 4 / 4 / 98 : split into two functions to allow sidedef overloading killough 5 / 3 / 98 : reformatted cleaned up
static void P_LoadLineDefs (int lump)
{
  const byte *data; 
  int  i;
  numlines = W_LumpLength (lump) / sizeof(maplinedef_t);
  lines = Z_Calloc (numlines,sizeof(line_t),PU_LEVEL,0);
  data = W_CacheLumpNum (lump); 
  for (i=0; i<numlines; i++)
    {
      const maplinedef_t *mld = (const maplinedef_t *) data + i;
      line_t *ld = lines+i;
      vertex_t *v1, *v2;
      ld->flags = (unsigned short)SHORT(mld->flags);
      ld->special = SHORT(mld->special);
      ld->tag = SHORT(mld->tag);
      v1 = ld->v1 = &vertexes[(unsigned short)SHORT(mld->v1)];
      v2 = ld->v2 = &vertexes[(unsigned short)SHORT(mld->v2)];
      ld->dx = v2->x - v1->x;
      ld->dy = v2->y - v1->y;
      ld->tranlump = -1;   
      ld->slopetype = !ld->dx ? ST_VERTICAL : !ld->dy ? ST_HORIZONTAL :
        FixedDiv(ld->dy, ld->dx) > 0 ? ST_POSITIVE : ST_NEGATIVE;
      if (v1->x < v2->x)
        {
          ld->bbox[BOXLEFT] = v1->x;
          ld->bbox[BOXRIGHT] = v2->x;
        }
      else
        {
          ld->bbox[BOXLEFT] = v2->x;
          ld->bbox[BOXRIGHT] = v1->x;
        }
      if (v1->y < v2->y)
        {
          ld->bbox[BOXBOTTOM] = v1->y;
          ld->bbox[BOXTOP] = v2->y;
        }
      else
        {
          ld->bbox[BOXBOTTOM] = v2->y;
          ld->bbox[BOXTOP] = v1->y;
        }
      ld->soundorg.x = ld->bbox[BOXLEFT] / 2 + ld->bbox[BOXRIGHT] / 2;
      ld->soundorg.y = ld->bbox[BOXTOP] / 2 + ld->bbox[BOXBOTTOM] / 2;
      ld->iLineID=i; 
      ld->sidenum[0] = SHORT(mld->sidenum[0]);
      ld->sidenum[1] = SHORT(mld->sidenum[1]);
      { 
        int j;
        for (j=0; j < 2; j++)
        {
          if (ld->sidenum[j] != NO_INDEX && ld->sidenum[j] >= numsides) {
            ld->sidenum[j] = NO_INDEX;
            lprintf(LO_WARN, "P_LoadLineDefs: linedef %d has out-of-range sidedef number\n",numlines-i-1);
          }
        }
        if (ld->sidenum[0] == NO_INDEX) {
          ld->sidenum[0] = 0;  
          lprintf(LO_WARN, "P_LoadLineDefs: linedef %d missing first sidedef\n",numlines-i-1);
        }
        if ((ld->sidenum[1] == NO_INDEX) && (ld->flags & ML_TWOSIDED)) {
          ld->flags &= ~ML_TWOSIDED;  
          lprintf(LO_WARN, "P_LoadLineDefs: linedef %d has two-sided flag set, but no second sidedef\n",numlines-i-1);
        }
      }
      if (ld->sidenum[0] != NO_INDEX && ld->special)
        sides[*ld->sidenum].special = ld->special;
    }
  W_UnlockLumpNum(lump); 
}
static void P_LoadLineDefs ( int lump ) { const byte * data ; int i ; numlines = W_LumpLength ( lump ) / sizeof ( maplinedef_t ) ; lines = Z_Calloc ( numlines , sizeof ( line_t ) , PU_LEVEL , 0 ) ; data = W_CacheLumpNum ( lump ) ; for ( i = 0 ; i < numlines ; i ++ ) { const maplinedef_t * mld = ( const maplinedef_t * ) data + i ; line_t * ld = lines + i ; vertex_t * v1 , * v2 ; ld -> flags = ( unsigned short ) SHORT ( mld -> flags ) ; ld -> special = SHORT ( mld -> special ) ; ld -> tag = SHORT ( mld -> tag ) ; v1 = ld -> v1 = & vertexes [ ( unsigned short ) SHORT ( mld -> v1 ) ] ; v2 = ld -> v2 = & vertexes [ ( unsigned short ) SHORT ( mld -> v2 ) ] ; ld -> dx = v2 -> x - v1 -> x ; ld -> dy = v2 -> y - v1 -> y ; ld -> tranlump = -1 ; ld -> slopetype = ! ld -> dx ? ST_VERTICAL : ! ld -> dy ? ST_HORIZONTAL : FixedDiv ( ld -> dy , ld -> dx ) > 0 ? ST_POSITIVE : ST_NEGATIVE ; if ( v1 -> x < v2 -> x ) { ld -> bbox [ BOXLEFT ] = v1 -> x ; ld -> bbox [ BOXRIGHT ] = v2 -> x ; } else { ld -> bbox [ BOXLEFT ] = v2 -> x ; ld -> bbox [ BOXRIGHT ] = v1 -> x ; } if ( v1 -> y < v2 -> y ) { ld -> bbox [ BOXBOTTOM ] = v1 -> y ; ld -> bbox [ BOXTOP ] = v2 -> y ; } else { ld -> bbox [ BOXBOTTOM ] = v2 -> y ; ld -> bbox [ BOXTOP ] = v1 -> y ; } ld -> soundorg . x = ld -> bbox [ BOXLEFT ] / 2 + ld -> bbox [ BOXRIGHT ] / 2 ; ld -> soundorg . y = ld -> bbox [ BOXTOP ] / 2 + ld -> bbox [ BOXBOTTOM ] / 2 ; ld -> iLineID = i ; ld -> sidenum [ 0 ] = SHORT ( mld -> sidenum [ 0 ] ) ; ld -> sidenum [ 1 ] = SHORT ( mld -> sidenum [ 1 ] ) ; { int j ; for ( j = 0 ; j < 2 ; j ++ ) { if ( ld -> sidenum [ j ] != NO_INDEX && ld -> sidenum [ j ] >= numsides ) { ld -> sidenum [ j ] = NO_INDEX ; lprintf ( LO_WARN , " \n " , numlines - i - 1 ) ; } } if ( ld -> sidenum [ 0 ] == NO_INDEX ) { ld -> sidenum [ 0 ] = 0 ; lprintf ( LO_WARN , " \n " , numlines - i - 1 ) ; } if ( ( ld -> sidenum [ 1 ] == NO_INDEX ) && ( ld -> flags & ML_TWOSIDED ) ) { ld -> flags &= ~ ML_TWOSIDED ; lprintf ( LO_WARN , " \n " , numlines - i - 1 ) ; } } if ( ld -> sidenum [ 0 ] != NO_INDEX && ld -> special ) sides [ * ld -> sidenum ] . special = ld -> special ; } W_UnlockLumpNum ( lump ) ; }
P_LoadLineDefs
Also counts secret lines for intermissions.
P_LoadLineDefs Also counts secret lines for intermissions .
// cph - const* // cph - wad lump handling updated // killough 4/11/98: no translucency by default /* calculate sound origin of line to be its midpoint */ //e6y: fix sound origin for large levels // no need for comp_sound test, these are only used when comp_sound = 0 // proff 04/05/2000: needed for OpenGL /* cph 2006/09/30 - fix sidedef errors right away.
         * cph 2002/07/20 - these errors are fatal if not fixed, so apply them
         * in compatibility mode - a desync is better than a crash! */ // killough 11/98: fix common wad errors (missing sidedefs): // Substitute dummy sidedef for missing right side // cph - print a warning about the bug // Clear 2s flag for missing left side // cph - print a warning about the bug // killough 4/4/98: support special sidedef interpretation below // cph - release the lump