mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-15 20:20:54 +00:00
- thinned out Blood's network code.
This commit is contained in:
parent
84b6af24d3
commit
9440ddb68f
5 changed files with 7 additions and 344 deletions
|
@ -536,14 +536,7 @@ void ProcessFrame(void)
|
|||
gPlayer[i].input.q16mlook = gFifoInput[gNetFifoTail&255][i].q16mlook;
|
||||
}
|
||||
gNetFifoTail++;
|
||||
#if 0
|
||||
if (!(gFrame&7))
|
||||
{
|
||||
CalcGameChecksum();
|
||||
memcpy(gCheckFifo[gCheckHead[myconnectindex]&255][myconnectindex], gChecksum, sizeof(gChecksum));
|
||||
gCheckHead[myconnectindex]++;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
if (gPlayer[i].input.keyFlags.quit)
|
||||
|
|
|
@ -485,59 +485,6 @@ extern void G_SetupGlobalPsky(void);
|
|||
|
||||
#pragma pack(push,1)
|
||||
|
||||
#if 0
|
||||
struct sectortype
|
||||
{
|
||||
short wallptr, wallnum;
|
||||
int ceilingz, floorz;
|
||||
unsigned short ceilingstat, floorstat;
|
||||
short ceilingpicnum, ceilingheinum;
|
||||
signed char ceilingshade;
|
||||
char ceilingpal, ceilingxpanning, ceilingypanning;
|
||||
short floorpicnum, floorheinum;
|
||||
signed char floorshade;
|
||||
char floorpal, floorxpanning, floorypanning;
|
||||
char visibility, filler;
|
||||
unsigned short lotag;
|
||||
short hitag, extra;
|
||||
};
|
||||
|
||||
struct walltype
|
||||
{
|
||||
int x, y;
|
||||
short point2, nextwall, nextsector;
|
||||
unsigned short cstat;
|
||||
short picnum, overpicnum;
|
||||
signed char shade;
|
||||
char pal, xrepeat, yrepeat, xpanning, ypanning;
|
||||
short lotag, hitag, extra;
|
||||
};
|
||||
|
||||
struct spritetype
|
||||
{
|
||||
int x, y, z;
|
||||
short cstat, picnum;
|
||||
signed char shade;
|
||||
char pal, clipdist, filler;
|
||||
unsigned char xrepeat, yrepeat;
|
||||
signed char xoffset, yoffset;
|
||||
short sectnum, statnum;
|
||||
short ang, owner, index, yvel, zvel;
|
||||
short type, hitag, extra;
|
||||
};
|
||||
|
||||
struct PICANM {
|
||||
unsigned int animframes : 5;
|
||||
unsigned int at0_5 : 1;
|
||||
unsigned int animtype : 2;
|
||||
signed int xoffset : 8;
|
||||
signed int yoffset : 8;
|
||||
unsigned int animspeed : 4;
|
||||
unsigned int at3_4 : 3; // type
|
||||
unsigned int at3_7 : 1; // filler
|
||||
};
|
||||
#endif
|
||||
|
||||
struct LOCATION {
|
||||
int x, y, z;
|
||||
int ang;
|
||||
|
@ -590,29 +537,6 @@ inline int DecBy(int a, int b)
|
|||
return a;
|
||||
}
|
||||
|
||||
#if 0
|
||||
inline float IncByF(float a, float b)
|
||||
{
|
||||
a += b;
|
||||
float q = fmod(a, b);
|
||||
a -= q;
|
||||
if (q < 0)
|
||||
a -= b;
|
||||
return a;
|
||||
}
|
||||
|
||||
inline float DecByF(float a, float b)
|
||||
{
|
||||
//a--;
|
||||
a -= fabs(b)*0.001;
|
||||
float q = fmod(a, b);
|
||||
a -= q;
|
||||
if (q < 0)
|
||||
a -= b;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline int ClipLow(int a, int b)
|
||||
{
|
||||
if (a < b)
|
||||
|
|
|
@ -510,9 +510,6 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
|
|||
gPredictTail = 0;
|
||||
gNetFifoMasterTail = 0;
|
||||
memset(gFifoInput, 0, sizeof(gFifoInput));
|
||||
memset(gChecksum, 0, sizeof(gChecksum));
|
||||
memset(gCheckFifo, 0, sizeof(gCheckFifo));
|
||||
memset(gCheckHead, 0, sizeof(gCheckHead));
|
||||
gSendCheckTail = 0;
|
||||
gCheckTail = 0;
|
||||
gBufferJitter = 0;
|
||||
|
|
|
@ -36,11 +36,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "menu.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
extern bool gHaveNetworking;
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
char packet[576];
|
||||
MapRecord *gStartNewGame = 0;
|
||||
PACKETMODE gPacketMode = PACKETMODE_1;
|
||||
ClockTicks gNetFifoClock = 0;
|
||||
|
@ -52,9 +49,6 @@ GINPUT gFifoInput[256][8];
|
|||
int myMinLag[8];
|
||||
int otherMinLag = 0;
|
||||
int myMaxLag = 0;
|
||||
unsigned int gChecksum[4];
|
||||
unsigned int gCheckFifo[256][8][4];
|
||||
int gCheckHead[8];
|
||||
int gSendCheckTail = 0;
|
||||
int gCheckTail = 0;
|
||||
int gInitialNetPlayers = 0;
|
||||
|
@ -82,14 +76,6 @@ void netResetToSinglePlayer(void)
|
|||
UpdateNetworkMenus();
|
||||
}
|
||||
|
||||
void netSendPacket(int nDest, char *pBuffer, int nSize)
|
||||
{
|
||||
}
|
||||
|
||||
void netSendPacketAll(char *pBuffer, int nSize)
|
||||
{
|
||||
}
|
||||
|
||||
void netReset(void)
|
||||
{
|
||||
gNetFifoClock = gFrameClock = totalclock = 0;
|
||||
|
@ -97,42 +83,15 @@ void netReset(void)
|
|||
gPredictTail = 0;
|
||||
gNetFifoTail = 0;
|
||||
memset(gNetFifoHead, 0, sizeof(gNetFifoHead));
|
||||
memset(gCheckFifo, 0, sizeof(gCheckFifo));
|
||||
memset(myMinLag, 0, sizeof(myMinLag));
|
||||
otherMinLag = 0;
|
||||
myMaxLag = 0;
|
||||
memset(gCheckHead, 0, sizeof(gCheckHead));
|
||||
gSendCheckTail = 0;
|
||||
gCheckTail = 0;
|
||||
bOutOfSync = 0;
|
||||
gBufferJitter = 1;
|
||||
}
|
||||
|
||||
void CalcGameChecksum(void)
|
||||
{
|
||||
}
|
||||
|
||||
void netCheckSync(void)
|
||||
{
|
||||
}
|
||||
|
||||
short netGetPacket(short *pSource, char *pMessage)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void netGetPackets(void)
|
||||
{
|
||||
}
|
||||
|
||||
void netBroadcastPlayerLogoff(int nPlayer)
|
||||
{
|
||||
}
|
||||
|
||||
void netBroadcastMyLogoff(bool bRestart)
|
||||
{
|
||||
}
|
||||
|
||||
void netBroadcastPlayerInfo(int nPlayer)
|
||||
{
|
||||
PROFILE *pProfile = &gProfile[nPlayer];
|
||||
|
@ -144,85 +103,8 @@ void netBroadcastPlayerInfo(int nPlayer)
|
|||
return;
|
||||
}
|
||||
|
||||
void netBroadcastNewGame(void)
|
||||
{
|
||||
}
|
||||
|
||||
void netWaitForEveryone(char a1)
|
||||
{
|
||||
}
|
||||
|
||||
void netMasterUpdate(void)
|
||||
{
|
||||
if (myconnectindex != connecthead)
|
||||
return;
|
||||
char v4 = 0;
|
||||
do
|
||||
{
|
||||
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
||||
if (gNetFifoMasterTail >= gNetFifoHead[p])
|
||||
{
|
||||
if (v4)
|
||||
return;
|
||||
char *pPacket = packet;
|
||||
PutPacketByte(pPacket, 254);
|
||||
for (; p >= 0; p = connectpoint2[p])
|
||||
netSendPacket(p, packet, pPacket-packet);
|
||||
return;
|
||||
}
|
||||
v4 = 1;
|
||||
char *pPacket = packet;
|
||||
PutPacketByte(pPacket, 0);
|
||||
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
||||
{
|
||||
GINPUT *pInput = &gFifoInput[gNetFifoMasterTail&255][p];
|
||||
if (pInput->buttonFlags.byte)
|
||||
pInput->syncFlags.buttonChange = 1;
|
||||
if (pInput->keyFlags.word)
|
||||
pInput->syncFlags.keyChange = 1;
|
||||
if (pInput->useFlags.byte)
|
||||
pInput->syncFlags.useChange = 1;
|
||||
if (pInput->newWeapon)
|
||||
pInput->syncFlags.weaponChange = 1;
|
||||
if (pInput->q16mlook)
|
||||
pInput->syncFlags.mlookChange = 1;
|
||||
PutPacketByte(pPacket, pInput->syncFlags.byte);
|
||||
PutPacketWord(pPacket, pInput->forward);
|
||||
PutPacketDWord(pPacket, pInput->q16turn);
|
||||
PutPacketWord(pPacket, pInput->strafe);
|
||||
if (pInput->syncFlags.buttonChange)
|
||||
PutPacketByte(pPacket, pInput->buttonFlags.byte);
|
||||
if (pInput->syncFlags.keyChange)
|
||||
PutPacketWord(pPacket, pInput->keyFlags.word);
|
||||
if (pInput->syncFlags.useChange)
|
||||
PutPacketByte(pPacket, pInput->useFlags.byte);
|
||||
if (pInput->syncFlags.weaponChange)
|
||||
PutPacketByte(pPacket, pInput->newWeapon);
|
||||
if (pInput->syncFlags.mlookChange)
|
||||
PutPacketDWord(pPacket, pInput->q16mlook);
|
||||
}
|
||||
if ((gNetFifoMasterTail&15) == 0)
|
||||
{
|
||||
for (int p = connectpoint2[connecthead]; p >= 0; p = connectpoint2[p])
|
||||
PutPacketByte(pPacket, ClipRange(myMinLag[p], -128, 127));
|
||||
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
||||
myMinLag[p] = 0x7fffffff;
|
||||
}
|
||||
while (gSendCheckTail != gCheckHead[myconnectindex])
|
||||
{
|
||||
PutPacketBuffer(pPacket, gCheckFifo[gSendCheckTail&255][myconnectindex], 16);
|
||||
gSendCheckTail++;
|
||||
}
|
||||
for (int p = connectpoint2[connecthead]; p >= 0; p = connectpoint2[p])
|
||||
netSendPacket(p, packet, pPacket-packet);
|
||||
gNetFifoMasterTail++;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void netGetInput(void)
|
||||
{
|
||||
if (numplayers > 1)
|
||||
netGetPackets();
|
||||
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
||||
if (gNetFifoHead[myconnectindex]-200 > gNetFifoHead[p])
|
||||
return;
|
||||
|
@ -243,81 +125,6 @@ void netGetInput(void)
|
|||
}
|
||||
return;
|
||||
}
|
||||
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
||||
{
|
||||
if (p != myconnectindex)
|
||||
{
|
||||
int nLag = gNetFifoHead[myconnectindex]-1-gNetFifoHead[p];
|
||||
myMinLag[p] = ClipHigh(nLag, myMinLag[p]);
|
||||
myMaxLag = ClipLow(nLag, myMaxLag);
|
||||
}
|
||||
}
|
||||
if (((gNetFifoHead[myconnectindex]-1)&15) == 0)
|
||||
{
|
||||
int t = myMaxLag-gBufferJitter;
|
||||
myMaxLag = 0;
|
||||
if (t > 0)
|
||||
gBufferJitter += (3+t)>>2;
|
||||
else if (t < 0)
|
||||
gBufferJitter -= (1-t)>>2;
|
||||
}
|
||||
if (myconnectindex != connecthead)
|
||||
{
|
||||
char *pPacket = packet;
|
||||
PutPacketByte(pPacket, 1);
|
||||
if (input.buttonFlags.byte)
|
||||
input.syncFlags.buttonChange = 1;
|
||||
if (input.keyFlags.word)
|
||||
input.syncFlags.keyChange = 1;
|
||||
if (input.useFlags.byte)
|
||||
input.syncFlags.useChange = 1;
|
||||
if (input.newWeapon)
|
||||
input.syncFlags.weaponChange = 1;
|
||||
if (input.q16mlook)
|
||||
input.syncFlags.mlookChange = 1;
|
||||
PutPacketByte(pPacket, input.syncFlags.byte);
|
||||
PutPacketWord(pPacket, input.forward);
|
||||
PutPacketDWord(pPacket, input.q16turn);
|
||||
PutPacketWord(pPacket, input.strafe);
|
||||
if (input.syncFlags.buttonChange)
|
||||
PutPacketByte(pPacket, input.buttonFlags.byte);
|
||||
if (input.syncFlags.keyChange)
|
||||
PutPacketWord(pPacket, input.keyFlags.word);
|
||||
if (input.syncFlags.useChange)
|
||||
PutPacketByte(pPacket, input.useFlags.byte);
|
||||
if (input.syncFlags.weaponChange)
|
||||
PutPacketByte(pPacket, input.newWeapon);
|
||||
if (input.syncFlags.mlookChange)
|
||||
PutPacketDWord(pPacket, input.q16mlook);
|
||||
if (((gNetFifoHead[myconnectindex]-1)&15) == 0)
|
||||
{
|
||||
int t = myMinLag[connecthead]-otherMinLag;
|
||||
if (klabs(t) > 2)
|
||||
{
|
||||
if (klabs(t) > 8)
|
||||
{
|
||||
if (t < 0)
|
||||
t++;
|
||||
t >>= 1;
|
||||
}
|
||||
else
|
||||
t = ksgn(t);
|
||||
totalclock -= t<<2;
|
||||
otherMinLag += t;
|
||||
myMinLag[connecthead] -= t;
|
||||
}
|
||||
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
||||
myMinLag[p] = 0x7fffffff;
|
||||
}
|
||||
while (gSendCheckTail != gCheckHead[myconnectindex])
|
||||
{
|
||||
PutPacketBuffer(pPacket, gCheckFifo[gSendCheckTail&255][myconnectindex], 16);
|
||||
gSendCheckTail++;
|
||||
}
|
||||
netSendPacket(connecthead, packet, pPacket-packet);
|
||||
return;
|
||||
}
|
||||
netMasterUpdate();
|
||||
}
|
||||
|
||||
void netInitialize(bool bConsole)
|
||||
|
|
|
@ -43,7 +43,6 @@ enum NETWORKMODE {
|
|||
|
||||
#define kNetDefaultPort 23513
|
||||
|
||||
extern char packet[576];
|
||||
extern MapRecord *gStartNewGame;
|
||||
extern PACKETMODE gPacketMode;
|
||||
extern ClockTicks gNetFifoClock;
|
||||
|
@ -55,9 +54,6 @@ extern GINPUT gFifoInput[256][8];
|
|||
extern int myMinLag[8];
|
||||
extern int otherMinLag;
|
||||
extern int myMaxLag;
|
||||
extern unsigned int gChecksum[4];
|
||||
extern unsigned int gCheckFifo[256][8][4];
|
||||
extern int gCheckHead[8];
|
||||
extern int gSendCheckTail;
|
||||
extern int gCheckTail;
|
||||
extern int gInitialNetPlayers;
|
||||
|
@ -72,73 +68,19 @@ extern char gNetAddress[32];
|
|||
extern int gNetPort;
|
||||
|
||||
|
||||
inline void PutPacketByte(char *&p, int a2)
|
||||
{
|
||||
//dassert(p - packet + 1 < sizeof(packet));
|
||||
*p++ = a2;
|
||||
}
|
||||
|
||||
inline void PutPacketWord(char *&p, int a2)
|
||||
{
|
||||
//dassert(p - packet + 2 < sizeof(packet));
|
||||
*(short*)p = a2;
|
||||
p += 2;
|
||||
}
|
||||
|
||||
inline void PutPacketDWord(char *&p, int a2)
|
||||
{
|
||||
//dassert(p - packet + 4 < sizeof(packet));
|
||||
*(int*)p = a2;
|
||||
p += 4;
|
||||
}
|
||||
|
||||
inline void PutPacketBuffer(char *&p, const void *pBuffer, int size)
|
||||
{
|
||||
//dassert(p + size < packet + sizeof(packet));
|
||||
memcpy(p, pBuffer, size);
|
||||
p += size;
|
||||
}
|
||||
|
||||
inline char GetPacketByte(char *&p)
|
||||
{
|
||||
return *p++;
|
||||
}
|
||||
|
||||
inline short GetPacketWord(char *&p)
|
||||
{
|
||||
short t = *(short*)p;
|
||||
p += 2;
|
||||
return t;
|
||||
}
|
||||
|
||||
inline int GetPacketDWord(char *&p)
|
||||
{
|
||||
int t = *(int*)p;
|
||||
p += 4;
|
||||
return t;
|
||||
}
|
||||
|
||||
inline void GetPacketBuffer(char *&p, void *pBuffer, int size)
|
||||
{
|
||||
//dassert(p + size < packet + sizeof(packet));
|
||||
memcpy(pBuffer, p, size);
|
||||
p += size;
|
||||
}
|
||||
|
||||
void netReset(void);
|
||||
void netResetToSinglePlayer(void);
|
||||
void netWaitForEveryone(char a1);
|
||||
void netGetPackets(void);
|
||||
void CalcGameChecksum(void);
|
||||
void netBroadcastPlayerLogoff(int nPlayer);
|
||||
void netBroadcastMyLogoff(bool bRestart);
|
||||
inline void netWaitForEveryone(char a1) {}
|
||||
inline void netGetPackets(void) {}
|
||||
inline void CalcGameChecksum(void) {}
|
||||
inline void netBroadcastPlayerLogoff(int nPlayer) {}
|
||||
inline void netBroadcastMyLogoff(bool bRestart) {}
|
||||
void netInitialize(bool bConsole);
|
||||
void netBroadcastPlayerInfo(int nPlayer);
|
||||
void netCheckSync(void);
|
||||
inline void netCheckSync(void) {}
|
||||
void netMasterUpdate(void);
|
||||
void netGetInput(void);
|
||||
void netPlayerQuit(int nPlayer);
|
||||
void netDeinitialize(void);
|
||||
void netBroadcastNewGame(void);
|
||||
|
||||
END_BLD_NS
|
||||
|
|
Loading…
Reference in a new issue