mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
Eliminate the need for cache1d to calculate and remember the CRC32 of every GRP loaded.
git-svn-id: https://svn.eduke32.com/eduke32@6489 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d33107808e
commit
e979aa1ff4
5 changed files with 5 additions and 75 deletions
|
@ -23,7 +23,6 @@
|
|||
#include "cache1d.h"
|
||||
#include "pragmas.h"
|
||||
#include "baselayer.h"
|
||||
#include "crc32.h"
|
||||
|
||||
#ifdef WITHKPLIB
|
||||
#include "kplib.h"
|
||||
|
@ -681,7 +680,6 @@ static uint8_t groupfilgrp[MAXGROUPFILES];
|
|||
static char *gfilelist[MAXGROUPFILES];
|
||||
static char *groupname[MAXGROUPFILES];
|
||||
static int32_t *gfileoffs[MAXGROUPFILES];
|
||||
static int32_t groupcrc[MAXGROUPFILES];
|
||||
|
||||
static uint8_t filegrp[MAXOPENFILES];
|
||||
static int32_t filepos[MAXOPENFILES];
|
||||
|
@ -708,25 +706,6 @@ static int32_t kread_grp(int32_t handle, void *buffer, int32_t leng);
|
|||
static int32_t klseek_grp(int32_t handle, int32_t offset, int32_t whence);
|
||||
static void kclose_grp(int32_t handle);
|
||||
|
||||
static void initgroupfile_crc32(int32_t handle)
|
||||
{
|
||||
int32_t b, crcval = 0;
|
||||
#define BUFFER_SIZE (1024 * 1024 * 8)
|
||||
uint8_t *buf = (uint8_t *)Xmalloc(BUFFER_SIZE);
|
||||
klseek_grp(handle, 0, BSEEK_SET);
|
||||
|
||||
do
|
||||
{
|
||||
b = kread_grp(handle, buf, BUFFER_SIZE);
|
||||
if (b > 0) crcval = Bcrc32((uint8_t *)buf, b, crcval);
|
||||
}
|
||||
while (b == BUFFER_SIZE);
|
||||
|
||||
groupcrc[handle] = crcval;
|
||||
klseek_grp(handle, 0, BSEEK_SET);
|
||||
Bfree(buf);
|
||||
}
|
||||
|
||||
int initgroupfile(const char *filename)
|
||||
{
|
||||
char buf[70];
|
||||
|
@ -758,7 +737,7 @@ int initgroupfile(const char *filename)
|
|||
|
||||
kzaddstack(zfn);
|
||||
Bfree(zfn);
|
||||
return 0;
|
||||
return MAXGROUPFILES;
|
||||
}
|
||||
klseek_grp(numgroupfiles,0,BSEEK_SET);
|
||||
|
||||
|
@ -788,10 +767,8 @@ int initgroupfile(const char *filename)
|
|||
j += k;
|
||||
}
|
||||
gfileoffs[numgroupfiles][gnumfiles[numgroupfiles]] = j;
|
||||
initgroupfile_crc32(numgroupfiles);
|
||||
groupname[numgroupfiles] = Xstrdup(filename);
|
||||
numgroupfiles++;
|
||||
return 0;
|
||||
return numgroupfiles++;
|
||||
}
|
||||
klseek_grp(numgroupfiles, 0, BSEEK_SET);
|
||||
|
||||
|
@ -893,10 +870,8 @@ int initgroupfile(const char *filename)
|
|||
klseek_grp(numgroupfiles, 104, BSEEK_CUR);
|
||||
}
|
||||
gfileoffs[numgroupfiles][gnumfiles[numgroupfiles]] = j;
|
||||
initgroupfile_crc32(numgroupfiles);
|
||||
groupname[numgroupfiles] = Xstrdup(filename);
|
||||
numgroupfiles++;
|
||||
return 0;
|
||||
return numgroupfiles++;
|
||||
}
|
||||
|
||||
kclose_grp(numgroupfiles);
|
||||
|
@ -1077,14 +1052,7 @@ gnumfiles_continue: ;
|
|||
|
||||
void krename(int32_t crcval, int32_t filenum, const char *newname)
|
||||
{
|
||||
for (bssize_t k=numgroupfiles-1; k>=0; k--)
|
||||
{
|
||||
if (groupfil[k] >= 0 && groupcrc[k] == crcval)
|
||||
{
|
||||
Bstrncpy((char *)&gfilelist[k][filenum<<4], newname, 12);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Bstrncpy((char *)&gfilelist[crcval][filenum<<4], newname, 12);
|
||||
}
|
||||
|
||||
char const * kfileparent(int32_t const handle)
|
||||
|
|
|
@ -103,7 +103,6 @@ enum scripttoken_t
|
|||
T_MAPINFO, T_MAPFILE, T_MAPTITLE, T_MAPMD4, T_MHKFILE,
|
||||
T_ECHO,
|
||||
T_GLOBALFLAGS,
|
||||
T_RENAMEFILE,
|
||||
T_COPYTILE,
|
||||
T_GLOBALGAMEFLAGS,
|
||||
T_MULTIPSKY, T_HORIZFRAC, T_LOGNUMTILES,
|
||||
|
@ -391,7 +390,6 @@ static int32_t defsparser(scriptfile *script)
|
|||
{ "mapinfo", T_MAPINFO },
|
||||
{ "echo", T_ECHO },
|
||||
{ "globalflags", T_GLOBALFLAGS },
|
||||
{ "renamefile", T_RENAMEFILE },
|
||||
{ "copytile", T_COPYTILE },
|
||||
{ "globalgameflags", T_GLOBALGAMEFLAGS }, // dummy
|
||||
{ "multipsky", T_MULTIPSKY },
|
||||
|
@ -2636,17 +2634,6 @@ static int32_t defsparser(scriptfile *script)
|
|||
}
|
||||
break;
|
||||
|
||||
case T_RENAMEFILE:
|
||||
{
|
||||
int32_t crcval = 0, filenum = -1;
|
||||
char *newname = NULL;
|
||||
if (scriptfile_getnumber(script,&crcval)) break;
|
||||
if (scriptfile_getnumber(script,&filenum)) break;
|
||||
if (scriptfile_getstring(script,&newname)) break;
|
||||
krename(crcval, filenum, newname);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_MULTIPSKY:
|
||||
{
|
||||
char *blockend;
|
||||
|
|
|
@ -9242,7 +9242,6 @@ enum
|
|||
T_DEFINESOUND,
|
||||
T_INCLUDEDEFAULT,
|
||||
|
||||
T_RENAMEFILE,
|
||||
T_GLOBALGAMEFLAGS,
|
||||
|
||||
T_GAMESTARTUP,
|
||||
|
@ -9285,7 +9284,6 @@ static int32_t parsegroupfiles(scriptfile *script)
|
|||
{ "#includedefault", T_INCLUDEDEFAULT },
|
||||
{ "loadgrp", T_LOADGRP },
|
||||
{ "noautoload", T_NOAUTOLOAD },
|
||||
{ "renamefile", T_RENAMEFILE },
|
||||
{ "globalgameflags", T_GLOBALGAMEFLAGS },
|
||||
};
|
||||
|
||||
|
@ -9335,16 +9333,6 @@ static int32_t parsegroupfiles(scriptfile *script)
|
|||
case T_NOAUTOLOAD:
|
||||
NoAutoLoad = 1;
|
||||
break;
|
||||
case T_RENAMEFILE:
|
||||
{
|
||||
int32_t crcval = 0, filenum = -1;
|
||||
char *newname = NULL;
|
||||
if (scriptfile_getnumber(script,&crcval)) break;
|
||||
if (scriptfile_getnumber(script,&filenum)) break;
|
||||
if (scriptfile_getstring(script,&newname)) break;
|
||||
krename(crcval, filenum, newname);
|
||||
}
|
||||
break;
|
||||
case T_GLOBALGAMEFLAGS:
|
||||
{
|
||||
if (scriptfile_getnumber(script,&duke3d_m32_globalflags)) break;
|
||||
|
|
|
@ -393,7 +393,7 @@ static int32_t G_LoadGrpDependencyChain(grpfile_t const * const grp)
|
|||
int32_t const i = G_TryLoadingGrp(grp->filename);
|
||||
|
||||
if (grp->type->postprocessing)
|
||||
grp->type->postprocessing(grp->type->crcval);
|
||||
grp->type->postprocessing(i);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -5414,19 +5414,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case T_RENAMEFILE:
|
||||
{
|
||||
int32_t fileCRC = 0;
|
||||
int32_t fileNum = -1;
|
||||
char * newName = NULL;
|
||||
|
||||
if (scriptfile_getnumber(pScript, &fileCRC)) break;
|
||||
if (scriptfile_getnumber(pScript, &fileNum)) break;
|
||||
if (scriptfile_getstring(pScript, &newName)) break;
|
||||
|
||||
krename(fileCRC, fileNum, newName);
|
||||
}
|
||||
break;
|
||||
case T_GLOBALGAMEFLAGS: scriptfile_getnumber(pScript, &duke3d_globalflags); break;
|
||||
case T_EOF: return 0;
|
||||
default: break;
|
||||
|
|
Loading…
Reference in a new issue