Cleanup and bugfixes
This commit is contained in:
parent
c9c56886aa
commit
3a7fe7f7ed
9 changed files with 47 additions and 103 deletions
|
|
@ -3623,7 +3623,7 @@ static void SV_GenContext(void)
|
|||
void D_QuitNetGame(void)
|
||||
{
|
||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||
if (!netgame || !netbuffer)
|
||||
if (!netgame || !doomcom)
|
||||
return;
|
||||
|
||||
DEBFILE("===========================================================================\n"
|
||||
|
|
|
|||
|
|
@ -304,7 +304,6 @@ extern char liveeventbackup[256];
|
|||
void M_StartupLocale(void);
|
||||
void *M_Memcpy(void* dest, const void* src, size_t n);
|
||||
char *va(const char *format, ...) FUNCPRINTF;
|
||||
char *xva(const char *format, ...) FUNCPRINTF;
|
||||
|
||||
char *M_GetToken(const char *inputString);
|
||||
void M_UnGetToken(void);
|
||||
|
|
|
|||
38
src/g_game.c
38
src/g_game.c
|
|
@ -724,7 +724,7 @@ tic_t G_GetBestTime(INT16 map)
|
|||
return besttime;
|
||||
|
||||
for (UINT16 k = 0; k < record->numpresets; k++)
|
||||
if (record->presets[k].besttime < besttime)
|
||||
if (record->presets[k].besttime && record->presets[k].besttime < besttime)
|
||||
besttime = record->presets[k].besttime;
|
||||
|
||||
return besttime;
|
||||
|
|
@ -742,34 +742,34 @@ boolean G_EmblemsEnabled(void)
|
|||
|
||||
char *G_GetRecordReplayFolder(boolean home, boolean breaker)
|
||||
{
|
||||
return xva("%s%smedia"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s",
|
||||
return strdup(va("%s%smedia"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s",
|
||||
home ? srb2home : "",
|
||||
home ? PATHSEP : "",
|
||||
breaker ? "itembreaker" : "timeattack",
|
||||
currentrecordpreset
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
const char *tasuffixes[] = {
|
||||
[TA_TIMEBEST] = "time-best",
|
||||
[TA_LAPBEST] = "lap-best",
|
||||
[TA_LAST] = "last",
|
||||
[TA_GUEST] = "guest",
|
||||
const char *replaysuffixes[] = {
|
||||
[REPLAY_BESTTIME] = "time-best",
|
||||
[REPLAY_BESTLAP] = "lap-best",
|
||||
[REPLAY_LAST] = "last",
|
||||
[REPLAY_GUEST] = "guest",
|
||||
};
|
||||
|
||||
char *G_GetRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, timeattackreplay_e which)
|
||||
char *G_GetRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, recordreplay_e which)
|
||||
{
|
||||
const char *map = G_BuildMapName(mapnum), *suf = tasuffixes[which];
|
||||
if (which != TA_GUEST)
|
||||
return xva("%s"PATHSEP"%s-%s-%s.lmp", folder, map, skins[skinnum].name, suf);
|
||||
const char *map = G_BuildMapName(mapnum), *suf = replaysuffixes[which];
|
||||
if (which != REPLAY_GUEST)
|
||||
return strdup(va("%s"PATHSEP"%s-%s-%s.lmp", folder, map, skins[skinnum].name, suf));
|
||||
else
|
||||
return xva("%s"PATHSEP"%s-%s.lmp", folder, map, suf);
|
||||
return strdup(va("%s"PATHSEP"%s-%s.lmp", folder, map, suf));
|
||||
}
|
||||
|
||||
boolean G_CheckRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, timeattackreplay_e which)
|
||||
boolean G_CheckRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, recordreplay_e which)
|
||||
{
|
||||
const char *map = G_BuildMapName(mapnum), *suf = tasuffixes[which];
|
||||
if (which != TA_GUEST)
|
||||
const char *map = G_BuildMapName(mapnum), *suf = replaysuffixes[which];
|
||||
if (which != REPLAY_GUEST)
|
||||
return FIL_FileExists(va("%s"PATHSEP"%s-%s-%s.lmp", folder, map, skins[skinnum].name, suf));
|
||||
else
|
||||
return FIL_FileExists(va("%s"PATHSEP"%s-%s.lmp", folder, map, suf));
|
||||
|
|
@ -817,14 +817,14 @@ static void G_UpdateRecordReplays(void)
|
|||
gpath = G_GetRecordReplayFolder(true, modeattacking == ATTACKING_ITEMBREAK);
|
||||
M_MkdirEach(gpath, M_PathParts(gpath) - 4, 0755);
|
||||
|
||||
lastdemo = G_GetRecordReplay(gpath, gamemap, cv_chooseskin.value, TA_LAST);
|
||||
lastdemo = G_GetRecordReplay(gpath, gamemap, cv_chooseskin.value, REPLAY_LAST);
|
||||
|
||||
if (FIL_FileExists(lastdemo))
|
||||
{
|
||||
UINT8 *buf;
|
||||
size_t len = FIL_ReadFile(lastdemo, &buf);
|
||||
|
||||
CLEANUP(pfree) char *bestdemo = G_GetRecordReplay(gpath, gamemap, cv_chooseskin.value, TA_TIMEBEST);
|
||||
CLEANUP(pfree) char *bestdemo = G_GetRecordReplay(gpath, gamemap, cv_chooseskin.value, REPLAY_BESTTIME);
|
||||
if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1)
|
||||
{ // Better time, save this demo.
|
||||
if (FIL_FileExists(bestdemo))
|
||||
|
|
@ -836,7 +836,7 @@ static void G_UpdateRecordReplays(void)
|
|||
if (modeattacking == ATTACKING_TIME)
|
||||
{
|
||||
free(bestdemo);
|
||||
bestdemo = G_GetRecordReplay(gpath, gamemap, cv_chooseskin.value, TA_LAPBEST);
|
||||
bestdemo = G_GetRecordReplay(gpath, gamemap, cv_chooseskin.value, REPLAY_BESTLAP);
|
||||
if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & (1<<1))
|
||||
{ // Better lap time, save this demo.
|
||||
if (FIL_FileExists(bestdemo))
|
||||
|
|
|
|||
16
src/g_game.h
16
src/g_game.h
|
|
@ -314,12 +314,12 @@ typedef struct
|
|||
|
||||
typedef enum
|
||||
{
|
||||
TA_TIMEBEST,
|
||||
TA_LAPBEST,
|
||||
TA_LAST,
|
||||
TA_GUEST,
|
||||
TA__MAX,
|
||||
} timeattackreplay_e;
|
||||
REPLAY_BESTTIME,
|
||||
REPLAY_BESTLAP,
|
||||
REPLAY_LAST,
|
||||
REPLAY_GUEST,
|
||||
REPLAY__MAX,
|
||||
} recordreplay_e;
|
||||
|
||||
extern maprecord_t **maprecords;
|
||||
extern size_t nummaprecords;
|
||||
|
|
@ -332,8 +332,8 @@ void G_ClearRecords(void);
|
|||
tic_t G_GetBestTime(INT16 map);
|
||||
boolean G_EmblemsEnabled(void);
|
||||
char *G_GetRecordReplayFolder(boolean home, boolean breaker);
|
||||
char *G_GetRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, timeattackreplay_e which);
|
||||
boolean G_CheckRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, timeattackreplay_e which);
|
||||
char *G_GetRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, recordreplay_e which);
|
||||
boolean G_CheckRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, recordreplay_e which);
|
||||
|
||||
FUNCMATH INT32 G_TicsToHours(tic_t tics);
|
||||
FUNCMATH INT32 G_TicsToMinutes(tic_t tics, boolean full);
|
||||
|
|
|
|||
28
src/m_menu.c
28
src/m_menu.c
|
|
@ -697,28 +697,28 @@ void Nextmap_OnChange(void)
|
|||
boolean showreplay = false, showguest = false;
|
||||
|
||||
// best time
|
||||
visible = G_CheckRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, TA_TIMEBEST);
|
||||
visible = G_CheckRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, REPLAY_BESTTIME);
|
||||
M_SetItemVisible(MN_SP_REPLAY, "REPLAYTIME", visible);
|
||||
M_SetItemVisible(MN_SP_GUESTREPLAY, "SAVETIME", visible);
|
||||
if (visible)
|
||||
showreplay = showguest = true;
|
||||
|
||||
// best lap
|
||||
visible = levellistmode != LLM_ITEMBREAKER && G_CheckRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, TA_LAPBEST);
|
||||
visible = levellistmode != LLM_ITEMBREAKER && G_CheckRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, REPLAY_BESTLAP);
|
||||
M_SetItemVisible(MN_SP_REPLAY, "REPLAYLAP", visible);
|
||||
M_SetItemVisible(MN_SP_GUESTREPLAY, "SAVELAP", visible);
|
||||
if (visible)
|
||||
showreplay = showguest = true;
|
||||
|
||||
// last
|
||||
visible = G_CheckRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, TA_LAST);
|
||||
visible = G_CheckRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, REPLAY_LAST);
|
||||
M_SetItemVisible(MN_SP_REPLAY, "REPLAYLAST", visible);
|
||||
M_SetItemVisible(MN_SP_GUESTREPLAY, "SAVELAST", visible);
|
||||
if (visible)
|
||||
showreplay = showguest = true;
|
||||
|
||||
// guest
|
||||
visible = G_CheckRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, TA_GUEST);;
|
||||
visible = G_CheckRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, REPLAY_GUEST);;
|
||||
M_SetItemVisible(MN_SP_REPLAY, "REPLAYGUEST", visible);
|
||||
M_SetItemVisible(MN_SP_GUESTREPLAY, "DELETE", visible);
|
||||
M_SetItemVisible(MN_SP_GHOST, "GUEST", visible);
|
||||
|
|
@ -5315,7 +5315,7 @@ INT32 MR_Statistics(INT32 choice)
|
|||
|
||||
if (!statsMapList || nummapheaders != statsMapListLen)
|
||||
{
|
||||
statsMapList = Z_Realloc(statsMapList, nummapheaders * sizeof(*statsMapList), PU_LEVEL, NULL);
|
||||
statsMapList = Z_Realloc(statsMapList, nummapheaders * sizeof(*statsMapList), PU_STATIC, NULL);
|
||||
statsMapListLen = nummapheaders;
|
||||
}
|
||||
|
||||
|
|
@ -5791,7 +5791,7 @@ INT32 MR_QuitTimeAttackMenu(INT32 choice)
|
|||
INT32 MR_ChooseTimeAttack(INT32 choice)
|
||||
{
|
||||
CLEANUP(pfree) char *gpath = G_GetRecordReplayFolder(true, levellistmode == LLM_ITEMBREAKER);
|
||||
CLEANUP(pfree) char *demopath = G_GetRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, TA_LAST);
|
||||
CLEANUP(pfree) char *demopath = G_GetRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, REPLAY_LAST);
|
||||
|
||||
(void)choice;
|
||||
emeralds = 0;
|
||||
|
|
@ -5841,7 +5841,7 @@ INT32 MR_TimeAttackPreset(INT32 arg)
|
|||
// Player has selected the "REPLAY" from the time attack screen
|
||||
INT32 MR_ReplayTimeAttack(INT32 arg)
|
||||
{
|
||||
if (arg < 0 || arg >= TA__MAX)
|
||||
if (arg < 0 || arg >= REPLAY__MAX)
|
||||
return false;
|
||||
|
||||
CLEANUP(pfree) char *gpath = G_GetRecordReplayFolder(false, levellistmode == LLM_ITEMBREAKER);
|
||||
|
|
@ -5853,7 +5853,7 @@ INT32 MR_ReplayTimeAttack(INT32 arg)
|
|||
static void M_EraseGuest(INT32 choice)
|
||||
{
|
||||
CLEANUP(pfree) char *gpath = G_GetRecordReplayFolder(true, levellistmode == LLM_ITEMBREAKER);
|
||||
CLEANUP(pfree) char *rguest = G_GetRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, TA_GUEST);
|
||||
CLEANUP(pfree) char *rguest = G_GetRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, REPLAY_GUEST);
|
||||
(void)choice;
|
||||
if (FIL_FileExists(rguest))
|
||||
remove(rguest);
|
||||
|
|
@ -5863,10 +5863,10 @@ static void M_EraseGuest(INT32 choice)
|
|||
M_StartMessage(M_GetText("Guest replay data erased.\n"),NULL,MM_NOTHING);
|
||||
}
|
||||
|
||||
static void M_OverwriteGuest(timeattackreplay_e which)
|
||||
static void M_OverwriteGuest(recordreplay_e which)
|
||||
{
|
||||
CLEANUP(pfree) char *gpath = G_GetRecordReplayFolder(true, levellistmode == LLM_ITEMBREAKER);
|
||||
CLEANUP(pfree) char *rguest = G_GetRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, TA_GUEST);
|
||||
CLEANUP(pfree) char *rguest = G_GetRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, REPLAY_GUEST);
|
||||
CLEANUP(pfree) char *overwrite = G_GetRecordReplay(gpath, cv_nextmap.value, cv_chooseskin.value, which);
|
||||
UINT8 *buf;
|
||||
size_t len = FIL_ReadFile(overwrite, &buf);
|
||||
|
|
@ -5887,19 +5887,19 @@ static void M_OverwriteGuest(timeattackreplay_e which)
|
|||
static void M_OverwriteGuest_Time(INT32 choice)
|
||||
{
|
||||
(void)choice;
|
||||
M_OverwriteGuest(TA_TIMEBEST);
|
||||
M_OverwriteGuest(REPLAY_BESTTIME);
|
||||
}
|
||||
|
||||
static void M_OverwriteGuest_Lap(INT32 choice)
|
||||
{
|
||||
(void)choice;
|
||||
M_OverwriteGuest(TA_LAPBEST);
|
||||
M_OverwriteGuest(REPLAY_BESTLAP);
|
||||
}
|
||||
|
||||
static void M_OverwriteGuest_Last(INT32 choice)
|
||||
{
|
||||
(void)choice;
|
||||
M_OverwriteGuest(TA_LAST);
|
||||
M_OverwriteGuest(REPLAY_LAST);
|
||||
}
|
||||
|
||||
INT32 MR_SetGuestReplay(INT32 arg)
|
||||
|
|
@ -5922,7 +5922,7 @@ INT32 MR_SetGuestReplay(INT32 arg)
|
|||
return true;
|
||||
}
|
||||
CLEANUP(pfree) char *gpath = G_GetRecordReplayFolder(true, levellistmode == LLM_ITEMBREAKER);
|
||||
if (G_CheckRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, TA_GUEST))
|
||||
if (G_CheckRecordReplay(gpath, cv_nextmap.value, UINT16_MAX, REPLAY_GUEST))
|
||||
M_StartMessage(M_GetText("Are you sure you want to\noverwrite the guest replay data?\n\n(Press 'Y' to confirm)\n"), which, MM_YESNO);
|
||||
else
|
||||
which(0);
|
||||
|
|
|
|||
|
|
@ -1827,32 +1827,6 @@ char *va(const char *format, ...)
|
|||
return string;
|
||||
}
|
||||
|
||||
/** Allocates and returns a string made out of varargs.
|
||||
*
|
||||
* \param format Format string.
|
||||
* \return Pointer to the resulting string.
|
||||
*/
|
||||
char *xva(const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char *string;
|
||||
|
||||
va_start(argptr, format);
|
||||
int size = vsnprintf(NULL, 0, format, argptr);
|
||||
if (size < 0)
|
||||
I_Error("xva: can't format string");
|
||||
string = static_cast<char *>(malloc((unsigned)size+1));
|
||||
if (!string)
|
||||
I_Error("xva: out of memory");
|
||||
va_end(argptr);
|
||||
|
||||
va_start(argptr, format);
|
||||
vsprintf(string, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
/** Creates a string in the first argument that is the second argument followed
|
||||
* by the third argument followed by the first argument.
|
||||
* Useful for making filenames with full path. s1 = s2+s3+s1
|
||||
|
|
|
|||
|
|
@ -8247,7 +8247,7 @@ static void P_ResetSpawnpoints(void)
|
|||
skyboxviewpnts[i] = skyboxcenterpnts[i] = NULL;
|
||||
}
|
||||
|
||||
static void P_TryAddGhosts(const char *gpath, boolean all, timeattackreplay_e which)
|
||||
static void P_TryAddGhosts(const char *gpath, boolean all, recordreplay_e which)
|
||||
{
|
||||
for (INT32 i = 0; i < numskins; i++)
|
||||
{
|
||||
|
|
@ -8267,19 +8267,19 @@ static void P_LoadRecordGhosts(void)
|
|||
|
||||
// Best Time ghost
|
||||
if (cv_ghost_besttime.value)
|
||||
P_TryAddGhosts(gpath, cv_ghost_besttime.value != 1, TA_TIMEBEST);
|
||||
P_TryAddGhosts(gpath, cv_ghost_besttime.value != 1, REPLAY_BESTTIME);
|
||||
|
||||
// Best Lap ghost
|
||||
if (modeattacking != ATTACKING_ITEMBREAK && cv_ghost_bestlap.value)
|
||||
P_TryAddGhosts(gpath, cv_ghost_bestlap.value != 1, TA_LAPBEST);
|
||||
P_TryAddGhosts(gpath, cv_ghost_bestlap.value != 1, REPLAY_BESTLAP);
|
||||
|
||||
// Last ghost
|
||||
if (cv_ghost_last.value)
|
||||
P_TryAddGhosts(gpath, cv_ghost_last.value != 1, TA_LAST);
|
||||
P_TryAddGhosts(gpath, cv_ghost_last.value != 1, REPLAY_LAST);
|
||||
|
||||
// Guest ghost
|
||||
if (cv_ghost_guest.value)
|
||||
P_TryAddGhosts(gpath, false, TA_GUEST);
|
||||
P_TryAddGhosts(gpath, false, REPLAY_GUEST);
|
||||
|
||||
// Staff Attack ghosts
|
||||
if (cv_ghost_staff.value)
|
||||
|
|
|
|||
28
src/z_zone.c
28
src/z_zone.c
|
|
@ -654,31 +654,3 @@ char *Z_StrDup(const char *s)
|
|||
{
|
||||
return strcpy(ZZ_Alloc(strlen(s) + 1), s);
|
||||
}
|
||||
|
||||
/** Allocates and returns a string made out of varargs.
|
||||
* Allocated for Zone Memory.
|
||||
*
|
||||
* \param format Format string.
|
||||
* \return Pointer to the resulting string.
|
||||
*/
|
||||
char *zva(INT32 tag, void *user, const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char *string;
|
||||
|
||||
va_start(argptr, format);
|
||||
int size = vsnprintf(NULL, 0, format, argptr);
|
||||
if (size < 0)
|
||||
I_Error("Z_xva: can't format string");
|
||||
string = Z_Malloc((unsigned)size+1, tag, user);
|
||||
if (!string)
|
||||
I_Error("Z_xva: out of memory");
|
||||
va_end(argptr);
|
||||
|
||||
va_start(argptr, format);
|
||||
vsprintf(string, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,6 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag);
|
|||
//
|
||||
char *Z_StrDup(const char *in);
|
||||
#define Z_Unlock(p) (void)p // TODO: remove this now that NDS code has been removed
|
||||
char *zva(INT32 tag, void *user, const char *format, ...);
|
||||
|
||||
// for use with CLEANUP macro
|
||||
FUNCINLINE static ATTRINLINE void Z_Pfree(void *p)
|
||||
|
|
|
|||
Loading…
Reference in a new issue