K_KartLegacyUpdatePosition from saturn and fix laps+1 uses

Description:
"this checked the distance to every single waypoint on the map always and unconditionally, but we dont need the distance unconditionally so only check if we need to
+5fps in techbatics hadal classic timedemo"
This commit is contained in:
NepDisk 2025-07-20 19:07:59 -04:00
parent 580f2da4bf
commit 2d2a04b4d3
2 changed files with 38 additions and 23 deletions

View file

@ -2212,7 +2212,7 @@ static void K_drawKartLaps(void)
if (numlaps >= 10)
{
UINT8 ln[2];
ln[0] = ((stplyr->laps+1 / 10) % 10);
ln[0] = ((stplyr->laps / 10) % 10);
ln[1] = (stplyr->laps % 10);
V_DrawScaledPatch(fx+13, fy, V_HUDTRANS|splitflags, fontv[PINGNUM_FONT].font[ln[0]]);

View file

@ -10271,32 +10271,47 @@ void K_KartLegacyUpdatePosition(player_t *player)
// This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now)
for (mo = boss3cap; mo != NULL; mo = mo->tracer)
{
pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x,
mo->y - player->mo->y),
mo->z - player->mo->z) / FRACUNIT;
imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x,
mo->y - players[i].mo->y),
mo->z - players[i].mo->z) / FRACUNIT;
const boolean isprevcheckpointp = mo->health == player->starpostnum;
const boolean isnextcheckpointp = mo->health == (player->starpostnum + 1);
if (mo->health == player->starpostnum && (!mo->movecount || mo->movecount == player->laps+1))
if ((isprevcheckpointp || isnextcheckpointp) && (!mo->movecount || mo->movecount == player->laps))
{
player->prevcheck += pmo;
ppcd++;
pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x,
mo->y - player->mo->y),
mo->z - player->mo->z) / FRACUNIT;
if (isprevcheckpointp)
{
player->prevcheck += pmo;
ppcd++;
}
if (isnextcheckpointp)
{
player->nextcheck += pmo;
pncd++;
}
}
if (mo->health == (player->starpostnum + 1) && (!mo->movecount || mo->movecount == player->laps+1))
const boolean isprevcheckpointi = mo->health == players[i].starpostnum;
const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1);
if ((isprevcheckpointi || isnextcheckpointi) && (!mo->movecount || mo->movecount == players[i].laps))
{
player->nextcheck += pmo;
pncd++;
}
if (mo->health == players[i].starpostnum && (!mo->movecount || mo->movecount == players[i].laps+1))
{
players[i].prevcheck += imo;
ipcd++;
}
if (mo->health == (players[i].starpostnum + 1) && (!mo->movecount || mo->movecount == players[i].laps+1))
{
players[i].nextcheck += imo;
incd++;
imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x,
mo->y - players[i].mo->y),
mo->z - players[i].mo->z) / FRACUNIT;
if (isprevcheckpointi)
{
players[i].prevcheck += imo;
ipcd++;
}
if (isnextcheckpointi )
{
players[i].nextcheck += imo;
incd++;
}
}
}