From 29c6dae77623a6384cbacd777ed2547e93edf1ae Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 19 Mar 2019 23:39:04 -0500 Subject: [PATCH] Add command to lower netreplay sync frequency This makes for smaller replay files while keeping sync checks in place! --- src/d_netcmd.c | 1 + src/g_game.c | 12 ++++++++++-- src/g_game.h | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 0522fd71..b13df51e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -811,6 +811,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); CV_RegisterVar(&cv_recordmultiplayerdemos); + CV_RegisterVar(&cv_netdemosyncquality); // FIXME: not to be here.. but needs be done for config loading CV_RegisterVar(&cv_usegamma); diff --git a/src/g_game.c b/src/g_game.c index 0b52c528..7335939c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -341,6 +341,9 @@ INT16 prevmap, nextmap; 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}; +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; // Analog Control @@ -5221,7 +5224,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) void G_WriteAllGhostTics(void) { - INT32 i; + INT32 i, counter = leveltime; for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) @@ -5230,6 +5233,11 @@ void G_WriteAllGhostTics(void) if (!players[i].mo) 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); 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 || abs(ghost->y-oldghost[playernum].y) > 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].y = ghost->y; diff --git a/src/g_game.h b/src/g_game.h index e5f94793..f78a06d0 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -38,7 +38,7 @@ extern boolean playeringame[MAXPLAYERS]; // demoplaying back and demo recording extern boolean demoplayback, titledemo, fromtitledemo, demorecording, timingdemo, demosaved, demodefersave, demo_loadfiles, demo_ignorefiles; extern tic_t demosavebutton; -extern consvar_t cv_recordmultiplayerdemos; +extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality; // Quit after playing a demo from cmdline. extern boolean singledemo;