Add command to lower netreplay sync frequency

This makes for smaller replay files while keeping
sync checks in place!
This commit is contained in:
fickleheart 2019-03-19 23:39:04 -05:00
parent 64ceb441e3
commit 29c6dae776
3 changed files with 12 additions and 3 deletions

View file

@ -811,6 +811,7 @@ void D_RegisterClientCommands(void)
COM_AddCommand("displayplayer", Command_Displayplayer_f); COM_AddCommand("displayplayer", Command_Displayplayer_f);
CV_RegisterVar(&cv_recordmultiplayerdemos); CV_RegisterVar(&cv_recordmultiplayerdemos);
CV_RegisterVar(&cv_netdemosyncquality);
// FIXME: not to be here.. but needs be done for config loading // FIXME: not to be here.. but needs be done for config loading
CV_RegisterVar(&cv_usegamma); CV_RegisterVar(&cv_usegamma);

View file

@ -341,6 +341,9 @@ INT16 prevmap, nextmap;
static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}};
consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t netdemosyncquality_cons_t[] = {{1, "MIN"}, {35, "MAX"}, {0, NULL}};
consvar_t cv_netdemosyncquality = {"netdemo_syncquality", "1", CV_SAVE, netdemosyncquality_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static UINT8 *savebuffer; static UINT8 *savebuffer;
// Analog Control // Analog Control
@ -5221,7 +5224,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim)
void G_WriteAllGhostTics(void) void G_WriteAllGhostTics(void)
{ {
INT32 i; INT32 i, counter = leveltime;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (!playeringame[i] || players[i].spectator) if (!playeringame[i] || players[i].spectator)
@ -5230,6 +5233,11 @@ void G_WriteAllGhostTics(void)
if (!players[i].mo) if (!players[i].mo)
continue; continue;
counter++;
if (counter % cv_netdemosyncquality.value != 0) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size.
continue;
WRITEUINT8(demo_p, i); WRITEUINT8(demo_p, i);
G_WriteGhostTic(players[i].mo, i); G_WriteGhostTic(players[i].mo, i);
} }
@ -5264,7 +5272,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
if (abs(ghost->x-oldghost[playernum].x) > MAXMOM if (abs(ghost->x-oldghost[playernum].x) > MAXMOM
|| abs(ghost->y-oldghost[playernum].y) > MAXMOM || abs(ghost->y-oldghost[playernum].y) > MAXMOM
|| abs(ghost->z-oldghost[playernum].z) > MAXMOM || abs(ghost->z-oldghost[playernum].z) > MAXMOM
|| (leveltime & 255) == 1) // Hack to enable slightly nicer resyncing || ((UINT8)(leveltime & 255) > 0 && (UINT8)(leveltime & 255) <= (UINT8)cv_netdemosyncquality.value)) // Hack to enable slightly nicer resyncing
{ {
oldghost[playernum].x = ghost->x; oldghost[playernum].x = ghost->x;
oldghost[playernum].y = ghost->y; oldghost[playernum].y = ghost->y;

View file

@ -38,7 +38,7 @@ extern boolean playeringame[MAXPLAYERS];
// demoplaying back and demo recording // demoplaying back and demo recording
extern boolean demoplayback, titledemo, fromtitledemo, demorecording, timingdemo, demosaved, demodefersave, demo_loadfiles, demo_ignorefiles; extern boolean demoplayback, titledemo, fromtitledemo, demorecording, timingdemo, demosaved, demodefersave, demo_loadfiles, demo_ignorefiles;
extern tic_t demosavebutton; extern tic_t demosavebutton;
extern consvar_t cv_recordmultiplayerdemos; extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality;
// Quit after playing a demo from cmdline. // Quit after playing a demo from cmdline.
extern boolean singledemo; extern boolean singledemo;