Cache PHS for large maps, because the loading time is insane for large maps.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3564 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
0f5a25025d
commit
fdcdfe2d5a
|
@ -445,13 +445,13 @@ void SV_CalcPHS (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (developer.value)
|
|
||||||
Con_TPrintf (STL_BUILDINGPHS);
|
|
||||||
|
|
||||||
num = sv.world.worldmodel->numleafs;
|
num = sv.world.worldmodel->numleafs;
|
||||||
rowwords = (num+31)>>5;
|
rowwords = (num+31)>>5;
|
||||||
rowbytes = rowwords*4;
|
rowbytes = rowwords*4;
|
||||||
|
|
||||||
|
if (developer.value)
|
||||||
|
Con_TPrintf (STL_BUILDINGPHS);
|
||||||
|
|
||||||
sv.pvs = Hunk_AllocName (rowbytes*num, "phs vis");
|
sv.pvs = Hunk_AllocName (rowbytes*num, "phs vis");
|
||||||
scan = sv.pvs;
|
scan = sv.pvs;
|
||||||
vcount = 0;
|
vcount = 0;
|
||||||
|
@ -471,6 +471,19 @@ void SV_CalcPHS (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*this routine takes an exponential amount of time, so cache it if its too big*/
|
||||||
|
if (rowbytes*num >= 0x100000)
|
||||||
|
{
|
||||||
|
sv.phs = COM_LoadHunkFile(va("maps/%s.phs", sv.name));
|
||||||
|
if (sv.phs && com_filesize == rowbytes*num + 8 && ((unsigned*)sv.phs)[0] == *(unsigned*)"QPHS" && ((unsigned*)sv.phs)[1] == *(unsigned*)"\1\0\0\0")
|
||||||
|
{
|
||||||
|
sv.phs += 8;
|
||||||
|
Con_DPrintf("Loaded cached PHS\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Con_DPrintf("Stale cached PHS\n");
|
||||||
|
}
|
||||||
|
|
||||||
sv.phs = Hunk_AllocName (rowbytes*num, "phs hear");
|
sv.phs = Hunk_AllocName (rowbytes*num, "phs hear");
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -506,6 +519,18 @@ void SV_CalcPHS (void)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rowbytes*num >= 0x100000)
|
||||||
|
{
|
||||||
|
vfsfile_t *f = FS_OpenVFS(va("maps/%s.phs", sv.name), "wb", FS_GAMEONLY);
|
||||||
|
if (f)
|
||||||
|
{
|
||||||
|
VFS_WRITE(f, "QPHS\1\0\0\0", 8);
|
||||||
|
VFS_WRITE(f, sv.phs, rowbytes*num);
|
||||||
|
VFS_CLOSE(f);
|
||||||
|
Con_Printf("Written PHS cache (%u bytes)\n", rowbytes*num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (num)
|
if (num)
|
||||||
if (developer.value)
|
if (developer.value)
|
||||||
Con_TPrintf (STL_PHSINFO, vcount/num, count/num, num);
|
Con_TPrintf (STL_PHSINFO, vcount/num, count/num, num);
|
||||||
|
@ -762,6 +787,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us
|
||||||
//reset the server time.
|
//reset the server time.
|
||||||
sv.time = 0.1; //some progs don't like time starting at 0.
|
sv.time = 0.1; //some progs don't like time starting at 0.
|
||||||
//cos of spawn funcs like self.nextthink = time...
|
//cos of spawn funcs like self.nextthink = time...
|
||||||
|
//NQ uses 1, QW uses 0. Awkward.
|
||||||
sv.starttime = Sys_DoubleTime();
|
sv.starttime = Sys_DoubleTime();
|
||||||
|
|
||||||
COM_FlushTempoaryPacks();
|
COM_FlushTempoaryPacks();
|
||||||
|
|
Loading…
Reference in New Issue