mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-01 01:25:38 +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:
parent
0399c02f0c
commit
b153ad664a
@ -77,7 +77,7 @@ void Draw_CacheWadInitFromFile(FileHandle_t hFile, int len, char *name, int cach
|
|||||||
wadinfo_t header;
|
wadinfo_t header;
|
||||||
|
|
||||||
FS_Read(&header, sizeof(wadinfo_t), 1, hFile);
|
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);
|
Sys_Error("Wad file %s doesn't have WAD3 id\n", name);
|
||||||
|
|
||||||
wad->lumps = (lumpinfo_s *)Mem_Malloc(len - header.infotableofs);
|
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;
|
lumpinfo_t *lump_p;
|
||||||
wadinfo_t header;
|
wadinfo_t header;
|
||||||
header = *(wadinfo_t *)raw;
|
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");
|
Con_Printf("Custom file doesn't have WAD3 id\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -428,7 +428,7 @@ void Host_UpdateStats(void)
|
|||||||
lastcputicks = cputicks;
|
lastcputicks = cputicks;
|
||||||
|
|
||||||
if (lastrunticks)
|
if (lastrunticks)
|
||||||
cpuPercent = (cputicks - lastcputicks) / (runticks - lastrunticks);
|
cpuPercent = (double)(cputicks - lastcputicks) / (double)(runticks - lastrunticks);
|
||||||
else
|
else
|
||||||
lastrunticks = runticks;
|
lastrunticks = runticks;
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ void Host_UpdateStats(void)
|
|||||||
}
|
}
|
||||||
if (cpuPercent > 0.999)
|
if (cpuPercent > 0.999)
|
||||||
cpuPercent = 0.999;
|
cpuPercent = 0.999;
|
||||||
if (cpuPercent < 0.1)
|
else if (cpuPercent < 0.0)
|
||||||
cpuPercent = 0.0;
|
cpuPercent = 0.0;
|
||||||
last = Sys_FloatTime();
|
last = Sys_FloatTime();
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ void Netchan_CreateFragments_(qboolean server, netchan_t *chan, sizebuf_t *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compress if not done already
|
// 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];
|
unsigned char compressed[65536];
|
||||||
char hdr[4] = "BZ2";
|
char hdr[4] = "BZ2";
|
||||||
@ -1383,7 +1383,7 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
|
|||||||
p = n;
|
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];
|
char uncompressed[65536];
|
||||||
unsigned int uncompressedSize = 65536;
|
unsigned int uncompressedSize = 65536;
|
||||||
|
@ -79,11 +79,8 @@ int W_LoadWadFile(char *filename)
|
|||||||
Q_strncpy(wad->wadname, filename, sizeof(wad->wadname) - 1);
|
Q_strncpy(wad->wadname, filename, sizeof(wad->wadname) - 1);
|
||||||
wadinfo_t *header = (wadinfo_t *)wad->wad_base;
|
wadinfo_t *header = (wadinfo_t *)wad->wad_base;
|
||||||
wad->wadname[sizeof(wad->wadname) - 1] = 0;
|
wad->wadname[sizeof(wad->wadname) - 1] = 0;
|
||||||
wad->loaded = 1;
|
wad->loaded = TRUE;
|
||||||
if (header->identification[0] != 'W'
|
if (*(uint32 *)header->identification != MAKEID('W', 'A', 'D', '3'))
|
||||||
|| header->identification[1] != 'A'
|
|
||||||
|| header->identification[2] != 'D'
|
|
||||||
|| header->identification[3] != '3')
|
|
||||||
Sys_Error("Wad file %s doesn't have WAD3 id\n", filename);
|
Sys_Error("Wad file %s doesn't have WAD3 id\n", filename);
|
||||||
wad->wad_numlumps = LittleLong(header->numlumps);
|
wad->wad_numlumps = LittleLong(header->numlumps);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user