Fix NO CONTEST Pwr.Lv when more than 1 lap behind

This commit is contained in:
Sally Coolatta 2022-08-15 19:47:01 -04:00
parent 96ff6dfd15
commit ddfa9e9d88
4 changed files with 55 additions and 41 deletions

View file

@ -3616,11 +3616,14 @@ static void G_DoCompleted(void)
wipegamestate = GS_NULL; wipegamestate = GS_NULL;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i]) if (playeringame[i])
{ {
// SRB2Kart: exitlevel shouldn't get you the points // SRB2Kart: exitlevel shouldn't get you the points
if (!players[i].exiting && !(players[i].pflags & PF_NOCONTEST)) if (!players[i].exiting && !(players[i].pflags & PF_NOCONTEST))
{ {
clientPowerAdd[i] = 0;
if (players[i].bot) if (players[i].bot)
{ {
K_FakeBotResults(&players[i]); K_FakeBotResults(&players[i]);
@ -3638,6 +3641,7 @@ static void G_DoCompleted(void)
G_PlayerFinishLevel(i); // take away cards and stuff G_PlayerFinishLevel(i); // take away cards and stuff
} }
}
// play some generic music if there's no win/cool/lose music going on (for exitlevel commands) // play some generic music if there's no win/cool/lose music going on (for exitlevel commands)
if ((gametyperules & GTR_CIRCUIT) && ((multiplayer && demo.playback) || j == r_splitscreen+1) && (cv_inttime.value > 0)) if ((gametyperules & GTR_CIRCUIT) && ((multiplayer && demo.playback) || j == r_splitscreen+1) && (cv_inttime.value > 0))

View file

@ -203,9 +203,9 @@ void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
return; return;
} }
CONS_Printf("\n========\n"); //CONS_Printf("\n========\n");
CONS_Printf("* Power Level change for player %s (LAP %d) *\n", player_names[playerNum], lap); //CONS_Printf("* Power Level change for player %s (LAP %d) *\n", player_names[playerNum], lap);
CONS_Printf("========\n"); //CONS_Printf("========\n");
yourPower = clientpowerlevels[playerNum][powerType]; yourPower = clientpowerlevels[playerNum][powerType];
if (yourPower == 0) if (yourPower == 0)
@ -214,12 +214,12 @@ void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
return; return;
} }
CONS_Printf("%s's PWR.LV: %d\n", player_names[playerNum], yourPower); //CONS_Printf("%s's PWR.LV: %d\n", player_names[playerNum], yourPower);
yourScore = K_PowerLevelPlacementScore(player); yourScore = K_PowerLevelPlacementScore(player);
CONS_Printf("%s's gametype score: %d\n", player_names[playerNum], yourScore); //CONS_Printf("%s's gametype score: %d\n", player_names[playerNum], yourScore);
CONS_Printf("========\n"); //CONS_Printf("========\n");
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
UINT16 theirScore = 0; UINT16 theirScore = 0;
@ -240,7 +240,7 @@ void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
continue; continue;
} }
CONS_Printf("%s VS %s:\n", player_names[playerNum], player_names[i]); //CONS_Printf("%s VS %s:\n", player_names[playerNum], player_names[i]);
theirPower = clientpowerlevels[i][powerType]; theirPower = clientpowerlevels[i][powerType];
if (theirPower == 0) if (theirPower == 0)
@ -249,14 +249,14 @@ void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
continue; continue;
} }
CONS_Printf("%s's PWR.LV: %d\n", player_names[i], theirPower); //CONS_Printf("%s's PWR.LV: %d\n", player_names[i], theirPower);
theirScore = K_PowerLevelPlacementScore(&players[i]); theirScore = K_PowerLevelPlacementScore(&players[i]);
CONS_Printf("%s's gametype score: %d\n", player_names[i], theirScore); //CONS_Printf("%s's gametype score: %d\n", player_names[i], theirScore);
if (yourScore == theirScore && forfeit == false) // Tie -- neither get any points for this match up. if (yourScore == theirScore && forfeit == false) // Tie -- neither get any points for this match up.
{ {
CONS_Printf("TIE, no change.\n"); //CONS_Printf("TIE, no change.\n");
continue; continue;
} }
@ -266,13 +266,13 @@ void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
{ {
diff = theirPower - yourPower; diff = theirPower - yourPower;
inc += K_CalculatePowerLevelInc(diff); inc += K_CalculatePowerLevelInc(diff);
CONS_Printf("WON! Diff is %d, increment is %d\n", diff, inc); //CONS_Printf("WON! Diff is %d, increment is %d\n", diff, inc);
} }
else // This player lost... else // This player lost...
{ {
diff = yourPower - theirPower; diff = yourPower - theirPower;
inc -= K_CalculatePowerLevelInc(diff); inc -= K_CalculatePowerLevelInc(diff);
CONS_Printf("LOST... Diff is %d, increment is %d\n", diff, inc); //CONS_Printf("LOST... Diff is %d, increment is %d\n", diff, inc);
} }
if (exitBonus == false) if (exitBonus == false)
@ -293,10 +293,10 @@ void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
} }
} }
CONS_Printf("Reduced (%d / %d = %d) because it's not the end of the race\n", prevInc, numlaps, inc); //CONS_Printf("Reduced (%d / %d = %d) because it's not the end of the race\n", prevInc, numlaps, inc);
} }
CONS_Printf("========\n"); //CONS_Printf("========\n");
if (inc == 0) if (inc == 0)
{ {
@ -304,21 +304,42 @@ void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
continue; continue;
} }
CONS_Printf("Total Result:\n"); //CONS_Printf("Total Result:\n");
CONS_Printf("Increment: %d\n", inc); //CONS_Printf("Increment: %d\n", inc);
CONS_Printf("%s current: %d\n", player_names[playerNum], clientPowerAdd[playerNum]); //CONS_Printf("%s current: %d\n", player_names[playerNum], clientPowerAdd[playerNum]);
clientPowerAdd[playerNum] += inc; clientPowerAdd[playerNum] += inc;
CONS_Printf("%s final: %d\n", player_names[playerNum], clientPowerAdd[playerNum]); //CONS_Printf("%s final: %d\n", player_names[playerNum], clientPowerAdd[playerNum]);
CONS_Printf("%s current: %d\n", player_names[i], clientPowerAdd[i]); //CONS_Printf("%s current: %d\n", player_names[i], clientPowerAdd[i]);
clientPowerAdd[i] -= inc; clientPowerAdd[i] -= inc;
CONS_Printf("%s final: %d\n", player_names[i], clientPowerAdd[i]); //CONS_Printf("%s final: %d\n", player_names[i], clientPowerAdd[i]);
CONS_Printf("========\n"); //CONS_Printf("========\n");
} }
} }
void K_UpdatePowerLevelsOnFailure(player_t *player)
{
// Update upon spectate / quit / NO CONTEST
INT16 lapsLeft = 0;
UINT8 i;
lapsLeft = (numlaps - player->latestlap) + 1;
if (lapsLeft <= 0)
{
return;
}
for (i = 0; i < lapsLeft; i++)
{
K_UpdatePowerLevels(player, player->latestlap + (i + 1), true);
}
player->latestlap = numlaps+1;
}
INT16 K_FinalPowerIncrement(player_t *player, INT16 yourPower, INT16 baseInc) INT16 K_FinalPowerIncrement(player_t *player, INT16 yourPower, INT16 baseInc)
{ {
INT16 inc = baseInc; INT16 inc = baseInc;
@ -387,9 +408,9 @@ void K_CashInPowerLevels(void)
SINT8 powerType = K_UsingPowerLevels(); SINT8 powerType = K_UsingPowerLevels();
UINT8 i; UINT8 i;
CONS_Printf("\n========\n"); //CONS_Printf("\n========\n");
CONS_Printf("Cashing in power level changes...\n"); //CONS_Printf("Cashing in power level changes...\n");
CONS_Printf("========\n"); //CONS_Printf("========\n");
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
@ -398,7 +419,7 @@ void K_CashInPowerLevels(void)
INT16 inc = K_FinalPowerIncrement(&players[i], clientpowerlevels[i][powerType], clientPowerAdd[i]); INT16 inc = K_FinalPowerIncrement(&players[i], clientpowerlevels[i][powerType], clientPowerAdd[i]);
clientpowerlevels[i][powerType] += inc; clientpowerlevels[i][powerType] += inc;
CONS_Printf("%s: %d -> %d (%d)\n", player_names[i], clientpowerlevels[i][powerType] - inc, clientpowerlevels[i][powerType], inc); //CONS_Printf("%s: %d -> %d (%d)\n", player_names[i], clientpowerlevels[i][powerType] - inc, clientpowerlevels[i][powerType], inc);
if (!demo.playback && i == consoleplayer && inc != 0) if (!demo.playback && i == consoleplayer && inc != 0)
{ {
@ -416,7 +437,7 @@ void K_CashInPowerLevels(void)
clientPowerAdd[i] = 0; clientPowerAdd[i] = 0;
} }
CONS_Printf("========\n"); //CONS_Printf("========\n");
} }
void K_SetPowerLevelScrambles(SINT8 powertype) void K_SetPowerLevelScrambles(SINT8 powertype)
@ -552,7 +573,6 @@ void K_PlayerForfeit(UINT8 playerNum, boolean pointLoss)
UINT16 yourPower = 0; UINT16 yourPower = 0;
INT16 inc = 0; INT16 inc = 0;
INT16 lapsLeft = 0;
UINT8 i; UINT8 i;
// power level & spectating is netgames only // power level & spectating is netgames only
@ -608,18 +628,8 @@ void K_PlayerForfeit(UINT8 playerNum, boolean pointLoss)
return; return;
} }
lapsLeft = (numlaps - players[playerNum].latestlap) + 1; K_UpdatePowerLevelsOnFailure(&players[playerNum]);
if (lapsLeft <= 0) inc = K_FinalPowerIncrement(&players[playerNum], yourPower, clientPowerAdd[playerNum]);
{
return;
}
for (i = 0; i < lapsLeft; i++)
{
K_UpdatePowerLevels(&players[i], players[playerNum].latestlap + (i + 1), true);
}
inc = K_FinalPowerIncrement(&players[i], yourPower, clientPowerAdd[i]);
if (inc >= 0) if (inc >= 0)
{ {

View file

@ -42,6 +42,7 @@ INT16 K_CalculatePowerLevelInc(INT16 diff);
INT16 K_PowerLevelPlacementScore(player_t *player); INT16 K_PowerLevelPlacementScore(player_t *player);
INT16 K_CalculatePowerLevelAvg(void); INT16 K_CalculatePowerLevelAvg(void);
void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit); void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit);
void K_UpdatePowerLevelsOnFailure(player_t *player);
INT16 K_FinalPowerIncrement(player_t *player, INT16 yourPower, INT16 increment); INT16 K_FinalPowerIncrement(player_t *player, INT16 yourPower, INT16 increment);
void K_CashInPowerLevels(void); void K_CashInPowerLevels(void);
void K_SetPowerLevelScrambles(SINT8 powertype); void K_SetPowerLevelScrambles(SINT8 powertype);

View file

@ -3851,8 +3851,7 @@ void P_DoTimeOver(player_t *player)
} }
player->pflags |= PF_NOCONTEST; player->pflags |= PF_NOCONTEST;
player->latestlap = numlaps+1; K_UpdatePowerLevelsOnFailure(player);
K_UpdatePowerLevels(player, numlaps+1, false);
if (G_GametypeUsesLives()) if (G_GametypeUsesLives())
{ {