2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-01 01:25:38 +03:00

Merge pull request #136 from WPMGPRoSToTeMa/netbufextend

Extended net buffers
This commit is contained in:
theAsmodai 2016-01-23 18:31:59 +03:00
commit 4b12ceb8e1
4 changed files with 50 additions and 3 deletions

View File

@ -214,8 +214,18 @@ void Netchan_Setup(netsrc_t socketnumber, netchan_t *chan, netadr_t adr, int pla
chan->connect_time = (float)realtime;
chan->message.buffername = "netchan->message";
chan->message.data = chan->message_buf;
chan->message.maxsize = sizeof(chan->message_buf);
#ifdef REHLDS_FIXES
if (player_slot != -1)
{
chan->message.data = g_GameClients[player_slot]->GetExtendedMessageBuffer();
chan->message.maxsize = NET_MAX_PAYLOAD;
}
else
#endif
{
chan->message.data = chan->message_buf;
chan->message.maxsize = sizeof(chan->message_buf);
}
#ifdef REHLDS_FIXES
chan->message.cursize = 0;
#endif // REHLDS_FIXES
@ -326,6 +336,14 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
int send_from_frag[MAX_STREAMS] = { 0, 0 };
int send_from_regular = 0;
#ifdef REHLDS_FIXES
if (chan->message.cursize > MAX_MSGLEN)
{
Netchan_CreateFragments_(chan == &g_pcls.netchan ? 1 : 0, chan, &chan->message);
SZ_Clear(&chan->message);
}
#endif
// If we have data in the waiting list(s) and we have cleared the current queue(s), then
// push the waitlist(s) into the current queue(s)
Netchan_FragSend(chan);
@ -380,7 +398,11 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
}
if (send_from_regular) {
#ifdef REHLDS_FIXES
Q_memcpy(chan->reliable_buf, chan->message.data, chan->message.cursize);
#else
Q_memcpy(chan->reliable_buf, chan->message_buf, chan->message.cursize);
#endif
chan->reliable_length = chan->message.cursize;
SZ_Clear(&chan->message);

View File

@ -157,7 +157,6 @@ typedef struct server_s
struct rehlds_server_t {
//map for sv.model_precache (for faster resolving of model index by its name)
#if defined(REHLDS_FIXES)
CStringKeyStaticMap<int, 7, HL_MODEL_MAX * 2> modelsMap; //case-sensitive keys for better performance
@ -165,6 +164,11 @@ struct rehlds_server_t {
CICaseStringKeyStaticMap<int, 7, HL_MODEL_MAX * 2> modelsMap; //use case-insensitive keys to conform original engine's behavior
#endif
#ifdef REHLDS_FIXES
// Extended net buffers
uint8_t reliableDatagramBuffer[NET_MAX_PAYLOAD];
uint8_t signonData[NET_MAX_PAYLOAD];
#endif
};

View File

@ -5583,8 +5583,13 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
g_psv.datagram.cursize = 0;
g_psv.reliable_datagram.buffername = "Server Reliable Datagram";
#ifdef REHLDS_FIXES
g_psv.reliable_datagram.data = g_rehlds_sv.reliableDatagramBuffer;
g_psv.reliable_datagram.maxsize = sizeof(g_rehlds_sv.reliableDatagramBuffer);
#else
g_psv.reliable_datagram.data = g_psv.reliable_datagram_buf;
g_psv.reliable_datagram.maxsize = sizeof(g_psv.reliable_datagram_buf);
#endif
g_psv.reliable_datagram.cursize = 0;
g_psv.spectator.buffername = "Server Spectator Buffer";
@ -5596,8 +5601,13 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
g_psv.multicast.maxsize = sizeof(g_psv.multicast_buf);
g_psv.signon.buffername = "Server Signon Buffer";
#ifdef REHLDS_FIXES
g_psv.signon.data = g_rehlds_sv.signonData;
g_psv.signon.maxsize = sizeof(g_rehlds_sv.signonData);
#else
g_psv.signon.data = g_psv.signon_data;
g_psv.signon.maxsize = sizeof(g_psv.signon_data);
#endif
g_psv.signon.cursize = 0;
g_psv.num_edicts = g_psvs.maxclients + 1;

View File

@ -35,6 +35,9 @@ class CNetChan : public INetChan
private:
netchan_t* m_pNetChan;
#ifdef REHLDS_FIXES
uint8_t m_messageBuffer[NET_MAX_PAYLOAD];
#endif
public:
CNetChan(netchan_t* chan);
@ -42,6 +45,11 @@ public:
virtual sizebuf_t* GetMessageBuf();
virtual netchan_t* GetChan();
public:
#ifdef REHLDS_FIXES
uint8_t* GetExtendedMessageBuffer() { return m_messageBuffer; };
#endif
};
@ -90,6 +98,9 @@ public:
public:
bool GetSpawnedOnce() const { return m_bSpawnedOnce; }
void SetSpawnedOnce(bool spawned) { m_bSpawnedOnce = spawned; }
#ifdef REHLDS_FIXES
uint8_t* GetExtendedMessageBuffer() { return m_NetChan.GetExtendedMessageBuffer(); };
#endif
};
class CRehldsServerStatic : public IRehldsServerStatic {