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

Fixed message fragments validation.

Fixed NET_GetLong.
Passing netadr_t to functions by reference instead of copying.
Added missed Q_ prefix for stdlib functions.
This commit is contained in:
asmodai 2015-06-07 03:55:42 +03:00
parent 324ff95e72
commit c3e5486612
31 changed files with 263 additions and 193 deletions

View File

@ -92,7 +92,7 @@ void Cbuf_InsertText(char *text)
#ifdef REHLDS_FIXES
if (currLen)
memmove(cmd_text.data + addLen, cmd_text.data, currLen);
Q_memmove(cmd_text.data + addLen, cmd_text.data, currLen);
Q_memcpy(cmd_text.data, text, addLen);
cmd_text.cursize += addLen;
@ -131,7 +131,7 @@ void Cbuf_InsertTextLines(char *text)
#ifdef REHLDS_FIXES
if (currLen)
memmove(cmd_text.data + addLen + 1, cmd_text.data, currLen);
Q_memmove(cmd_text.data + addLen + 1, cmd_text.data, currLen);
cmd_text.data[0] = '\n'; // TODO: Why we need leading \n, if there is no commands in the start?
Q_memcpy(&cmd_text.data[1], text, addLen);
@ -225,7 +225,7 @@ void Cbuf_Execute(void)
cmd_text.cursize -= i;
#ifdef REHLDS_FIXES
// dst overlaps src
memmove(text, text + i, cmd_text.cursize);
Q_memmove(text, text + i, cmd_text.cursize);
#else // REHLDS_FIXES
Q_memcpy(text, text + i, cmd_text.cursize);
#endif // REHLDS_FIXES
@ -559,7 +559,7 @@ void Cmd_Shutdown(void)
{
Z_Free(cmd_argv[i]);
}
memset(cmd_argv, 0, sizeof(cmd_argv));
Q_memset(cmd_argv, 0, sizeof(cmd_argv));
cmd_argc = 0;
cmd_args = NULL;

View File

@ -95,7 +95,7 @@ qboolean COM_CreateCustomization(customization_t *pListHead, resource_t *pResour
*pCustomization = 0;
pCust = (customization_t *)Mem_ZeroMalloc(sizeof(customization_t));
memcpy(&pCust->resource, pResource, sizeof(pCust->resource));
Q_memcpy(&pCust->resource, pResource, sizeof(pCust->resource));
if (pResource->nDownloadSize <= 0)
{
bError = 1;

View File

@ -2030,7 +2030,7 @@ NOXREF int COM_ExpandFilename(char *filename)
char netpath[MAX_PATH];
FS_GetLocalPath(filename, netpath, ARRAYSIZE(netpath));
strcpy(filename, netpath);
Q_strcpy(filename, netpath);
return *filename != 0;
}
@ -2303,12 +2303,12 @@ void COM_ParseDirectoryFromCmd(const char *pCmdName, char *pDirName, const char
if (pParameter)
{
// Grab it
strcpy(pDirName, pParameter);
Q_strcpy(pDirName, pParameter);
}
else if (pDefault)
{
// Ok, then use the default
strcpy(pDirName, pDefault);
Q_strcpy(pDirName, pDefault);
}
else
{

View File

@ -119,6 +119,7 @@ extern int loadsize;
#define Q_memset memset
#define Q_memcpy memcpy
#define Q_memmove memmove
#define Q_strlen strlen
#define Q_memcmp memcmp
#define Q_strcpy strcpy

View File

@ -65,7 +65,7 @@ void DELTAJIT_CreateDescription(delta_t* delta, deltajitdata_t &jitdesc) {
return;
}
memset(&jitdesc, 0, sizeof(jitdesc));
Q_memset(&jitdesc, 0, sizeof(jitdesc));
jitdesc.numblocks = numMemBlocks;
jitdesc.numFields = delta->fieldCount;

View File

@ -20,7 +20,7 @@ CStringPoolMap g_EdStringPool;
sizebuf_t g_EdStringPool_Hunk;
void Ed_StrPool_Init() {
memset(&g_EdStringPool_Hunk, 0, sizeof(g_EdStringPool_Hunk));
Q_memset(&g_EdStringPool_Hunk, 0, sizeof(g_EdStringPool_Hunk));
g_EdStringPool_Hunk.maxsize = 128 * 1024;
g_EdStringPool_Hunk.data = (byte*) Hunk_AllocName(g_EdStringPool_Hunk.maxsize, "Ed_StrPool");
@ -43,7 +43,7 @@ char* Ed_StrPool_Alloc(const char* origStr) {
Sys_Error(__FUNCTION__ ": Too long string allocated: %s", origStr);
}
strcpy(str, origStr);
Q_strcpy(str, origStr);
char* new_p = str;
for (unsigned int i = 0; i < len; i++, new_p++)
{
@ -80,7 +80,7 @@ char* Ed_StrPool_Alloc(const char* origStr) {
if (!val) {
val = (char*) Hunk_Alloc(len);
memcpy(val, str, len);
Q_memcpy(val, str, len);
}
g_EdStringPool.put(val, val);

View File

@ -325,7 +325,7 @@ int FileSystem_SetGameDirectory(const char *pDefaultDir, const char *pGameDir)
}
pchLang = CRehldsPlatformHolder::get()->SteamApps() ? CRehldsPlatformHolder::get()->SteamApps()->GetCurrentGameLanguage() : NULL;
strncpy(language, pchLang ? pchLang : "english", sizeof(language));
Q_strncpy(language, pchLang ? pchLang : "english", sizeof(language));
if (!g_bIsDedicatedServer && !IsGameSubscribed(pGameDir))
return 0;
@ -469,12 +469,12 @@ int FileSystem_AddFallbackGameDir(const char *pGameDir)
char language[128];
const char * pchLang = CRehldsPlatformHolder::get()->SteamApps() ? CRehldsPlatformHolder::get()->SteamApps()->GetCurrentGameLanguage() : NULL;
strncpy(language, pchLang ? pchLang : "english", sizeof(language));
Q_strncpy(language, pchLang ? pchLang : "english", sizeof(language));
if (strlen(language) != 0 && Q_stricmp(language, "english"))
{
char temp[MAX_PATH];
sprintf(temp, "%s/%s_%s", GetBaseDirectory(), pGameDir, language);
Q_sprintf(temp, "%s/%s_%s", GetBaseDirectory(), pGameDir, language);
g_pFileSystem->AddSearchPath(temp, "GAME");
}
g_pFileSystem->AddSearchPath(pGameDir, "GAME");

View File

@ -341,13 +341,13 @@ void FS_Rename(const char *originalName, const char *newName)
if (FS_GetLocalPath(originalName, localPath, 512))
{
strcpy(newPath, localPath);
Q_strcpy(newPath, localPath);
cut = strstr(newPath, originalName);
if (cut)
{
*cut = 0;
strcat(newPath, newName);
Q_strcat(newPath, newName);
rename(localPath, newPath);
}
}

View File

@ -163,7 +163,7 @@ qboolean HPAK_FindResource(hash_pack_directory_t *pDir, unsigned char *hash, str
if (Q_memcmp(hash, pDir->p_rgEntries[i].resource.rgucMD5_hash, 16) == 0)
{
if (pResourceEntry)
memcpy(pResourceEntry, &pDir->p_rgEntries[i].resource, sizeof(resource_t));
Q_memcpy(pResourceEntry, &pDir->p_rgEntries[i].resource, sizeof(resource_t));
return TRUE;
}
@ -180,7 +180,7 @@ void HPAK_AddToQueue(char *pakname, struct resource_s *pResource, void *pData, F
Q_memset(n, 0, sizeof(hash_pack_queue_t));
n->pakname = Mem_Strdup(pakname);
memcpy(&n->resource, pResource, sizeof(resource_t));
Q_memcpy(&n->resource, pResource, sizeof(resource_t));
n->datasize = pResource->nDownloadSize;
n->data = Mem_Malloc(pResource->nDownloadSize);
if (!n->data)
@ -363,7 +363,7 @@ void HPAK_AddLump(qboolean bUseQueue, char *pakname, struct resource_s *pResourc
pNewEntry = &newdirectory.p_rgEntries[i];
while (i < olddirectory.nEntries)
{
memcpy(&newdirectory.p_rgEntries[i + 1], &olddirectory.p_rgEntries[i + 1], sizeof(hash_pack_entry_t));
Q_memcpy(&newdirectory.p_rgEntries[i + 1], &olddirectory.p_rgEntries[i + 1], sizeof(hash_pack_entry_t));
i++;
}
break;
@ -378,7 +378,7 @@ void HPAK_AddLump(qboolean bUseQueue, char *pakname, struct resource_s *pResourc
Q_memset(pNewEntry, 0, sizeof(hash_pack_entry_t));
FS_Seek(iWrite, hash_pack_header.nDirectoryOffset, FILESYSTEM_SEEK_HEAD);
memcpy(&pNewEntry->resource, pResource, sizeof(resource_t));
Q_memcpy(&pNewEntry->resource, pResource, sizeof(resource_t));
pNewEntry->nOffset = FS_Tell(iWrite);
pNewEntry->nFileLength = pResource->nDownloadSize;
@ -523,7 +523,7 @@ void HPAK_RemoveLump(char *pakname, resource_t *pResource)
if (Q_memcmp(olddir.p_rgEntries[i].resource.rgucMD5_hash, pResource->rgucMD5_hash, 16))
{
newentry = &newdir.p_rgEntries[n++];
memcpy(newentry, oldentry, sizeof(hash_pack_entry_t));
Q_memcpy(newentry, oldentry, sizeof(hash_pack_entry_t));
newentry->nOffset = FS_Tell(tmp);
FS_Seek(fp, oldentry->nOffset, FILESYSTEM_SEEK_HEAD);
@ -599,7 +599,7 @@ qboolean HPAK_ResourceForIndex(char *pakname, int nIndex, struct resource_s *pRe
directory.p_rgEntries = (hash_pack_entry_t *)Mem_Malloc(sizeof(hash_pack_entry_t) * directory.nEntries);
FS_Read(directory.p_rgEntries, sizeof(hash_pack_entry_t) * directory.nEntries, 1, fp);
entry = &directory.p_rgEntries[nIndex - 1];
memcpy(pResource, &entry->resource, sizeof(resource_t));
Q_memcpy(pResource, &entry->resource, sizeof(resource_t));
FS_Close(fp);
Mem_Free(directory.p_rgEntries);
return TRUE;
@ -622,7 +622,7 @@ qboolean HPAK_ResourceForHash(char *pakname, unsigned char *hash, struct resourc
continue;
if (pResourceEntry)
memcpy(pResourceEntry, &p->resource, sizeof(resource_t));
Q_memcpy(pResourceEntry, &p->resource, sizeof(resource_t));
return TRUE;
}
@ -734,25 +734,25 @@ void HPAK_List_f(void)
switch (entry->resource.type)
{
case t_sound:
strcpy(type, "sound");
Q_strcpy(type, "sound");
break;
case t_skin:
strcpy(type, "skin");
Q_strcpy(type, "skin");
break;
case t_model:
strcpy(type, "model");
Q_strcpy(type, "model");
break;
case t_decal:
strcpy(type, "decal");
Q_strcpy(type, "decal");
break;
case t_generic:
strcpy(type, "generic");
Q_strcpy(type, "generic");
break;
case t_eventscript:
strcpy(type, "event");
Q_strcpy(type, "event");
break;
default:
strcpy(type, "?");
Q_strcpy(type, "?");
break;
}
Con_Printf("%i: %10s %.2fK %s\n : %s\n", nCurrent + 1, type, entry->resource.nDownloadSize / 1024.0f, szFileName, MD5_Print(entry->resource.rgucMD5_hash));
@ -834,7 +834,7 @@ void HPAK_CreatePak(char *pakname, struct resource_s *pResource, void *pData, Fi
Q_memset(hash_pack_dir.p_rgEntries, 0, sizeof(hash_pack_entry_t) * hash_pack_dir.nEntries);
pCurrentEntry = &hash_pack_dir.p_rgEntries[0];
memcpy(&pCurrentEntry->resource, pResource, sizeof(resource_t));
Q_memcpy(&pCurrentEntry->resource, pResource, sizeof(resource_t));
pCurrentEntry->nOffset = FS_Tell(fp);
pCurrentEntry->nFileLength = pResource->nDownloadSize;
@ -963,25 +963,25 @@ void HPAK_Validate_f(void)
switch (entry->resource.type)
{
case t_sound:
strcpy(type, "sound");
Q_strcpy(type, "sound");
break;
case t_skin:
strcpy(type, "skin");
Q_strcpy(type, "skin");
break;
case t_model:
strcpy(type, "model");
Q_strcpy(type, "model");
break;
case t_decal:
strcpy(type, "decal");
Q_strcpy(type, "decal");
break;
case t_generic:
strcpy(type, "generic");
Q_strcpy(type, "generic");
break;
case t_eventscript:
strcpy(type, "event");
Q_strcpy(type, "event");
break;
default:
strcpy(type, "?");
Q_strcpy(type, "?");
break;
}
@ -1113,25 +1113,25 @@ void HPAK_Extract_f(void)
switch (entry->resource.type)
{
case t_sound:
strcpy(type, "sound");
Q_strcpy(type, "sound");
break;
case t_skin:
strcpy(type, "skin");
Q_strcpy(type, "skin");
break;
case t_model:
strcpy(type, "model");
Q_strcpy(type, "model");
break;
case t_decal:
strcpy(type, "decal");
Q_strcpy(type, "decal");
break;
case t_generic:
strcpy(type, "generic");
Q_strcpy(type, "generic");
break;
case t_eventscript:
strcpy(type, "event");
Q_strcpy(type, "event");
break;
default:
strcpy(type, "?");
Q_strcpy(type, "?");
break;
}

View File

@ -1063,7 +1063,7 @@ void Host_Version(void)
Q_strcpy(gpszVersionString, "1.0.1.4");
Q_strcpy(gpszProductString, "valve");
strcpy(szFileName, "steam.inf");
Q_strcpy(szFileName, "steam.inf");
FileHandle_t fp = FS_Open(szFileName, "r");
if (fp)
{
@ -1128,7 +1128,7 @@ int Host_Init(quakeparms_t *parms)
CRehldsPlatformHolder::get()->srand(CRehldsPlatformHolder::get()->time(NULL));
memcpy(&host_parms, parms, sizeof(host_parms));
Q_memcpy(&host_parms, parms, sizeof(host_parms));
com_argc = parms->argc;
com_argv = parms->argv;
realtime = 0;

View File

@ -508,8 +508,8 @@ void Host_Quit_Restart_f(void)
if (g_psv.active || (g_pcls.state == ca_active && g_pcls.trueaddress[0] && g_pPostRestartCmdLineArgs))
{
strcat(g_pPostRestartCmdLineArgs, " +connect ");
strcat(g_pPostRestartCmdLineArgs, g_pcls.servername);
Q_strcat(g_pPostRestartCmdLineArgs, " +connect ");
Q_strcat(g_pPostRestartCmdLineArgs, g_pcls.servername);
}
else
{
@ -520,7 +520,7 @@ void Host_Quit_Restart_f(void)
Cbuf_AddText("save quick\n");
Cbuf_Execute();
strcat(g_pPostRestartCmdLineArgs, " +load quick");
Q_strcat(g_pPostRestartCmdLineArgs, " +load quick");
}
}
@ -839,7 +839,7 @@ void Host_Map(qboolean bIsDemo, char *mapstring, char *mapName, qboolean loadGam
{
Q_strcpy(g_pcls.spawnparms, "");
for (i = 0; i < Cmd_Argc(); i++)
strncat(g_pcls.spawnparms, Cmd_Argv(i), sizeof(g_pcls.spawnparms) - strlen(g_pcls.spawnparms) - 1);
Q_strncat(g_pcls.spawnparms, Cmd_Argv(i), sizeof(g_pcls.spawnparms) - strlen(g_pcls.spawnparms) - 1);
}
}
if (sv_gpNewUserMsgs)
@ -898,8 +898,8 @@ void Host_Map_f(void)
mapstring[0] = 0;
for (i = 0; i < Cmd_Argc(); i++)
{
strncat(mapstring, Cmd_Argv(i), 62 - Q_strlen(mapstring));
strncat(mapstring, " ", 62 - Q_strlen(mapstring));
Q_strncat(mapstring, Cmd_Argv(i), 62 - Q_strlen(mapstring));
Q_strncat(mapstring, " ", 62 - Q_strlen(mapstring));
}
Q_strcat(mapstring, "\n");
Q_strncpy(name, Cmd_Argv(1), sizeof(name) - 1);
@ -2312,7 +2312,7 @@ void Host_ClearSaveDirectory(void)
const char *pfn;
Q_snprintf(szName, sizeof(szName), "%s", Host_SaveGameDirectory());
strncat(szName, "*.HL?", sizeof(szName) - strlen(szName) - 1);
Q_strncat(szName, "*.HL?", sizeof(szName) - strlen(szName) - 1);
COM_FixSlashes(szName);
if (Sys_FindFirstPathID(szName, "GAMECONFIG") != NULL)
@ -2321,7 +2321,7 @@ void Host_ClearSaveDirectory(void)
Q_snprintf(szName, sizeof(szName), "%s", Host_SaveGameDirectory());
COM_FixSlashes(szName);
FS_CreateDirHierarchy(szName, "GAMECONFIG");
strncat(szName, "*.HL?", sizeof(szName) - strlen(szName) - 1);
Q_strncat(szName, "*.HL?", sizeof(szName) - strlen(szName) - 1);
for (pfn = Sys_FindFirstPathID(szName, "GAMECONFIG"); pfn; pfn = Sys_FindNext(NULL))
{

View File

@ -39,7 +39,7 @@ void *Mem_Malloc(size_t size)
void *Mem_ZeroMalloc(size_t size)
{
void *p = malloc(size);
memset(p, 0, size);
Q_memset(p, 0, size);
return p;
}

View File

@ -282,10 +282,10 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean trackCRC)
while (*(p++) == '/')
;
strncpy(tmpName, p, sizeof(tmpName) - 1);
Q_strncpy(tmpName, p, sizeof(tmpName) - 1);
tmpName[sizeof(tmpName) - 1] = '\0';
strncpy(mod->name, tmpName, sizeof(mod->name) - 1);
Q_strncpy(mod->name, tmpName, sizeof(mod->name) - 1);
mod->name[sizeof(mod->name) - 1] = '\0';
}
@ -652,7 +652,7 @@ void Mod_LoadVisibility(lump_t *l)
return;
}
loadmodel->visdata = (byte*) Hunk_AllocName(l->filelen, loadname);
memcpy(loadmodel->visdata, mod_base + l->fileofs, l->filelen);
Q_memcpy(loadmodel->visdata, mod_base + l->fileofs, l->filelen);
}
/* <513a6> ../engine/model.c:913 */

View File

@ -83,8 +83,8 @@
#define MAX_STREAMS 2
// Flow control bytes per second limits
#define MAX_RATE 20000
#define MIN_RATE 1000
#define MAX_RATE 100000.0f
#define MIN_RATE 1000.0f
// Default data rate
#define DEFAULT_RATE (9999.0f)
@ -237,7 +237,12 @@ typedef struct flow_s
// Size of fragmentation buffer internal buffers
#define FRAGMENT_SIZE 1400
#ifndef REHLDS_FIXES
#define MAX_FRAGMENTS 25000
#else
#define MAX_FRAGMENTS ((65536 + FRAGMENT_SIZE - 1) / FRAGMENT_SIZE) // should be enough for any send buf
#endif
#define UDP_HEADER_SIZE 28
#define MAX_RELIABLE_PAYLOAD 1200

View File

@ -379,7 +379,7 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
}
if (send_from_regular) {
memcpy(chan->reliable_buf, chan->message_buf, chan->message.cursize);
Q_memcpy(chan->reliable_buf, chan->message_buf, chan->message.cursize);
chan->reliable_length = chan->message.cursize;
SZ_Clear(&chan->message);
@ -431,7 +431,7 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
}
memcpy(chan->reliable_buf + chan->reliable_length, pbuf->frag_message.data, pbuf->frag_message.cursize);
Q_memcpy(chan->reliable_buf + chan->reliable_length, pbuf->frag_message.data, pbuf->frag_message.cursize);
chan->reliable_length += pbuf->frag_message.cursize;
chan->frag_length[i] = pbuf->frag_message.cursize;
@ -640,6 +640,7 @@ qboolean Netchan_Validate(netchan_t *chan, qboolean *frag_message, unsigned int
if (!frag_message[i])
continue;
#ifndef REHLDS_FIXES
if (FRAG_GETID(fragid[i]) > MAX_FRAGMENTS || FRAG_GETCOUNT(fragid[i]) > MAX_FRAGMENTS)
{
return FALSE;
@ -649,7 +650,27 @@ qboolean Netchan_Validate(netchan_t *chan, qboolean *frag_message, unsigned int
{
return FALSE;
}
#else // REHLDS_FIXES
// total fragments should be <= MAX_FRAGMENTS and current fragment can't be > total fragments
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)
return FALSE;
int frag_end = frag_offset[i] + frag_length[i];
// end of fragment is out of the packet
if (frag_end + msg_readcount > net_message.cursize)
return FALSE;
// fragment overlaps next stream's fragment or placed after it
for (int j = i + 1; j < MAX_STREAMS; j++)
{
if (frag_end > frag_offset[j]) // don't add msg_readcount for comparison
return FALSE;
}
#endif // REHLDS_FIXES
}
return TRUE;
@ -850,17 +871,15 @@ qboolean Netchan_Process(netchan_t *chan)
}
// Rearrange incoming data to not have the frag stuff in the middle of it
int wpos = msg_readcount + frag_offset[i];
int rpos = msg_readcount + frag_offset[i] + frag_length[i];
int epos = net_message.cursize - rpos;
for (j = 0; j < epos; j++) {
net_message.data[wpos + j] = net_message.data[rpos + j];
}
int rpos = wpos + frag_length[i];
Q_memmove(net_message.data + wpos, net_message.data + rpos, net_message.cursize - rpos);
net_message.cursize -= frag_length[i];
for (j = i + 1; j < MAX_STREAMS; j++)
{
frag_offset[j] -= frag_length[i];
frag_offset[j] -= frag_length[i]; // fragments order already validated
}
}
@ -1015,8 +1034,8 @@ void Netchan_CreateFragments_(qboolean server, netchan_t *chan, sizebuf_t *msg)
if (!BZ2_bzBuffToBuffCompress((char *)compressed, &compressedSize, (char *)msg->data, msg->cursize, 9, 0, 30))
{
Con_DPrintf("Compressing split packet (%d -> %d bytes)\n", msg->cursize, compressedSize);
memcpy(msg->data, hdr, sizeof(hdr));
memcpy(msg->data + sizeof(hdr), compressed, compressedSize);
Q_memcpy(msg->data, hdr, sizeof(hdr));
Q_memcpy(msg->data + sizeof(hdr), compressed, compressedSize);
msg->cursize = compressedSize + sizeof(hdr);
}
}
@ -1388,7 +1407,7 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
char uncompressed[65536];
unsigned int uncompressedSize = 65536;
BZ2_bzBuffToBuffDecompress(uncompressed, &uncompressedSize, (char*)net_message.data + 4, net_message.cursize - 4, 1, 0);
memcpy(net_message.data, uncompressed, uncompressedSize);
Q_memcpy(net_message.data, uncompressed, uncompressedSize);
net_message.cursize = uncompressedSize;
}
@ -1504,12 +1523,12 @@ qboolean Netchan_CopyFileFragments(netchan_t *chan)
{
// Copy it in
cursize -= msg_readcount;
memcpy(&buffer[pos], &p->frag_message.data[msg_readcount], cursize);
Q_memcpy(&buffer[pos], &p->frag_message.data[msg_readcount], cursize);
p->frag_message.cursize = cursize;
}
else
{
memcpy(&buffer[pos], p->frag_message.data, cursize);
Q_memcpy(&buffer[pos], p->frag_message.data, cursize);
}
pos += p->frag_message.cursize;
Mem_Free(p);
@ -1550,10 +1569,10 @@ qboolean Netchan_CopyFileFragments(netchan_t *chan)
FileHandle_t handle;
#ifdef REHLDS_CHECKS
strncpy(filedir, filename, sizeof(filedir) - 1);
Q_strncpy(filedir, filename, sizeof(filedir) - 1);
filedir[sizeof(filedir) - 1] = 0;
#else
strncpy(filedir, filename, sizeof(filedir));
Q_strncpy(filedir, filename, sizeof(filedir));
#endif // REHLDS_CHECKS
COM_FixSlashes(filedir);
pszFileName = strrchr(filedir, '\\');

View File

@ -154,7 +154,7 @@ short unsigned int Q_ntohs(short unsigned int netshort)
}
/* <d31f4> ../engine/net_ws.c:194 */
void NetadrToSockadr(netadr_t *a, struct sockaddr *s)
void NetadrToSockadr(const netadr_t *a, struct sockaddr *s)
{
Q_memset(s, 0, sizeof(*s));
@ -216,7 +216,7 @@ NOXREF short unsigned int NET_HostToNetShort(short unsigned int us_in)
}
/* <d32b0> ../engine/net_ws.c:252 */
qboolean NET_CompareAdr(netadr_t a, netadr_t b)
qboolean NET_CompareAdr(netadr_t& a, netadr_t& b)
{
if (a.type != b.type)
{
@ -249,7 +249,7 @@ qboolean NET_CompareAdr(netadr_t a, netadr_t b)
}
/* <d32e9> ../engine/net_ws.c:277 */
qboolean NET_CompareClassBAdr(netadr_t a, netadr_t b)
qboolean NET_CompareClassBAdr(netadr_t& a, netadr_t& b)
{
if (a.type != b.type)
{
@ -277,7 +277,7 @@ qboolean NET_CompareClassBAdr(netadr_t a, netadr_t b)
}
/* <d3325> ../engine/net_ws.c:302 */
qboolean NET_IsReservedAdr(netadr_t a)
qboolean NET_IsReservedAdr(netadr_t& a)
{
if (a.type == NA_LOOPBACK)
{
@ -314,7 +314,7 @@ qboolean NET_IsReservedAdr(netadr_t a)
}
/* <d3352> ../engine/net_ws.c:332 */
qboolean NET_CompareBaseAdr(netadr_t a, netadr_t b)
qboolean NET_CompareBaseAdr(netadr_t& a, netadr_t& b)
{
if (a.type != b.type)
{
@ -345,7 +345,7 @@ qboolean NET_CompareBaseAdr(netadr_t a, netadr_t b)
}
/* <d2bd7> ../engine/net_ws.c:357 */
char *NET_AdrToString(netadr_t a)
char *NET_AdrToString(const netadr_t& a)
{
static char s[64];
@ -364,7 +364,7 @@ char *NET_AdrToString(netadr_t a)
}
/* <d3406> ../engine/net_ws.c:375 */
char *NET_BaseAdrToString(netadr_t a)
char *NET_BaseAdrToString(netadr_t& a)
{
static char s[64];
@ -515,7 +515,7 @@ qboolean NET_StringToAdr(const char *s, netadr_t *a)
}
/* <d3579> ../engine/net_ws.c:502 */
qboolean NET_IsLocalAddress(netadr_t adr)
qboolean NET_IsLocalAddress(netadr_t& adr)
{
return adr.type == NA_LOOPBACK ? TRUE : FALSE;
}
@ -625,7 +625,7 @@ qboolean NET_GetLoopPacket(netsrc_t sock, netadr_t *in_from_, sizebuf_t *msg)
}
/* <d3659> ../engine/net_ws.c:612 */
void NET_SendLoopPacket(netsrc_t sock, int length, void *data, netadr_t to)
void NET_SendLoopPacket(netsrc_t sock, int length, void *data, const netadr_t& to)
{
int i;
loopback_t *loop;
@ -722,7 +722,7 @@ void NET_AddToLagged(netsrc_t sock, packetlag_t *pList, packetlag_t *pPacket, ne
pPacket->pPacketData = pStart;
pPacket->nSize = messagedata.cursize;
pPacket->receivedTime = timestamp;
memcpy(&pPacket->net_from_, net_from_, sizeof(netadr_t));
Q_memcpy(&pPacket->net_from_, net_from_, sizeof(netadr_t));
}
/* <d385e> ../engine/net_ws.c:731 */
@ -827,7 +827,7 @@ qboolean NET_LagPacket(qboolean newdata, netsrc_t sock, netadr_t *from, sizebuf_
NET_RemoveFromPacketList(pPacket);
NET_TransferRawData(&in_message, pPacket->pPacketData, pPacket->nSize);
memcpy(&in_from, &pPacket->net_from_, sizeof(in_from));
Q_memcpy(&in_from, &pPacket->net_from_, sizeof(in_from));
if (pPacket->pPacketData)
free(pPacket->pPacketData);
@ -855,27 +855,36 @@ void NET_FlushSocket(netsrc_t sock)
/* <d2cf1> ../engine/net_ws.c:911 */
qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
{
int packetNumber; // 913
int packetCount; // 913
unsigned int packetNumber; // 913
unsigned int packetCount; // 913
int sequenceNumber; // 913
unsigned char packetID; // 914
static int gNetSplitFlags[NET_WS_MAX_FRAGMENTS]; // 918
SPLITPACKET *pHeader = (SPLITPACKET *) pData; // 915
sequenceNumber = pHeader->sequenceNumber;
packetID = pHeader->packetID;
packetCount = packetID & 0xF;
packetNumber = (unsigned int)packetID >> 4;
if (packetNumber >= NET_WS_MAX_FRAGMENTS || packetCount > NET_WS_MAX_FRAGMENTS)
{
Con_Printf("Malformed packet number (%i)\n", packetID >> 4);
Con_Printf("Malformed packet number (%i/%i)\n", packetNumber + 1, packetCount);
return FALSE;
}
if (gNetSplit.currentSequence == -1 || sequenceNumber != gNetSplit.currentSequence)
{
gNetSplit.currentSequence = pHeader->sequenceNumber;
gNetSplit.splitCount = packetID & 0xF;
gNetSplit.splitCount = packetCount;
#ifdef REHLDS_FIXES
gNetSplit.totalSize = 0;
// clear part's sequence
for (int i = 0; i < NET_WS_MAX_FRAGMENTS; i++)
gNetSplitFlags[i] = -1;
#endif
if (net_showpackets.value == 4.0f)
Con_Printf("<-- Split packet restart %i count %i seq\n", gNetSplit.splitCount, sequenceNumber);
}
@ -905,10 +914,13 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (SPLIT_SIZE * packetNumber + packetPayloadSize > 4010)
{
Con_Printf("Malformed packet size (%i, %i)\n", SPLIT_SIZE * packetNumber, packetPayloadSize);
#ifdef REHLDS_FIXES
gNetSplit.currentSequence = -1;
#endif
return FALSE;
}
memcpy(&gNetSplit.buffer[SPLIT_SIZE * packetNumber], pHeader + 1, packetPayloadSize);
Q_memcpy(&gNetSplit.buffer[SPLIT_SIZE * packetNumber], pHeader + 1, packetPayloadSize);
}
if (gNetSplit.splitCount > 0)
@ -916,35 +928,39 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (packetCount > 0)
{
int i = 0;
while (gNetSplitFlags[i] == gNetSplit.currentSequence && i < packetCount)
++i;
if (i < packetCount)
for (int i = 0; i < packetCount; i++)
{
Con_Printf(
"Split packet without all %i parts, part %i had wrong sequence %i/%i\n",
packetCount,
i + 1,
gNetSplitFlags[i],
gNetSplit.currentSequence);
return FALSE;
if (gNetSplitFlags[i] != gNetSplit.currentSequence)
{
Con_Printf(
"Split packet without all %i parts, part %i had wrong sequence %i/%i\n",
packetCount,
i + 1,
gNetSplitFlags[i],
gNetSplit.currentSequence);
#ifdef REHLDS_FIXES
gNetSplit.currentSequence = -1; // no more parts can be attached, clear it
#endif
return FALSE;
}
}
}
gNetSplit.currentSequence = -1;
if (gNetSplit.totalSize <= 4010)
{
memcpy(pData, gNetSplit.buffer, gNetSplit.totalSize);
Q_memcpy(pData, gNetSplit.buffer, gNetSplit.totalSize);
*outSize = gNetSplit.totalSize;
return TRUE;
}
else
{
#ifdef REHLDS_FIXES
*outSize = 0;
#endif
Con_Printf("Split packet too large! %d bytes\n", gNetSplit.totalSize);
return FALSE;
}
}
/* <d3bd9> ../engine/net_ws.c:1021 */
@ -1260,7 +1276,7 @@ qboolean NET_GetPacket_internal(netsrc_t sock)
{
Q_memcpy(net_message.data, in_message.data, in_message.cursize);
net_message.cursize = in_message.cursize;
memcpy(&net_from, &in_from, 0x14u);
Q_memcpy(&net_from, &in_from, 0x14u);
NET_ThreadUnlock();
return bret;
}
@ -1373,12 +1389,12 @@ int NET_SendLong(netsrc_t sock, int s, const char *buf, int len, int flags, cons
pPacket->packetID = (packetNumber << 4) + packetCount;
memcpy(packet + sizeof(SPLITPACKET), buf + (packetNumber * SPLIT_SIZE), size);
Q_memcpy(packet + sizeof(SPLITPACKET), buf + (packetNumber * SPLIT_SIZE), size);
if (net_showpackets.value == 4.0f)
{
netadr_t adr;
memset(&adr, 0, sizeof(adr));
Q_memset(&adr, 0, sizeof(adr));
SockadrToNetadr((struct sockaddr *)to, &adr);
@ -1420,7 +1436,7 @@ void NET_SendPacket_api(unsigned int length, void *data, const netadr_t &to) {
}
/* <d43aa> ../engine/net_ws.c:1599 */
void NET_SendPacket(netsrc_t sock, int length, void *data, netadr_t to)
void NET_SendPacket(netsrc_t sock, int length, void *data, const netadr_t& to)
{
int ret;
struct sockaddr addr;
@ -2091,7 +2107,7 @@ void NET_Shutdown(void)
}
/* <d4ccb> ../engine/net_ws.c:2470 */
qboolean NET_JoinGroup(netsrc_t sock, netadr_t addr)
qboolean NET_JoinGroup(netsrc_t sock, netadr_t& addr)
{
ip_mreq mreq;
int net_socket = ip_sockets[sock];
@ -2117,7 +2133,7 @@ qboolean NET_JoinGroup(netsrc_t sock, netadr_t addr)
}
/* <d4d51> ../engine/net_ws.c:2504 */
qboolean NET_LeaveGroup(netsrc_t sock, netadr_t addr)
qboolean NET_LeaveGroup(netsrc_t sock, netadr_t& addr)
{
ip_mreq mreq;
int net_socket = ip_sockets[sock];

View File

@ -228,22 +228,22 @@ extern net_messages_t *normalqueue;
void NET_ThreadLock(void);
void NET_ThreadUnlock(void);
short unsigned int Q_ntohs(short unsigned int netshort);
void NetadrToSockadr(netadr_t *a, struct sockaddr *s);
void NetadrToSockadr(const netadr_t *a, struct sockaddr *s);
void SockadrToNetadr(const struct sockaddr *s, netadr_t *a);
NOXREF short unsigned int NET_HostToNetShort(short unsigned int us_in);
qboolean NET_CompareAdr(netadr_t a, netadr_t b);
qboolean NET_CompareClassBAdr(netadr_t a, netadr_t b);
qboolean NET_IsReservedAdr(netadr_t a);
qboolean NET_CompareBaseAdr(netadr_t a, netadr_t b);
char *NET_AdrToString(netadr_t a);
char *NET_BaseAdrToString(netadr_t a);
qboolean NET_CompareAdr(netadr_t& a, netadr_t& b);
qboolean NET_CompareClassBAdr(netadr_t& a, netadr_t& b);
qboolean NET_IsReservedAdr(netadr_t& a);
qboolean NET_CompareBaseAdr(netadr_t& a, netadr_t& b);
char *NET_AdrToString(const netadr_t& a);
char *NET_BaseAdrToString(netadr_t& a);
qboolean NET_StringToSockaddr(const char *s, struct sockaddr *sadr);
qboolean NET_StringToAdr(const char *s, netadr_t *a);
qboolean NET_IsLocalAddress(netadr_t adr);
qboolean NET_IsLocalAddress(netadr_t& adr);
char *NET_ErrorString(int code);
void NET_TransferRawData(sizebuf_t *msg, unsigned char *pStart, int nSize);
qboolean NET_GetLoopPacket(netsrc_t sock, netadr_t *in_from_, sizebuf_t *msg);
void NET_SendLoopPacket(netsrc_t sock, int length, void *data, netadr_t to);
void NET_SendLoopPacket(netsrc_t sock, int length, void *data, const netadr_t& to);
void NET_RemoveFromPacketList(packetlag_t *pPacket);
NOXREF int NET_CountLaggedList(packetlag_t *pList);
void NET_ClearLaggedList(packetlag_t *pList);
@ -265,7 +265,7 @@ void NET_AllocateQueues(void);
void NET_FlushQueues(void);
int NET_SendLong(netsrc_t sock, int s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen);
void NET_SendPacket_api(unsigned int length, void *data, const netadr_t &to);
void NET_SendPacket(netsrc_t sock, int length, void *data, netadr_t to);
void NET_SendPacket(netsrc_t sock, int length, void *data, const netadr_t& to);
int NET_IPSocket(char *net_interface, int port, qboolean multicast);
void NET_OpenIP(void);
int NET_IPXSocket(int hostshort);
@ -277,7 +277,7 @@ void MaxPlayers_f(void);
void NET_Init(void);
void NET_ClearLagData(qboolean bClient, qboolean bServer);
void NET_Shutdown(void);
qboolean NET_JoinGroup(netsrc_t sock, netadr_t addr);
qboolean NET_LeaveGroup(netsrc_t sock, netadr_t addr);
qboolean NET_JoinGroup(netsrc_t sock, netadr_t& addr);
qboolean NET_LeaveGroup(netsrc_t sock, netadr_t& addr);
#endif // NET_WS_H

View File

@ -288,7 +288,7 @@ int _PM_TestPlayerPosition(vec_t *pos, pmtrace_t *ptrace, int(*pfnIgnore)(physen
tr = PM_PlayerTrace(pmove->origin, pmove->origin, 0, -1);
if (ptrace)
memcpy(ptrace, &tr, sizeof(tr));
Q_memcpy(ptrace, &tr, sizeof(tr));
for (int i = 0; i < pmove->numphysent; i++)
{
@ -527,7 +527,7 @@ pmtrace_t _PM_PlayerTrace(vec_t *start, vec_t *end, int traceFlags, int numphyse
if (j == 0 || testtrace.allsolid || testtrace.startsolid || testtrace.fraction < total.fraction)
{
bool remember = (total.startsolid == 0);
memcpy(&total, &testtrace, sizeof(total));
Q_memcpy(&total, &testtrace, sizeof(total));
if (!remember)
total.startsolid = 1;
closest = j;
@ -563,7 +563,7 @@ pmtrace_t _PM_PlayerTrace(vec_t *start, vec_t *end, int traceFlags, int numphyse
if (total.fraction < trace.fraction)
{
memcpy(&trace, &total, sizeof(trace));
Q_memcpy(&trace, &total, sizeof(trace));
trace.ent = i;
}
}

View File

@ -1361,7 +1361,7 @@ void EV_Playback(int flags, const edict_t *pInvoker, short unsigned int eventind
ei->packet_index = -1;
if (pInvoker)
ei->entity_index = invoker;
memcpy(&ei->args, &eargs, sizeof(ei->args));
Q_memcpy(&ei->args, &eargs, sizeof(ei->args));
ei->fire_time = delay;
continue;
}
@ -1382,7 +1382,7 @@ void EV_Playback(int flags, const edict_t *pInvoker, short unsigned int eventind
ei->packet_index = -1;
if (pInvoker)
ei->entity_index = invoker;
memcpy(&ei->args, &eargs, sizeof(ei->args));
Q_memcpy(&ei->args, &eargs, sizeof(ei->args));
ei->fire_time = delay;
}
@ -2024,7 +2024,7 @@ void PF_RunPlayerMove_I(edict_t *fakeclient, const float *viewangles, float forw
SV_PreRunCmd();
SV_RunCmd(&cmd, 0);
memcpy(&host_client->lastcmd, &cmd, sizeof(host_client->lastcmd));
Q_memcpy(&host_client->lastcmd, &cmd, sizeof(host_client->lastcmd));
sv_player = oldclient;
host_client = old;
@ -2634,7 +2634,7 @@ int PF_CreateInstancedBaseline(int classname, struct entity_state_s *baseline)
return 0;
bls->classname[bls->number] = classname;
memcpy(&bls->baseline[bls->number], baseline, sizeof(struct entity_state_s));
Q_memcpy(&bls->baseline[bls->number], baseline, sizeof(struct entity_state_s));
bls->number += 1;
return bls->number;
}

View File

@ -220,7 +220,7 @@ void SV_SetLogAddress_f(void)
}
g_psvs.log.net_log_ = TRUE;
memcpy(&g_psvs.log.net_address_, &adr, sizeof(netadr_t));
Q_memcpy(&g_psvs.log.net_address_, &adr, sizeof(netadr_t));
Con_Printf("logaddress: %s\n", NET_AdrToString(adr));
}
@ -292,7 +292,7 @@ void SV_AddLogAddress_f(void)
}
tmp->next = NULL;
memcpy(&tmp->log.net_address_, &adr, sizeof(netadr_t));
Q_memcpy(&tmp->log.net_address_, &adr, sizeof(netadr_t));
list = firstLog;
@ -310,7 +310,7 @@ void SV_AddLogAddress_f(void)
return;
}
firstLog->next = NULL;
memcpy(&firstLog->log.net_address_, &adr, sizeof(netadr_t));
Q_memcpy(&firstLog->log.net_address_, &adr, sizeof(netadr_t));
}
Con_Printf("logaddress_add: %s\n", NET_AdrToString(adr));

View File

@ -1765,7 +1765,7 @@ qboolean SV_FilterUser(USERID_t *userid)
else
{
if (i + 1 < j)
memmove(filter, &filter[1], sizeof(userfilter_t) * (j - i + 1));
Q_memmove(filter, &filter[1], sizeof(userfilter_t) * (j - i + 1));
numuserfilters = --j;
}
@ -1827,6 +1827,9 @@ typedef struct challenge_s
} challenge_t;
challenge_t g_rg_sv_challenges[1024];
#ifdef REHLDS_OPT_PEDANTIC
int g_oldest_challenge = 0;
#endif
bool SV_CheckChallenge_api(const netadr_t &adr, int nChallengeValue) {
netadr_t localAdr = adr;
@ -2243,7 +2246,7 @@ void SV_ConnectClient_internal(void)
qboolean bIsSecure;
client = NULL;
memcpy(&adr, &net_from, sizeof(adr));
Q_memcpy(&adr, &net_from, sizeof(adr));
nAuthProtocol = -1;
reconnect = FALSE;
port = Q_atoi("27005");
@ -2338,7 +2341,7 @@ void SV_ConnectClient_internal(void)
SV_RejectConnection(&adr, "STEAM certificate length error! %i/%i\n", net_message.cursize - msg_readcount, sizeof(szSteamAuthBuf));
return;
}
memcpy(szSteamAuthBuf, &net_message.data[msg_readcount], len);
Q_memcpy(szSteamAuthBuf, &net_message.data[msg_readcount], len);
client->network_userid.clientip = *(uint32 *)&adr.ip[0];
if (adr.type == NA_LOOPBACK)
{
@ -2450,8 +2453,10 @@ void SVC_Ping(void)
void SVC_GetChallenge(void)
{
int i;
#ifndef REHLDS_OPT_PEDANTIC
int oldest = 0;
int oldestTime = 0x7FFFFFFFu;
int oldestTime = INT_MAX;
#endif
char data[1024];
qboolean steam = FALSE;
@ -2464,19 +2469,30 @@ void SVC_GetChallenge(void)
{
if (NET_CompareBaseAdr(net_from, g_rg_sv_challenges[i].adr))
break;
#ifndef REHLDS_OPT_PEDANTIC
if (g_rg_sv_challenges[i].time < oldestTime)
{
oldest = i;
oldestTime = g_rg_sv_challenges[i].time;
}
#endif
}
if (i == MAX_CHALLENGES)
{
#ifdef REHLDS_OPT_PEDANTIC
// oldest challenge is always next after last generated
i = g_oldest_challenge++;
if (g_oldest_challenge >= MAX_CHALLENGES)
g_oldest_challenge = 0;
#else
i = oldest;
g_rg_sv_challenges[oldest].challenge = (RandomLong(0, 0x8FFFu) << 16) | RandomLong(0, 0xFFFFu);
g_rg_sv_challenges[oldest].adr = net_from;
g_rg_sv_challenges[oldest].time = realtime;
#endif
// generate new challenge number
g_rg_sv_challenges[i].challenge = ( RandomLong(0, 36863) << 16 ) | ( RandomLong(0, 65535) );
g_rg_sv_challenges[i].adr = net_from;
g_rg_sv_challenges[i].time = (int)realtime;
}
if (steam)
Q_snprintf(data, sizeof(data), "\xFF\xFF\xFF\xFF%c00000000 %u 3 %I64i %d\n", S2C_CHALLENGE, g_rg_sv_challenges[i].challenge, Steam_GSGetSteamID(), Steam_GSBSecure());
@ -2495,8 +2511,10 @@ void SVC_GetChallenge(void)
void SVC_ServiceChallenge(void)
{
int i;
#ifndef REHLDS_OPT_PEDANTIC
int oldest = 0;
int oldestTime = 0x7FFFFFFFu;
int oldestTime = INT_MAX;
#endif
char data[128];
const char *type;
@ -2515,18 +2533,29 @@ void SVC_ServiceChallenge(void)
if (NET_CompareBaseAdr(net_from, g_rg_sv_challenges[i].adr))
break;
#ifndef REHLDS_OPT_PEDANTIC
if (g_rg_sv_challenges[i].time < oldestTime)
{
oldestTime = g_rg_sv_challenges[i].time;
oldest = i;
}
#endif
}
if (i == MAX_CHALLENGES)
if (i == MAX_CHALLENGES) // no challenge for ip
{
g_rg_sv_challenges[oldest].challenge = (RandomLong(0, 36863) << 16) | (RandomLong(0, 65535));
g_rg_sv_challenges[oldest].adr = net_from;
g_rg_sv_challenges[oldest].time = (int)realtime;
#ifdef REHLDS_OPT_PEDANTIC
// oldest challenge is always next after last generated
i = g_oldest_challenge++;
if(g_oldest_challenge >= MAX_CHALLENGES)
g_oldest_challenge = 0;
#else
i = oldest;
#endif
// generate new challenge number
g_rg_sv_challenges[i].challenge = (RandomLong(0, 36863) << 16) | (RandomLong(0, 65535));
g_rg_sv_challenges[i].adr = net_from;
g_rg_sv_challenges[i].time = (int)realtime;
}
Q_snprintf(data, sizeof(data), "%c%c%c%cchallenge %s %u\n", 255, 255, 255, 255, type, g_rg_sv_challenges[i].challenge);
@ -3135,7 +3164,7 @@ void SV_EndRedirect(void)
/* <a81f5> ../engine/sv_main.c:4170 */
void SV_BeginRedirect(redirect_t rd, netadr_t *addr)
{
memcpy(&sv_redirectto, addr, sizeof(sv_redirectto));
Q_memcpy(&sv_redirectto, addr, sizeof(sv_redirectto));
sv_redirected = rd;
outputbuf[0] = 0;
}
@ -3441,8 +3470,8 @@ void SV_CheckRate(client_t *cl)
{
if (cl->netchan.rate > sv_maxrate.value)
{
if (sv_maxrate.value > 100000.0f)
cl->netchan.rate = 100000.0;
if (sv_maxrate.value > MAX_RATE)
cl->netchan.rate = MAX_RATE;
else
cl->netchan.rate = sv_maxrate.value;
}
@ -3451,8 +3480,8 @@ void SV_CheckRate(client_t *cl)
{
if (cl->netchan.rate < sv_minrate.value)
{
if (sv_minrate.value < 1000.0f)
cl->netchan.rate = 1000.0;
if (sv_minrate.value < MIN_RATE)
cl->netchan.rate = MIN_RATE;
else
cl->netchan.rate = sv_minrate.value;
}
@ -3530,7 +3559,7 @@ qboolean SV_FilterPacket(void)
else
{
if (i < numipfilters - 1)
memcpy(curFilter, &curFilter[1], sizeof(ipfilter_t) * (numipfilters - i - 1));
Q_memcpy(curFilter, &curFilter[1], sizeof(ipfilter_t) * (numipfilters - i - 1));
--numipfilters;
}
@ -5916,13 +5945,13 @@ void SV_BanId_f(void)
userfilters[i].banTime = banTime;
userfilters[i].banEndTime = (banTime == 0.0f) ? 0.0f : banTime * 60.0f + realtime;
memcpy(&userfilters[i].userid, id, sizeof(USERID_t));
Q_memcpy(&userfilters[i].userid, id, sizeof(USERID_t));
// give 3-rd party plugins a chance to serialize ID
g_RehldsHookchains.m_SerializeSteamId.callChain(NULL, &userfilters[i].userid);
if (banTime == 0.0f)
sprintf(szreason, "permanently");
Q_sprintf(szreason, "permanently");
else
Q_snprintf(szreason, sizeof(szreason), "for %.2f minutes", banTime);
@ -6022,7 +6051,7 @@ void Host_Kick_f(void)
argsStartNum = 3;
}
strncpy(idstring, p, 63);
Q_strncpy(idstring, p, 63);
idstring[63] = 0;
if (!Q_strnicmp(idstring, "STEAM_", 6) || !Q_strnicmp(idstring, "VALVE_", 6))
@ -6143,7 +6172,7 @@ void SV_RemoveId_f(void)
return;
}
strncpy(idstring, Cmd_Argv(1), sizeof(idstring) - 1);
Q_strncpy(idstring, Cmd_Argv(1), sizeof(idstring) - 1);
idstring[63] = 0;
if (!idstring[0])
{
@ -6162,10 +6191,10 @@ void SV_RemoveId_f(void)
slot--;
USERID_t id;
memcpy(&id, &userfilters[slot].userid, sizeof(id));
Q_memcpy(&id, &userfilters[slot].userid, sizeof(id));
if (slot + 1 < numuserfilters)
memcpy(&userfilters[slot], &userfilters[slot + 1], (numuserfilters - (slot + 1)) * sizeof(userfilter_t));
Q_memcpy(&userfilters[slot], &userfilters[slot + 1], (numuserfilters - (slot + 1)) * sizeof(userfilter_t));
numuserfilters--;
Con_Printf("UserID filter removed for %s, id %s\n", idstring, SV_GetIDString(&id));
@ -6183,7 +6212,7 @@ void SV_RemoveId_f(void)
if (!Q_stricmp(SV_GetIDString(&userfilters[i].userid), idstring))
{
if (i + 1 < numuserfilters)
memcpy(&userfilters[i], &userfilters[i + 1], (numuserfilters - (i + 1)) * sizeof(userfilter_t));
Q_memcpy(&userfilters[i], &userfilters[i + 1], (numuserfilters - (i + 1)) * sizeof(userfilter_t));
numuserfilters--;
Con_Printf("UserID filter removed for %s\n", idstring);
@ -6292,7 +6321,7 @@ void SV_AddIP_f(void)
if (!host_client->connected || !host_client->active || !host_client->spawned || host_client->fakeclient)
continue;
memcpy(&net_from, &host_client->netchan.remote_address, sizeof(net_from));
Q_memcpy(&net_from, &host_client->netchan.remote_address, sizeof(net_from));
if (SV_FilterPacket())
{
SV_ClientPrintf("The server operator has added you to banned list\n");
@ -6314,7 +6343,7 @@ void SV_RemoveIP_f(void)
if (ipfilters[i].mask == f.mask && ipfilters[i].compare.u32 == f.compare.u32)
{
if (i + 1 < numipfilters)
memcpy(&ipfilters[i], &ipfilters[i + 1], (numipfilters - (i + 1)) * sizeof(ipfilter_t));
Q_memcpy(&ipfilters[i], &ipfilters[i + 1], (numipfilters - (i + 1)) * sizeof(ipfilter_t));
numipfilters--;
ipfilters[numipfilters].banTime = 0.0f;
ipfilters[numipfilters].banEndTime = 0.0f;
@ -6384,19 +6413,19 @@ void SV_KickPlayer(int nPlayerSlot, int nReason)
return;
USERID_t id;
memcpy(&id, &client->network_userid, sizeof(id));
Q_memcpy(&id, &client->network_userid, sizeof(id));
Log_Printf("Secure: \"%s<%i><%s><>\" was detected cheating and dropped from the server.\n", client->name, client->userid, SV_GetIDString(&id), nReason);
char rgchT[1024];
rgchT[0] = svc_print;
sprintf(
Q_sprintf(
&rgchT[1],
"\n********************************************\nYou have been automatically disconnected\nfrom this secure server because an illegal\ncheat was detected on your computer.\nRepeat violators may be permanently banned\nfrom all secure servers.\n\nFor help cleaning your system of cheats, visit:\nhttp://www.counter-strike.net/cheat.html\n********************************************\n\n"
);
Netchan_Transmit(&g_psvs.clients[nPlayerSlot].netchan, strlen(rgchT) + 1, (byte *)rgchT);
sprintf(rgchT, "%s was automatically disconnected\nfrom this secure server.\n", client->name);
Q_sprintf(rgchT, "%s was automatically disconnected\nfrom this secure server.\n", client->name);
for (int i = 0; i < g_psvs.maxclients; i++)
{
if (!g_psvs.clients[i].active && !g_psvs.clients[i].spawned || g_psvs.clients[i].fakeclient)
@ -7133,10 +7162,10 @@ qboolean SV_CompareUserID_internal(USERID_t *id1, USERID_t *id2)
char szID1[64];
char szID2[64];
strncpy(szID1, SV_GetIDString(id1), sizeof(szID1) - 1);
Q_strncpy(szID1, SV_GetIDString(id1), sizeof(szID1) - 1);
szID1[sizeof(szID1) - 1] = 0;
strncpy(szID2, SV_GetIDString(id2), sizeof(szID2) - 1);
Q_strncpy(szID2, SV_GetIDString(id2), sizeof(szID2) - 1);
szID2[sizeof(szID2) - 1] = 0;
return Q_stricmp(szID1, szID2) ? FALSE : TRUE;

View File

@ -280,7 +280,7 @@ int SV_FlyMove(edict_t *ent, float time, trace_t *steptrace)
{
blocked |= 2u;
if (steptrace)
memcpy(steptrace, &trace, 0x38u);
Q_memcpy(steptrace, &trace, 0x38u);
}
SV_Impact(ent, trace.ent, &trace);

View File

@ -57,7 +57,7 @@ int CServerRemoteAccess::ReadDataResponse_noVirt(void *data, int len)
bytesToCopy = 0;
if (bytesToCopy)
memcpy(data, response.Base(), bytesToCopy);
Q_memcpy(data, response.Base(), bytesToCopy);
m_iBytesSent += bytesToCopy;
@ -150,7 +150,7 @@ void CServerRemoteAccess::GetMapList(CUtlBuffer &value)
char mapName[MAX_PATH];
char mapwild[64];
strcpy(mapwild, "maps/*.bsp");
Q_strcpy(mapwild, "maps/*.bsp");
for (findfn = Sys_FindFirst(mapwild, 0); findfn; findfn = Sys_FindNext(0))
{
_snprintf(curDir, MAX_PATH, "maps/%s", findfn);

View File

@ -186,13 +186,13 @@ void CSteam3Server::OnGSClientApprove(GSClientApprove_t *pGSClientSteam2Accept)
char msg[256];
if (SV_FilterUser(&cl->network_userid))
{
sprintf(msg, "You have been banned from this server\n");
Q_sprintf(msg, "You have been banned from this server\n");
SV_RejectConnection(&cl->netchan.remote_address, msg);
SV_DropClient(cl, 0, "STEAM UserID %s is in server ban list\n", SV_GetClientIDString(cl));
}
else if (SV_CheckForDuplicateSteamID(cl) != -1)
{
sprintf(msg, "Your UserID is already in use on this server.\n");
Q_sprintf(msg, "Your UserID is already in use on this server.\n");
SV_RejectConnection(&cl->netchan.remote_address, msg);
SV_DropClient(cl, 0, "STEAM UserID %s is already\nin use on this server\n", SV_GetClientIDString(cl));
}

View File

@ -431,7 +431,7 @@ void SV_CopyEdictToPhysent(physent_t *pe, int e, edict_t *check)
}
else
{
sprintf(pe->name, "?");
Q_sprintf(pe->name, "?");
}
}
else
@ -577,7 +577,7 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
pe = &pmove->moveents[pmove->nummoveent++];
}
memcpy(pe, ve, sizeof(physent_t));
Q_memcpy(pe, ve, sizeof(physent_t));
}
if (node->axis != -1)
@ -838,7 +838,7 @@ void SV_RunCmd(usercmd_t *ucmd, int random_seed)
pmove->friction = sv_player->v.friction;
pmove->spectator = 0;
pmove->waterjumptime = sv_player->v.teleport_time;
memcpy(&pmove->cmd, &cmd, sizeof(pmove->cmd));
Q_memcpy(&pmove->cmd, &cmd, sizeof(pmove->cmd));
pmove->dead = sv_player->v.health <= 0.0;
pmove->movetype = sv_player->v.movetype;
pmove->flags = sv_player->v.flags;

View File

@ -505,7 +505,7 @@ NOXREF void Sys_Warning(const char *pszWarning, ...)
char text[1024];
va_start(argptr, pszWarning);
vsnprintf(text, sizeof(text), pszWarning, argptr);
Q_vsnprintf(text, sizeof(text), pszWarning, argptr);
va_end(argptr);
Sys_Printf(text);
@ -1084,7 +1084,7 @@ void LoadThisDll(const char *szDllFilename)
}
pextdll = &g_rgextdll[g_iextdllMac++];
memset(pextdll, 0, sizeof(*pextdll));
Q_memset(pextdll, 0, sizeof(*pextdll));
pextdll->lDLLHandle = hDLL;
return;

View File

@ -207,7 +207,7 @@ NOXREF void Sys_CheckOSVersion(void)
{
struct _OSVERSIONINFOA verInfo;
memset(&verInfo, 0, sizeof(verInfo));
Q_memset(&verInfo, 0, sizeof(verInfo));
verInfo.dwOSVersionInfoSize = sizeof(verInfo);
if (!GetVersionExA(&verInfo))
Sys_Error("Couldn't get OS info");
@ -500,7 +500,7 @@ int Sys_InitGame(char *lpOrgCmdLine, char *pBaseDir, void *pwnd, int bIsDedicate
}
#endif // SWDS
g_bIsDedicatedServer = bIsDedicated;
memset(&gmodinfo, 0, sizeof(modinfo_t));
Q_memset(&gmodinfo, 0, sizeof(modinfo_t));
SV_ResetModInfo();
TraceInit("Sys_Init()", "Sys_Shutdown()", 0);
@ -642,7 +642,7 @@ NOXREF int BuildMapCycleListHints(char **hints)
Con_Printf("Unable to allocate memory for map cycle hints list");
return 0;
}
strcpy(*hints, szMap);
Q_strcpy(*hints, szMap);
length = FS_Size(pFile);
if (length)
{
@ -695,7 +695,7 @@ bool CDedicatedServerAPI::Init_noVirt(char *basedir, char *cmdline, CreateInterf
if (!dedicated_)
return false;
strcpy(this->m_OrigCmd, cmdline);
Q_strcpy(this->m_OrigCmd, cmdline);
if (!strstr(cmdline, "-nobreakpad"))
{
CRehldsPlatformHolder::get()->SteamAPI_UseBreakpadCrashHandler(va("%d", build_number()), "Aug 8 2013", "11:17:26", 0, 0, 0);

View File

@ -90,7 +90,7 @@ void ForceReloadProfile()
Sys_Error("Only dedicated mode is supported");
/*
v0 = GetRateRegistrySetting(rate.string);
strncpy(szRate, v0, 0x20u);
Q_strncpy(szRate, v0, 0x20u);
Cvar_DirectSet(&rate, szRate);
*/
}

View File

@ -46,7 +46,7 @@ void W_CleanupName(char *in, char *out)
out[i] = c;
}
if (i < 16)
memset(&out[i], 0, 16 - i);
Q_memset(&out[i], 0, 16 - i);
}
/* <c6d06> ../engine/wad.c:62 */
@ -149,7 +149,7 @@ void W_Shutdown(void)
if (!wad->loaded)
break;
memset(wad, 0, sizeof(wadlist_t));
Q_memset(wad, 0, sizeof(wadlist_t));
}
}

View File

@ -1113,7 +1113,7 @@ void SV_SingleClipMoveToEntity(edict_t *ent, const vec_t *start, const vec_t *mi
if (i == 0 || testtrace.allsolid || testtrace.startsolid || testtrace.fraction < trace->fraction)
{
int isSolid = trace->startsolid;
memcpy(trace, &testtrace, sizeof(trace_t));
Q_memcpy(trace, &testtrace, sizeof(trace_t));
if (isSolid)
trace->startsolid = TRUE;
closest = i;

View File

@ -404,7 +404,7 @@ NOXREF void Hunk_Print(qboolean all)
//
// print the single block
//
memcpy(name, h->name, HUNK_NAME_LEN);
Q_memcpy(name, h->name, HUNK_NAME_LEN);
if (all)
Con_Printf("%8p :%8i %8s\n", h, h->size, name);
@ -412,7 +412,7 @@ NOXREF void Hunk_Print(qboolean all)
// print the total
//
if (next == endlow || next == endhigh ||
strncmp(h->name, next->name, HUNK_NAME_LEN))
Q_strncmp(h->name, next->name, HUNK_NAME_LEN))
{
if (!all)
Con_Printf(" :%8i %8s (TOTAL)\n", sum, name);
@ -906,13 +906,13 @@ NOXREF char *CommatizeNumber(int num, char *pout)
int len = 0;
int i;
char outbuf[50];
memset(outbuf, 0, 50);
Q_memset(outbuf, 0, 50);
while (num)
{
char tempbuf[50];
int temp = num % 1000;
num = num / 1000;
strcpy(tempbuf, outbuf);
Q_strcpy(tempbuf, outbuf);
Q_snprintf(outbuf, sizeof(outbuf), ",%03i%s", temp, tempbuf);
}
@ -924,9 +924,9 @@ NOXREF char *CommatizeNumber(int num, char *pout)
break;
if (i == len)
strcpy(pout, "0");
Q_strcpy(pout, "0");
else
strcpy(pout, &outbuf[i]); //copy from i to get rid of the first comma and leading zeros
Q_strcpy(pout, &outbuf[i]); //copy from i to get rid of the first comma and leading zeros
return pout;
}