Skip to content

Commit

Permalink
Fixed (all games): Mobj types from game modes where they should not b…
Browse files Browse the repository at this point in the history
…e present could be spawned dynamically once the map had started (for example, attempting to spawn an Archvile while playing Ultimate DOOM via XG or the ccmd "spawnmobj").
  • Loading branch information
danij committed Jun 21, 2009
1 parent ea4de6f commit fac87b6
Show file tree
Hide file tree
Showing 28 changed files with 1,306 additions and 1,138 deletions.
19 changes: 10 additions & 9 deletions doomsday/plugins/common/src/p_map.c
Expand Up @@ -1751,10 +1751,10 @@ if(lineWasHit)
#if __JHERETIC__
if(puffType == MT_BLASTERPUFF1)
{ // Make blaster big puff.
mobj_t* mo =
P_SpawnMobj3fv(MT_BLASTERPUFF2, pos, P_Random() << 24, 0);
mobj_t* mo;

S_StartSound(SFX_BLSHIT, mo);
if((mo = P_SpawnMobj3fv(MT_BLASTERPUFF2, pos, P_Random() << 24, 0)))
S_StartSound(SFX_BLSHIT, mo);
}
else
P_SpawnPuff(pos[VX], pos[VY], pos[VZ], P_Random() << 24);
Expand Down Expand Up @@ -2653,12 +2653,13 @@ boolean PIT_ChangeSector(mobj_t* thing, void* data)
#endif
{
// Spray blood in a random direction.
mo = P_SpawnMobj3f(MT_BLOOD, thing->pos[VX], thing->pos[VY],
thing->pos[VZ] + (thing->height /2),
P_Random() << 24, 0);

mo->mom[MX] = FIX2FLT((P_Random() - P_Random()) << 12);
mo->mom[MY] = FIX2FLT((P_Random() - P_Random()) << 12);
if((mo = P_SpawnMobj3f(MT_BLOOD, thing->pos[VX], thing->pos[VY],
thing->pos[VZ] + (thing->height /2),
P_Random() << 24, 0)))
{
mo->mom[MX] = FIX2FLT((P_Random() - P_Random()) << 12);
mo->mom[MY] = FIX2FLT((P_Random() - P_Random()) << 12);
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions doomsday/plugins/common/src/p_player.c
Expand Up @@ -1170,8 +1170,7 @@ DEFCC(CCmdSpawnMobj)
else
angle = 0;

mo = P_SpawnMobj3fv(type, pos, angle, spawnFlags);
if(mo)
if((mo = P_SpawnMobj3fv(type, pos, angle, spawnFlags)))
{
#if __JDOOM64__
// jd64 > kaiser - another cheesy hack!!!
Expand Down
122 changes: 0 additions & 122 deletions doomsday/plugins/common/src/p_start.c
Expand Up @@ -730,32 +730,6 @@ mobj_t* P_SpawnMobjAtSpot(mobjtype_t type, const mapspot_t* spot)
if(mo->flags & MF_COUNTITEM)
totalItems++;
#endif

#if __JHEXEN__
if(spot->flags & MTF_DORMANT)
{
mo->flags2 |= MF2_DORMANT;
if(mo->type == MT_ICEGUY)
{
P_MobjChangeState(mo, S_ICEGUY_DORMANT);
}
mo->tics = -1;
}
#endif

#if __JDOOM64__
/*if(spot->flags & MTF_WALKOFF)
mo->flags |= (MF_FLOAT | MF_DROPOFF);
if(spot->flags & MTF_TRANSLUCENT)
mo->flags |= MF_SHADOW;
if(spot->flags & MTF_FLOAT)
{
mo->pos[VZ] += 96;
mo->flags |= (MF_FLOAT | MF_NOGRAVITY);
}*/
#endif
}

return mo;
Expand All @@ -776,7 +750,6 @@ static void spawnMapThing(const mapspot_t* spot)

int spawnMask;
mobjtype_t type;
const mobjinfo_t* info;

/*#if _DEBUG
Con_Message("spawnMapThing: x:[%g, %g, %g] angle:%i ednum:%i flags:%i\n",
Expand Down Expand Up @@ -913,101 +886,6 @@ Con_Message("spawnMapThing: x:[%g, %g, %g] angle:%i ednum:%i flags:%i\n",
spot->pos[VY], spot->pos[VZ]);
return;
}
info = &MOBJINFO[type];

// Clients only spawn local objects.
if(!(info->flags & MF_LOCAL) && IS_CLIENT)
return;

// Not for deathmatch?
if(deathmatch && (info->flags & MF_NOTDMATCH))
return;

// Check for specific disabled objects.
#if __JDOOM__ || __JDOOM64__
if((spot->flags & MSF_NOTSINGLE) && IS_NETGAME)
{
// Cooperative weapons?
if(cfg.noCoopWeapons && !deathmatch && type >= MT_CLIP &&
type <= MT_SUPERSHOTGUN)
return;

// Don't spawn any special objects in coop?
if(cfg.noCoopAnything && !deathmatch)
return;

// BFG disabled in netgames?
if(cfg.noNetBFG && type == MT_MISC25)
return;
}
# if __JDOOM__
switch(type)
{
case MT_SPIDER: // 68, Arachnotron
case MT_VILE: // 64, Archvile
case MT_BOSSBRAIN: // 88, Boss Brain
case MT_BOSSSPIT: // 89, Boss Shooter
case MT_KNIGHT: // 69, Hell Knight
case MT_FATSO: // 67, Mancubus
case MT_PAIN: // 71, Pain Elemental
case MT_MEGA: // 74, MegaSphere
case MT_CHAINGUY: // 65, Former Human Commando
case MT_UNDEAD: // 66, Revenant
case MT_WOLFSS: // 84, Wolf SS
if(gameMode != commercial)
return;
break;

default:
break;
}
# endif
#elif __JHERETIC__
switch(type)
{
case MT_WSKULLROD:
case MT_WPHOENIXROD:
case MT_AMSKRDWIMPY:
case MT_AMSKRDHEFTY:
case MT_AMPHRDWIMPY:
case MT_AMPHRDHEFTY:
case MT_AMMACEWIMPY:
case MT_AMMACEHEFTY:
case MT_ARTISUPERHEAL:
case MT_ARTITELEPORT:
case MT_ITEMSHIELD2:
if(gameMode == shareware)
{ // Don't place on map in shareware version.
return;
}
break;

default:
break;
}
#elif __JHEXEN__
switch(type)
{
case MT_ZLYNCHED_NOHEART:
P_SpawnMobj3fv(MT_BLOODPOOL, spot->pos, 0,
spot->flags | MSF_Z_FLOOR);
break;

default:
break;
}
#endif

// Don't spawn any monsters if -noMonstersParm.
if(noMonstersParm)
{
if((info->flags & MF_COUNTKILL)
#if __JDOOM__ || __JDOOM64__
|| type == MT_SKULL
#endif
)
return;
}

// Spawn it!
P_SpawnMobjAtSpot(type, spot);
Expand Down
48 changes: 27 additions & 21 deletions doomsday/plugins/common/src/p_user.c
Expand Up @@ -744,19 +744,24 @@ boolean P_UndoPlayerMorph(player_t *player)
mo = P_SpawnMobj3fv(MT_PLAYER, pos, angle, 0);
# endif

if(!mo)
return false;

if(P_TestMobjLocation(mo) == false)
{ // Didn't fit
P_MobjRemove(mo, false);
mo = P_SpawnMobj3fv(oldBeast, pos, angle, 0);

mo->health = player->health;
mo->special1 = weapon;
mo->player = player;
mo->dPlayer = player->plr;
mo->flags = oldFlags;
mo->flags2 = oldFlags2;
player->plr->mo = mo;
player->morphTics = 2 * 35;
if((mo = P_SpawnMobj3fv(oldBeast, pos, angle, 0)))
{
mo->health = player->health;
mo->special1 = weapon;
mo->player = player;
mo->dPlayer = player->plr;
mo->flags = oldFlags;
mo->flags2 = oldFlags2;
player->plr->mo = mo;
player->morphTics = 2 * 35;
}

return false;
}

Expand Down Expand Up @@ -801,15 +806,17 @@ boolean P_UndoPlayerMorph(player_t *player)
an = angle >> ANGLETOFINESHIFT;
// REWRITE ME - I MATCH HEXEN UNTIL HERE

fog = P_SpawnMobj3f(MT_TFOG,
pos[VX] + 20 * FIX2FLT(finecosine[an]),
pos[VY] + 20 * FIX2FLT(finesine[an]),
pos[VZ] + TELEFOGHEIGHT, angle + ANG180, 0);
if((fog = P_SpawnMobj3f(MT_TFOG,
pos[VX] + 20 * FIX2FLT(finecosine[an]),
pos[VY] + 20 * FIX2FLT(finesine[an]),
pos[VZ] + TELEFOGHEIGHT, angle + ANG180, 0)))
{
# if __JHERETIC__
S_StartSound(SFX_TELEPT, fog);
S_StartSound(SFX_TELEPT, fog);
# else
S_StartSound(SFX_TELEPORT, fog);
S_StartSound(SFX_TELEPORT, fog);
# endif
}
P_PostMorphWeapon(player, weapon);

player->update |= PSF_MORPH_TIME | PSF_HEALTH;
Expand Down Expand Up @@ -1106,12 +1113,11 @@ void P_PlayerThinkMove(player_t *player)
if(player->powers[PT_SPEED] && !(mapTime & 1) &&
P_ApproxDistance(plrmo->mom[MX], plrmo->mom[MY]) > 12)
{
mobj_t *speedMo;
int playerNum;
mobj_t* speedMo;
int playerNum;

speedMo = P_SpawnMobj3fv(MT_PLAYER_SPEED, plrmo->pos,
plrmo->angle, 0);
if(speedMo)
if((speedMo = P_SpawnMobj3fv(MT_PLAYER_SPEED, plrmo->pos,
plrmo->angle, 0)))
{
playerNum = P_GetPlayerNum(player);

Expand Down
29 changes: 16 additions & 13 deletions doomsday/plugins/common/src/p_xgline.c
Expand Up @@ -1623,11 +1623,13 @@ int C_DECL XLTrav_LineTeleport(linedef_t* newLine, boolean dummy,
// Spawn flash at the old position?
if(info->iparm[2])
{
flash = P_SpawnMobj3fv(MT_TFOG, mobj->pos, mobj->angle + ANG180, 0);

// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
if((flash = P_SpawnMobj3fv(MT_TFOG, mobj->pos,
mobj->angle + ANG180, 0)))
{
// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
}
}

// Get the thing's position along the source linedef
Expand Down Expand Up @@ -1742,14 +1744,15 @@ int C_DECL XLTrav_LineTeleport(linedef_t* newLine, boolean dummy,
if(info->iparm[2])
{
an = mobj->angle >> ANGLETOFINESHIFT;
flash = P_SpawnMobj3f(MT_TFOG,
mobj->pos[VX] + 24 * FIX2FLT(finecosine[an]),
mobj->pos[VY] + 24 * FIX2FLT(finesine[an]),
mobj->pos[VZ], mobj->angle + ANG180, 0);

// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
if((flash = P_SpawnMobj3f(MT_TFOG,
mobj->pos[VX] + 24 * FIX2FLT(finecosine[an]),
mobj->pos[VY] + 24 * FIX2FLT(finesine[an]),
mobj->pos[VZ], mobj->angle + ANG180, 0)))
{
// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
}
}

// Adjust the player's view, incase there has been a height change
Expand Down
29 changes: 17 additions & 12 deletions doomsday/plugins/common/src/p_xgsec.c
Expand Up @@ -2246,11 +2246,14 @@ int C_DECL XSTrav_Teleport(sector_t* sector, boolean ceiling, void* context,
#if __JHERETIC__
fogDelta = ((thing->flags & MF_MISSILE)? 0 : TELEFOGHEIGHT);
#endif
flash = P_SpawnMobj3f(MT_TFOG, oldpos[VX], oldpos[VY],
oldpos[VZ] + fogDelta, oldAngle + ANG180, 0);
// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
if((flash = P_SpawnMobj3f(MT_TFOG, oldpos[VX], oldpos[VY],
oldpos[VZ] + fogDelta,
oldAngle + ANG180, 0)))
{
// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
}
}

an = mo->angle >> ANGLETOFINESHIFT;
Expand All @@ -2259,13 +2262,15 @@ int C_DECL XSTrav_Teleport(sector_t* sector, boolean ceiling, void* context,
if(!info->iparm[2])
{
// New position
flash = P_SpawnMobj3f(MT_TFOG,
mo->pos[VX] + 20 * FIX2FLT(finecosine[an]),
mo->pos[VY] + 20 * FIX2FLT(finesine[an]),
mo->pos[VZ] + fogDelta, mo->angle, 0);
// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
if((flash = P_SpawnMobj3f(MT_TFOG,
mo->pos[VX] + 20 * FIX2FLT(finecosine[an]),
mo->pos[VY] + 20 * FIX2FLT(finesine[an]),
mo->pos[VZ] + fogDelta, mo->angle, 0)))
{
// Play a sound?
if(info->iparm[3])
S_StartSound(info->iparm[3], flash);
}
}

// Adjust the angle to match that of the teleporter exit
Expand Down

0 comments on commit fac87b6

Please sign in to comment.