mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-30 03:32:58 +00:00
Refactor recorddata_t and separate into recordtimes_t
This commit is contained in:
parent
b323c6bdb7
commit
05d8d83dcc
5 changed files with 31 additions and 23 deletions
|
|
@ -152,11 +152,16 @@ struct skinreference_t
|
|||
#define MV_MYSTICMELODY (1<<4)
|
||||
#define MV_MAX (MV_VISITED|MV_BEATEN|MV_ENCORE|MV_SPBATTACK|MV_MYSTICMELODY)
|
||||
|
||||
struct recordtimes_t
|
||||
{
|
||||
tic_t time; ///< Time in which the level was finished.
|
||||
tic_t lap; ///< Best lap time for this level.
|
||||
};
|
||||
|
||||
struct recorddata_t
|
||||
{
|
||||
UINT8 mapvisited;
|
||||
tic_t time; ///< Time in which the level was finished.
|
||||
tic_t lap; ///< Best lap time for this level.
|
||||
recordtimes_t timeattack; ///< Best times for Time Attack
|
||||
};
|
||||
|
||||
#define KARTSPEED_AUTO -1
|
||||
|
|
|
|||
29
src/g_game.c
29
src/g_game.c
|
|
@ -386,10 +386,10 @@ void G_ClearRecords(void)
|
|||
// For easy retrieval of records
|
||||
tic_t G_GetBestTime(INT16 map)
|
||||
{
|
||||
if (!mapheaderinfo[map] || mapheaderinfo[map]->records.time <= 0)
|
||||
if (!mapheaderinfo[map] || mapheaderinfo[map]->records.timeattack.time <= 0)
|
||||
return (tic_t)UINT32_MAX;
|
||||
|
||||
return mapheaderinfo[map]->records.time;
|
||||
return mapheaderinfo[map]->records.timeattack.time;
|
||||
}
|
||||
|
||||
// BE RIGHT BACK
|
||||
|
|
@ -536,21 +536,22 @@ void G_TickTimeStickerMedals(void)
|
|||
void G_UpdateRecords(void)
|
||||
{
|
||||
UINT8 earnedEmblems;
|
||||
recordtimes_t *record = &mapheaderinfo[gamemap-1]->records.timeattack;
|
||||
|
||||
if (modeattacking & ATTACKING_TIME)
|
||||
{
|
||||
tic_t time = players[consoleplayer].realtime;
|
||||
if (players[consoleplayer].pflags & PF_NOCONTEST)
|
||||
time = UINT32_MAX;
|
||||
if (((mapheaderinfo[gamemap-1]->records.time == 0) || (time < mapheaderinfo[gamemap-1]->records.time))
|
||||
if (((record->time == 0) || (time < record->time))
|
||||
&& (time < UINT32_MAX)) // DNF
|
||||
mapheaderinfo[gamemap-1]->records.time = time;
|
||||
record->time = time;
|
||||
}
|
||||
|
||||
if (modeattacking & ATTACKING_LAP)
|
||||
{
|
||||
if ((mapheaderinfo[gamemap-1]->records.lap == 0) || (bestlap < mapheaderinfo[gamemap-1]->records.lap))
|
||||
mapheaderinfo[gamemap-1]->records.lap = bestlap;
|
||||
if ((record->lap == 0) || (bestlap < record->lap))
|
||||
record->lap = bestlap;
|
||||
}
|
||||
|
||||
// Check emblems when level data is updated
|
||||
|
|
@ -5069,8 +5070,8 @@ void G_LoadGameData(void)
|
|||
recorddata_t dummyrecord;
|
||||
|
||||
dummyrecord.mapvisited = READUINT8(save.p);
|
||||
dummyrecord.time = (tic_t)READUINT32(save.p);
|
||||
dummyrecord.lap = (tic_t)READUINT32(save.p);
|
||||
dummyrecord.timeattack.time = (tic_t)READUINT32(save.p);
|
||||
dummyrecord.timeattack.lap = (tic_t)READUINT32(save.p);
|
||||
|
||||
if (mapnum < nummapheaders && mapheaderinfo[mapnum])
|
||||
{
|
||||
|
|
@ -5081,8 +5082,8 @@ void G_LoadGameData(void)
|
|||
}
|
||||
else if (
|
||||
(dummyrecord.mapvisited & MV_BEATEN)
|
||||
|| dummyrecord.time != 0
|
||||
|| dummyrecord.lap != 0
|
||||
|| dummyrecord.timeattack.time != 0
|
||||
|| dummyrecord.timeattack.lap != 0
|
||||
)
|
||||
{
|
||||
// Invalid, but we don't want to lose all the juicy statistics.
|
||||
|
|
@ -5684,8 +5685,8 @@ void G_SaveGameData(void)
|
|||
|
||||
WRITEUINT8(save.p, mapvisitedtemp);
|
||||
|
||||
WRITEUINT32(save.p, mapheaderinfo[i]->records.time);
|
||||
WRITEUINT32(save.p, mapheaderinfo[i]->records.lap);
|
||||
WRITEUINT32(save.p, mapheaderinfo[i]->records.timeattack.time);
|
||||
WRITEUINT32(save.p, mapheaderinfo[i]->records.timeattack.lap);
|
||||
|
||||
if (--numgamedatamapheaders == 0)
|
||||
break;
|
||||
|
|
@ -5702,8 +5703,8 @@ void G_SaveGameData(void)
|
|||
|
||||
WRITEUINT8(save.p, unloadedmap->records.mapvisited);
|
||||
|
||||
WRITEUINT32(save.p, unloadedmap->records.time);
|
||||
WRITEUINT32(save.p, unloadedmap->records.lap);
|
||||
WRITEUINT32(save.p, unloadedmap->records.timeattack.time);
|
||||
WRITEUINT32(save.p, unloadedmap->records.timeattack.lap);
|
||||
|
||||
if (--numgamedatamapheaders == 0)
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -3503,8 +3503,9 @@ void M_DrawTimeAttack(void)
|
|||
|
||||
if (currentMenu == &PLAY_TimeAttackDef)
|
||||
{
|
||||
tic_t timerec = mapheaderinfo[map]->records.time;
|
||||
tic_t laprec = mapheaderinfo[map]->records.lap;
|
||||
recordtimes_t *record = &mapheaderinfo[map]->records.timeattack;
|
||||
tic_t timerec = record->time;
|
||||
tic_t laprec = record->lap;
|
||||
UINT32 timeheight = 82;
|
||||
|
||||
if ((gametypes[levellist.newgametype]->rules & GTR_CIRCUIT)
|
||||
|
|
@ -7236,13 +7237,13 @@ static void M_DrawStatsMaps(void)
|
|||
if (!(mapheaderinfo[i]->typeoflevel & (TOL_RACE|TOL_BATTLE|TOL_SPECIAL|TOL_VERSUS)))
|
||||
continue;
|
||||
|
||||
if (mapheaderinfo[i]->records.time <= 0)
|
||||
if (mapheaderinfo[i]->records.timeattack.time <= 0)
|
||||
{
|
||||
mapsunfinished++;
|
||||
continue;
|
||||
}
|
||||
|
||||
besttime += mapheaderinfo[i]->records.time;
|
||||
besttime += mapheaderinfo[i]->records.timeattack.time;
|
||||
}
|
||||
|
||||
V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 60, 0,
|
||||
|
|
@ -7322,7 +7323,7 @@ static void M_DrawStatsMaps(void)
|
|||
)
|
||||
)
|
||||
{
|
||||
besttime = mapheaderinfo[mnum]->records.time;
|
||||
besttime = mapheaderinfo[mnum]->records.timeattack.time;
|
||||
|
||||
if (besttime)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3470,9 +3470,9 @@ boolean M_GotLowEnoughTime(INT32 tictime)
|
|||
if (!mapheaderinfo[i] || (mapheaderinfo[i]->menuflags & LF2_NOTIMEATTACK))
|
||||
continue;
|
||||
|
||||
if (!mapheaderinfo[i]->records.time)
|
||||
if (!mapheaderinfo[i]->records.timeattack.time)
|
||||
return false;
|
||||
if ((curtics += mapheaderinfo[i]->records.time) > tictime)
|
||||
if ((curtics += mapheaderinfo[i]->records.timeattack.time) > tictime)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ TYPEDEF (precipprops_t);
|
|||
TYPEDEF (skinrecord_t);
|
||||
TYPEDEF (unloaded_skin_t);
|
||||
TYPEDEF (skinreference_t);
|
||||
TYPEDEF (recordtimes_t);
|
||||
TYPEDEF (recorddata_t);
|
||||
TYPEDEF (cupwindata_t);
|
||||
TYPEDEF (scene_t);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue