p_mobj.c
/*
=================
=
= P_SpawnMapThing
=
= The fields of the mapthing should already be in host byte order
==================
*/
P_SpawnMapThing
The fields of the mapthing should already be in host byte order
P_SpawnMapThing The fields of the mapthing should already be in host byte order
void P_SpawnMapThing (mapthing_t *mthing)
{
	int			i;
	mobj_t		*mobj;
	fixed_t		x,y,z;
	if (mthing->type == 11)
	{
		if (deathmatch_p < deathmatchstarts + MAXDMSTARTS)
			D_memcpy (deathmatch_p, mthing, sizeof(*mthing));
		deathmatch_p++;
		return;
	}
#if 0
if (mthing->type > 4)
return;	
#endif
	if (mthing->type <= 4)
	{
		if (mthing->type <= MAXPLAYERS)
		{
			D_memcpy (&playerstarts[mthing->type-1], mthing, sizeof(*mthing));
			if (netgame != gt_deathmatch)
				P_SpawnPlayer (mthing);
		}
		return;
	}
	if (!P_MapThingSpawnsMobj(mthing))
		return;
	for (i=0 ; i< NUMMOBJTYPES ; i++)
		if (mthing->type == mobjinfo[i].doomednum)
			break;
	if (i==NUMMOBJTYPES)
		I_Error ("P_SpawnMapThing: Unknown type %i at (%i, %i)",mthing->type
		, mthing->x, mthing->y);
	x = mthing->x << FRACBITS;
	y = mthing->y << FRACBITS;
	if (mobjinfo[i].flags & MF_SPAWNCEILING)
		z = ONCEILINGZ;
	else
		z = ONFLOORZ;
	mobj = P_SpawnMobj (x,y,z, i);
	if (mobj->tics > 0)
		mobj->tics = 1 + (P_Random () % mobj->tics);
	if (mobj->flags & MF_COUNTKILL)
		totalkills++;
	if (mobj->flags & MF_COUNTITEM)
		totalitems++;
	mobj->angle = ANG45 * (mthing->angle/45);
	if (mthing->options & MTF_AMBUSH)
		mobj->flags |= MF_AMBUSH;
	mobj->spawnx = mthing->x;
	mobj->spawny = mthing->y;
	mobj->spawntype = mthing->type;
	mobj->spawnangle = mthing->angle;
}
void P_SpawnMapThing ( mapthing_t * mthing ) { int i ; mobj_t * mobj ; fixed_t x , y , z ; if ( mthing -> type == 11 ) { if ( deathmatch_p < deathmatchstarts + MAXDMSTARTS ) D_memcpy ( deathmatch_p , mthing , sizeof ( * mthing ) ) ; deathmatch_p ++ ; return ; } #if 0 if ( mthing -> type > 4 ) return ; #endif if ( mthing -> type <= 4 ) { if ( mthing -> type <= MAXPLAYERS ) { D_memcpy ( & playerstarts [ mthing -> type - 1 ] , mthing , sizeof ( * mthing ) ) ; if ( netgame != gt_deathmatch ) P_SpawnPlayer ( mthing ) ; } return ; } if ( ! P_MapThingSpawnsMobj ( mthing ) ) return ; for ( i = 0 ; i < NUMMOBJTYPES ; i ++ ) if ( mthing -> type == mobjinfo [ i ] . doomednum ) break ; if ( i == NUMMOBJTYPES ) I_Error ( " " , mthing -> type , mthing -> x , mthing -> y ) ; x = mthing -> x << FRACBITS ; y = mthing -> y << FRACBITS ; if ( mobjinfo [ i ] . flags & MF_SPAWNCEILING ) z = ONCEILINGZ ; else z = ONFLOORZ ; mobj = P_SpawnMobj ( x , y , z , i ) ; if ( mobj -> tics > 0 ) mobj -> tics = 1 + ( P_Random ( ) % mobj -> tics ) ; if ( mobj -> flags & MF_COUNTKILL ) totalkills ++ ; if ( mobj -> flags & MF_COUNTITEM ) totalitems ++ ; mobj -> angle = ANG45 * ( mthing -> angle / 45 ) ; if ( mthing -> options & MTF_AMBUSH ) mobj -> flags |= MF_AMBUSH ; mobj -> spawnx = mthing -> x ; mobj -> spawny = mthing -> y ; mobj -> spawntype = mthing -> type ; mobj -> spawnangle = mthing -> angle ; }
P_SpawnMapThing
The fields of the mapthing should already be in host byte order
P_SpawnMapThing The fields of the mapthing should already be in host byte order
/* count deathmatch start positions */ /* check for players specially */ /*DEBUG */ /* save spots for respawning in network games */ /* find which type to spawn */ /* spawn it */