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

Added names for network constants.

This commit is contained in:
asmodai 2015-06-07 21:06:20 +03:00
parent c3e5486612
commit 895f0beda5
14 changed files with 67 additions and 57 deletions

View File

@ -137,7 +137,7 @@ typedef struct client_static_s
cactive_t state;
netchan_t netchan;
sizebuf_t datagram;
byte datagram_buf[4000];
byte datagram_buf[MAX_DATAGRAM];
double connect_time;
int connect_retry;
int challenge;
@ -146,7 +146,7 @@ typedef struct client_static_s
char trueaddress[32];
float slist_time;
int signon;
char servername[260];
char servername[MAX_PATH];
char mapstring[64];
char spawnparms[2048];
char userinfo[256];
@ -164,7 +164,7 @@ typedef struct client_static_s
FileHandle_t demoheader;
qboolean demowaiting;
qboolean demoappending;
char demofilename[260];
char demofilename[MAX_PATH];
int demoframecount;
int td_lastframe;
int td_startframe;
@ -174,7 +174,7 @@ typedef struct client_static_s
double packet_loss_recalc_time;
int playerbits;
soundfade_t soundfade;
char physinfo[256];
char physinfo[MAX_PHYSINFO_STRING];
unsigned char md5_clientdll[16];
netadr_t game_stream;
netadr_t connect_stream;
@ -210,7 +210,7 @@ typedef struct client_state_s
vec3_t simorg;
vec3_t simvel;
vec3_t simangles;
vec_t predicted_origins[64][3];
vec3_t predicted_origins[64];
vec3_t prediction_error;
float idealpitch;
vec3_t viewheight;

View File

@ -1088,7 +1088,7 @@ void Host_Version(void)
{
char szSteamVersionId[32];
FS_GetInterfaceVersion(szSteamVersionId, sizeof(szSteamVersionId) - 1);
_snprintf(gpszVersionString, sizeof(gpszVersionString), "%s/%s", &com_token[Q_strlen("PatchVersion=")], szSteamVersionId);
Q_snprintf(gpszVersionString, sizeof(gpszVersionString), "%s/%s", &com_token[Q_strlen("PatchVersion=")], szSteamVersionId);
gpszVersionString[sizeof(gpszVersionString) - 1] = 0;
}
++gotKeys;
@ -1179,7 +1179,7 @@ int Host_Init(quakeparms_t *parms)
_snprintf(versionString, sizeof(versionString), "%s,%i,%i", gpszVersionString, PROTOCOL_VERSION, build_number());
Q_snprintf(versionString, sizeof(versionString), "%s,%i,%i", gpszVersionString, PROTOCOL_VERSION, build_number());
Cvar_Set("sv_version", versionString);
Con_DPrintf("%4.1f Mb heap\n", (double)parms->memsize / (1024.0f * 1024.0f));
R_InitTextures();

View File

@ -392,7 +392,7 @@ void Mod_AdInit(void)
s = com_argv[i + 1];
if (s && *s)
{
_snprintf(filename, MAX_PATH, "%s", s);
Q_snprintf(filename, MAX_PATH, "%s", s);
if (FS_FileSize(filename) > 0)
{
Sys_Error("Mod_Init(): reverse me");
@ -1326,7 +1326,7 @@ void Mod_LoadBrushModel_internal(model_t *mod, void *buffer)
if (i < mod->numsubmodels - 1)
{
_snprintf(name, 10, "*%i", i + 1);
Q_snprintf(name, 10, "*%i", i + 1);
submodel = Mod_FindName(0, name);
*submodel = *mod;
loadmodel = submodel;

View File

@ -91,8 +91,17 @@
// NETWORKING INFO
// Max size of udp packet payload
#define MAX_UDP_PACKET 4010 // 9 bytes SPLITHEADER + 4000 payload?
// Max length of a reliable message
#define MAX_MSGLEN 3990 // 10 reserved for fragheader?
// Max length of unreliable message
#define MAX_DATAGRAM 4000
// This is the packet payload without any header bytes (which are attached for actual sending)
#define NET_MAX_PAYLOAD 3990
#define NET_MAX_PAYLOAD 65536
// This is the payload plus any header info (excluding UDP header)
@ -116,7 +125,7 @@
// Pad this to next higher 16 byte boundary
// This is the largest packet that can come in/out over the wire, before processing the header
// bytes will be stripped by the networking channel layer
//#define NET_MAX_MESSAGE PAD_NUMBER( ( NET_MAX_PAYLOAD + HEADER_BYTES ), 16 )
//#define NET_MAX_MESSAGE PAD_NUMBER( ( MAX_MSGLEN + HEADER_BYTES ), 16 )
// This is currently used value in the engine. TODO: define above gives 4016, check it why.
#define NET_MAX_MESSAGE 4037
@ -241,7 +250,7 @@ typedef struct flow_s
#ifndef REHLDS_FIXES
#define MAX_FRAGMENTS 25000
#else
#define MAX_FRAGMENTS ((65536 + FRAGMENT_SIZE - 1) / FRAGMENT_SIZE) // should be enough for any send buf
#define MAX_FRAGMENTS ((NET_MAX_PAYLOAD + FRAGMENT_SIZE - 1) / FRAGMENT_SIZE) // should be enough for any send buf
#endif
#define UDP_HEADER_SIZE 28
@ -335,11 +344,11 @@ typedef struct netchan_s
// Staging and holding areas
sizebuf_t message;
byte message_buf[NET_MAX_PAYLOAD];
byte message_buf[MAX_MSGLEN];
// Reliable message buffer. We keep adding to it until reliable is acknowledged. Then we clear it.
int reliable_length;
byte reliable_buf[NET_MAX_PAYLOAD];
byte reliable_buf[MAX_MSGLEN];
// Waiting list of buffered fragments to go onto queue. Multiple outgoing buffers can be queued in succession.
fragbufwaiting_t *waitlist[MAX_STREAMS];

View File

@ -117,12 +117,13 @@ void Netchan_OutOfBandPrint(netsrc_t sock, netadr_t adr, char *format, ...)
{
va_list argptr;
char string[8192];
size_t len;
va_start(argptr, format);
Q_vsnprintf(string, sizeof(string), format, argptr);
len = Q_vsnprintf(string, sizeof(string), format, argptr);
va_end(argptr);
Netchan_OutOfBand(sock, adr, Q_strlen(string) + 1, (byte *)string);
Netchan_OutOfBand(sock, adr, len + 1, (byte *)string);
}
/* <65776> ../engine/net_chan.c:196 */
@ -417,7 +418,7 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
FileHandle_t hfile;
if (pbuf->iscompressed)
{
_snprintf(compressedfilename, sizeof(compressedfilename), "%s.ztmp", pbuf->filename);
Q_snprintf(compressedfilename, sizeof(compressedfilename), "%s.ztmp", pbuf->filename);
hfile = FS_Open(compressedfilename, "rb");
}
else
@ -500,7 +501,7 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
}
// Is there room for the unreliable payload?
int max_send_size = 1400;
int max_send_size = MAX_ROUTEABLE_PACKET;
if (!send_resending)
max_send_size = sb_send.maxsize;
@ -539,7 +540,7 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
NET_SendPacket(chan->sock, sb_send.cursize, sb_send.data, chan->remote_address);
}
if (g_psv.active && sv_lan.value != 0.0f && sv_lan_rate.value > 1000.0)
if (g_psv.active && sv_lan.value != 0.0f && sv_lan_rate.value > MIN_RATE)
fRate = 1.0 / sv_lan_rate.value;
else
fRate = 1.0 / chan->rate;
@ -655,7 +656,7 @@ qboolean Netchan_Validate(netchan_t *chan, qboolean *frag_message, unsigned int
if (FRAG_GETCOUNT(fragid[i]) > MAX_FRAGMENTS || FRAG_GETID(fragid[i]) > FRAG_GETCOUNT(fragid[i]))
return FALSE;
if ((size_t)frag_length[i] > FRAGMENT_SIZE || (size_t)frag_offset[i] > 65535)
if ((size_t)frag_length[i] > FRAGMENT_SIZE || (size_t)frag_offset[i] > NET_MAX_PAYLOAD - 1)
return FALSE;
int frag_end = frag_offset[i] + frag_length[i];
@ -1208,7 +1209,7 @@ int Netchan_CreateFileFragments(qboolean server, netchan_t *chan, const char *fi
fragbufwaiting_t *p;
int send;
fragbuf_t *buf;
char compressedfilename[260];
char compressedfilename[MAX_PATH];
int firstfragment;
int bufferid;
int bCompressed;
@ -1221,7 +1222,7 @@ int Netchan_CreateFileFragments(qboolean server, netchan_t *chan, const char *fi
bCompressed = FALSE;
chunksize = chan->pfnNetchan_Blocksize(chan->connection_status);
Q_snprintf(compressedfilename, 0x104u, "%s.ztmp", filename);
Q_snprintf(compressedfilename, sizeof compressedfilename, "%s.ztmp", filename);
compressedFileTime = FS_GetFileTime(compressedfilename);
if (compressedFileTime >= FS_GetFileTime(filename))
{

View File

@ -49,8 +49,8 @@ qboolean noipx;
int use_thread;
unsigned char net_message_buffer[65536];
unsigned char in_message_buf[65536];
unsigned char net_message_buffer[NET_MAX_PAYLOAD];
unsigned char in_message_buf[NET_MAX_PAYLOAD];
sizebuf_t in_message;
netadr_t in_from;
@ -841,13 +841,13 @@ void NET_FlushSocket(netsrc_t sock)
struct sockaddr from;
socklen_t fromlen;
int net_socket;
unsigned char buf[4010];
unsigned char buf[MAX_UDP_PACKET];
net_socket = ip_sockets[sock];
if (net_socket)
{
fromlen = 16;
while (CRehldsPlatformHolder::get()->recvfrom(net_socket, (char*)buf, 4010, 0, &from, &fromlen) > 0)
while (CRehldsPlatformHolder::get()->recvfrom(net_socket, (char*)buf, sizeof buf, 0, &from, &fromlen) > 0)
;
}
}
@ -911,7 +911,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
);
}
if (SPLIT_SIZE * packetNumber + packetPayloadSize > 4010)
if (SPLIT_SIZE * packetNumber + packetPayloadSize > MAX_UDP_PACKET)
{
Con_Printf("Malformed packet size (%i, %i)\n", SPLIT_SIZE * packetNumber, packetPayloadSize);
#ifdef REHLDS_FIXES
@ -928,7 +928,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (packetCount > 0)
{
for (int i = 0; i < packetCount; i++)
for (unsigned int i = 0; i < packetCount; i++)
{
if (gNetSplitFlags[i] != gNetSplit.currentSequence)
{
@ -947,7 +947,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
}
gNetSplit.currentSequence = -1;
if (gNetSplit.totalSize <= 4010)
if (gNetSplit.totalSize <= MAX_UDP_PACKET)
{
Q_memcpy(pData, gNetSplit.buffer, gNetSplit.totalSize);
*outSize = gNetSplit.totalSize;
@ -972,7 +972,7 @@ qboolean NET_QueuePacket(netsrc_t sock)
int net_socket; // 1026
int protocol; // 1027
int err; // 1028
unsigned char buf[4010]; // 1029
unsigned char buf[MAX_UDP_PACKET]; // 1029
#ifdef _WIN32
for (protocol = 0; protocol < 2; protocol++)
@ -991,7 +991,7 @@ qboolean NET_QueuePacket(netsrc_t sock)
continue;
fromlen = sizeof(from);
ret = CRehldsPlatformHolder::get()->recvfrom(net_socket, (char *)buf, 4010, 0, &from, &fromlen);
ret = CRehldsPlatformHolder::get()->recvfrom(net_socket, (char *)buf, sizeof buf, 0, &from, &fromlen);
if (ret == -1)
{
#ifdef _WIN32
@ -1021,13 +1021,13 @@ qboolean NET_QueuePacket(netsrc_t sock)
continue;
}
SockadrToNetadr(&from, &in_from);
if (ret != 4010)
if (ret != MAX_UDP_PACKET)
break;
Con_Printf("NET_QueuePacket: Oversize packet from %s\n", NET_AdrToString(in_from));
}
if (ret == -1 || ret == 4010) {
if (ret == -1 || ret == MAX_UDP_PACKET) {
return NET_LagPacket(0, sock, 0, 0);
}

View File

@ -106,7 +106,7 @@ typedef struct LONGPACKET_t
int splitCount;
int totalSize;
// TODO: It should be NET_MAX_MESSAGE, but value differs
char buffer[4010]; // This has to be big enough to hold the largest message
char buffer[MAX_UDP_PACKET]; // This has to be big enough to hold the largest message
} LONGPACKET;
/* <d2ae9> ../engine/net_ws.c:900 */
@ -212,8 +212,8 @@ extern cvar_t net_graph;
extern cvar_t net_graphwidth;
extern cvar_t net_scale;
extern cvar_t net_graphpos;
extern unsigned char net_message_buffer[65536];
extern unsigned char in_message_buf[65536];
extern unsigned char net_message_buffer[NET_MAX_PAYLOAD];
extern unsigned char in_message_buf[NET_MAX_PAYLOAD];
extern sizebuf_t in_message;
extern netadr_t in_from;
extern int ip_sockets[3];

View File

@ -1129,7 +1129,7 @@ short unsigned int EV_Precache(int type, const char *psz)
Host_Error("EV_Precache: only file type 1 supported currently\n");
char szpath[MAX_PATH];
_snprintf(szpath, sizeof(szpath), "%s", psz);
Q_snprintf(szpath, sizeof(szpath), "%s", psz);
COM_FixSlashes(szpath);
int scriptSize = 0;
@ -1525,7 +1525,7 @@ int PF_IsMapValid_I(char *mapname)
return 0;
_snprintf(cBuf, sizeof(cBuf), "maps/%.32s.bsp", mapname);
Q_snprintf(cBuf, sizeof(cBuf), "maps/%.32s.bsp", mapname);
return FS_FileExists(cBuf);
}

View File

@ -59,7 +59,7 @@
#include "userid.h"
#include "pm_defs.h"
#include "inst_baseline.h"
#include "net_ws.h"
#define DEFAULT_SOUND_PACKET_VOLUME 255
#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0f
@ -153,9 +153,9 @@ typedef struct server_s
extra_baselines_t *instance_baselines;
server_state_t state;
sizebuf_t datagram;
unsigned char datagram_buf[4000];
unsigned char datagram_buf[MAX_DATAGRAM];
sizebuf_t reliable_datagram;
unsigned char reliable_datagram_buf[4000];
unsigned char reliable_datagram_buf[MAX_DATAGRAM];
sizebuf_t multicast;
unsigned char multicast_buf[1024];
sizebuf_t spectator;
@ -212,7 +212,7 @@ typedef struct client_s
double nextping;
double svtimebase;
sizebuf_t datagram;
byte datagram_buf[4000];
byte datagram_buf[MAX_DATAGRAM];
double connection_started;
double next_messagetime;
double next_messageinterval;
@ -533,7 +533,7 @@ extern cvar_t sv_allow_dlfile;
extern cvar_t sv_version;
extern int sv_playermodel;
extern char outputbuf[1400];
extern char outputbuf[MAX_ROUTEABLE_PACKET];
extern redirect_t sv_redirected;
extern netadr_t sv_redirectto;

View File

@ -95,7 +95,7 @@ int numuserfilters;
int sv_playermodel;
//int player_datacounts[32];
char outputbuf[1400];
char outputbuf[MAX_ROUTEABLE_PACKET];
redirect_t sv_redirected;
netadr_t sv_redirectto;
@ -1527,7 +1527,7 @@ void SV_New_f(void)
{
int i;
client_t *client;
unsigned char data[65536];
unsigned char data[NET_MAX_PAYLOAD];
sizebuf_t msg;
edict_t *ent;
char szRejectReason[128];
@ -1611,7 +1611,7 @@ void SV_New_f(void)
/* <a7132> ../engine/sv_main.c:2057 */
void SV_SendRes_f(void)
{
unsigned char data[65536];
unsigned char data[NET_MAX_PAYLOAD];
sizebuf_t msg;
Q_memset(&msg, 0, sizeof(msg));
@ -1636,7 +1636,7 @@ void SV_SendRes_f(void)
/* <a8922> ../engine/sv_main.c:2096 */
void SV_Spawn_f(void)
{
unsigned char data[65536];
unsigned char data[NET_MAX_PAYLOAD];
sizebuf_t msg;
Q_memset(&msg, 0, sizeof(msg));
@ -2778,7 +2778,7 @@ NOXREF void SVC_InfoString(void)
int count = 0;
int proxy = 0;
sizebuf_t buf;
unsigned char data[1400];
unsigned char data[MAX_ROUTEABLE_PACKET];
char address[256];
char gd[260];
char info[2048];
@ -2891,7 +2891,7 @@ NOXREF void SVC_Info(qboolean bDetailed)
int i;
int count = 0;
sizebuf_t buf;
unsigned char data[1400];
unsigned char data[MAX_ROUTEABLE_PACKET];
char szModURL_Info[512];
char szModURL_DL[512];
int mod_version;
@ -4551,7 +4551,7 @@ void SV_CleanupEnts(void)
/* <a96d8> ../engine/sv_main.c:5999 */
qboolean SV_SendClientDatagram(client_t *client)
{
unsigned char buf[4000];
unsigned char buf[MAX_DATAGRAM];
sizebuf_t msg;
msg.buffername = "Client Datagram";
@ -5361,7 +5361,7 @@ void SetCStrikeFlags(void)
void SV_ActivateServer(int runPhysics)
{
int i;
unsigned char data[65536];
unsigned char data[NET_MAX_PAYLOAD];
sizebuf_t msg;
client_t *cl;
UserMsg *pTemp;

View File

@ -94,13 +94,13 @@ const char* CServerRemoteAccess::LookupStringValue(const char *variable)
count++;
}
_snprintf(s_ReturnBuf, sizeof(s_ReturnBuf) - 1, "%d", count);
Q_snprintf(s_ReturnBuf, sizeof(s_ReturnBuf) - 1, "%d", count);
return s_ReturnBuf;
}
if (!Q_stricmp(variable, "maxplayers"))
{
_snprintf(s_ReturnBuf, sizeof(s_ReturnBuf) - 1, "%d", g_psvs.maxclients);
Q_snprintf(s_ReturnBuf, sizeof(s_ReturnBuf) - 1, "%d", g_psvs.maxclients);
return s_ReturnBuf;
}
@ -153,7 +153,7 @@ void CServerRemoteAccess::GetMapList(CUtlBuffer &value)
Q_strcpy(mapwild, "maps/*.bsp");
for (findfn = Sys_FindFirst(mapwild, 0); findfn; findfn = Sys_FindNext(0))
{
_snprintf(curDir, MAX_PATH, "maps/%s", findfn);
Q_snprintf(curDir, MAX_PATH, "maps/%s", findfn);
FS_GetLocalPath(curDir, curDir, MAX_PATH);
if (Q_strstr(curDir, com_gamedir))
{

View File

@ -198,7 +198,7 @@ void CSteam3Server::OnGSClientApprove(GSClientApprove_t *pGSClientSteam2Accept)
}
else
{
_snprintf(msg, 0x200u, "\"%s<%i><%s><>\" STEAM USERID validated\n", cl->name, cl->userid, SV_GetClientIDString(cl));
Q_snprintf(msg, 0x200u, "\"%s<%i><%s><>\" STEAM USERID validated\n", cl->name, cl->userid, SV_GetClientIDString(cl));
Con_DPrintf("%s", msg);
Log_Printf("%s", msg);
}

View File

@ -285,7 +285,7 @@ int SV_TransferConsistencyInfo(void)
}
else
{
_snprintf(filename, MAX_PATH, "sound/%s", r->szFileName);
Q_snprintf(filename, MAX_PATH, "sound/%s", r->szFileName);
}
MD5_Hash_File(r->rgucMD5_hash, filename, FALSE, FALSE, NULL);

View File

@ -112,7 +112,7 @@ qboolean TEX_InitFromWad(char *path)
{
ForwardSlashes(pszWadFile);
COM_FileBase(pszWadFile, wadName);
_snprintf(wadPath, 0x100u, "%s", wadName);
Q_snprintf(wadPath, 0x100u, "%s", wadName);
COM_DefaultExtension(wadPath, ".wad");
if (Q_strstr(wadName, "pldecal") || Q_strstr(wadName, "tempdecal"))