2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-01 01:25:38 +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
if (host_speeds.value != 0.0f) // FIXED: do calculations only if host_speeds is enabled
{
#endif // REHLDS_FIXES
{
pass1 = (float)((time[1] - time[0]) * 1000.0);
pass2 = (float)((time[2] - time[1]) * 1000.0);
pass3 = (float)((time[3] - time[2]) * 1000.0);
@ -808,9 +808,9 @@ void Host_Speeds(double *time)
fps = 1.0 / frameTime;
else
fps = 999.0;
// FIXED: do calculations only if host_speeds is enabled
#ifndef REHLDS_FIXES
}
if (host_speeds.value != 0.0f)
{
#endif // REHLDS_FIXES

View File

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

View File

@ -411,7 +411,8 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data)
pbuf = chan->fragbufs[i];
fragment_size = 0; // Compiler warning.
if (pbuf) {
if (pbuf)
{
fragment_size = pbuf->frag_message.cursize;
// Files set size a bit differently.
@ -912,10 +913,8 @@ void Netchan_FragSend(netchan_t *chan)
}
fragbufwaiting_t *prev = nullptr;
while (true) {
if (!chan->waitlist[i]->next)
break;
while (chan->waitlist[i]->next)
{
prev = chan->waitlist[i];
chan->waitlist[i] = chan->waitlist[i]->next;
}
@ -1112,8 +1111,8 @@ void Netchan_CreateFileFragmentsFromBuffer(qboolean server, netchan_t *chan, con
fragbufwaiting_t *p;
fragbuf_t *buf;
unsigned char *pbuf;
signed int bCompressed;
signed int firstfragment;
qboolean bCompressed;
qboolean firstfragment;
signed int bufferid;
int remaining;
int pos;
@ -1221,7 +1220,7 @@ int Netchan_CreateFileFragments(qboolean server, netchan_t *chan, const char *fi
if (FS_FileSize(filename) > sv_filetransfermaxsize.value)
return FALSE;
auto wait = (fragbufwaiting_t *)Mem_ZeroMalloc(0xCu);
auto wait = (fragbufwaiting_t *)Mem_ZeroMalloc(sizeof(fragbufwaiting_t));
auto buf = Netchan_AllocFragbuf();
buf->bufferid = 1;
@ -1260,9 +1259,9 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
int send;
fragbuf_t *buf;
char compressedfilename[MAX_PATH];
int firstfragment;
qboolean firstfragment;
int bufferid;
int bCompressed;
qboolean bCompressed;
int pos;
fragbufwaiting_t *wait;
int uncompressed_size;
@ -1278,7 +1277,7 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
{
filesize = FS_Size(hfile);
FS_Close(hfile);
bCompressed = 1;
bCompressed = TRUE;
hfile = FS_Open(filename, "rb");
if (!hfile)
{
@ -1326,7 +1325,7 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
FS_Write(compressed, compressedSize, 1, destFile);
FS_Close(destFile);
filesize = compressedSize;
bCompressed = 1;
bCompressed = TRUE;
}
}
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);
if (gNetSplitFlags[packetNumber] == sequenceNumber)
{
Con_NetPrintf( "NET_GetLong: Ignoring duplicated split packet %i of %i ( %i bytes )\n",
packetNumber + 1, packetCount, packetPayloadSize
);
Con_NetPrintf("NET_GetLong: Ignoring duplicated split packet %i of %i ( %i bytes )\n", packetNumber + 1, packetCount, packetPayloadSize);
}
else
{
@ -900,9 +898,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (net_showpackets.value == 4.0f)
{
Con_Printf("<-- Split packet %i of %i, %i bytes %i seq\n",
packetNumber + 1, packetCount, packetPayloadSize, sequenceNumber
);
Con_Printf("<-- Split packet %i of %i, %i bytes %i seq\n", packetNumber + 1, packetCount, packetPayloadSize, sequenceNumber);
}
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)
++curPack->num_entities;
#endif //REHLDS_OPT_PEDANTIC
}
#ifdef REHLDS_FIXES
@ -4745,7 +4744,7 @@ void SV_UpdateToReliableMessages(void)
#ifdef REHLDS_FIXES
// skip update in this frame if would overflow
if (client->sendinfo && client->sendinfo_time <= realtime && ( 1 + 1 + 4 + ( int )Q_strlen( client->userinfo ) + 1 + 16 + g_psv.reliable_datagram.cursize <= g_psv.reliable_datagram.maxsize ) )
if (client->sendinfo && client->sendinfo_time <= realtime && (1 + 1 + 4 + (int)Q_strlen(client->userinfo) + 1 + 16 + g_psv.reliable_datagram.cursize <= g_psv.reliable_datagram.maxsize))
#else // REHLDS_FIXES
if (client->sendinfo && client->sendinfo_time <= realtime)
#endif // REHLDS_FIXES
@ -4792,8 +4791,8 @@ void SV_UpdateToReliableMessages(void)
SZ_Clear(&g_psv.spectator);
}
//Fix for the "server failed to transmit file 'AY&SY..." bug
//https://github.com/dreamstalker/rehlds/issues/38
// Fix for the "server failed to transmit file 'AY&SY..." bug
// https://github.com/dreamstalker/rehlds/issues/38
#ifdef REHLDS_FIXES
bool svReliableCompressed = false;
#endif
@ -4803,55 +4802,56 @@ void SV_UpdateToReliableMessages(void)
{
client = &g_psvs.clients[i];
//Fix for the "server failed to transmit file 'AY&SY..." bug
//https://github.com/dreamstalker/rehlds/issues/38
// Fix for the "server failed to transmit file 'AY&SY..." bug
// https://github.com/dreamstalker/rehlds/issues/38
#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);
}
else
{
Netchan_CreateFragments(TRUE, &client->netchan, &g_psv.reliable_datagram);
svReliableCompressed = true;
}
SZ_Write(&client->netchan.message, g_psv.reliable_datagram.data, g_psv.reliable_datagram.cursize);
}
else
{
Netchan_CreateFragments(TRUE, &client->netchan, &g_psv.reliable_datagram);
svReliableCompressed = true;
}
#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);
}
else
{
Netchan_CreateFragments(TRUE, &client->netchan, &g_psv.reliable_datagram);
}
SZ_Write(&client->netchan.message, g_psv.reliable_datagram.data, g_psv.reliable_datagram.cursize);
}
else
{
Netchan_CreateFragments(TRUE, &client->netchan, &g_psv.reliable_datagram);
}
#endif
if (g_psv.datagram.cursize + client->datagram.cursize < client->datagram.maxsize)
{
SZ_Write(&client->datagram, g_psv.datagram.data, g_psv.datagram.cursize);
}
else
{
Con_DPrintf("Warning: Ignoring unreliable datagram for %s, would overflow\n", client->name);
}
if (g_psv.datagram.cursize + client->datagram.cursize < client->datagram.maxsize)
{
SZ_Write(&client->datagram, g_psv.datagram.data, g_psv.datagram.cursize);
}
else
{
Con_DPrintf("Warning: Ignoring unreliable datagram for %s, would overflow\n", client->name);
}
if (client->proxy)
if (client->proxy)
{
if (g_psv.spectator.cursize + client->datagram.cursize < client->datagram.maxsize)
{
if (g_psv.spectator.cursize + client->datagram.cursize < client->datagram.maxsize)
{
SZ_Write(&client->datagram, g_psv.spectator.data, g_psv.spectator.cursize);
}
SZ_Write(&client->datagram, g_psv.spectator.data, g_psv.spectator.cursize);
}
#ifdef REHLDS_FIXES
else
{
Con_DPrintf("Warning: Ignoring spectator datagram for %s, would overflow\n", client->name);
}
#endif
else
{
Con_DPrintf("Warning: Ignoring spectator datagram for %s, would overflow\n", client->name);
}
#endif
}
}
@ -6070,7 +6070,7 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
Sequence_OnLevelLoad(server);
ContinueLoadingProgressBar("Server", 4, 0.0);
if (gmodinfo.clientDllCRC)
if (gmodinfo.clientcrccheck)
{
char szDllName[64];
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"))
{
pinfo->bIsMod = 1;
pinfo->clientDllCRC = Q_atoi(pvalue) != 0;
pinfo->clientcrccheck = Q_atoi(pvalue) != 0;
}
else if (!Q_stricmp(pkey, "type"))
{

View File

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

View File

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

View File

@ -40,9 +40,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
#ifdef _WIN32
Module 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);
#endif