components/prboom/g_game.c
//
// G_CheckSpot
// Returns false if the player cannot be respawned
// at the given mapthing_t spot
// because something is occupying it
//
G_CheckSpot
Returns false if the player cannot be respawned
at the given mapthing_t spot
because something is occupying it
G_CheckSpot Returns false if the player cannot be respawned at the given mapthing_t spot because something is occupying it
static boolean G_CheckSpot(int playernum, mapthing_t *mthing)
{
  fixed_t     x,y;
  subsector_t *ss;
  int         i;
  if (!players[playernum].mo)
    {
      for (i=0 ; i<playernum ; i++)
        if (players[i].mo->x == mthing->x << FRACBITS
            && players[i].mo->y == mthing->y << FRACBITS)
          return false;
      return true;
    }
  x = mthing->x << FRACBITS;
  y = mthing->y << FRACBITS;
   Old code:
   if (!P_CheckPosition (players[playernum].mo, x, y))
      return false;
  players[playernum].mo->flags |=  MF_SOLID;
  i = P_CheckPosition(players[playernum].mo, x, y);
  players[playernum].mo->flags &= ~MF_SOLID;
  if (!i)
    return false;
   flush an old corpse if needed
   killough 2/8/98: make corpse queue have an adjustable limit
   killough 8/1/98: Fix bugs causing strange crashes
  if (bodyquesize > 0)
    {
      static int queuesize;
      if (queuesize < bodyquesize)
	{
	  bodyque = realloc(bodyque, bodyquesize*sizeof*bodyque);
	  memset(bodyque+queuesize, 0,
		 (bodyquesize-queuesize)*sizeof*bodyque);
	  queuesize = bodyquesize;
	}
      if (bodyqueslot >= bodyquesize)
	P_RemoveMobj(bodyque[bodyqueslot % bodyquesize]);
      bodyque[bodyqueslot++ % bodyquesize] = players[playernum].mo;
    }
  else
    if (!bodyquesize)
      P_RemoveMobj(players[playernum].mo);
   spawn a teleport fog
  ss = R_PointInSubsector (x,y);
  {  Teleport fog at respawn point
    fixed_t xa,ya;
    int an;
    mobj_t      *mo;
    an = ( ANG45 * ((signed)mthing->angle/45) ) >> ANGLETOFINESHIFT;
    xa = finecosine[an];
    ya = finesine[an];
    if (compatibility_level <= finaldoom_compatibility || compatibility_level == prboom_4_compatibility)
      switch (an) {
      case -4096: xa = finetangent[2048];    finecosine[-4096]
          	ya = finetangent[0];       finesine[-4096]
          	break;
      case -3072: xa = finetangent[3072];    finecosine[-3072]
          	ya = finetangent[1024];    finesine[-3072]
          	break;
      case -2048: xa = finesine[0];    finecosine[-2048]
          	ya = finetangent[2048];    finesine[-2048]
          	break;
      case -1024:	xa = finesine[1024];      finecosine[-1024]
          	ya = finetangent[3072];   finesine[-1024]
          	break;
      case 1024:
      case 2048:
      case 3072:
      case 4096:
      case 0:	break; 
      default:	I_Error("G_CheckSpot: unexpected angle %d\n",an);
      }
    mo = P_SpawnMobj(x+20*xa, y+20*ya, ss->sector->floorheight, MT_TFOG);
    if (players[consoleplayer].viewz != 1)
      S_StartSound(mo, sfx_telept);   don't start sound on first frame
  }
  return true;
}
static boolean G_CheckSpot ( int playernum , mapthing_t * mthing ) { fixed_t x , y ; subsector_t * ss ; int i ; if ( ! players [ playernum ] . mo ) { for ( i = 0 ; i < playernum ; i ++ ) if ( players [ i ] . mo -> x == mthing -> x << FRACBITS && players [ i ] . mo -> y == mthing -> y << FRACBITS ) return false ; return true ; } x = mthing -> x << FRACBITS ; y = mthing -> y << FRACBITS ; players [ playernum ] . mo -> flags |= MF_SOLID ; i = P_CheckPosition ( players [ playernum ] . mo , x , y ) ; players [ playernum ] . mo -> flags &= ~ MF_SOLID ; if ( ! i ) return false ; if ( bodyquesize > 0 ) { static int queuesize ; if ( queuesize < bodyquesize ) { bodyque = realloc ( bodyque , bodyquesize * sizeof * bodyque ) ; memset ( bodyque + queuesize , 0 , ( bodyquesize - queuesize ) * sizeof * bodyque ) ; queuesize = bodyquesize ; } if ( bodyqueslot >= bodyquesize ) P_RemoveMobj ( bodyque [ bodyqueslot % bodyquesize ] ) ; bodyque [ bodyqueslot ++ % bodyquesize ] = players [ playernum ] . mo ; } else if ( ! bodyquesize ) P_RemoveMobj ( players [ playernum ] . mo ) ; ss = R_PointInSubsector ( x , y ) ; { fixed_t xa , ya ; int an ; mobj_t * mo ; an = ( ANG45 * ( ( signed ) mthing -> angle / 45 ) ) >> ANGLETOFINESHIFT ; xa = finecosine [ an ] ; ya = finesine [ an ] ; if ( compatibility_level <= finaldoom_compatibility || compatibility_level == prboom_4_compatibility ) switch ( an ) { case -4096 : xa = finetangent [ 2048 ] ; ya = finetangent [ 0 ] ; break ; case -3072 : xa = finetangent [ 3072 ] ; ya = finetangent [ 1024 ] ; break ; case -2048 : xa = finesine [ 0 ] ; ya = finetangent [ 2048 ] ; break ; case -1024 : xa = finesine [ 1024 ] ; ya = finetangent [ 3072 ] ; break ; case 1024 : case 2048 : case 3072 : case 4096 : case 0 : break ; default : I_Error ( " \n " , an ) ; } mo = P_SpawnMobj ( x + 20 * xa , y + 20 * ya , ss -> sector -> floorheight , MT_TFOG ) ; if ( players [ consoleplayer ] . viewz != 1 ) S_StartSound ( mo , sfx_telept ) ; } return true ; }
G_CheckSpot
Returns false if the player cannot be respawned
at the given mapthing_t spot
because something is occupying it
G_CheckSpot Returns false if the player cannot be respawned at the given mapthing_t spot because something is occupying it
// first spawn of level, before corpses // killough 4/2/98: fix bug where P_CheckPosition() uses a non-solid // corpse to detect collisions with other players in DM starts // // Old code: // if (!P_CheckPosition (players[playernum].mo, x, y)) //    return false; // flush an old corpse if needed // killough 2/8/98: make corpse queue have an adjustable limit // killough 8/1/98: Fix bugs causing strange crashes // spawn a teleport fog // Teleport fog at respawn point /* BUG: an can end up negative, because mthing->angle is (signed) short.
 * We have to emulate original Doom's behaviour, deferencing past the start
 * of the array, into the previous array (finetangent) */ // finecosine[-4096] // finesine[-4096] // finecosine[-3072] // finesine[-3072] // finecosine[-2048] // finesine[-2048] // finecosine[-1024] // finesine[-1024] /* correct angles set above */ // don't start sound on first frame