Skip to content

Commit

Permalink
Continued work on the commonization of map spot handling and auto-spa…
Browse files Browse the repository at this point in the history
…wning of mobjs relative to them when loading a map. Clean up.
  • Loading branch information
danij committed Jun 21, 2009
1 parent fac87b6 commit 34fd5d4
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 224 deletions.
1 change: 0 additions & 1 deletion doomsday/plugins/common/include/p_mapsetup.h
Expand Up @@ -46,5 +46,4 @@ void P_SetupForMapData(int type, uint num);

void P_SetupMap(int episode, int map, int playermask, skillmode_t skill);
char* P_GetMapNiceName(void);
void P_SpawnThings(void);
#endif
20 changes: 10 additions & 10 deletions doomsday/plugins/common/include/p_start.h
Expand Up @@ -68,17 +68,17 @@
# define MSF_NOTDM 0x00000400 // Can not be spawned in the Deathmatch gameMode.
# define MSF_NOTCOOP 0x00000800 // Can not be spawned in the Co-op gameMode.
#elif __JHEXEN__
# define MTF_FIGHTER 0x00000020
# define MTF_CLERIC 0x00000040
# define MTF_MAGE 0x00000080
# define MTF_GSINGLE 0x00000100
# define MTF_GCOOP 0x00000200
# define MTF_GDEATHMATCH 0x00000400
# define MSF_FIGHTER 0x00000020
# define MSF_CLERIC 0x00000040
# define MSF_MAGE 0x00000080
# define MSF_NOTSINGLE 0x00000100
# define MSF_NOTCOOP 0x00000200
# define MSF_NOTDM 0x00000400
// The following are not currently implemented.
# define MTF_SHADOW 0x00000800 // (ZDOOM) Thing is 25% translucent.
# define MTF_INVISIBLE 0x00001000 // (ZDOOM) Makes the thing invisible.
# define MSF_SHADOW 0x00000800 // (ZDOOM) Thing is 25% translucent.
# define MSF_INVISIBLE 0x00001000 // (ZDOOM) Makes the thing invisible.
# define MSF_FRIENDLY 0x00002000 // (ZDOOM) Friendly monster.
# define MTF_STILL 0x00004000 // (ZDOOM) Thing stands still (only useful for specific Strife monsters or friendlies).
# define MSF_STILL 0x00004000 // (ZDOOM) Thing stands still (only useful for specific Strife monsters or friendlies).
#endif

// New flags:
Expand All @@ -98,7 +98,7 @@
^ (MSF_EASY|MSF_MEDIUM|MSF_HARD|MSF_AMBUSH|MSF_NOTSINGLE|MSF_NOTDM|MSF_NOTCOOP|MSF_FRIENDLY))
#elif __JHEXEN__
#define MASK_UNKNOWN_MSF_FLAGS (0xffffffff \
^ (MSF_EASY|MTF_NORMAL|MSF_HARD|MSF_AMBUSH|MTF_DORMANT|MTF_FIGHTER|MTF_CLERIC|MTF_MAGE|MTF_GSINGLE|MTF_GCOOP|MTF_GDEATHMATCH|MTF_SHADOW|MTF_INVISIBLE|MSF_FRIENDLY|MTF_STILL))
^ (MSF_EASY|MTF_NORMAL|MSF_HARD|MSF_AMBUSH|MTF_DORMANT|MSF_FIGHTER|MSF_CLERIC|MSF_MAGE|MSF_GSINGLE|MSF_GCOOP|MSF_GDEATHMATCH|MSF_SHADOW|MSF_INVISIBLE|MSF_FRIENDLY|MSF_STILL))
#endif

typedef struct {
Expand Down
142 changes: 135 additions & 7 deletions doomsday/plugins/common/src/p_mapsetup.c
Expand Up @@ -317,6 +317,85 @@ int applySurfaceColor(void* obj, void* context)
}
#endif

static boolean checkMapSpotSpawnFlags(const mapspot_t* spot)
{
#if __JHEXEN__
static unsigned int classFlags[] = {
MSF_FIGHTER,
MSF_CLERIC,
MSF_MAGE
};
#endif

int spawnMask;

// Don't spawn things flagged for Multiplayer if we're not in a netgame.
if(!IS_NETGAME && (spot->flags & MSF_NOTSINGLE))
return false;

// Don't spawn things flagged for Not Deathmatch if we're deathmatching.
if(deathmatch && (spot->flags & MSF_NOTDM))
return false;

// Don't spawn things flagged for Not Coop if we're coop'in.
if(IS_NETGAME && !deathmatch && (spot->flags & MSF_NOTCOOP))
return false;

// Check for appropriate skill level.
if(gameSkill == SM_BABY || gameSkill == SM_EASY)
spawnMask = MSF_EASY;
else if(gameSkill == SM_HARD
#if !__JDOOM64__
|| gameSkill == SM_NIGHTMARE
#endif
)
spawnMask = MSF_HARD;
else
spawnMask = MSF_MEDIUM;

if(!(spot->flags & spawnMask))
return false;

#if __JHEXEN__
// Check current character classes with spawn flags.
if(IS_NETGAME == false)
{ // Single player.
if((spot->flags & classFlags[cfg.playerClass[0]]) == 0)
{ // Not for current class.
return false;
}
}
else if(deathmatch == false)
{ // Cooperative.
int i;

spawnMask = 0;
for(i = 0; i < MAXPLAYERS; ++i)
{
if(players[i].plr->inGame)
{
spawnMask |= classFlags[cfg.playerClass[i]];
}
}

// No players are in the game when a dedicated server is started.
// In this case, we'll be generous and spawn stuff for all the
// classes.
if(!spawnMask)
{
spawnMask |= MSF_FIGHTER | MSF_CLERIC | MSF_MAGE;
}

if((spot->flags & spawnMask) == 0)
{
return false;
}
}
#endif

return true;
}

static void P_LoadMapObjs(void)
{
uint i;
Expand Down Expand Up @@ -429,18 +508,68 @@ static void P_LoadMapObjs(void)
}
#endif

// Create special start positions.
switch(spot->doomEdNum)
{
default:
break;
default: // A spot that should auto-spawn one (or more) mobjs.
{
mobjtype_t type;

if(!checkMapSpotSpawnFlags(spot))
continue;

// Find which type to spawn.
if((type = P_DoomEdNumToMobjType(spot->doomEdNum)) != MT_NONE)
{ // A known type; spawn it!
mobj_t* mo;
/*#if _DEBUG
Con_Message("spawning x:[%g, %g, %g] angle:%i ednum:%i flags:%i\n",
spot->pos[VX], spot->pos[VY], spot->pos[VZ], spot->angle,
spot->doomedNum, spot->flags);
#endif*/

if((mo = P_SpawnMobj3fv(type, spot->pos, spot->angle,
spot->flags)))
{
if(mo->tics > 0)
mo->tics = 1 + (P_Random() % mo->tics);

case 11: // Deathmatch.
#if __JHEXEN__
mo->tid = spot->tid;
mo->special = spot->special;
mo->args[0] = spot->arg1;
mo->args[1] = spot->arg2;
mo->args[2] = spot->arg3;
mo->args[3] = spot->arg4;
mo->args[4] = spot->arg5;
#endif

#if __JHEXEN__
if(mo->flags2 & MF2_FLOATBOB)
mo->special1 = FLT2FIX(spot->pos[VZ]);
#endif

#if __JDOOM__ || __JDOOM64__ || __JHERETIC__
if(mo->flags & MF_COUNTKILL)
totalKills++;
if(mo->flags & MF_COUNTITEM)
totalItems++;
#endif
}
}
else
{
Con_Message("spawnMapThing: Warning, unknown thing num %i "
"at [%g, %g, %g].\n", spot->doomEdNum,
spot->pos[VX], spot->pos[VY], spot->pos[VZ]);
}
break;
}
case 11: // Player start (deathmatch).
P_CreatePlayerStart(0, 0, true, spot->pos[VX], spot->pos[VY],
spot->pos[VZ], spot->angle, spot->flags);
break;

case 1: // Players 1 through 4.
case 1: // Player starts 1 through 4.
case 2:
case 3:
case 4:
Expand Down Expand Up @@ -469,7 +598,7 @@ static void P_LoadMapObjs(void)
#endif

#if __JHEXEN__
case 9100: // Players 5 through 8.
case 9100: // Player starts 5 through 8.
case 9101:
case 9102:
case 9103:
Expand Down Expand Up @@ -635,7 +764,6 @@ int P_SetupMapWorker(void* ptr)

DD_InitThinkers();
P_LoadMapObjs();
P_SpawnThings();

#if __JDOOM__
if(gameMode == commercial)
Expand Down

0 comments on commit 34fd5d4

Please sign in to comment.