- deleted sync.cpp.

This commit is contained in:
Christoph Oelckers 2020-09-02 16:57:03 +02:00
parent 621a1e0b3d
commit b3d4bab4dd
4 changed files with 0 additions and 459 deletions

View file

@ -55,7 +55,6 @@ set( PCH_SOURCES
src/spike.cpp src/spike.cpp
src/sprite.cpp src/sprite.cpp
src/sumo.cpp src/sumo.cpp
src/sync.cpp
src/text.cpp src/text.cpp
src/track.cpp src/track.cpp
src/vator.cpp src/vator.cpp

View file

@ -64,12 +64,9 @@ SWBOOL ready2send = 0;
SWBOOL CommEnabled = FALSE; SWBOOL CommEnabled = FALSE;
uint8_t CommPlayers = 0; uint8_t CommPlayers = 0;
int movefifoplc, movefifosendplc; //, movefifoend[MAX_SW_PLAYERS]; int movefifoplc, movefifosendplc; //, movefifoend[MAX_SW_PLAYERS];
unsigned int MoveThingsCount;
//int myminlag[MAX_SW_PLAYERS]; //int myminlag[MAX_SW_PLAYERS];
int mymaxlag, otherminlag, bufferjitter = 1; int mymaxlag, otherminlag, bufferjitter = 1;
extern char sync_first[MAXSYNCBYTES][60];
extern int sync_found;
// GAME.C sync state variables // GAME.C sync state variables
uint8_t syncstat[MAXSYNCBYTES]; uint8_t syncstat[MAXSYNCBYTES];
@ -128,8 +125,6 @@ InitNetVars(void)
predictmovefifoplc = 0; predictmovefifoplc = 0;
memset(&syncstat, 0, sizeof(syncstat)); memset(&syncstat, 0, sizeof(syncstat));
memset(sync_first, 0, sizeof(sync_first));
sync_found = FALSE;
TRAVERSE_CONNECT(pnum) TRAVERSE_CONNECT(pnum)
{ {
@ -151,15 +146,6 @@ InitTimingVars(void)
MoveSkip8 = 2; MoveSkip8 = 2;
MoveSkip2 = 0; MoveSkip2 = 0;
MoveSkip4 = 1; // start slightly offset so these MoveSkip4 = 1; // start slightly offset so these
// don't move the same
// as the Skip2's
MoveThingsCount = 0;
// CTW REMOVED
//if (gTenActivated)
// tenResetClock();
// CTW REMOVED END
} }

View file

@ -7593,7 +7593,6 @@ domovethings(void)
short i, pnum; short i, pnum;
PLAYERp pp; PLAYERp pp;
extern unsigned int MoveThingsCount;
extern int FinishTimer; extern int FinishTimer;
@ -7616,7 +7615,6 @@ domovethings(void)
// count the number of times this loop is called and use // count the number of times this loop is called and use
// for things like sync testing // for things like sync testing
MoveThingsCount++;
totalsynctics += synctics; totalsynctics += synctics;

View file

@ -1,442 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 1997, 2005 - 3D Realms Entertainment
This file is part of Shadow Warrior version 1.2
Shadow Warrior is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Original Source: 1997 - Frank Maddin and Jim Norwood
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "build.h"
#include "game.h"
#include "tags.h"
#include "names2.h"
#include "network.h"
#include "menus.h"
#include "m_crc32.h"
BEGIN_SW_NS
char sync_first[MAXSYNCBYTES][60];
int sync_found = FALSE;
#if SYNC_TEST
SWBOOL SyncPrintMode = TRUE;
short NumSyncBytes = 1;
inline void updatecrc(uint16_t& dcrc, uint8_t xz) { dcrc = (uint16_t)CRC1(dcrc, uint8_t(xz), GetCRCTable()); }
uint8_t
PlayerSync(void)
{
short i;
unsigned short crc = 0;
PLAYERp pp;
for (i = connecthead; i >= 0; i = connectpoint2[i])
{
pp = Player + i;
updatecrc(crc, pp->posx & 255);
updatecrc(crc, pp->posy & 255);
updatecrc(crc, pp->posz & 255);
updatecrc(crc, FixedToInt(pp->q16ang) & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
PlayerSync2(void)
{
short i;
unsigned short crc = 0;
PLAYERp pp;
for (i = connecthead; i >= 0; i = connectpoint2[i])
{
pp = Player + i;
updatecrc(crc, FixedToInt(pp->q16horiz) & 255);
updatecrc(crc, User[pp->PlayerSprite]->Health & 255);
updatecrc(crc, pp->bcnt & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
SOSync(void)
{
unsigned short crc = 0;
SECTOR_OBJECTp sop;
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
{
updatecrc(crc, (sop->xmid) & 255);
updatecrc(crc, (sop->ymid) & 255);
updatecrc(crc, (sop->zmid) & 255);
updatecrc(crc, (sop->vel) & 255);
updatecrc(crc, (sop->ang) & 255);
updatecrc(crc, (sop->ang_moving) & 255);
updatecrc(crc, (sop->spin_ang) & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
EnemySync(void)
{
unsigned short crc = 0;
short j, nextj;
SPRITEp spr;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], j, nextj)
{
spr = &sprite[j];
updatecrc(crc, (spr->x) & 255);
updatecrc(crc, (spr->y) & 255);
updatecrc(crc, (spr->z) & 255);
updatecrc(crc, (spr->ang) & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
MissileSync(void)
{
unsigned short crc = 0;
short j, nextj;
SPRITEp spr;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_MISSILE], j, nextj)
{
spr = &sprite[j];
updatecrc(crc, (spr->x) & 255);
updatecrc(crc, (spr->y) & 255);
updatecrc(crc, (spr->z) & 255);
updatecrc(crc, (spr->ang) & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
MissileSkip4Sync(void)
{
unsigned short crc = 0;
short j, nextj;
SPRITEp spr;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_MISSILE_SKIP4], j, nextj)
{
spr = &sprite[j];
updatecrc(crc, (spr->x) & 255);
updatecrc(crc, (spr->y) & 255);
updatecrc(crc, (spr->z) & 255);
updatecrc(crc, (spr->ang) & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
ShrapSync(void)
{
unsigned short crc = 0;
short j, nextj;
SPRITEp spr;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SHRAP], j, nextj)
{
spr = &sprite[j];
updatecrc(crc, (spr->x) & 255);
updatecrc(crc, (spr->y) & 255);
updatecrc(crc, (spr->z) & 255);
updatecrc(crc, (spr->ang) & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
MiscSync(void)
{
unsigned short crc = 0;
short j, nextj;
SPRITEp spr;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_MISC], j, nextj)
{
spr = &sprite[j];
updatecrc(crc, (spr->x) & 255);
updatecrc(crc, (spr->y) & 255);
updatecrc(crc, (spr->z) & 255);
updatecrc(crc, (spr->ang) & 255);
}
return (uint8_t) crc & 255;
}
uint8_t
RandomSync(void)
{
unsigned short crc = 0;
updatecrc(crc, randomseed & 255);
updatecrc(crc, (randomseed >> 8) & 255);
if (NumSyncBytes == 1)
{
updatecrc(crc,PlayerSync() & 255);
updatecrc(crc,PlayerSync2() & 255);
updatecrc(crc,MissileSync() & 255);
}
return (uint8_t) crc & 255;
}
/*
#define STAT_SKIP2_START 2
#define STAT_ENEMY 2
#define STAT_DEAD_ACTOR 3 //misc actor stuff - dead guys etc
#define STAT_MISSILE 4
#define STAT_SKIP2_END 4
#define STAT_SKIP4_START 5
#define STAT_ITEM 5
#define STAT_SKIP4 6
#define STAT_MISSILE_SKIP4 7
#define STAT_ENEMY_SKIP4 8
#define STAT_SKIP4_END 8
*/
const char *SyncNames[] =
{
"RandomSync",
"PlayerSync",
"PlayerSync2",
"SOSync",
"EnemySync",
"MissileSync",
"ShrapSync",
"MiscSync",
"MissileSkip4Sync",
NULL
};
static uint8_t(*SyncFunc[MAXSYNCBYTES + 1]) (void) =
{
RandomSync,
PlayerSync,
PlayerSync2,
SOSync,
EnemySync,
MissileSync,
ShrapSync,
MiscSync,
MissileSkip4Sync,
NULL
};
void
getsyncstat(void)
{
int i;
PLAYERp pp = Player + myconnectindex;
unsigned int val;
static unsigned int count;
if (!CommEnabled)
return;
if (numplayers < 2)
return;
for (i = 0; SyncFunc[i]; i++)
{
pp->syncval[pp->syncvalhead & (SYNCFIFOSIZ - 1)][i] = (*SyncFunc[i])();
}
val = pp->syncval[pp->syncvalhead & (SYNCFIFOSIZ - 1)][0];
count += val;
pp->syncvalhead++;
}
////////////////////////////////////////////////////////////////////////
//
// Sync Message print
//
////////////////////////////////////////////////////////////////////////
void
SyncStatMessage(void)
{
int i, j;
static unsigned int MoveCount = 0;
extern unsigned int MoveThingsCount;
if (!CommEnabled)
return;
if (!SyncPrintMode)
return;
if (numplayers <= 1)
return;
for (i = 0; i < NumSyncBytes; i++)
{
// syncstat is NON 0 - out of sync
if (syncstat[i] != 0)
{
if (NumSyncBytes > 1)
{
Printf(PRINT_NOTIFY, "GAME OUT OF SYNC - %s", SyncNames[i]);
}
if (!sync_found && sync_first[i][0] == '\0')
{
// sync_found one so test all of them and then never test again
sync_found = TRUE;
// save off loop count
MoveCount = MoveThingsCount;
for (j = 0; j < NumSyncBytes; j++)
{
if (syncstat[j] != 0 && sync_first[j][0] == '\0')
{
sprintf(ds, "OUT OF SYNC - %s", SyncNames[j]);
strcpy(sync_first[j], ds);
}
}
}
}
}
// print out the sync_first message you got
for (i = 0; i < NumSyncBytes; i++)
{
if (sync_first[i][0] != '\0')
{
if (NumSyncBytes > 1)
{
Printf(PRINT_NOTIFY, "FIRST %s\n", sync_first[i]);
Printf(PRINT_NOTIFY, "MoveCount %u\n",MoveCount);
}
else
{
// production out of sync error
sprintf(ds,"GAME OUT OF SYNC!");
MNU_DrawString(160, 20, ds, 0, 19, 0);
sprintf(ds,"Restart the game.");
MNU_DrawString(160, 30, ds, 0, 19, 0);
}
}
}
}
void
GetSyncInfoFromPacket(uint8_t *packbuf, int packbufleng, int *j, int otherconnectindex)
{
int sb, i;
extern int syncvaltottail;
PLAYERp ppo = &Player[otherconnectindex];
SWBOOL found = FALSE;
// have had problems with this routine crashing when players quit
// games.
// if ready2send is not set then don't try to get sync info
if (!ready2send)
return;
// Suspect that its trying to traverse the connect list
// for a player that does not exist. This tries to take care of that
TRAVERSE_CONNECT(i)
{
if (otherconnectindex == i)
found = TRUE;
}
if (!found)
return;
// sync testing
//while ((*j) != packbufleng) // changed this on Kens suggestion
while ((*j) < packbufleng)
{
for (sb = 0; sb < NumSyncBytes; sb++)
{
ppo->syncval[ppo->syncvalhead & (SYNCFIFOSIZ - 1)][sb] = packbuf[(*j)++];
}
ppo->syncvalhead++;
}
// update syncstat
// if any of the syncstat vars is non-0 then there is a problem
TRAVERSE_CONNECT(i)
{
if (Player[i].syncvalhead == syncvaltottail)
return;
}
//for (sb = 0; sb < NumSyncBytes; sb++)
// syncstat[sb] = 0;
while (TRUE)
{
for (i = connectpoint2[connecthead]; i >= 0; i = connectpoint2[i])
{
for (sb = 0; sb < NumSyncBytes; sb++)
{
if (Player[i].syncval[syncvaltottail & (SYNCFIFOSIZ - 1)][sb] != Player[connecthead].syncval[syncvaltottail & (SYNCFIFOSIZ - 1)][sb])
{
syncstat[sb] = 1;
}
}
}
syncvaltottail++;
TRAVERSE_CONNECT(i)
{
if (Player[i].syncvalhead == syncvaltottail)
return;
}
}
}
#endif
END_SW_NS