mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-30 13:00:54 +00:00
Refactor replay saving handler for later use
This commit is contained in:
parent
4b7d2aea84
commit
b2cbe3ed6d
6 changed files with 48 additions and 17 deletions
|
@ -2627,7 +2627,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||||
LUAh_MapChange(mapnumber);
|
LUAh_MapChange(mapnumber);
|
||||||
#endif*/
|
#endif*/
|
||||||
|
|
||||||
demosaved = demodefersave = false;
|
demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING;
|
||||||
demo.savebutton = 0;
|
demo.savebutton = 0;
|
||||||
G_InitNew(pencoremode, mapname, resetplayer, skipprecutscene);
|
G_InitNew(pencoremode, mapname, resetplayer, skipprecutscene);
|
||||||
if (demo.playback && !demo.timing)
|
if (demo.playback && !demo.timing)
|
||||||
|
|
14
src/g_game.c
14
src/g_game.c
|
@ -288,7 +288,6 @@ UINT32 timesBeatenWithEmeralds;
|
||||||
|
|
||||||
//@TODO put these all in a struct for namespacing purposes?
|
//@TODO put these all in a struct for namespacing purposes?
|
||||||
static char demoname[128];
|
static char demoname[128];
|
||||||
boolean demosaved, demodefersave;
|
|
||||||
static UINT8 *demobuffer = NULL;
|
static UINT8 *demobuffer = NULL;
|
||||||
static UINT8 *demo_p, *demotime_p;
|
static UINT8 *demo_p, *demotime_p;
|
||||||
static UINT8 *demoend;
|
static UINT8 *demoend;
|
||||||
|
@ -3325,7 +3324,7 @@ void G_ExitLevel(void)
|
||||||
// Remove CEcho text on round end.
|
// Remove CEcho text on round end.
|
||||||
HU_ClearCEcho();
|
HU_ClearCEcho();
|
||||||
|
|
||||||
if (multiplayer && demo.recording && cv_recordmultiplayerdemos.value == 2)
|
if (multiplayer && demo.recording && (demo.savemode == DSM_WILLSAVE || demo.savemode == DSM_WILLAUTOSAVE))
|
||||||
G_SaveDemo();
|
G_SaveDemo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3860,6 +3859,9 @@ void G_AfterIntermission(void)
|
||||||
D_StartTitle();
|
D_StartTitle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (demo.recording && demo.savemode != DSM_NOTSAVING)
|
||||||
|
G_SaveDemo();
|
||||||
|
|
||||||
if (modeattacking) // End the run.
|
if (modeattacking) // End the run.
|
||||||
{
|
{
|
||||||
M_EndModeAttackRun();
|
M_EndModeAttackRun();
|
||||||
|
@ -4004,6 +4006,9 @@ static void G_DoContinued(void)
|
||||||
// when something new is added.
|
// when something new is added.
|
||||||
void G_EndGame(void)
|
void G_EndGame(void)
|
||||||
{
|
{
|
||||||
|
if (demo.recording && demo.savemode != DSM_NOTSAVING)
|
||||||
|
G_SaveDemo();
|
||||||
|
|
||||||
// Only do evaluation and credits in coop games.
|
// Only do evaluation and credits in coop games.
|
||||||
if (gametype == GT_COOP)
|
if (gametype == GT_COOP)
|
||||||
{
|
{
|
||||||
|
@ -7665,13 +7670,14 @@ void G_SaveDemo(void)
|
||||||
md5_buffer((char *)p+16, demo_p - (p+16), p); // make a checksum of everything after the checksum in the file.
|
md5_buffer((char *)p+16, demo_p - (p+16), p); // make a checksum of everything after the checksum in the file.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
demosaved = FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer); // finally output the file.
|
if (FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer)) // finally output the file.
|
||||||
|
demo.savemode = DSM_SAVED;
|
||||||
free(demobuffer);
|
free(demobuffer);
|
||||||
demo.recording = false;
|
demo.recording = false;
|
||||||
|
|
||||||
if (modeattacking != ATTACKING_RECORD)
|
if (modeattacking != ATTACKING_RECORD)
|
||||||
{
|
{
|
||||||
if (demosaved)
|
if (demo.savemode == DSM_SAVED)
|
||||||
CONS_Printf(M_GetText("Demo %s recorded\n"), demoname);
|
CONS_Printf(M_GetText("Demo %s recorded\n"), demoname);
|
||||||
else
|
else
|
||||||
CONS_Alert(CONS_WARNING, M_GetText("Demo %s not saved\n"), demoname);
|
CONS_Alert(CONS_WARNING, M_GetText("Demo %s not saved\n"), demoname);
|
||||||
|
|
|
@ -36,7 +36,6 @@ extern boolean playeringame[MAXPLAYERS];
|
||||||
// ======================================
|
// ======================================
|
||||||
|
|
||||||
// demoplaying back and demo recording
|
// demoplaying back and demo recording
|
||||||
extern boolean demosaved, demodefersave;
|
|
||||||
extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality;
|
extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality;
|
||||||
|
|
||||||
// Publicly-accessible demo vars
|
// Publicly-accessible demo vars
|
||||||
|
|
|
@ -733,7 +733,7 @@ void P_Ticker(boolean run)
|
||||||
G_WriteAllGhostTics();
|
G_WriteAllGhostTics();
|
||||||
|
|
||||||
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && InputDown(gc_lookback, 1))
|
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && InputDown(gc_lookback, 1))
|
||||||
demodefersave = true;
|
demo.savemode = DSM_WILLSAVE; // DSM_TITLEENTRY
|
||||||
}
|
}
|
||||||
if (demo.playback) // Use Ghost data for consistency checks.
|
if (demo.playback) // Use Ghost data for consistency checks.
|
||||||
{
|
{
|
||||||
|
|
|
@ -2017,10 +2017,23 @@ static void ST_overlayDrawer(void)
|
||||||
// Replay manual-save stuff
|
// Replay manual-save stuff
|
||||||
if (demo.recording && multiplayer && demo.savebutton && demo.savebutton + 3*TICRATE < leveltime)
|
if (demo.recording && multiplayer && demo.savebutton && demo.savebutton + 3*TICRATE < leveltime)
|
||||||
{
|
{
|
||||||
if (demodefersave || cv_recordmultiplayerdemos.value == 2)
|
switch (demo.savemode)
|
||||||
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|(G_BattleGametype() ? V_REDMAP : V_SKYMAP), "Replay will be saved.");
|
{
|
||||||
else
|
case DSM_NOTSAVING:
|
||||||
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|(G_BattleGametype() ? V_REDMAP : V_SKYMAP), "Look Backward: Save replay");
|
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|(G_BattleGametype() ? V_REDMAP : V_SKYMAP), "Look Backward: Save replay");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DSM_WILLAUTOSAVE:
|
||||||
|
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|(G_BattleGametype() ? V_REDMAP : V_SKYMAP), "Replay will be saved." /*" (Look Backward: Change title)"*/);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DSM_WILLSAVE:
|
||||||
|
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|(G_BattleGametype() ? V_REDMAP : V_SKYMAP), "Replay will be saved.");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // Don't render anything
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ST_drawDebugInfo();
|
ST_drawDebugInfo();
|
||||||
|
|
|
@ -562,10 +562,20 @@ dotimer:
|
||||||
string);
|
string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demo.recording && cv_recordmultiplayerdemos.value == 1)
|
if ((demo.recording || demo.savemode == DSM_SAVED) && !demo.playback)
|
||||||
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|hilicol, "Look Backward: Save replay");
|
switch (demo.savemode)
|
||||||
else if (demosaved && !demo.playback)
|
{
|
||||||
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|hilicol, "Replay saved!");
|
case DSM_NOTSAVING:
|
||||||
|
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|hilicol, "Look Backward: Save replay");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DSM_SAVED:
|
||||||
|
V_DrawRightAlignedThinString(BASEVIDWIDTH - 2, 2, V_SNAPTOTOP|V_SNAPTORIGHT|V_ALLOWLOWERCASE|hilicol, "Replay saved!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // Don't render any text here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Make it obvious that scrambling is happening next round.
|
// Make it obvious that scrambling is happening next round.
|
||||||
if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0))
|
if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0))
|
||||||
|
@ -582,10 +592,13 @@ void Y_Ticker(void)
|
||||||
if (intertype == int_none)
|
if (intertype == int_none)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (demo.recording && cv_recordmultiplayerdemos.value == 1 && (demodefersave || InputDown(gc_lookback, 1)))
|
if (demo.recording)
|
||||||
{
|
{
|
||||||
demodefersave = false;
|
if (demo.savemode == DSM_NOTSAVING && InputDown(gc_lookback, 1))
|
||||||
G_SaveDemo();
|
demo.savemode = DSM_WILLSAVE; // DSM_TITLEENTRY
|
||||||
|
|
||||||
|
if (demo.savemode == DSM_WILLSAVE || demo.savemode == DSM_WILLAUTOSAVE)
|
||||||
|
G_SaveDemo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for pause or menu up in single player
|
// Check for pause or menu up in single player
|
||||||
|
|
Loading…
Reference in a new issue