ref: 835d92710f1f958b899eb842c556b75fbb809244
parent: 91565e8f96357b37cfd8f69d3196b7bc13417d53
author: Fabian Greffrath <fabian@greffrath.com>
date: Mon Feb 18 16:47:36 EST 2019
Revert "doom: use separate pointers and buffers for demo recording and playback" This reverts commit 4220bb2e7fee9bf5c86abbbf79a396bac7db1766 until the issue surrounding G_ReadDemoTiccmd() is sorted out. Sorry for the noise!
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -454,6 +454,9 @@
" may cause demos and network games to get out of sync.\n");
}
+ if (demorecording)
+ G_BeginRecording ();
+
main_loop_started = true;
I_SetWindowTitle(gamedescription);
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -134,10 +134,8 @@
boolean lowres_turn; // low resolution turning for longtics
boolean demoplayback;
boolean netdemo;
-byte* demo_in_buffer;
-byte* demo_out_buffer;
-byte* demo_in_p;
-byte* demo_out_p = NULL;
+byte* demobuffer;
+byte* demo_p;
byte* demoend;
boolean singledemo; // quit after playing a demo from cmdline
@@ -1912,28 +1910,28 @@
void G_ReadDemoTiccmd (ticcmd_t* cmd)
{
- if (*demo_in_p == DEMOMARKER)
+ if (*demo_p == DEMOMARKER)
{
- // end of demo data stream
- G_CheckDemoStatus ();
- return;
- }
- cmd->forwardmove = ((signed char)*demo_in_p++);
- cmd->sidemove = ((signed char)*demo_in_p++);
+ // end of demo data stream
+ G_CheckDemoStatus ();
+ return;
+ }
+ cmd->forwardmove = ((signed char)*demo_p++);
+ cmd->sidemove = ((signed char)*demo_p++);
// If this is a longtics demo, read back in higher resolution
if (longtics)
{
- cmd->angleturn = *demo_in_p++;
- cmd->angleturn |= (*demo_in_p++) << 8;
+ cmd->angleturn = *demo_p++;
+ cmd->angleturn |= (*demo_p++) << 8;
}
else
{
- cmd->angleturn = ((unsigned char) *demo_in_p++)<<8;
+ cmd->angleturn = ((unsigned char) *demo_p++)<<8;
}
- cmd->buttons = (unsigned char)*demo_in_p++;
+ cmd->buttons = (unsigned char)*demo_p++;
}
// Increase the size of the demo buffer to allow unlimited demos
@@ -1947,62 +1945,57 @@
// Find the current size
- current_length = demoend - demo_out_buffer;
+ current_length = demoend - demobuffer;
// Generate a new buffer twice the size
new_length = current_length * 2;
new_demobuffer = Z_Malloc(new_length, PU_STATIC, 0);
- new_demop = new_demobuffer + (demo_out_p - demo_out_buffer);
+ new_demop = new_demobuffer + (demo_p - demobuffer);
// Copy over the old data
- memcpy(new_demobuffer, demo_out_buffer, current_length);
+ memcpy(new_demobuffer, demobuffer, current_length);
// Free the old buffer and point the demo pointers at the new buffer.
- Z_Free(demo_out_buffer);
+ Z_Free(demobuffer);
- demo_out_buffer = new_demobuffer;
- demo_out_p = new_demop;
- demoend = demo_out_buffer + new_length;
+ demobuffer = new_demobuffer;
+ demo_p = new_demop;
+ demoend = demobuffer + new_length;
}
void G_WriteDemoTiccmd (ticcmd_t* cmd)
-{
+{
byte *demo_start;
- if (demo_out_p == NULL)
- {
- G_BeginRecording();
- }
+ if (gamekeydown[key_demo_quit]) // press q to end demo recording
+ G_CheckDemoStatus ();
- if (gamekeydown[key_demo_quit]) // press q to end demo recording
- G_CheckDemoStatus ();
+ demo_start = demo_p;
- demo_start = demo_out_p;
+ *demo_p++ = cmd->forwardmove;
+ *demo_p++ = cmd->sidemove;
- *demo_out_p++ = cmd->forwardmove;
- *demo_out_p++ = cmd->sidemove;
-
// If this is a longtics demo, record in higher resolution
if (longtics)
{
- *demo_out_p++ = (cmd->angleturn & 0xff);
- *demo_out_p++ = (cmd->angleturn >> 8) & 0xff;
+ *demo_p++ = (cmd->angleturn & 0xff);
+ *demo_p++ = (cmd->angleturn >> 8) & 0xff;
}
else
{
- *demo_out_p++ = cmd->angleturn >> 8;
+ *demo_p++ = cmd->angleturn >> 8;
}
- *demo_out_p++ = cmd->buttons;
+ *demo_p++ = cmd->buttons;
// reset demo pointer back
- demo_out_p = demo_start;
+ demo_p = demo_start;
- if (demo_out_p > demoend - 16)
+ if (demo_p > demoend - 16)
{
if (vanilla_demo_limit)
{
@@ -2050,8 +2043,8 @@
i = M_CheckParmWithArgs("-maxdemo", 1);
if (i)
maxsize = atoi(myargv[i+1])*1024;
- demo_out_buffer = Z_Malloc (maxsize,PU_STATIC,NULL);
- demoend = demo_out_buffer + maxsize;
+ demobuffer = Z_Malloc (maxsize,PU_STATIC,NULL);
+ demoend = demobuffer + maxsize;
demorecording = true;
}
@@ -2079,7 +2072,7 @@
{
int i;
- demo_out_p = demo_out_buffer;
+ demo_p = demobuffer;
//!
// @category demo
@@ -2095,24 +2088,24 @@
if (longtics)
{
- *demo_out_p++ = DOOM_191_VERSION;
+ *demo_p++ = DOOM_191_VERSION;
}
else
{
- *demo_out_p++ = G_VanillaVersionCode();
+ *demo_p++ = G_VanillaVersionCode();
}
- *demo_out_p++ = gameskill;
- *demo_out_p++ = gameepisode;
- *demo_out_p++ = gamemap;
- *demo_out_p++ = deathmatch;
- *demo_out_p++ = respawnparm;
- *demo_out_p++ = fastparm;
- *demo_out_p++ = nomonsters;
- *demo_out_p++ = consoleplayer;
-
+ *demo_p++ = gameskill;
+ *demo_p++ = gameepisode;
+ *demo_p++ = gamemap;
+ *demo_p++ = deathmatch;
+ *demo_p++ = respawnparm;
+ *demo_p++ = fastparm;
+ *demo_p++ = nomonsters;
+ *demo_p++ = consoleplayer;
+
for (i=0 ; i<MAXPLAYERS ; i++)
- *demo_out_p++ = playeringame[i];
+ *demo_p++ = playeringame[i];
}
@@ -2177,10 +2170,10 @@
lumpnum = W_GetNumForName(defdemoname);
gameaction = ga_nothing;
- demo_in_buffer = W_CacheLumpNum(lumpnum, PU_STATIC);
- demo_in_p = demo_in_buffer;
+ demobuffer = W_CacheLumpNum(lumpnum, PU_STATIC);
+ demo_p = demobuffer;
- demoversion = *demo_in_p++;
+ demoversion = *demo_p++;
longtics = false;
@@ -2206,17 +2199,17 @@
DemoVersionDescription(demoversion));
}
- skill = *demo_in_p++;
- episode = *demo_in_p++;
- map = *demo_in_p++;
- deathmatch = *demo_in_p++;
- respawnparm = *demo_in_p++;
- fastparm = *demo_in_p++;
- nomonsters = *demo_in_p++;
- consoleplayer = *demo_in_p++;
+ skill = *demo_p++;
+ episode = *demo_p++;
+ map = *demo_p++;
+ deathmatch = *demo_p++;
+ respawnparm = *demo_p++;
+ fastparm = *demo_p++;
+ nomonsters = *demo_p++;
+ consoleplayer = *demo_p++;
for (i=0 ; i<MAXPLAYERS ; i++)
- playeringame[i] = *demo_in_p++;
+ playeringame[i] = *demo_p++;
if (playeringame[1] || M_CheckParm("-solo-net") > 0
|| M_CheckParm("-netdemo") > 0)
@@ -2311,9 +2304,9 @@
if (demorecording)
{
- *demo_out_p++ = DEMOMARKER;
- M_WriteFile (demoname, demo_out_buffer, demo_out_p - demo_out_buffer);
- Z_Free (demo_out_buffer);
+ *demo_p++ = DEMOMARKER;
+ M_WriteFile (demoname, demobuffer, demo_p - demobuffer);
+ Z_Free (demobuffer);
demorecording = false;
I_Error ("Demo %s recorded",demoname);
}