From aa15b34a0863f26462bc90fc338cfd3f5bd9ef48 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Tue, 27 Feb 2018 19:53:12 -0500 Subject: [PATCH] Actual Race starts --- src/g_game.c | 38 ++++++++++++++++++++++++++++++-------- src/g_game.h | 2 +- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 3d7d5d42..2f148cda 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2611,7 +2611,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) { if (!(spawnpoint = G_FindCTFStart(playernum)) // find a CTF start && !(spawnpoint = G_FindMatchStart(playernum))) // find a DM start - spawnpoint = G_FindCoopStart(playernum); // fallback + spawnpoint = G_FindRaceStart(playernum); // fallback } // -- DM/Tag/CTF-spectator/etc -- @@ -2621,14 +2621,14 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) { if (!(spawnpoint = G_FindMatchStart(playernum)) // find a DM start && !(spawnpoint = G_FindCTFStart(playernum))) // find a CTF start - spawnpoint = G_FindCoopStart(playernum); // fallback + spawnpoint = G_FindRaceStart(playernum); // fallback } // -- Other game modes -- // Order: Coop->DM->CTF else { - if (!(spawnpoint = G_FindCoopStart(playernum)) // find a Co-op start + if (!(spawnpoint = G_FindRaceStart(playernum)) // find a Race start && !(spawnpoint = G_FindMatchStart(playernum))) // find a DM start spawnpoint = G_FindCTFStart(playernum); // fallback } @@ -2760,24 +2760,46 @@ mapthing_t *G_FindMatchStart(INT32 playernum) return NULL; } -mapthing_t *G_FindCoopStart(INT32 playernum) +mapthing_t *G_FindRaceStart(INT32 playernum) { if (numcoopstarts) { + INT32 i, pos = 0; + //if there's 6 players in a map with 3 player starts, this spawns them 1/2/3/1/2/3. - if (G_CheckSpot(playernum, playerstarts[playernum % numcoopstarts])) - return playerstarts[playernum % numcoopstarts]; + /*if (G_CheckSpot(playernum, playerstarts[playernum % numcoopstarts])) + return playerstarts[playernum % numcoopstarts];*/ + + // SRB2Kart: figure out player spawn pos from points + for (i = 0; i < MAXPLAYERS; i++) + { + if (i == playernum) + continue; + if (players[i].score > players[playernum]->score) + pos++; + } + + if (G_CheckSpot(playernum, playerstarts[pos % numcoopstarts])) + return playerstarts[pos % numcoopstarts]; //Don't bother checking to see if the player 1 start is open. //Just spawn there. - return playerstarts[0]; + //return playerstarts[0]; + + // SRB2Kart: We have solid players, so that is less ideal. + if (playernum == consoleplayer + || (splitscreen && playernum == secondarydisplayplayer) + || (splitscreen > 1 && playernum == thirddisplayplayer) + || (splitscreen > 2 && playernum == fourthdisplayplayer)) + CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Race starts!\n")); + return NULL; } if (playernum == consoleplayer || (splitscreen && playernum == secondarydisplayplayer) || (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 2 && playernum == fourthdisplayplayer)) - CONS_Alert(CONS_WARNING, M_GetText("No Co-op starts in this map!\n")); + CONS_Alert(CONS_WARNING, M_GetText("No Race starts in this map!\n")); return NULL; } diff --git a/src/g_game.h b/src/g_game.h index 8ea9d8f6..9e11727f 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -112,7 +112,7 @@ char *G_BuildMapTitle(INT32 mapnum); // XMOD spawning mapthing_t *G_FindCTFStart(INT32 playernum); mapthing_t *G_FindMatchStart(INT32 playernum); -mapthing_t *G_FindCoopStart(INT32 playernum); +mapthing_t *G_FindRaceStart(INT32 playernum); void G_SpawnPlayer(INT32 playernum, boolean starpost); // Can be called by the startup code or M_Responder.