From 940cf0e2ecca6777494c65ec249b1be8f6c82219 Mon Sep 17 00:00:00 2001 From: WPMGPRoSToTeMa Date: Sat, 23 Jan 2016 18:25:54 +0300 Subject: [PATCH] Extended server reliable and signon buffers Extended client netchan message buffer --- rehlds/engine/net_chan.cpp | 26 ++++++++++++++++++++++++-- rehlds/engine/server.h | 6 +++++- rehlds/engine/sv_main.cpp | 10 ++++++++++ rehlds/rehlds/rehlds_interfaces_impl.h | 11 +++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/net_chan.cpp b/rehlds/engine/net_chan.cpp index 655231c..9927a8b 100644 --- a/rehlds/engine/net_chan.cpp +++ b/rehlds/engine/net_chan.cpp @@ -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); diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index f2829f0..aaf0a28 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -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 modelsMap; //case-sensitive keys for better performance @@ -165,6 +164,11 @@ struct rehlds_server_t { CICaseStringKeyStaticMap 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 }; diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index e71929c..1feca9b 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -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; diff --git a/rehlds/rehlds/rehlds_interfaces_impl.h b/rehlds/rehlds/rehlds_interfaces_impl.h index acb5dcd..63f2ccd 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.h +++ b/rehlds/rehlds/rehlds_interfaces_impl.h @@ -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 {