From b289e6bc5e60e470d976c0f144134b2b4851f55d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Sep 2020 19:27:05 +0200 Subject: [PATCH] - cleanup. --- source/core/binaryangle.h | 37 ++++++++++++++++++++++++++++++++++++- source/core/d_net.cpp | 10 +++++----- source/core/d_net.h | 2 +- source/core/d_protocol.cpp | 6 +++--- source/core/d_ticcmd.h | 34 ++-------------------------------- source/core/mainloop.cpp | 4 ++-- 6 files changed, 49 insertions(+), 44 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index c30b7237f..1986f2d83 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -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 #include @@ -5,7 +41,6 @@ #include "xs_Float.h" // needed for reliably overflowing float->int conversions. #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 { diff --git a/source/core/d_net.cpp b/source/core/d_net.cpp index e94b68c45..4a4737743 100644 --- a/source/core/d_net.cpp +++ b/source/core/d_net.cpp @@ -76,7 +76,7 @@ extern uint8_t *demo_p; // [RH] Special "ticcmds" get recorded in demos extern FString savedescription; extern FString savegamefile; -short consistancy[MAXPLAYERS][BACKUPTICS]; +short consistency[MAXPLAYERS][BACKUPTICS]; #define netbuffer (doomcom.data) @@ -318,7 +318,7 @@ void Net_ClearBuffers () memset (resendcount, 0, sizeof(resendcount)); memset (lastrecvtime, 0, sizeof(lastrecvtime)); memset (currrecvtime, 0, sizeof(currrecvtime)); - memset (consistancy, 0, sizeof(consistancy)); + memset (consistency, 0, sizeof(consistency)); nodeingame[0] = true; for (i = 0; i < MAXPLAYERS; i++) @@ -637,7 +637,7 @@ bool HGetPacket (void) fprintf (debugfile, "%c%2x", i==k?'|':' ', ((uint8_t *)netbuffer)[i]); if (numtics) fprintf (debugfile, " <<%4x>>\n", - consistancy[playerfornode[doomcom.remotenode]][nettics[doomcom.remotenode]%BACKUPTICS] & 0xFFFF); + consistency[playerfornode[doomcom.remotenode]][nettics[doomcom.remotenode]%BACKUPTICS] & 0xFFFF); else fprintf (debugfile, "\n"); } @@ -1239,7 +1239,7 @@ void NetUpdate (void) // the other players. if (l == 0) { - WriteWord (localcmds[localstart].consistancy, &cmddata); + WriteWord (localcmds[localstart].consistency, &cmddata); // [RH] Write out special "ticcmds" before real ticcmd if (specials.used[start]) { @@ -1254,7 +1254,7 @@ void NetUpdate (void) int len; uint8_t *spec; - WriteWord (netcmds[playerbytes[l]][start].consistancy, &cmddata); + WriteWord (netcmds[playerbytes[l]][start].consistency, &cmddata); spec = NetSpecs[playerbytes[l]][start].GetData (&len); if (spec != NULL) { diff --git a/source/core/d_net.h b/source/core/d_net.h index 138829e91..1562c1dbf 100644 --- a/source/core/d_net.h +++ b/source/core/d_net.h @@ -78,7 +78,7 @@ extern bool hadlate; 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 ticcmd_t playercmds[MAXPLAYERS]; -extern short consistancy[MAXPLAYERS][BACKUPTICS]; +extern short consistency[MAXPLAYERS][BACKUPTICS]; #endif diff --git a/source/core/d_protocol.cpp b/source/core/d_protocol.cpp index 82c1d110c..0a7fe8802 100644 --- a/source/core/d_protocol.cpp +++ b/source/core/d_protocol.cpp @@ -224,7 +224,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, ticcmd_t &cmd, ticcmd_ { if (arc.BeginObject(key)) { - arc("consistency", cmd.consistancy) + arc("consistency", cmd.consistency) ("ucmd", cmd.ucmd) .EndObject(); } @@ -319,7 +319,7 @@ int SkipTicCmd (uint8_t **stream, int count) return skip; } -extern short consistancy[MAXPLAYERS][BACKUPTICS]; +extern short consistency[MAXPLAYERS][BACKUPTICS]; void ReadTicCmd (uint8_t **stream, int player, int tic) { int type; @@ -329,7 +329,7 @@ void ReadTicCmd (uint8_t **stream, int player, int tic) int ticmod = tic % BACKUPTICS; tcmd = &netcmds[player][ticmod]; - tcmd->consistancy = ReadWord (stream); + tcmd->consistency = ReadWord (stream); start = *stream; diff --git a/source/core/d_ticcmd.h b/source/core/d_ticcmd.h index cf1e1e95b..a338c3736 100644 --- a/source/core/d_ticcmd.h +++ b/source/core/d_ticcmd.h @@ -1,42 +1,12 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $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__ +#pragma once #include "d_protocol.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 { InputPacket ucmd; - uint16_t consistancy; // checks for net game + uint16_t consistency; // checks for net game }; - FArchive &operator<< (FArchive &arc, ticcmd_t &cmd); - -#endif // __D_TICCMD_H__ diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index b4070011f..c26297a2d 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -118,7 +118,7 @@ void G_BuildTiccmd(ticcmd_t* cmd) { I_GetEvent(); 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; } #endif - consistancy[i][buf] = gi->GetPlayerChecksum(i); + consistency[i][buf] = gi->GetPlayerChecksum(i); } } }