components/prboom/p_map.c
// This routine checks for Lost Souls trying to be spawned      // phares
// across 1-sided lines, impassible lines, or "monsters can't   //   |
// cross" lines. Draw an imaginary line between the PE          //   V
// and the new Lost Soul spawn spot. If that line crosses
// a 'blocking' line, then disallow the spawn. Only search
// lines in the blocks of the blockmap where the bounding box
// of the trajectory line resides. Then check bounding box
// of the trajectory vs. the bounding box of each blocking
// line to see if the trajectory and the blocking line cross.
// Then check the PE and LS to see if they're on different
// sides of the blocking line. If so, return true, otherwise
// false.
This routine checks for Lost Souls trying to be spawned      // phares
across 1-sided lines, impassible lines, or "monsters can't   //   |
cross" lines. Draw an imaginary line between the PE          //   V
and the new Lost Soul spawn spot. If that line crosses
a 'blocking' line, then disallow the spawn. Only search
lines in the blocks of the blockmap where the bounding box
of the trajectory line resides. Then check bounding box
of the trajectory vs. the bounding box of each blocking
line to see if the trajectory and the blocking line cross.
Then check the PE and LS to see if they're on different
sides of the blocking line. If so, return true, otherwise
false.
This routine checks for Lost Souls trying to be spawned // phares across 1 - sided lines impassible lines or " monsters can ' t // | cross " lines . Draw an imaginary line between the PE // V and the new Lost Soul spawn spot . If that line crosses a ' blocking ' line then disallow the spawn . Only search lines in the blocks of the blockmap where the bounding box of the trajectory line resides . Then check bounding box of the trajectory vs . the bounding box of each blocking line to see if the trajectory and the blocking line cross . Then check the PE and LS to see if they ' re on different sides of the blocking line . If so return true otherwise false .
boolean Check_Sides(mobj_t* actor, int x, int y)
  {
  int bx,by,xl,xh,yl,yh;
  pe_x = actor->x;
  pe_y = actor->y;
  ls_x = x;
  ls_y = y;
  tmbbox[BOXLEFT]   = pe_x < x ? pe_x : x;
  tmbbox[BOXRIGHT]  = pe_x > x ? pe_x : x;
  tmbbox[BOXTOP]    = pe_y > y ? pe_y : y;
  tmbbox[BOXBOTTOM] = pe_y < y ? pe_y : y;
  xl = (tmbbox[BOXLEFT]   - bmaporgx)>>MAPBLOCKSHIFT;
  xh = (tmbbox[BOXRIGHT]  - bmaporgx)>>MAPBLOCKSHIFT;
  yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
  yh = (tmbbox[BOXTOP]    - bmaporgy)>>MAPBLOCKSHIFT;
  validcount++; 
  for (bx = xl ; bx <= xh ; bx++)
    for (by = yl ; by <= yh ; by++)
      if (!P_BlockLinesIterator(bx,by,PIT_CrossLine))
        return true;                                                
  return(false);                                                    
  }
boolean Check_Sides ( mobj_t * actor , int x , int y ) { int bx , by , xl , xh , yl , yh ; pe_x = actor -> x ; pe_y = actor -> y ; ls_x = x ; ls_y = y ; tmbbox [ BOXLEFT ] = pe_x < x ? pe_x : x ; tmbbox [ BOXRIGHT ] = pe_x > x ? pe_x : x ; tmbbox [ BOXTOP ] = pe_y > y ? pe_y : y ; tmbbox [ BOXBOTTOM ] = pe_y < y ? pe_y : y ; xl = ( tmbbox [ BOXLEFT ] - bmaporgx ) >> MAPBLOCKSHIFT ; xh = ( tmbbox [ BOXRIGHT ] - bmaporgx ) >> MAPBLOCKSHIFT ; yl = ( tmbbox [ BOXBOTTOM ] - bmaporgy ) >> MAPBLOCKSHIFT ; yh = ( tmbbox [ BOXTOP ] - bmaporgy ) >> MAPBLOCKSHIFT ; validcount ++ ; for ( bx = xl ; bx <= xh ; bx ++ ) for ( by = yl ; by <= yh ; by ++ ) if ( ! P_BlockLinesIterator ( bx , by , PIT_CrossLine ) ) return true ; return ( false ) ; }
This routine checks for Lost Souls trying to be spawned      // phares
across 1-sided lines, impassible lines, or "monsters can't   //   |
cross" lines.
This routine checks for Lost Souls trying to be spawned // phares across 1 - sided lines impassible lines or " monsters can ' t // | cross " lines .
// Here is the bounding box of the trajectory // Determine which blocks to look in for blocking lines // xl->xh, yl->yh determine the mapblock set to search // prevents checking same line twice //   ^ //   |