mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-17 02:01:15 +00:00
Revamped race position
Should support ties for real now :V
This commit is contained in:
parent
94b1ce7ce3
commit
f985401ca4
1 changed files with 30 additions and 16 deletions
46
src/g_game.c
46
src/g_game.c
|
@ -2764,7 +2764,8 @@ mapthing_t *G_FindRaceStart(INT32 playernum)
|
||||||
{
|
{
|
||||||
if (numcoopstarts)
|
if (numcoopstarts)
|
||||||
{
|
{
|
||||||
INT32 i, pos = 0;
|
UINT8 i;
|
||||||
|
UINT8 pos = 0;
|
||||||
|
|
||||||
// SRB2Kart: figure out player spawn pos from points
|
// SRB2Kart: figure out player spawn pos from points
|
||||||
if (!playeringame[playernum] || players[playernum].spectator)
|
if (!playeringame[playernum] || players[playernum].spectator)
|
||||||
|
@ -2772,34 +2773,47 @@ mapthing_t *G_FindRaceStart(INT32 playernum)
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (i == playernum)
|
|
||||||
continue;
|
|
||||||
if (!playeringame[i] || players[i].spectator)
|
if (!playeringame[i] || players[i].spectator)
|
||||||
continue;
|
continue;
|
||||||
if (players[i].score > players[playernum].score)
|
if (i == playernum)
|
||||||
pos++;
|
continue;
|
||||||
if (i != 0)
|
|
||||||
|
if (players[i].score < players[playernum].score)
|
||||||
{
|
{
|
||||||
INT32 j;
|
UINT8 j;
|
||||||
for (j = 0; j < i; j++) // I don't like loops in loops, but is needed to resolve ties :<
|
UINT8 num = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < MAXPLAYERS; j++) // I hate similar loops inside loops... :<
|
||||||
{
|
{
|
||||||
if (i == j)
|
|
||||||
continue;
|
|
||||||
if (!playeringame[j] || players[j].spectator)
|
if (!playeringame[j] || players[j].spectator)
|
||||||
continue;
|
continue;
|
||||||
if (players[i].score == players[j].score)
|
if (j == playernum)
|
||||||
pos++;
|
continue;
|
||||||
|
if (j == i)
|
||||||
|
continue;
|
||||||
|
if (players[j].score == players[i].score)
|
||||||
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (num > 1) // found dupes
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (players[i].score > players[playernum].score || i < playernum)
|
||||||
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_CheckSpot(playernum, playerstarts[pos % numcoopstarts]))
|
if (G_CheckSpot(playernum, playerstarts[pos % numcoopstarts]))
|
||||||
return playerstarts[pos % numcoopstarts];
|
return playerstarts[pos % numcoopstarts];
|
||||||
|
|
||||||
// Your spot isn't available? Go for the old behavior
|
// Your spot isn't available? Find whatever you can get first.
|
||||||
// if there's 6 players in a map with 3 player starts, this spawns them 1/2/3/1/2/3.
|
for (i = 0; i < numcoopstarts; i++)
|
||||||
if (G_CheckSpot(playernum, playerstarts[playernum % numcoopstarts]))
|
{
|
||||||
return playerstarts[playernum % numcoopstarts];
|
if (G_CheckSpot(playernum, playerstarts[i]))
|
||||||
|
return playerstarts[i];
|
||||||
|
}
|
||||||
|
|
||||||
// SRB2Kart: We have solid players, so this behavior is less ideal.
|
// SRB2Kart: We have solid players, so this behavior is less ideal.
|
||||||
// Don't bother checking to see if the player 1 start is open.
|
// Don't bother checking to see if the player 1 start is open.
|
||||||
|
|
Loading…
Reference in a new issue