ref: 1b4411d96923b16575aeef36c9a4d3c2aea0d64d
parent: 19b8c7428afd6a42485a76bdf938e686e8450543
author: Simon Howard <fraggle@gmail.com>
date: Thu Feb 23 14:12:02 EST 2006
Add lowres_turn to indicate whether we generate angleturns which are 8-bit as opposed to 16-bit. This is used when recording demos without -longtics enabled. Sync this option between clients in a netgame, so that if one player is recording a Vanilla demo, all clients record in lowres. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 378
--- a/src/d_net.c
+++ b/src/d_net.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: d_net.c 374 2006-02-19 13:42:27Z fraggle $
+// $Id: d_net.c 378 2006-02-23 19:12:02Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,13 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.18 2006/02/23 19:12:01 fraggle
+// Add lowres_turn to indicate whether we generate angleturns which are
+// 8-bit as opposed to 16-bit. This is used when recording demos without
+// -longtics enabled. Sync this option between clients in a netgame, so
+// that if one player is recording a Vanilla demo, all clients record
+// in lowres.
+//
// Revision 1.17 2006/02/19 13:42:27 fraggle
// Move tic number expansion code to common code. Parse game data packets
// received from the server.
@@ -97,7 +104,7 @@
//-----------------------------------------------------------------------------
-static const char rcsid[] = "$Id: d_net.c 374 2006-02-19 13:42:27Z fraggle $";
+static const char rcsid[] = "$Id: d_net.c 378 2006-02-23 19:12:02Z fraggle $";
#include "d_main.h"
@@ -190,7 +197,7 @@
// Never go more than a second ahead
- if (maketic - gameticdiv > 35)
+ if (maketic - gameticdiv > 3)
break;
I_StartTic ();
@@ -199,7 +206,7 @@
//printf ("mk:%i ",maketic);
G_BuildTiccmd(&cmd);
- if (netgame)
+ if (netgame && !demoplayback)
{
NET_CL_SendTiccmd(&cmd, maketic);
}
@@ -230,6 +237,7 @@
consoleplayer = 0;
netgame = false;
ticdup = 1;
+ lowres_turn = false;
for (i=0; i<MAXPLAYERS; i++)
{
@@ -300,8 +308,32 @@
NET_CL_Disconnect();
}
+static int GetLowTic(void)
+{
+ int i;
+ int lowtic;
+ if (demoplayback)
+ {
+ lowtic = maketic;
+ }
+ else
+ {
+ lowtic = INT_MAX;
+
+ for (i=0; i<MAXPLAYERS; ++i)
+ {
+ if (playeringame[i])
+ {
+ if (nettics[i] < lowtic)
+ lowtic = nettics[i];
+ }
+ }
+ }
+ return lowtic;
+}
+
//
// TryRunTics
//
@@ -318,7 +350,6 @@
int realtics;
int availabletics;
int counts;
- int numplaying;
// get real tics
entertic = I_GetTime ()/ticdup;
@@ -328,18 +359,8 @@
// get available tics
NetUpdate ();
- lowtic = INT_MAX;
- numplaying = 0;
+ lowtic = GetLowTic();
- for (i=0; i<MAXPLAYERS; ++i)
- {
- if (playeringame[i])
- {
- ++numplaying;
- if (nettics[i] < lowtic)
- lowtic = nettics[i];
- }
- }
availabletics = lowtic - gametic/ticdup;
// decide how many tics to run
@@ -362,15 +383,12 @@
while (lowtic < gametic/ticdup + counts)
{
NetUpdate ();
- lowtic = INT_MAX;
+
+ lowtic = GetLowTic();
- for (i=0; i<MAXPLAYERS; ++i)
- if (playeringame[i] && nettics[i] < lowtic)
- lowtic = nettics[i];
-
if (lowtic < gametic/ticdup)
I_Error ("TryRunTics: lowtic < gametic");
-
+
// don't stay in here forever -- give the menu a chance to work
if (I_GetTime ()/ticdup - entertic >= 20)
{
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: doomstat.h 374 2006-02-19 13:42:27Z fraggle $
+// $Id: doomstat.h 378 2006-02-23 19:12:02Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -187,6 +187,11 @@
extern boolean demoplayback;
extern boolean demorecording;
+// Round angleturn in ticcmds to the nearest 256. This is used when
+// recording Vanilla demos in netgames.
+
+extern boolean lowres_turn;
+
// Quit after playing a demo from cmdline.
extern boolean singledemo;
@@ -296,6 +301,13 @@
//-----------------------------------------------------------------------------
//
// $Log$
+// Revision 1.11 2006/02/23 19:12:01 fraggle
+// Add lowres_turn to indicate whether we generate angleturns which are
+// 8-bit as opposed to 16-bit. This is used when recording demos without
+// -longtics enabled. Sync this option between clients in a netgame, so
+// that if one player is recording a Vanilla demo, all clients record
+// in lowres.
+//
// Revision 1.10 2006/02/19 13:42:27 fraggle
// Move tic number expansion code to common code. Parse game data packets
// received from the server.
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: g_game.c 374 2006-02-19 13:42:27Z fraggle $
+// $Id: g_game.c 378 2006-02-23 19:12:02Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,13 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.26 2006/02/23 19:12:01 fraggle
+// Add lowres_turn to indicate whether we generate angleturns which are
+// 8-bit as opposed to 16-bit. This is used when recording demos without
+// -longtics enabled. Sync this option between clients in a netgame, so
+// that if one player is recording a Vanilla demo, all clients record
+// in lowres.
+//
// Revision 1.25 2006/02/19 13:42:27 fraggle
// Move tic number expansion code to common code. Parse game data packets
// received from the server.
@@ -127,7 +134,7 @@
static const char
-rcsid[] = "$Id: g_game.c 374 2006-02-19 13:42:27Z fraggle $";
+rcsid[] = "$Id: g_game.c 378 2006-02-23 19:12:02Z fraggle $";
#include <string.h>
#include <stdlib.h>
@@ -234,6 +241,7 @@
char demoname[32];
boolean demorecording;
boolean longtics; // cph's doom 1.91 longtics hack
+boolean lowres_turn; // low resolution turning for longtics
boolean demoplayback;
boolean netdemo;
byte* demobuffer;
@@ -563,6 +571,16 @@
sendsave = false;
cmd->buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<<BTS_SAVESHIFT);
}
+
+ // low-res turning
+
+ if (lowres_turn)
+ {
+ // round angleturn to the nearest 256 boundary
+ // for recording demos with single byte values for turn
+
+ cmd->angleturn = (cmd->angleturn + 128) & 0xff00;
+ }
}
@@ -1616,7 +1634,7 @@
}
else
{
- cmd->angleturn = ((unsigned char)*demo_p++)<<8;
+ cmd->angleturn = ((unsigned char) *demo_p++)<<8;
}
cmd->buttons = (unsigned char)*demo_p++;
@@ -1644,7 +1662,7 @@
}
else
{
- *demo_p++ = (cmd->angleturn+128)>>8;
+ *demo_p++ = cmd->angleturn >> 8;
}
*demo_p++ = cmd->buttons;
@@ -1693,7 +1711,11 @@
// Check for the longtics parameter, to record hires angle
// turns in demos
longtics = M_CheckParm("-longtics") != 0;
-
+
+ // If not recording a longtics demo, record in low res
+
+ lowres_turn = !longtics;
+
demo_p = demobuffer;
// Save the right version code for this demo
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: net_client.c 377 2006-02-23 18:20:29Z fraggle $
+// $Id: net_client.c 378 2006-02-23 19:12:02Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -21,6 +21,13 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.29 2006/02/23 19:12:01 fraggle
+// Add lowres_turn to indicate whether we generate angleturns which are
+// 8-bit as opposed to 16-bit. This is used when recording demos without
+// -longtics enabled. Sync this option between clients in a netgame, so
+// that if one player is recording a Vanilla demo, all clients record
+// in lowres.
+//
// Revision 1.28 2006/02/23 18:20:29 fraggle
// Fix bugs in resend code for server->client data
//
@@ -135,6 +142,7 @@
#include "deh_main.h"
#include "g_game.h"
#include "i_system.h"
+#include "m_argv.h"
#include "net_client.h"
#include "net_common.h"
#include "net_defs.h"
@@ -408,7 +416,7 @@
NET_WriteInt16(packet, sendobj->time);
- NET_WriteTiccmdDiff(packet, &sendobj->cmd, false);
+ NET_WriteTiccmdDiff(packet, &sendobj->cmd, lowres_turn);
}
// Send the packet
@@ -541,6 +549,7 @@
startepisode = settings.episode;
startmap = settings.map;
startskill = settings.skill;
+ lowres_turn = settings.lowres_turn;
memset(recvwindow, 0, sizeof(recvwindow));
recvwindow_start = 0;
@@ -676,7 +685,7 @@
index = seq - recvwindow_start + i;
- if (!NET_ReadFullTiccmd(packet, &cmd, false))
+ if (!NET_ReadFullTiccmd(packet, &cmd, lowres_turn))
{
return;
}
@@ -896,6 +905,7 @@
NET_WriteInt32(packet, NET_MAGIC_NUMBER);
NET_WriteInt16(packet, gamemode);
NET_WriteInt16(packet, gamemission);
+ NET_WriteInt8(packet, lowres_turn);
NET_WriteString(packet, net_player_name);
NET_WriteString(packet, PACKAGE_STRING);
NET_Conn_SendPacket(&client_connection, packet);
@@ -910,6 +920,13 @@
int last_send_time;
server_addr = addr;
+
+ // Are we recording a demo? Possibly set lowres turn mode
+
+ if (M_CheckParm("-record") > 0 && M_CheckParm("-longtics") == 0)
+ {
+ lowres_turn = true;
+ }
// create a new network I/O context and add just the
// necessary module
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: net_server.c 377 2006-02-23 18:20:29Z fraggle $
+// $Id: net_server.c 378 2006-02-23 19:12:02Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -21,6 +21,13 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.31 2006/02/23 19:12:02 fraggle
+// Add lowres_turn to indicate whether we generate angleturns which are
+// 8-bit as opposed to 16-bit. This is used when recording demos without
+// -longtics enabled. Sync this option between clients in a netgame, so
+// that if one player is recording a Vanilla demo, all clients record
+// in lowres.
+//
// Revision 1.30 2006/02/23 18:20:29 fraggle
// Fix bugs in resend code for server->client data
//
@@ -176,6 +183,10 @@
int last_send_time;
char *name;
+ // recording a demo without -longtics
+
+ boolean recording_lowres;
+
// time query variables
int last_time_req_time;
@@ -432,6 +443,7 @@
{
unsigned int magic;
unsigned int cl_gamemode, cl_gamemission;
+ unsigned int cl_recording_lowres;
char *player_name;
char *client_version;
int i;
@@ -453,7 +465,8 @@
// read the game mode and mission
if (!NET_ReadInt16(packet, &cl_gamemode)
- || !NET_ReadInt16(packet, &cl_gamemission))
+ || !NET_ReadInt16(packet, &cl_gamemission)
+ || !NET_ReadInt8(packet, &cl_recording_lowres))
{
return;
}
@@ -537,6 +550,10 @@
return;
}
+ // TODO: Add server option to allow rejecting clients which
+ // set lowres_turn. This is potentially desirable as the
+ // presence of such clients affects turning resolution.
+
// Adopt the game mode and mission of the first connecting client
if (num_clients == 0)
@@ -557,6 +574,8 @@
// Activate, initialise connection
NET_SV_InitNewClient(client, addr, player_name);
+
+ client->recording_lowres = cl_recording_lowres;
}
if (client->connection.state == NET_CONN_STATE_WAITING_ACK)
@@ -595,15 +614,25 @@
return;
}
- // Change server state
+ // Assign player numbers
- server_state = SERVER_IN_GAME;
- sv_settings = settings;
+ NET_SV_AssignPlayers();
- // Send start packets to each connected node
+ // Check if anyone is recording a demo and set lowres_turn if so.
- NET_SV_AssignPlayers();
+ settings.lowres_turn = false;
+ for (i=0; i<MAXPLAYERS; ++i)
+ {
+ if (sv_players[i]->recording_lowres)
+ {
+ settings.lowres_turn = true;
+ break;
+ }
+ }
+
+ // Send start packets to each connected node
+
for (i=0; i<MAXPLAYERS; ++i)
{
if (sv_players[i] == NULL)
@@ -617,6 +646,11 @@
NET_WriteSettings(startpacket, &settings);
}
+ // Change server state
+
+ server_state = SERVER_IN_GAME;
+ sv_settings = settings;
+
memset(recvwindow, 0, sizeof(recvwindow));
recvwindow_start = 0;
}
@@ -824,7 +858,7 @@
unsigned int time;
if (!NET_ReadInt16(packet, &time)
- || !NET_ReadTiccmdDiff(packet, &diff, false))
+ || !NET_ReadTiccmdDiff(packet, &diff, sv_settings.lowres_turn))
{
return;
}
@@ -923,7 +957,7 @@
// Add command
- NET_WriteFullTiccmd(packet, cmd, false);
+ NET_WriteFullTiccmd(packet, cmd, sv_settings.lowres_turn);
}
// Send packet
--- a/src/net_structrw.c
+++ b/src/net_structrw.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: net_structrw.c 376 2006-02-23 18:19:05Z fraggle $
+// $Id: net_structrw.c 378 2006-02-23 19:12:02Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -21,6 +21,13 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.8 2006/02/23 19:12:02 fraggle
+// Add lowres_turn to indicate whether we generate angleturns which are
+// 8-bit as opposed to 16-bit. This is used when recording demos without
+// -longtics enabled. Sync this option between clients in a netgame, so
+// that if one player is recording a Vanilla demo, all clients record
+// in lowres.
+//
// Revision 1.7 2006/02/23 18:19:05 fraggle
// Add lowres_turn parameter to net_full_ticcmd_t structure r/w functions
//
@@ -70,6 +77,7 @@
NET_WriteInt8(packet, settings->map);
NET_WriteInt8(packet, settings->skill);
NET_WriteInt8(packet, settings->gameversion);
+ NET_WriteInt8(packet, settings->lowres_turn);
}
boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings)
@@ -80,7 +88,8 @@
&& NET_ReadInt8(packet, (unsigned int *) &settings->episode)
&& NET_ReadInt8(packet, (unsigned int *) &settings->map)
&& NET_ReadInt8(packet, (unsigned int *) &settings->skill)
- && NET_ReadInt8(packet, (unsigned int *) &settings->gameversion);
+ && NET_ReadInt8(packet, (unsigned int *) &settings->gameversion)
+ && NET_ReadInt8(packet, (unsigned int *) &settings->lowres_turn);
}
void NET_WriteTiccmdDiff(net_packet_t *packet, net_ticdiff_t *diff,