- cleanup.

This commit is contained in:
Christoph Oelckers 2020-09-13 19:27:05 +02:00
parent 4f0856c02b
commit b289e6bc5e
6 changed files with 49 additions and 44 deletions

View file

@ -1,3 +1,39 @@
/*
** binaryangle.h
**
** type safe representations of high precision angle and horizon values.
** Angle uses natural 32 bit overflow to clamp to one rotation.
**
**---------------------------------------------------------------------------
** Copyright 2020 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#pragma once #pragma once
#include <math.h> #include <math.h>
@ -5,7 +41,6 @@
#include "xs_Float.h" // needed for reliably overflowing float->int conversions. #include "xs_Float.h" // needed for reliably overflowing float->int conversions.
#include "build.h" #include "build.h"
// type safe representations of high precision angle and horizon values. Angle uses natural 32 bit overflow to clamp to one rotation.
class binangle class binangle
{ {

View file

@ -76,7 +76,7 @@ extern uint8_t *demo_p; // [RH] Special "ticcmds" get recorded in demos
extern FString savedescription; extern FString savedescription;
extern FString savegamefile; extern FString savegamefile;
short consistancy[MAXPLAYERS][BACKUPTICS]; short consistency[MAXPLAYERS][BACKUPTICS];
#define netbuffer (doomcom.data) #define netbuffer (doomcom.data)
@ -318,7 +318,7 @@ void Net_ClearBuffers ()
memset (resendcount, 0, sizeof(resendcount)); memset (resendcount, 0, sizeof(resendcount));
memset (lastrecvtime, 0, sizeof(lastrecvtime)); memset (lastrecvtime, 0, sizeof(lastrecvtime));
memset (currrecvtime, 0, sizeof(currrecvtime)); memset (currrecvtime, 0, sizeof(currrecvtime));
memset (consistancy, 0, sizeof(consistancy)); memset (consistency, 0, sizeof(consistency));
nodeingame[0] = true; nodeingame[0] = true;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
@ -637,7 +637,7 @@ bool HGetPacket (void)
fprintf (debugfile, "%c%2x", i==k?'|':' ', ((uint8_t *)netbuffer)[i]); fprintf (debugfile, "%c%2x", i==k?'|':' ', ((uint8_t *)netbuffer)[i]);
if (numtics) if (numtics)
fprintf (debugfile, " <<%4x>>\n", fprintf (debugfile, " <<%4x>>\n",
consistancy[playerfornode[doomcom.remotenode]][nettics[doomcom.remotenode]%BACKUPTICS] & 0xFFFF); consistency[playerfornode[doomcom.remotenode]][nettics[doomcom.remotenode]%BACKUPTICS] & 0xFFFF);
else else
fprintf (debugfile, "\n"); fprintf (debugfile, "\n");
} }
@ -1239,7 +1239,7 @@ void NetUpdate (void)
// the other players. // the other players.
if (l == 0) if (l == 0)
{ {
WriteWord (localcmds[localstart].consistancy, &cmddata); WriteWord (localcmds[localstart].consistency, &cmddata);
// [RH] Write out special "ticcmds" before real ticcmd // [RH] Write out special "ticcmds" before real ticcmd
if (specials.used[start]) if (specials.used[start])
{ {
@ -1254,7 +1254,7 @@ void NetUpdate (void)
int len; int len;
uint8_t *spec; uint8_t *spec;
WriteWord (netcmds[playerbytes[l]][start].consistancy, &cmddata); WriteWord (netcmds[playerbytes[l]][start].consistency, &cmddata);
spec = NetSpecs[playerbytes[l]][start].GetData (&len); spec = NetSpecs[playerbytes[l]][start].GetData (&len);
if (spec != NULL) if (spec != NULL)
{ {

View file

@ -78,7 +78,7 @@ extern bool hadlate;
extern uint64_t lastglobalrecvtime; // Identify the last time a packet was received. extern uint64_t lastglobalrecvtime; // Identify the last time a packet was received.
extern bool playeringame[MAXPLAYERS]; // as long as network isn't working - true for the first player, false for all others. extern bool playeringame[MAXPLAYERS]; // as long as network isn't working - true for the first player, false for all others.
extern ticcmd_t playercmds[MAXPLAYERS]; extern ticcmd_t playercmds[MAXPLAYERS];
extern short consistancy[MAXPLAYERS][BACKUPTICS]; extern short consistency[MAXPLAYERS][BACKUPTICS];
#endif #endif

View file

@ -224,7 +224,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, ticcmd_t &cmd, ticcmd_
{ {
if (arc.BeginObject(key)) if (arc.BeginObject(key))
{ {
arc("consistency", cmd.consistancy) arc("consistency", cmd.consistency)
("ucmd", cmd.ucmd) ("ucmd", cmd.ucmd)
.EndObject(); .EndObject();
} }
@ -319,7 +319,7 @@ int SkipTicCmd (uint8_t **stream, int count)
return skip; return skip;
} }
extern short consistancy[MAXPLAYERS][BACKUPTICS]; extern short consistency[MAXPLAYERS][BACKUPTICS];
void ReadTicCmd (uint8_t **stream, int player, int tic) void ReadTicCmd (uint8_t **stream, int player, int tic)
{ {
int type; int type;
@ -329,7 +329,7 @@ void ReadTicCmd (uint8_t **stream, int player, int tic)
int ticmod = tic % BACKUPTICS; int ticmod = tic % BACKUPTICS;
tcmd = &netcmds[player][ticmod]; tcmd = &netcmds[player][ticmod];
tcmd->consistancy = ReadWord (stream); tcmd->consistency = ReadWord (stream);
start = *stream; start = *stream;

View file

@ -1,42 +1,12 @@
// Emacs style mode select -*- C++ -*- #pragma once
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// DESCRIPTION:
// System specific interface stuff.
//
//-----------------------------------------------------------------------------
#ifndef __D_TICCMD_H__
#define __D_TICCMD_H__
#include "d_protocol.h" #include "d_protocol.h"
#include "packet.h" #include "packet.h"
// The data sampled per tick (single player)
// and transmitted to other peers (multiplayer).
// Mainly movements/button commands per game tick,
// plus a checksum for internal state consistency.
struct ticcmd_t struct ticcmd_t
{ {
InputPacket ucmd; InputPacket ucmd;
uint16_t consistancy; // checks for net game uint16_t consistency; // checks for net game
}; };
FArchive &operator<< (FArchive &arc, ticcmd_t &cmd); FArchive &operator<< (FArchive &arc, ticcmd_t &cmd);
#endif // __D_TICCMD_H__

View file

@ -118,7 +118,7 @@ void G_BuildTiccmd(ticcmd_t* cmd)
{ {
I_GetEvent(); I_GetEvent();
gi->GetInput(&cmd->ucmd, &CONTROL_GetInput()); gi->GetInput(&cmd->ucmd, &CONTROL_GetInput());
cmd->consistancy = consistancy[myconnectindex][(maketic / ticdup) % BACKUPTICS]; cmd->consistency = consistency[myconnectindex][(maketic / ticdup) % BACKUPTICS];
} }
//========================================================================== //==========================================================================
@ -290,7 +290,7 @@ static void GameTicker()
players[i].inconsistant = gametic - BACKUPTICS * ticdup; players[i].inconsistant = gametic - BACKUPTICS * ticdup;
} }
#endif #endif
consistancy[i][buf] = gi->GetPlayerChecksum(i); consistency[i][buf] = gi->GetPlayerChecksum(i);
} }
} }
} }