Merge branch 'fix-input-buffer' into 'next'
Allow input buffer to hold more than 64 tics See merge request STJr/SRB2!950
This commit is contained in:
commit
1c42102ddb
|
@ -195,24 +195,25 @@ static inline void *G_ScpyTiccmd(ticcmd_t* dest, void* src, const size_t n)
|
||||||
// of 512 bytes is like 0.1)
|
// of 512 bytes is like 0.1)
|
||||||
UINT16 software_MAXPACKETLENGTH;
|
UINT16 software_MAXPACKETLENGTH;
|
||||||
|
|
||||||
/** Guesses the value of a tic from its lowest byte and from maketic
|
/** Guesses the full value of a tic from its lowest byte, for a specific node
|
||||||
*
|
*
|
||||||
* \param low The lowest byte of the tic value
|
* \param low The lowest byte of the tic value
|
||||||
|
* \param node The node to deduce the tic for
|
||||||
* \return The full tic value
|
* \return The full tic value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
tic_t ExpandTics(INT32 low)
|
tic_t ExpandTics(INT32 low, INT32 node)
|
||||||
{
|
{
|
||||||
INT32 delta;
|
INT32 delta;
|
||||||
|
|
||||||
delta = low - (maketic & UINT8_MAX);
|
delta = low - (nettics[node] & UINT8_MAX);
|
||||||
|
|
||||||
if (delta >= -64 && delta <= 64)
|
if (delta >= -64 && delta <= 64)
|
||||||
return (maketic & ~UINT8_MAX) + low;
|
return (nettics[node] & ~UINT8_MAX) + low;
|
||||||
else if (delta > 64)
|
else if (delta > 64)
|
||||||
return (maketic & ~UINT8_MAX) - 256 + low;
|
return (nettics[node] & ~UINT8_MAX) - 256 + low;
|
||||||
else //if (delta < -64)
|
else //if (delta < -64)
|
||||||
return (maketic & ~UINT8_MAX) + 256 + low;
|
return (nettics[node] & ~UINT8_MAX) + 256 + low;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
@ -3999,8 +4000,8 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||||
|
|
||||||
// To save bytes, only the low byte of tic numbers are sent
|
// To save bytes, only the low byte of tic numbers are sent
|
||||||
// Use ExpandTics to figure out what the rest of the bytes are
|
// Use ExpandTics to figure out what the rest of the bytes are
|
||||||
realstart = ExpandTics(netbuffer->u.clientpak.client_tic);
|
realstart = ExpandTics(netbuffer->u.clientpak.client_tic, node);
|
||||||
realend = ExpandTics(netbuffer->u.clientpak.resendfrom);
|
realend = ExpandTics(netbuffer->u.clientpak.resendfrom, node);
|
||||||
|
|
||||||
if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS
|
if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS
|
||||||
|| netbuffer->packettype == PT_NODEKEEPALIVEMIS
|
|| netbuffer->packettype == PT_NODEKEEPALIVEMIS
|
||||||
|
@ -4252,15 +4253,15 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
realstart = ExpandTics(netbuffer->u.serverpak.starttic);
|
realstart = netbuffer->u.serverpak.starttic;
|
||||||
realend = realstart + netbuffer->u.serverpak.numtics;
|
realend = realstart + netbuffer->u.serverpak.numtics;
|
||||||
|
|
||||||
if (!txtpak)
|
if (!txtpak)
|
||||||
txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots
|
txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots
|
||||||
* netbuffer->u.serverpak.numtics];
|
* netbuffer->u.serverpak.numtics];
|
||||||
|
|
||||||
if (realend > gametic + BACKUPTICS)
|
if (realend > gametic + CLIENTBACKUPTICS)
|
||||||
realend = gametic + BACKUPTICS;
|
realend = gametic + CLIENTBACKUPTICS;
|
||||||
cl_packetmissed = realstart > neededtic;
|
cl_packetmissed = realstart > neededtic;
|
||||||
|
|
||||||
if (realstart <= neededtic && realend > neededtic)
|
if (realstart <= neededtic && realend > neededtic)
|
||||||
|
@ -4603,11 +4604,11 @@ static void SV_SendTics(void)
|
||||||
for (n = 1; n < MAXNETNODES; n++)
|
for (n = 1; n < MAXNETNODES; n++)
|
||||||
if (nodeingame[n])
|
if (nodeingame[n])
|
||||||
{
|
{
|
||||||
lasttictosend = maketic;
|
|
||||||
|
|
||||||
// assert supposedtics[n]>=nettics[n]
|
// assert supposedtics[n]>=nettics[n]
|
||||||
realfirsttic = supposedtics[n];
|
realfirsttic = supposedtics[n];
|
||||||
if (realfirsttic >= maketic)
|
lasttictosend = min(maketic, realfirsttic + CLIENTBACKUPTICS);
|
||||||
|
|
||||||
|
if (realfirsttic >= lasttictosend)
|
||||||
{
|
{
|
||||||
// well we have sent all tics we will so use extrabandwidth
|
// well we have sent all tics we will so use extrabandwidth
|
||||||
// to resent packet that are supposed lost (this is necessary since lost
|
// to resent packet that are supposed lost (this is necessary since lost
|
||||||
|
@ -4616,7 +4617,7 @@ static void SV_SendTics(void)
|
||||||
DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n",
|
DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n",
|
||||||
n, maketic, supposedtics[n], nettics[n]));
|
n, maketic, supposedtics[n], nettics[n]));
|
||||||
realfirsttic = nettics[n];
|
realfirsttic = nettics[n];
|
||||||
if (realfirsttic >= maketic || (I_GetTime() + n)&3)
|
if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3)
|
||||||
// all tic are ok
|
// all tic are ok
|
||||||
continue;
|
continue;
|
||||||
DEBFILE(va("Sent %d anyway\n", realfirsttic));
|
DEBFILE(va("Sent %d anyway\n", realfirsttic));
|
||||||
|
@ -4659,7 +4660,7 @@ static void SV_SendTics(void)
|
||||||
|
|
||||||
// Send the tics
|
// Send the tics
|
||||||
netbuffer->packettype = PT_SERVERTICS;
|
netbuffer->packettype = PT_SERVERTICS;
|
||||||
netbuffer->u.serverpak.starttic = (UINT8)realfirsttic;
|
netbuffer->u.serverpak.starttic = realfirsttic;
|
||||||
netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic);
|
netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic);
|
||||||
netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots);
|
netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots);
|
||||||
bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds;
|
bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds;
|
||||||
|
|
|
@ -34,6 +34,7 @@ applications may follow different packet versions.
|
||||||
|
|
||||||
// Networking and tick handling related.
|
// Networking and tick handling related.
|
||||||
#define BACKUPTICS 96
|
#define BACKUPTICS 96
|
||||||
|
#define CLIENTBACKUPTICS 32
|
||||||
#define MAXTEXTCMD 256
|
#define MAXTEXTCMD 256
|
||||||
//
|
//
|
||||||
// Packet structure
|
// Packet structure
|
||||||
|
@ -128,7 +129,7 @@ typedef struct
|
||||||
// this packet is too large
|
// this packet is too large
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UINT8 starttic;
|
tic_t starttic;
|
||||||
UINT8 numtics;
|
UINT8 numtics;
|
||||||
UINT8 numslots; // "Slots filled": Highest player number in use plus one.
|
UINT8 numslots; // "Slots filled": Highest player number in use plus one.
|
||||||
ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large
|
ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large
|
||||||
|
@ -520,7 +521,7 @@ extern consvar_t cv_resynchattempts, cv_blamecfail;
|
||||||
extern consvar_t cv_maxsend, cv_noticedownload, cv_downloadspeed;
|
extern consvar_t cv_maxsend, cv_noticedownload, cv_downloadspeed;
|
||||||
|
|
||||||
// Used in d_net, the only dependence
|
// Used in d_net, the only dependence
|
||||||
tic_t ExpandTics(INT32 low);
|
tic_t ExpandTics(INT32 low, INT32 node);
|
||||||
void D_ClientServerInit(void);
|
void D_ClientServerInit(void);
|
||||||
|
|
||||||
// Initialise the other field
|
// Initialise the other field
|
||||||
|
|
|
@ -838,7 +838,7 @@ static void DebugPrintpacket(const char *header)
|
||||||
size_t ntxtcmd = &((UINT8 *)netbuffer)[doomcom->datalength] - cmd;
|
size_t ntxtcmd = &((UINT8 *)netbuffer)[doomcom->datalength] - cmd;
|
||||||
|
|
||||||
fprintf(debugfile, " firsttic %u ply %d tics %d ntxtcmd %s\n ",
|
fprintf(debugfile, " firsttic %u ply %d tics %d ntxtcmd %s\n ",
|
||||||
(UINT32)ExpandTics(serverpak->starttic), serverpak->numslots, serverpak->numtics, sizeu1(ntxtcmd));
|
(UINT32)serverpak->starttic, serverpak->numslots, serverpak->numtics, sizeu1(ntxtcmd));
|
||||||
/// \todo Display more readable information about net commands
|
/// \todo Display more readable information about net commands
|
||||||
fprintfstringnewline((char *)cmd, ntxtcmd);
|
fprintfstringnewline((char *)cmd, ntxtcmd);
|
||||||
/*fprintfstring((char *)cmd, 3);
|
/*fprintfstring((char *)cmd, 3);
|
||||||
|
@ -857,8 +857,8 @@ static void DebugPrintpacket(const char *header)
|
||||||
case PT_NODEKEEPALIVE:
|
case PT_NODEKEEPALIVE:
|
||||||
case PT_NODEKEEPALIVEMIS:
|
case PT_NODEKEEPALIVEMIS:
|
||||||
fprintf(debugfile, " tic %4u resendfrom %u\n",
|
fprintf(debugfile, " tic %4u resendfrom %u\n",
|
||||||
(UINT32)ExpandTics(netbuffer->u.clientpak.client_tic),
|
(UINT32)ExpandTics(netbuffer->u.clientpak.client_tic, doomcom->remotenode),
|
||||||
(UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom));
|
(UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom, doomcom->remotenode));
|
||||||
break;
|
break;
|
||||||
case PT_TEXTCMD:
|
case PT_TEXTCMD:
|
||||||
case PT_TEXTCMD2:
|
case PT_TEXTCMD2:
|
||||||
|
|
Loading…
Reference in a new issue