2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Function Host_UpdateStats on Linux doesn't work correctly.

Fixed the computation of cpuPercent

Made signature checks (bz2, wad3) look more beatiful
This commit is contained in:
s1lentq 2015-05-10 18:18:12 +06:00
parent 0399c02f0c
commit b153ad664a
4 changed files with 8 additions and 11 deletions

View File

@ -77,7 +77,7 @@ void Draw_CacheWadInitFromFile(FileHandle_t hFile, int len, char *name, int cach
wadinfo_t header;
FS_Read(&header, sizeof(wadinfo_t), 1, hFile);
if (Q_strncmp(header.identification, "WAD3", 4))
if (*(uint32 *)header.identification != MAKEID('W', 'A', 'D', '3'))
Sys_Error("Wad file %s doesn't have WAD3 id\n", name);
wad->lumps = (lumpinfo_s *)Mem_Malloc(len - header.infotableofs);
@ -115,7 +115,7 @@ qboolean Draw_CustomCacheWadInit(int cacheMax, cachewad_t *wad, void *raw, int n
lumpinfo_t *lump_p;
wadinfo_t header;
header = *(wadinfo_t *)raw;
if (Q_strncmp(header.identification, "WAD3", 4))
if (*(uint32 *)header.identification != MAKEID('W', 'A', 'D', '3'))
{
Con_Printf("Custom file doesn't have WAD3 id\n");
return FALSE;

View File

@ -428,7 +428,7 @@ void Host_UpdateStats(void)
lastcputicks = cputicks;
if (lastrunticks)
cpuPercent = (cputicks - lastcputicks) / (runticks - lastrunticks);
cpuPercent = (double)(cputicks - lastcputicks) / (double)(runticks - lastrunticks);
else
lastrunticks = runticks;
@ -440,7 +440,7 @@ void Host_UpdateStats(void)
}
if (cpuPercent > 0.999)
cpuPercent = 0.999;
if (cpuPercent < 0.1)
else if (cpuPercent < 0.0)
cpuPercent = 0.0;
last = Sys_FloatTime();
}

View File

@ -1007,7 +1007,7 @@ void Netchan_CreateFragments_(qboolean server, netchan_t *chan, sizebuf_t *msg)
}
// Compress if not done already
if (msg->data[0] != 'B' || msg->data[1] != 'Z' || msg->data[2] != '2' || msg->data[3] != 0)
if (*(uint32 *)msg->data != MAKEID('B', 'Z', '2', '\0'))
{
unsigned char compressed[65536];
char hdr[4] = "BZ2";
@ -1383,7 +1383,7 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
p = n;
}
if (net_message.data[0] == 'B' && net_message.data[1] == 'Z' && net_message.data[2] == '2' && net_message.data[3] == 0)
if (*(uint32 *)net_message.data == MAKEID('B', 'Z', '2', '\0'))
{
char uncompressed[65536];
unsigned int uncompressedSize = 65536;

View File

@ -79,11 +79,8 @@ int W_LoadWadFile(char *filename)
Q_strncpy(wad->wadname, filename, sizeof(wad->wadname) - 1);
wadinfo_t *header = (wadinfo_t *)wad->wad_base;
wad->wadname[sizeof(wad->wadname) - 1] = 0;
wad->loaded = 1;
if (header->identification[0] != 'W'
|| header->identification[1] != 'A'
|| header->identification[2] != 'D'
|| header->identification[3] != '3')
wad->loaded = TRUE;
if (*(uint32 *)header->identification != MAKEID('W', 'A', 'D', '3'))
Sys_Error("Wad file %s doesn't have WAD3 id\n", filename);
wad->wad_numlumps = LittleLong(header->numlumps);