2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-06 12:05:34 +03:00

Small fixes and formatting. (#331)

* Allow hlds.exe to be renamed, just disable testing suite.

* Corrected structure field name.

* A bit of formatting and types fixes.

* Correct the code to avoid visual studio code parsing bug (it doesn't process half of pair curly braces in defines correctly).

* A bit more cleanup.
This commit is contained in:
Lev 2017-02-03 23:07:24 +05:00 committed by GitHub
parent 21d8ca5521
commit f5faf796d9
9 changed files with 72 additions and 76 deletions

View File

@ -794,8 +794,8 @@ void Host_Speeds(double *time)
#ifdef REHLDS_FIXES #ifdef REHLDS_FIXES
if (host_speeds.value != 0.0f) // FIXED: do calculations only if host_speeds is enabled if (host_speeds.value != 0.0f) // FIXED: do calculations only if host_speeds is enabled
{
#endif // REHLDS_FIXES #endif // REHLDS_FIXES
{
pass1 = (float)((time[1] - time[0]) * 1000.0); pass1 = (float)((time[1] - time[0]) * 1000.0);
pass2 = (float)((time[2] - time[1]) * 1000.0); pass2 = (float)((time[2] - time[1]) * 1000.0);
pass3 = (float)((time[3] - time[2]) * 1000.0); pass3 = (float)((time[3] - time[2]) * 1000.0);
@ -808,9 +808,9 @@ void Host_Speeds(double *time)
fps = 1.0 / frameTime; fps = 1.0 / frameTime;
else else
fps = 999.0; fps = 999.0;
// FIXED: do calculations only if host_speeds is enabled
#ifndef REHLDS_FIXES #ifndef REHLDS_FIXES
}
if (host_speeds.value != 0.0f) if (host_speeds.value != 0.0f)
{ {
#endif // REHLDS_FIXES #endif // REHLDS_FIXES

View File

@ -54,7 +54,7 @@ typedef struct modinfo_s
qboolean secure; qboolean secure;
MOD_GAMEPLAY_TYPE_E type; MOD_GAMEPLAY_TYPE_E type;
int num_edicts; int num_edicts;
int clientDllCRC; qboolean clientcrccheck;
} modinfo_t; } modinfo_t;
#endif // MODINFO_H #endif // MODINFO_H

View File

@ -411,7 +411,8 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
pbuf = chan->fragbufs[i]; pbuf = chan->fragbufs[i];
fragment_size = 0; // Compiler warning. fragment_size = 0; // Compiler warning.
if (pbuf) { if (pbuf)
{
fragment_size = pbuf->frag_message.cursize; fragment_size = pbuf->frag_message.cursize;
// Files set size a bit differently. // Files set size a bit differently.
@ -912,10 +913,8 @@ void Netchan_FragSend(netchan_t *chan)
} }
fragbufwaiting_t *prev = nullptr; fragbufwaiting_t *prev = nullptr;
while (true) { while (chan->waitlist[i]->next)
if (!chan->waitlist[i]->next) {
break;
prev = chan->waitlist[i]; prev = chan->waitlist[i];
chan->waitlist[i] = chan->waitlist[i]->next; chan->waitlist[i] = chan->waitlist[i]->next;
} }
@ -1112,8 +1111,8 @@ void Netchan_CreateFileFragmentsFromBuffer(qboolean server, netchan_t *chan, con
fragbufwaiting_t *p; fragbufwaiting_t *p;
fragbuf_t *buf; fragbuf_t *buf;
unsigned char *pbuf; unsigned char *pbuf;
signed int bCompressed; qboolean bCompressed;
signed int firstfragment; qboolean firstfragment;
signed int bufferid; signed int bufferid;
int remaining; int remaining;
int pos; int pos;
@ -1221,7 +1220,7 @@ int Netchan_CreateFileFragments(qboolean server, netchan_t *chan, const char *fi
if (FS_FileSize(filename) > sv_filetransfermaxsize.value) if (FS_FileSize(filename) > sv_filetransfermaxsize.value)
return FALSE; return FALSE;
auto wait = (fragbufwaiting_t *)Mem_ZeroMalloc(0xCu); auto wait = (fragbufwaiting_t *)Mem_ZeroMalloc(sizeof(fragbufwaiting_t));
auto buf = Netchan_AllocFragbuf(); auto buf = Netchan_AllocFragbuf();
buf->bufferid = 1; buf->bufferid = 1;
@ -1260,9 +1259,9 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
int send; int send;
fragbuf_t *buf; fragbuf_t *buf;
char compressedfilename[MAX_PATH]; char compressedfilename[MAX_PATH];
int firstfragment; qboolean firstfragment;
int bufferid; int bufferid;
int bCompressed; qboolean bCompressed;
int pos; int pos;
fragbufwaiting_t *wait; fragbufwaiting_t *wait;
int uncompressed_size; int uncompressed_size;
@ -1278,7 +1277,7 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
{ {
filesize = FS_Size(hfile); filesize = FS_Size(hfile);
FS_Close(hfile); FS_Close(hfile);
bCompressed = 1; bCompressed = TRUE;
hfile = FS_Open(filename, "rb"); hfile = FS_Open(filename, "rb");
if (!hfile) if (!hfile)
{ {
@ -1326,7 +1325,7 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
FS_Write(compressed, compressedSize, 1, destFile); FS_Write(compressed, compressedSize, 1, destFile);
FS_Close(destFile); FS_Close(destFile);
filesize = compressedSize; filesize = compressedSize;
bCompressed = 1; bCompressed = TRUE;
} }
} }
Mem_Free(uncompressed); Mem_Free(uncompressed);

View File

@ -886,9 +886,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
unsigned int packetPayloadSize = size - sizeof(SPLITPACKET); unsigned int packetPayloadSize = size - sizeof(SPLITPACKET);
if (gNetSplitFlags[packetNumber] == sequenceNumber) if (gNetSplitFlags[packetNumber] == sequenceNumber)
{ {
Con_NetPrintf( "NET_GetLong: Ignoring duplicated split packet %i of %i ( %i bytes )\n", Con_NetPrintf("NET_GetLong: Ignoring duplicated split packet %i of %i ( %i bytes )\n", packetNumber + 1, packetCount, packetPayloadSize);
packetNumber + 1, packetCount, packetPayloadSize
);
} }
else else
{ {
@ -900,9 +898,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (net_showpackets.value == 4.0f) if (net_showpackets.value == 4.0f)
{ {
Con_Printf("<-- Split packet %i of %i, %i bytes %i seq\n", Con_Printf("<-- Split packet %i of %i, %i bytes %i seq\n", packetNumber + 1, packetCount, packetPayloadSize, sequenceNumber);
packetNumber + 1, packetCount, packetPayloadSize, sequenceNumber
);
} }
if (SPLIT_SIZE * packetNumber + packetPayloadSize > MAX_UDP_PACKET) if (SPLIT_SIZE * packetNumber + packetPayloadSize > MAX_UDP_PACKET)

View File

@ -4612,7 +4612,6 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
if (add) if (add)
++curPack->num_entities; ++curPack->num_entities;
#endif //REHLDS_OPT_PEDANTIC #endif //REHLDS_OPT_PEDANTIC
} }
#ifdef REHLDS_FIXES #ifdef REHLDS_FIXES
@ -4806,8 +4805,9 @@ void SV_UpdateToReliableMessages(void)
// Fix for the "server failed to transmit file 'AY&SY..." bug // Fix for the "server failed to transmit file 'AY&SY..." bug
// https://github.com/dreamstalker/rehlds/issues/38 // https://github.com/dreamstalker/rehlds/issues/38
#ifdef REHLDS_FIXES #ifdef REHLDS_FIXES
if (!client->fakeclient && (client->active || g_GameClients[i]->GetSpawnedOnce())) if (!(!client->fakeclient && (client->active || g_GameClients[i]->GetSpawnedOnce())))
{ continue;
if (!svReliableCompressed && g_psv.reliable_datagram.cursize + client->netchan.message.cursize < client->netchan.message.maxsize) if (!svReliableCompressed && g_psv.reliable_datagram.cursize + client->netchan.message.cursize < client->netchan.message.maxsize)
{ {
SZ_Write(&client->netchan.message, g_psv.reliable_datagram.data, g_psv.reliable_datagram.cursize); SZ_Write(&client->netchan.message, g_psv.reliable_datagram.data, g_psv.reliable_datagram.cursize);
@ -4818,8 +4818,9 @@ void SV_UpdateToReliableMessages(void)
svReliableCompressed = true; svReliableCompressed = true;
} }
#else #else
if (!client->fakeclient && client->active) if (!(!client->fakeclient && client->active))
{ continue;
if (g_psv.reliable_datagram.cursize + client->netchan.message.cursize < client->netchan.message.maxsize) if (g_psv.reliable_datagram.cursize + client->netchan.message.cursize < client->netchan.message.maxsize)
{ {
SZ_Write(&client->netchan.message, g_psv.reliable_datagram.data, g_psv.reliable_datagram.cursize); SZ_Write(&client->netchan.message, g_psv.reliable_datagram.data, g_psv.reliable_datagram.cursize);
@ -4853,7 +4854,6 @@ void SV_UpdateToReliableMessages(void)
#endif #endif
} }
} }
}
SZ_Clear(&g_psv.reliable_datagram); SZ_Clear(&g_psv.reliable_datagram);
SZ_Clear(&g_psv.datagram); SZ_Clear(&g_psv.datagram);
@ -6070,7 +6070,7 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
Sequence_OnLevelLoad(server); Sequence_OnLevelLoad(server);
ContinueLoadingProgressBar("Server", 4, 0.0); ContinueLoadingProgressBar("Server", 4, 0.0);
if (gmodinfo.clientDllCRC) if (gmodinfo.clientcrccheck)
{ {
char szDllName[64]; char szDllName[64];
Q_snprintf(szDllName, sizeof(szDllName), "cl_dlls//client.dll"); Q_snprintf(szDllName, sizeof(szDllName), "cl_dlls//client.dll");

View File

@ -848,7 +848,7 @@ void DLL_SetModKey(modinfo_t *pinfo, char *pkey, char *pvalue)
else if (!Q_stricmp(pkey, "crcclientdll")) else if (!Q_stricmp(pkey, "crcclientdll"))
{ {
pinfo->bIsMod = 1; pinfo->bIsMod = 1;
pinfo->clientDllCRC = Q_atoi(pvalue) != 0; pinfo->clientcrccheck = Q_atoi(pvalue) != 0;
} }
else if (!Q_stricmp(pkey, "type")) else if (!Q_stricmp(pkey, "type"))
{ {

View File

@ -198,8 +198,8 @@ NOXREF qboolean Sys_IsWin98(void)
#pragma warning( disable : 4996 ) #pragma warning( disable : 4996 )
void Sys_CheckOSVersion(void) void Sys_CheckOSVersion(void)
{ {
OSVERSIONINFO verInfo;
OSVERSIONINFOA verInfo;
Q_memset(&verInfo, 0, sizeof(verInfo)); Q_memset(&verInfo, 0, sizeof(verInfo));
verInfo.dwOSVersionInfoSize = sizeof(verInfo); verInfo.dwOSVersionInfoSize = sizeof(verInfo);
if (!GetVersionEx(&verInfo)) if (!GetVersionEx(&verInfo))

View File

@ -142,8 +142,8 @@ int HookEngine(size_t addr)
#ifdef _WIN32 #ifdef _WIN32
Module hlds_exe; Module hlds_exe;
if (!FindModuleByName("hlds.exe", &hlds_exe)) if (!FindModuleByName("hlds.exe", &hlds_exe))
return (FALSE); printf("%s: launcher is not hlds.exe, tests playing/recording is disabled!\n", __FUNCTION__);
else
TestSuite_Init(&g_EngineModule, &hlds_exe, g_FunctionRefs); TestSuite_Init(&g_EngineModule, &hlds_exe, g_FunctionRefs);
#endif #endif

View File

@ -40,9 +40,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
#ifdef _WIN32 #ifdef _WIN32
Module hlds_exe; Module hlds_exe;
if (!FindModuleByName("hlds.exe", &hlds_exe)) if (!FindModuleByName("hlds.exe", &hlds_exe))
return (FALSE); printf("%s: launcher is not hlds.exe, tests playing/recording disabled!\n", __FUNCTION__);
else
TestSuite_Init(NULL, &hlds_exe, NULL); TestSuite_Init(NULL, &hlds_exe, NULL);
Rehlds_Debug_Init(NULL); Rehlds_Debug_Init(NULL);
#endif #endif