mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Avoid duplicated opponents check
This commit is contained in:
parent
2ec0fdcc46
commit
bc328e5040
1 changed files with 25 additions and 17 deletions
42
src/k_kart.c
42
src/k_kart.c
|
|
@ -15964,22 +15964,32 @@ boolean K_PlayerCanUseItem(player_t *player)
|
||||||
return (player->mo->health > 0 && !player->spectator && !P_PlayerInPain(player) && !mapreset && leveltime > introtime);
|
return (player->mo->health > 0 && !player->spectator && !P_PlayerInPain(player) && !mapreset && leveltime > introtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===
|
||||||
|
// THE EXP ZONE
|
||||||
|
// ===
|
||||||
|
|
||||||
|
static boolean K_IsValidOpponent(player_t *me, player_t *them)
|
||||||
|
{
|
||||||
|
UINT8 i = (them - players);
|
||||||
|
|
||||||
|
if (!playeringame[i] || players[i].spectator)
|
||||||
|
return false;
|
||||||
|
if (me == them)
|
||||||
|
return false;
|
||||||
|
if (G_SameTeam(me, them))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static UINT8 K_Opponents(player_t *player)
|
static UINT8 K_Opponents(player_t *player)
|
||||||
{
|
{
|
||||||
UINT8 opponents = 0; // players we are competing against
|
UINT8 opponents = 0; // players we are competing against
|
||||||
|
|
||||||
for (UINT8 i = 0; i < MAXPLAYERS; i++)
|
for (UINT8 i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (!playeringame[i] || players[i].spectator || player == players+i)
|
if (K_IsValidOpponent(player, &players[i]))
|
||||||
continue;
|
opponents++;
|
||||||
|
|
||||||
if (G_SameTeam(player, &players[i]) == true)
|
|
||||||
{
|
|
||||||
// You don't win/lose against your teammates.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
opponents++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return opponents;
|
return opponents;
|
||||||
|
|
@ -16019,15 +16029,9 @@ fixed_t K_GetGradingFactorAdjustment(player_t *player)
|
||||||
// Increase XP for each player you're beating...
|
// Increase XP for each player you're beating...
|
||||||
for (INT32 i = 0; i < MAXPLAYERS; i++)
|
for (INT32 i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (!playeringame[i] || players[i].spectator || player == players+i)
|
if (!K_IsValidOpponent(player, &players[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (G_SameTeam(player, &players[i]) == true)
|
|
||||||
{
|
|
||||||
// You don't win/lose against your teammates.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player->position < players[i].position)
|
if (player->position < players[i].position)
|
||||||
result += K_EXPGainPerWin(player);
|
result += K_EXPGainPerWin(player);
|
||||||
}
|
}
|
||||||
|
|
@ -16084,6 +16088,10 @@ UINT32 K_GetNumGradingPoints(void)
|
||||||
return numlaps * (1 + Obj_GetCheckpointCount());
|
return numlaps * (1 + Obj_GetCheckpointCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===
|
||||||
|
// END EXP ZONE
|
||||||
|
// ===
|
||||||
|
|
||||||
void K_BotHitPenalty(player_t *player)
|
void K_BotHitPenalty(player_t *player)
|
||||||
{
|
{
|
||||||
if (K_PlayerUsesBotMovement(player))
|
if (K_PlayerUsesBotMovement(player))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue