Instead of player->laptime, lets add curlap

Since lap time will only ever be used locally, it makes more sense to
just use one variable instead of a player struct variable
This commit is contained in:
TehRealSalt 2018-01-21 21:03:44 -05:00
parent 672c4b5298
commit 6f1dda7b7a
12 changed files with 34 additions and 36 deletions

View File

@ -940,7 +940,6 @@ static inline void resynch_write_others(resynchend_pak *rst)
rst->numboxes[i] = 0; rst->numboxes[i] = 0;
rst->totalring[i] = 0; rst->totalring[i] = 0;
rst->realtime[i] = 0; rst->realtime[i] = 0;
rst->laptime[i] = 0;
rst->laps[i] = 0; rst->laps[i] = 0;
continue; continue;
} }
@ -952,7 +951,6 @@ static inline void resynch_write_others(resynchend_pak *rst)
rst->numboxes[i] = SHORT(players[i].numboxes); rst->numboxes[i] = SHORT(players[i].numboxes);
rst->totalring[i] = SHORT(players[i].totalring); rst->totalring[i] = SHORT(players[i].totalring);
rst->realtime[i] = (tic_t)LONG(players[i].realtime); rst->realtime[i] = (tic_t)LONG(players[i].realtime);
rst->laptime[i] = (tic_t)LONG(players[i].laptime);
rst->laps[i] = players[i].laps; rst->laps[i] = players[i].laps;
} }
@ -974,7 +972,6 @@ static inline void resynch_read_others(resynchend_pak *p)
players[i].numboxes = SHORT(p->numboxes[i]); players[i].numboxes = SHORT(p->numboxes[i]);
players[i].totalring = SHORT(p->totalring[i]); players[i].totalring = SHORT(p->totalring[i]);
players[i].realtime = (tic_t)LONG(p->realtime[i]); players[i].realtime = (tic_t)LONG(p->realtime[i]);
players[i].laptime = (tic_t)LONG(p->laptime[i]);
players[i].laps = p->laps[i]; players[i].laps = p->laps[i];
} }
} }

View File

@ -169,7 +169,6 @@ typedef struct
INT16 numboxes[MAXPLAYERS]; INT16 numboxes[MAXPLAYERS];
INT16 totalring[MAXPLAYERS]; INT16 totalring[MAXPLAYERS];
tic_t realtime[MAXPLAYERS]; tic_t realtime[MAXPLAYERS];
tic_t laptime[MAXPLAYERS];
UINT8 laps[MAXPLAYERS]; UINT8 laps[MAXPLAYERS];
} ATTRPACK resynchend_pak; } ATTRPACK resynchend_pak;

View File

@ -463,7 +463,6 @@ typedef struct player_s
INT16 numboxes; // Number of item boxes obtained for Race Mode INT16 numboxes; // Number of item boxes obtained for Race Mode
INT16 totalring; // Total number of rings obtained for Race Mode INT16 totalring; // Total number of rings obtained for Race Mode
tic_t realtime; // integer replacement for leveltime tic_t realtime; // integer replacement for leveltime
tic_t laptime; // SRB2kart: Time spent on current lap, used for Record Attack
UINT8 laps; // Number of laps (optional) UINT8 laps; // Number of laps (optional)
//////////////////// ////////////////////

View File

@ -444,7 +444,7 @@ extern UINT8 gamespeed;
extern boolean franticitems; extern boolean franticitems;
extern boolean mirrormode; extern boolean mirrormode;
extern boolean comeback; extern boolean comeback;
extern tic_t bestlap; extern tic_t curlap, bestlap;
extern tic_t hidetime; extern tic_t hidetime;

View File

@ -244,7 +244,8 @@ UINT8 gamespeed; // Game's current speed (or difficulty, or cc, or etc); 0-2 for
boolean mirrormode; // Mirror Mode currently enabled? boolean mirrormode; // Mirror Mode currently enabled?
boolean franticitems; // Frantic items currently enabled? boolean franticitems; // Frantic items currently enabled?
boolean comeback; // Battle Mode's karma comeback is on/off boolean comeback; // Battle Mode's karma comeback is on/off
tic_t bestlap; // Best lap time, should be local tic_t curlap; // Current lap time, calculated locally
tic_t bestlap; // Best lap time, locally
tic_t hidetime; tic_t hidetime;
@ -2334,7 +2335,6 @@ void G_PlayerReborn(INT32 player)
INT32 balloon; INT32 balloon;
INT32 comebackpoints; INT32 comebackpoints;
INT32 comebackshowninfo; INT32 comebackshowninfo;
tic_t laptime;
score = players[player].score; score = players[player].score;
lives = players[player].lives; lives = players[player].lives;
@ -2393,7 +2393,6 @@ void G_PlayerReborn(INT32 player)
balloon = players[player].kartstuff[k_balloon]; balloon = players[player].kartstuff[k_balloon];
comebackpoints = players[player].kartstuff[k_comebackpoints]; comebackpoints = players[player].kartstuff[k_comebackpoints];
comebackshowninfo = players[player].kartstuff[k_comebackshowninfo]; comebackshowninfo = players[player].kartstuff[k_comebackshowninfo];
laptime = players[player].laptime;
p = &players[player]; p = &players[player];
memset(p, 0, sizeof (*p)); memset(p, 0, sizeof (*p));
@ -2456,8 +2455,6 @@ void G_PlayerReborn(INT32 player)
p->kartstuff[k_comebackshowninfo] = comebackshowninfo; p->kartstuff[k_comebackshowninfo] = comebackshowninfo;
p->kartstuff[k_comebacktimer] = comebacktime; p->kartstuff[k_comebacktimer] = comebacktime;
p->laptime = laptime;
// Don't do anything immediately // Don't do anything immediately
p->pflags |= PF_USEDOWN; p->pflags |= PF_USEDOWN;
p->pflags |= PF_ATTACKDOWN; p->pflags |= PF_ATTACKDOWN;

View File

@ -228,8 +228,6 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->totalring); lua_pushinteger(L, plr->totalring);
else if (fastcmp(field,"realtime")) else if (fastcmp(field,"realtime"))
lua_pushinteger(L, plr->realtime); lua_pushinteger(L, plr->realtime);
else if (fastcmp(field,"laptime"))
lua_pushinteger(L, plr->laptime);
else if (fastcmp(field,"laps")) else if (fastcmp(field,"laps"))
lua_pushinteger(L, plr->laps); lua_pushinteger(L, plr->laps);
else if (fastcmp(field,"ctfteam")) else if (fastcmp(field,"ctfteam"))
@ -503,8 +501,6 @@ static int player_set(lua_State *L)
plr->totalring = (INT16)luaL_checkinteger(L, 3); plr->totalring = (INT16)luaL_checkinteger(L, 3);
else if (fastcmp(field,"realtime")) else if (fastcmp(field,"realtime"))
plr->realtime = (tic_t)luaL_checkinteger(L, 3); plr->realtime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"laptime"))
plr->laptime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"laps")) else if (fastcmp(field,"laps"))
plr->laps = (UINT8)luaL_checkinteger(L, 3); plr->laps = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"ctfteam")) else if (fastcmp(field,"ctfteam"))

View File

@ -235,8 +235,8 @@ boolean cht_Responder(event_t *ev)
else else
ch = (UINT8)ev->data1; ch = (UINT8)ev->data1;
ret += cht_CheckCheat(&cheat_ultimate, (char)ch); //ret += cht_CheckCheat(&cheat_ultimate, (char)ch);
ret += cht_CheckCheat(&cheat_ultimate_joy, (char)ch); //ret += cht_CheckCheat(&cheat_ultimate_joy, (char)ch);
ret += cht_CheckCheat(&cheat_warp, (char)ch); ret += cht_CheckCheat(&cheat_warp, (char)ch);
ret += cht_CheckCheat(&cheat_warp_joy, (char)ch); ret += cht_CheckCheat(&cheat_warp_joy, (char)ch);
#ifdef DEVELOP #ifdef DEVELOP

View File

@ -736,9 +736,9 @@ static menuitem_t SP_LevelSelectMenu[] =
// Single Player Time Attack // Single Player Time Attack
static menuitem_t SP_TimeAttackMenu[] = static menuitem_t SP_TimeAttackMenu[] =
{ {
{IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 52}, {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 48},
{IT_STRING|IT_CVAR, NULL, "Player", &cv_chooseskin, 62}, {IT_STRING|IT_CVAR, NULL, "Player", &cv_chooseskin, 58},
{IT_STRING|IT_CVAR, NULL, "Color", &cv_playercolor, 72}, {IT_STRING|IT_CVAR, NULL, "Color", &cv_playercolor, 68},
{IT_DISABLED, NULL, "Guest Option...", &SP_GuestReplayDef, 100}, {IT_DISABLED, NULL, "Guest Option...", &SP_GuestReplayDef, 100},
{IT_DISABLED, NULL, "Replay...", &SP_ReplayDef, 110}, {IT_DISABLED, NULL, "Replay...", &SP_ReplayDef, 110},
@ -5507,7 +5507,7 @@ void M_DrawTimeAttackMenu(void)
{ {
UINT8 *colormap = R_GetTranslationColormap(cv_chooseskin.value-1, cv_playercolor.value, 0); UINT8 *colormap = R_GetTranslationColormap(cv_chooseskin.value-1, cv_playercolor.value, 0);
PictureOfUrFace = W_CachePatchName(skins[cv_chooseskin.value-1].face, PU_CACHE); PictureOfUrFace = W_CachePatchName(skins[cv_chooseskin.value-1].face, PU_CACHE);
V_DrawMappedPatch(256,90,0,PictureOfUrFace, colormap); V_DrawMappedPatch(256,88,0,PictureOfUrFace, colormap);
} }
// Level record list // Level record list

View File

@ -182,7 +182,6 @@ static void P_NetArchivePlayers(void)
WRITEINT16(save_p, players[i].numboxes); WRITEINT16(save_p, players[i].numboxes);
WRITEINT16(save_p, players[i].totalring); WRITEINT16(save_p, players[i].totalring);
WRITEUINT32(save_p, players[i].realtime); WRITEUINT32(save_p, players[i].realtime);
WRITEUINT32(save_p, players[i].laptime); // SRB2kart
WRITEUINT8(save_p, players[i].laps); WRITEUINT8(save_p, players[i].laps);
//////////////////// ////////////////////
@ -367,7 +366,6 @@ static void P_NetUnArchivePlayers(void)
players[i].numboxes = READINT16(save_p); // Number of item boxes obtained for Race Mode players[i].numboxes = READINT16(save_p); // Number of item boxes obtained for Race Mode
players[i].totalring = READINT16(save_p); // Total number of rings obtained for Race Mode players[i].totalring = READINT16(save_p); // Total number of rings obtained for Race Mode
players[i].realtime = READUINT32(save_p); // integer replacement for leveltime players[i].realtime = READUINT32(save_p); // integer replacement for leveltime
players[i].laptime = READUINT32(save_p); // SRB2kart: used to track best lap time
players[i].laps = READUINT8(save_p); // Number of laps (optional) players[i].laps = READUINT8(save_p); // Number of laps (optional)
//////////////////// ////////////////////

View File

@ -2204,7 +2204,7 @@ static void P_LevelInitStuff(void)
} }
players[i].realtime = countdown = countdown2 = 0; players[i].realtime = countdown = countdown2 = 0;
players[i].laptime = 0; // SRB2Kart curlap = bestlap = 0; // SRB2Kart
players[i].gotcontinue = false; players[i].gotcontinue = false;

View File

@ -4157,8 +4157,12 @@ DoneSection2:
} }
// SRB2Kart: save best lap for record attack // SRB2Kart: save best lap for record attack
bestlap = player->laptime; if (player == &players[consoleplayer])
player->laptime = 0; {
if (curlap < bestlap || bestlap == 0)
bestlap = curlap;
curlap = 0;
}
// Reset starposts (checkpoints) info // Reset starposts (checkpoints) info
// SRB2kart 200117 // SRB2kart 200117

View File

@ -8086,15 +8086,19 @@ static void P_DeathThink(player_t *player)
if (leveltime >= 4*TICRATE) if (leveltime >= 4*TICRATE)
{ {
player->realtime = leveltime - 4*TICRATE; player->realtime = leveltime - 4*TICRATE;
if (player->spectator || !circuitmap) if (player == &players[consoleplayer])
player->laptime = 0; {
else if (player->spectator || !circuitmap)
player->laptime++; // This is too complicated to sync to realtime, just sorta hope for the best :V curlap = 0;
else
curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V
}
} }
else else
{ {
player->realtime = 0; player->realtime = 0;
player->laptime = 0; if (player == &players[consoleplayer])
curlap = 0;
} }
} }
@ -9405,15 +9409,19 @@ void P_PlayerThink(player_t *player)
if (leveltime >= 4*TICRATE) if (leveltime >= 4*TICRATE)
{ {
player->realtime = leveltime - 4*TICRATE; player->realtime = leveltime - 4*TICRATE;
if (player->spectator || !circuitmap) if (player == &players[consoleplayer])
player->laptime = 0; {
else if (player->spectator || !circuitmap)
player->laptime++; // This is too complicated to sync to realtime, just sorta hope for the best :V curlap = 0;
else
curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V
}
} }
else else
{ {
player->realtime = 0; player->realtime = 0;
player->laptime = 0; if (player == &players[consoleplayer])
curlap = 0;
} }
} }