From 0c8e4c37d9baa3a1b3b157e04c098dd72fe456b1 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Jul 2012 02:18:15 +0000 Subject: [PATCH] - The complete FMapThing is overkill for storing player starts, so use a new minimal structure for them. SVN r3750 (trunk) --- src/doomdata.h | 19 ++++++++++++++++--- src/g_game.cpp | 18 +++++++++--------- src/g_game.h | 2 +- src/g_hexen/a_teleportother.cpp | 2 +- src/g_raven/a_artitele.cpp | 2 +- src/p_local.h | 4 +--- src/p_mobj.cpp | 12 +++++++----- src/p_setup.cpp | 8 ++++---- 8 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index e9b86781e..eeff13e2e 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -400,12 +400,25 @@ enum EMapThingFlags STF_ALTSHADOW = 0x0200, }; +// A simplified mapthing for player starts +struct FPlayerStart +{ + fixed_t x, y, z; + short angle, type; + + FPlayerStart() { } + FPlayerStart(const FMapThing *mthing) + : x(mthing->x), y(mthing->y), z(mthing->z), + angle(mthing->angle), + type(mthing->type) + { } +}; // Player spawn spots for deathmatch. -extern TArray deathmatchstarts; +extern TArray deathmatchstarts; // Player spawn spots. -extern FMapThing playerstarts[MAXPLAYERS]; -extern TArray AllPlayerStarts; +extern FPlayerStart playerstarts[MAXPLAYERS]; +extern TArray AllPlayerStarts; #endif // __DOOMDATA__ diff --git a/src/g_game.cpp b/src/g_game.cpp index 976876087..74189eadb 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1375,7 +1375,7 @@ void G_PlayerReborn (int player) // because something is occupying it // -bool G_CheckSpot (int playernum, FMapThing *mthing) +bool G_CheckSpot (int playernum, FPlayerStart *mthing) { fixed_t x; fixed_t y; @@ -1424,7 +1424,7 @@ bool G_CheckSpot (int playernum, FMapThing *mthing) // // [RH] Returns the distance of the closest player to the given mapthing -static fixed_t PlayersRangeFromSpot (FMapThing *spot) +static fixed_t PlayersRangeFromSpot (FPlayerStart *spot) { fixed_t closest = INT_MAX; fixed_t distance; @@ -1446,10 +1446,10 @@ static fixed_t PlayersRangeFromSpot (FMapThing *spot) } // [RH] Select the deathmatch spawn spot farthest from everyone. -static FMapThing *SelectFarthestDeathmatchSpot (size_t selections) +static FPlayerStart *SelectFarthestDeathmatchSpot (size_t selections) { fixed_t bestdistance = 0; - FMapThing *bestspot = NULL; + FPlayerStart *bestspot = NULL; unsigned int i; for (i = 0; i < selections; i++) @@ -1467,7 +1467,7 @@ static FMapThing *SelectFarthestDeathmatchSpot (size_t selections) } // [RH] Select a deathmatch spawn spot at random (original mechanism) -static FMapThing *SelectRandomDeathmatchSpot (int playernum, unsigned int selections) +static FPlayerStart *SelectRandomDeathmatchSpot (int playernum, unsigned int selections) { unsigned int i, j; @@ -1487,7 +1487,7 @@ static FMapThing *SelectRandomDeathmatchSpot (int playernum, unsigned int select void G_DeathMatchSpawnPlayer (int playernum) { unsigned int selections; - FMapThing *spot; + FPlayerStart *spot; selections = deathmatchstarts.Size (); // [RH] We can get by with just 1 deathmatch start @@ -1528,13 +1528,13 @@ void G_DeathMatchSpawnPlayer (int playernum) // // G_PickPlayerStart // -FMapThing *G_PickPlayerStart(int playernum, int flags) +FPlayerStart *G_PickPlayerStart(int playernum, int flags) { if ((level.flags2 & LEVEL2_RANDOMPLAYERSTARTS) || (flags & PPS_FORCERANDOM)) { if (!(flags & PPS_NOBLOCKINGCHECK)) { - TArray good_starts; + TArray good_starts; unsigned int i; // Find all unblocked player starts. @@ -1629,7 +1629,7 @@ void G_DoReborn (int playernum, bool freshbot) } else { // try to spawn at any random player's spot - FMapThing *start = G_PickPlayerStart(playernum, PPS_FORCERANDOM); + FPlayerStart *start = G_PickPlayerStart(playernum, PPS_FORCERANDOM); AActor *mo = P_SpawnPlayer(start, playernum); if (mo != NULL) P_PlayerStartStomp(mo); } diff --git a/src/g_game.h b/src/g_game.h index d5aec5ead..051be86b1 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -32,7 +32,7 @@ struct PNGHandle; // void G_DeathMatchSpawnPlayer (int playernum); -struct FMapThing *G_PickPlayerStart (int playernum, int flags = 0); +struct FPlayerStart *G_PickPlayerStart (int playernum, int flags = 0); enum { PPS_FORCERANDOM = 1, diff --git a/src/g_hexen/a_teleportother.cpp b/src/g_hexen/a_teleportother.cpp index ea99f48f0..2bf99640b 100644 --- a/src/g_hexen/a_teleportother.cpp +++ b/src/g_hexen/a_teleportother.cpp @@ -158,7 +158,7 @@ void P_TeleportToPlayerStarts (AActor *victim) fixed_t destX,destY; angle_t destAngle; - FMapThing *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK); + FPlayerStart *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK); destX = start->x; destY = start->y; destAngle = ANG45 * (start->angle/45); diff --git a/src/g_raven/a_artitele.cpp b/src/g_raven/a_artitele.cpp index 9f4bb939c..0778eac4b 100644 --- a/src/g_raven/a_artitele.cpp +++ b/src/g_raven/a_artitele.cpp @@ -38,7 +38,7 @@ bool AArtiTeleport::Use (bool pickup) } else { - FMapThing *start = G_PickPlayerStart(int(Owner->player - players)); + FPlayerStart *start = G_PickPlayerStart(int(Owner->player - players)); destX = start->x; destY = start->y; destAngle = ANG45 * (start->angle/45); diff --git a/src/p_local.h b/src/p_local.h index fe47f5999..840336f80 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -116,9 +116,7 @@ void P_UnPredictPlayer (); extern fixed_t FloatBobOffsets[64]; -struct FMapThing; - -APlayerPawn *P_SpawnPlayer (FMapThing *mthing, int playernum, bool tempplayer=false); +APlayerPawn *P_SpawnPlayer (struct FPlayerStart *mthing, int playernum, bool tempplayer=false); void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move); int P_FaceMobj (AActor *source, AActor *target, angle_t *delta); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 4cfc25a8e..18fdc3150 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4074,7 +4074,7 @@ EXTERN_CVAR (Bool, chasedemo) extern bool demonew; -APlayerPawn *P_SpawnPlayer (FMapThing *mthing, int playernum, bool tempplayer) +APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, bool tempplayer) { player_t *p; APlayerPawn *mobj, *oldactor; @@ -4356,7 +4356,8 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) // count deathmatch start positions if (mthing->type == 11) { - deathmatchstarts.Push (*mthing); + FPlayerStart start(mthing); + deathmatchstarts.Push(start); return NULL; } @@ -4480,11 +4481,12 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) return NULL; // save spots for respawning in network games - playerstarts[pnum] = *mthing; - AllPlayerStarts.Push(*mthing); + FPlayerStart start(mthing); + playerstarts[pnum] = start; + AllPlayerStarts.Push(start); if (!deathmatch && !(level.flags2 & LEVEL2_RANDOMPLAYERSTARTS)) { - return P_SpawnPlayer(&playerstarts[pnum], pnum); + return P_SpawnPlayer(&start, pnum); } return NULL; } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 4c98c7d90..37a9da789 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -182,9 +182,9 @@ BYTE* rejectmatrix; bool ForceNodeBuild; // Maintain single and multi player starting spots. -TArray deathmatchstarts (16); -FMapThing playerstarts[MAXPLAYERS]; -TArray AllPlayerStarts; +TArray deathmatchstarts (16); +FPlayerStart playerstarts[MAXPLAYERS]; +TArray AllPlayerStarts; static void P_AllocateSideDefs (int count); @@ -3988,7 +3988,7 @@ void P_SetupLevel (char *lumpname, int position) if (playeringame[i]) { players[i].mo = NULL; - FMapThing *mthing = G_PickPlayerStart(i); + FPlayerStart *mthing = G_PickPlayerStart(i); P_SpawnPlayer(mthing, i); } }