components/prboom/p_map.c
// phares 3/14/98
//
// P_CreateSecNodeList alters/creates the sector_list that shows what sectors
// the object resides in.
phares 3/14/98
P_CreateSecNodeList alters/creates the sector_list that shows what sectors
the object resides in.
phares 3 / 14 / 98 P_CreateSecNodeList alters / creates the sector_list that shows what sectors the object resides in .
void P_CreateSecNodeList(mobj_t* thing,fixed_t x,fixed_t y)
{
  int xl;
  int xh;
  int yl;
  int yh;
  int bx;
  int by;
  msecnode_t* node;
  mobj_t* saved_tmthing = tmthing; 
  fixed_t saved_tmx = tmx, saved_tmy = tmy; 
  node = sector_list;
  while (node)
    {
    node->m_thing = NULL;
    node = node->m_tnext;
    }
  tmthing = thing;
  tmx = x;
  tmy = y;
  tmbbox[BOXTOP]  = y + tmthing->radius;
  tmbbox[BOXBOTTOM] = y - tmthing->radius;
  tmbbox[BOXRIGHT]  = x + tmthing->radius;
  tmbbox[BOXLEFT]   = x - tmthing->radius;
  validcount++; 
  xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
  xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
  yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
  yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
  for (bx=xl ; bx<=xh ; bx++)
    for (by=yl ; by<=yh ; by++)
      P_BlockLinesIterator(bx,by,PIT_GetSectors);
  sector_list = P_AddSecnode(thing->subsector->sector,thing,sector_list);
  node = sector_list;
  while (node)
    {
    if (node->m_thing == NULL)
      {
      if (node == sector_list)
        sector_list = node->m_tnext;
      node = P_DelSecnode(node);
      }
    else
      node = node->m_tnext;
    }
  if ((compatibility_level < boom_compatibility_compatibility) ||
      (compatibility_level >= prboom_3_compatibility))
    tmthing = saved_tmthing;
  if ((compatibility_level < boom_compatibility_compatibility) ) {
    tmx = saved_tmx, tmy = saved_tmy;
    if (tmthing) {
      tmbbox[BOXTOP]  = tmy + tmthing->radius;
      tmbbox[BOXBOTTOM] = tmy - tmthing->radius;
      tmbbox[BOXRIGHT]  = tmx + tmthing->radius;
      tmbbox[BOXLEFT]   = tmx - tmthing->radius;
    }
  }
}
void P_CreateSecNodeList ( mobj_t * thing , fixed_t x , fixed_t y ) { int xl ; int xh ; int yl ; int yh ; int bx ; int by ; msecnode_t * node ; mobj_t * saved_tmthing = tmthing ; fixed_t saved_tmx = tmx , saved_tmy = tmy ; node = sector_list ; while ( node ) { node -> m_thing = NULL ; node = node -> m_tnext ; } tmthing = thing ; tmx = x ; tmy = y ; tmbbox [ BOXTOP ] = y + tmthing -> radius ; tmbbox [ BOXBOTTOM ] = y - tmthing -> radius ; tmbbox [ BOXRIGHT ] = x + tmthing -> radius ; tmbbox [ BOXLEFT ] = x - tmthing -> radius ; validcount ++ ; xl = ( tmbbox [ BOXLEFT ] - bmaporgx ) >> MAPBLOCKSHIFT ; xh = ( tmbbox [ BOXRIGHT ] - bmaporgx ) >> MAPBLOCKSHIFT ; yl = ( tmbbox [ BOXBOTTOM ] - bmaporgy ) >> MAPBLOCKSHIFT ; yh = ( tmbbox [ BOXTOP ] - bmaporgy ) >> MAPBLOCKSHIFT ; for ( bx = xl ; bx <= xh ; bx ++ ) for ( by = yl ; by <= yh ; by ++ ) P_BlockLinesIterator ( bx , by , PIT_GetSectors ) ; sector_list = P_AddSecnode ( thing -> subsector -> sector , thing , sector_list ) ; node = sector_list ; while ( node ) { if ( node -> m_thing == NULL ) { if ( node == sector_list ) sector_list = node -> m_tnext ; node = P_DelSecnode ( node ) ; } else node = node -> m_tnext ; } if ( ( compatibility_level < boom_compatibility_compatibility ) || ( compatibility_level >= prboom_3_compatibility ) ) tmthing = saved_tmthing ; if ( ( compatibility_level < boom_compatibility_compatibility ) ) { tmx = saved_tmx , tmy = saved_tmy ; if ( tmthing ) { tmbbox [ BOXTOP ] = tmy + tmthing -> radius ; tmbbox [ BOXBOTTOM ] = tmy - tmthing -> radius ; tmbbox [ BOXRIGHT ] = tmx + tmthing -> radius ; tmbbox [ BOXLEFT ] = tmx - tmthing -> radius ; } } }
phares 3/14/98
P_CreateSecNodeList alters/creates the sector_list that shows what sectors
the object resides in.
phares 3 / 14 / 98 P_CreateSecNodeList alters / creates the sector_list that shows what sectors the object resides in .
/* cph - see comment at func end */ /* ditto */ // First, clear out the existing m_thing fields. As each node is // added or verified as needed, m_thing will be set properly. When // finished, delete all nodes where m_thing is still NULL. These // represent the sectors the Thing has vacated. // used to make sure we only process a line once // Add the sector of the (x,y) point to sector_list. // Now delete any nodes that won't be used. These are the ones where // m_thing is still NULL. /* cph -
   * This is the strife we get into for using global variables. tmthing
   *  is being used by several different functions calling
   *  P_BlockThingIterator, including functions that can be called *from*
   *  P_BlockThingIterator. Using a global tmthing is not reentrant.
   * OTOH for Boom/MBF demos we have to preserve the buggy behavior.
   *  Fun. We restore its previous value unless we're in a Boom/MBF demo.
   */ /* And, duh, the same for tmx/y - cph 2002/09/22
   * And for tmbbox - cph 2003/08/10 */ /* ||
      (compatibility_level >= prboom_4_compatibility) */