components/prboom/p_tick.c
/*
 * P_SetTarget
 *
 * This function is used to keep track of pointer references to mobj thinkers.
 * In Doom, objects such as lost souls could sometimes be removed despite
 * their still being referenced. In Boom, 'target' mobj fields were tested
 * during each gametic, and any objects pointed to by them would be prevented
 * from being removed. But this was incomplete, and was slow (every mobj was
 * checked during every gametic). Now, we keep a count of the number of
 * references, and delay removal until the count is 0.
 */
P_SetTarget
This function is used to keep track of pointer references to mobj thinkers.
In Doom, objects such as lost souls could sometimes be removed despite
their still being referenced. In Boom, 'target' mobj fields were tested
during each gametic, and any objects pointed to by them would be prevented
from being removed. But this was incomplete, and was slow (every mobj was
checked during every gametic). Now, we keep a count of the number of
references, and delay removal until the count is 0.
P_SetTarget This function is used to keep track of pointer references to mobj thinkers . In Doom objects such as lost souls could sometimes be removed despite their still being referenced . In Boom ' target ' mobj fields were tested during each gametic and any objects pointed to by them would be prevented from being removed . But this was incomplete and was slow ( every mobj was checked during every gametic ) . Now we keep a count of the number of references and delay removal until the count is 0 .
void P_SetTarget(mobj_t **mop, mobj_t *targ)
{
  if (*mop)             
    (*mop)->thinker.references--;
  if ((*mop = targ))    
    targ->thinker.references++;
}
void P_SetTarget ( mobj_t * * mop , mobj_t * targ ) { if ( * mop ) ( * mop ) -> thinker . references -- ; if ( ( * mop = targ ) ) targ -> thinker . references ++ ; }
P_SetTarget
 This function is used to keep track of pointer references to mobj thinkers.
P_SetTarget This function is used to keep track of pointer references to mobj thinkers .
// If there was a target already, decrease its refcount // Set new target and if non-NULL, increase its counter