Skip to content

Commit

Permalink
Changed playerstart_t, removing the information duplicated from the a…
Browse files Browse the repository at this point in the history
…ssociated mapspot_t and instead referencing it in the mapSpots array.
  • Loading branch information
danij-deng committed Apr 19, 2010
1 parent e6a5e48 commit 877643e
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 79 deletions.
7 changes: 2 additions & 5 deletions doomsday/plugins/common/include/p_start.h
Expand Up @@ -124,9 +124,7 @@ typedef uint mapspotid_t;
typedef struct {
int plrNum;
uint entryPoint;
float pos[3];
angle_t angle;
int spawnFlags; // MSF_* flags.
mapspotid_t spot;
} playerstart_t;

extern uint numMapSpots;
Expand All @@ -153,8 +151,7 @@ void P_AddBossSpot(mapspotid_t id);
#endif

void P_CreatePlayerStart(int defaultPlrNum, uint entryPoint,
boolean deathmatch, float x, float y,
float z, angle_t angle, int spawnFlags);
boolean deathmatch, mapspotid_t spot);
void P_DestroyPlayerStarts(void);
uint P_GetNumPlayerStarts(boolean deathmatch);

Expand Down
5 changes: 3 additions & 2 deletions doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -755,8 +755,9 @@ void NetSv_NewPlayerEnters(int plrNum)

if((start = P_GetPlayerStart(nextMapEntryPoint, plrNum, false)))
{
P_SpawnPlayer(plrNum, pClass, start->pos[VX], start->pos[VY],
start->pos[VZ], start->angle, start->spawnFlags,
const mapspot_t* spot = &mapSpots[start->spot];
P_SpawnPlayer(plrNum, pClass, spot->pos[VX], spot->pos[VY],
spot->pos[VZ], spot->angle, spot->flags,
false, true);
}
else
Expand Down
11 changes: 3 additions & 8 deletions doomsday/plugins/common/src/p_mapsetup.c
Expand Up @@ -569,8 +569,7 @@ Con_Message("spawning x:[%g, %g, %g] angle:%i ednum:%i flags:%i\n",
break;
}
case 11: // Player start (deathmatch).
P_CreatePlayerStart(0, 0, true, spot->pos[VX], spot->pos[VY],
spot->pos[VZ], spot->angle, spot->flags);
P_CreatePlayerStart(0, 0, true, i);
break;

case 1: // Player starts 1 through 4.
Expand All @@ -584,9 +583,7 @@ Con_Message("spawning x:[%g, %g, %g] angle:%i ednum:%i flags:%i\n",
uint entryPoint = 0;
#endif

P_CreatePlayerStart(spot->doomEdNum, entryPoint, false,
spot->pos[VX], spot->pos[VY], spot->pos[VZ],
spot->angle, spot->flags);
P_CreatePlayerStart(spot->doomEdNum, entryPoint, false, i);
break;
}

Expand All @@ -606,9 +603,7 @@ Con_Message("spawning x:[%g, %g, %g] angle:%i ednum:%i flags:%i\n",
case 9101:
case 9102:
case 9103:
P_CreatePlayerStart(5 + spot->doomEdNum - 9100, spot->arg1,
false, spot->pos[VX], spot->pos[VY],
spot->pos[VZ], spot->angle, spot->flags);
P_CreatePlayerStart(5 + spot->doomEdNum - 9100, spot->arg1, false, i);
break;
#endif
}
Expand Down
7 changes: 4 additions & 3 deletions doomsday/plugins/common/src/p_saveg.c
Expand Up @@ -5609,9 +5609,10 @@ void SV_MapTeleport(uint map, uint position)

if((start = P_GetPlayerStart(position, i, false)))
{
P_SpawnPlayer(i, cfg.playerClass[i], start->pos[VX],
start->pos[VY], start->pos[VZ], start->angle,
start->spawnFlags, false, true);
const mapspot_t* spot = &mapSpots[start->spot];
P_SpawnPlayer(i, cfg.playerClass[i], spot->pos[VX],
spot->pos[VY], spot->pos[VZ], spot->angle,
spot->flags, false, true);
}
else
{
Expand Down
113 changes: 60 additions & 53 deletions doomsday/plugins/common/src/p_start.c
Expand Up @@ -226,11 +226,10 @@ void P_Init(void)
#endif
}

void P_CreatePlayerStart(int defaultPlrNum, uint entryPoint,
boolean deathmatch, float x, float y, float z,
angle_t angle, int spawnFlags)
void P_CreatePlayerStart(int defaultPlrNum, uint entryPoint, boolean deathmatch,
mapspotid_t spot)
{
playerstart_t* start;
playerstart_t* start;

if(deathmatch)
{
Expand All @@ -247,11 +246,7 @@ void P_CreatePlayerStart(int defaultPlrNum, uint entryPoint,

start->plrNum = defaultPlrNum;
start->entryPoint = entryPoint;
start->pos[VX] = x;
start->pos[VY] = y;
start->pos[VZ] = z;
start->angle = angle;
start->spawnFlags = spawnFlags;
start->spot = spot;
}

void P_DestroyPlayerStarts(void)
Expand Down Expand Up @@ -670,34 +665,41 @@ void P_RebornPlayer(int plrNum)
#else
uint entryPoint = 0;
#endif
boolean foundSpot = false;
const playerstart_t* assigned =
P_GetPlayerStart(entryPoint, plrNum, false);
boolean foundSpot = false;
const playerstart_t* assigned = P_GetPlayerStart(entryPoint, plrNum, false);

if(assigned && P_CheckSpot(assigned->pos[VX], assigned->pos[VY]))
{ // Appropriate player start spot is open.
Con_Printf("- spawning at assigned spot\n");
if(assigned)
{
const mapspot_t* spot = &mapSpots[assigned->spot];

if(P_CheckSpot(spot->pos[VX], spot->pos[VY]))
{ // Appropriate player start spot is open.
Con_Printf("- spawning at assigned spot\n");

pos[VX] = assigned->pos[VX];
pos[VY] = assigned->pos[VY];
pos[VZ] = assigned->pos[VZ];
angle = assigned->angle;
spawnFlags = assigned->spawnFlags;
pos[VX] = spot->pos[VX];
pos[VY] = spot->pos[VY];
pos[VZ] = spot->pos[VZ];
angle = spot->angle;
spawnFlags = spot->flags;

foundSpot = true;
foundSpot = true;
}
}

#if __JDOOM__ || __JHERETIC__ || __JDOOM64__
else
if(!foundSpot)
{
Con_Printf("- force spawning at %i.\n", p->startSpot);

if(assigned)
{
pos[VX] = assigned->pos[VX];
pos[VY] = assigned->pos[VY];
pos[VZ] = assigned->pos[VZ];
angle = assigned->angle;
spawnFlags = assigned->spawnFlags;
const mapspot_t* spot = &mapSpots[assigned->spot];

pos[VX] = spot->pos[VX];
pos[VY] = spot->pos[VY];
pos[VZ] = spot->pos[VZ];
angle = spot->angle;
spawnFlags = spot->flags;

// "Fuzz" the spawn position looking for room nearby.
makeCamera = !fuzzySpawnPosition(&pos[VX], &pos[VY],
Expand All @@ -713,7 +715,7 @@ void P_RebornPlayer(int plrNum)
}
}
#else
else
if(!foundSpot)
{
int i;

Expand All @@ -724,14 +726,16 @@ void P_RebornPlayer(int plrNum)

if((start = P_GetPlayerStart(rebornPosition, i, false)))
{
if(P_CheckSpot(start->pos[VX], start->pos[VY]))
const mapspot_t* spot = &mapSpots[start->spot];

if(P_CheckSpot(spot->pos[VX], spot->pos[VY]))
{
// Found an open start spot.
pos[VX] = start->pos[VX];
pos[VY] = start->pos[VY];
pos[VZ] = start->pos[VZ];
angle = start->angle;
spawnFlags = start->spawnFlags;
pos[VX] = spot->pos[VX];
pos[VY] = spot->pos[VY];
pos[VZ] = spot->pos[VZ];
angle = spot->angle;
spawnFlags = spot->flags;

foundSpot = true;
break;
Expand All @@ -746,11 +750,13 @@ void P_RebornPlayer(int plrNum)

if((start = P_GetPlayerStart(rebornPosition, plrNum, false)))
{
pos[VX] = start->pos[VX];
pos[VY] = start->pos[VY];
pos[VZ] = start->pos[VZ];
angle = start->angle;
spawnFlags = start->spawnFlags;
const mapspot_t* spot = &mapSpots[start->spot];

pos[VX] = spot->pos[VX];
pos[VY] = spot->pos[VY];
pos[VZ] = spot->pos[VZ];
angle = spot->angle;
spawnFlags = spot->flags;
}
else
{
Expand Down Expand Up @@ -872,11 +878,11 @@ void P_SpawnPlayers(void)
{
if(players[0].startSpot != i && playerStarts[i].plrNum == 1)
{
const playerstart_t* start = &playerStarts[i];
const mapspot_t* spot = &mapSpots[playerStarts[i].spot];

spawnPlayer(-1, PCLASS_PLAYER, start->pos[VX],
start->pos[VY], start->pos[VZ],
start->angle, start->spawnFlags, false,
spawnPlayer(-1, PCLASS_PLAYER, spot->pos[VX],
spot->pos[VY], spot->pos[VZ],
spot->angle, spot->flags, false,
false, false);
}
}
Expand All @@ -903,11 +909,13 @@ void P_SpawnPlayers(void)

if(start)
{
pos[VX] = start->pos[VX];
pos[VY] = start->pos[VY];
pos[VZ] = start->pos[VZ];
angle = start->angle;
spawnFlags = start->spawnFlags;
const mapspot_t* spot = &mapSpots[start->spot];

pos[VX] = spot->pos[VX];
pos[VY] = spot->pos[VY];
pos[VZ] = spot->pos[VZ];
angle = spot->angle;
spawnFlags = spot->flags;

// "Fuzz" the spawn position looking for room nearby.
makeCamera = !fuzzySpawnPosition(&pos[VX], &pos[VY],
Expand Down Expand Up @@ -971,13 +979,12 @@ void G_DeathMatchSpawnPlayer(int playerNum)

for(i = 0; i < 20; ++i)
{
const playerstart_t* start =
&deathmatchStarts[P_Random() % numPlayerDMStarts];
const mapspot_t* spot = &mapSpots[deathmatchStarts[P_Random() % numPlayerDMStarts].spot];

if(P_CheckSpot(start->pos[VX], start->pos[VY]))
if(P_CheckSpot(spot->pos[VX], spot->pos[VY]))
{
spawnPlayer(playerNum, pClass, start->pos[VX], start->pos[VY],
start->pos[VZ], start->angle, start->spawnFlags, false,
spawnPlayer(playerNum, pClass, spot->pos[VX], spot->pos[VY],
spot->pos[VZ], spot->angle, spot->flags, false,
true, true);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jheretic/src/p_telept.c
Expand Up @@ -251,8 +251,8 @@ void P_ArtiTele(player_t* player)
// Get a random deathmatch start.
if((start = P_GetPlayerStart(0, deathmatch? -1 : 0, deathmatch)))
{
P_Teleport(player->plr->mo, start->pos[VX], start->pos[VY],
start->angle, true);
const mapspot_t* spot = &mapSpots[start->spot];
P_Teleport(player->plr->mo, spot->pos[VX], spot->pos[VY], spot->angle, true);

#if __JHEXEN__
if(player->morphTics)
Expand Down
12 changes: 6 additions & 6 deletions doomsday/plugins/jhexen/src/p_telept.c
Expand Up @@ -75,8 +75,8 @@ void P_TeleportToPlayerStarts(mobj_t* mo)
// Get a random player start.
if((start = P_GetPlayerStart(0, -1, false)))
{
P_Teleport(mo, start->pos[VX], start->pos[VY],
start->angle, true);
const mapspot_t* spot = &mapSpots[start->spot];
P_Teleport(mo, spot->pos[VX], spot->pos[VY], spot->angle, true);
}
}

Expand All @@ -90,8 +90,8 @@ void P_TeleportToDeathmatchStarts(mobj_t* mo)
// First, try a random deathmatch start.
if((start = P_GetPlayerStart(0, -1, true)))
{
P_Teleport(mo, start->pos[VX], start->pos[VY],
start->angle, true);
const mapspot_t* spot = &mapSpots[start->spot];
P_Teleport(mo, spot->pos[VX], spot->pos[VY], spot->angle, true);
}
else
{
Expand Down Expand Up @@ -250,8 +250,8 @@ void P_ArtiTele(player_t* player)

if((start = P_GetPlayerStart(0, deathmatch? -1 : 0, deathmatch)))
{
P_Teleport(player->plr->mo, start->pos[VX], start->pos[VY],
start->angle, true);
const mapspot_t* spot = &mapSpots[start->spot];
P_Teleport(player->plr->mo, spot->pos[VX], spot->pos[VY], spot->angle, true);

#if __JHEXEN__
if(player->morphTics)
Expand Down

0 comments on commit 877643e

Please sign in to comment.