mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +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 "cache1d.h"
|
||||||
#include "pragmas.h"
|
#include "pragmas.h"
|
||||||
#include "baselayer.h"
|
#include "baselayer.h"
|
||||||
#include "crc32.h"
|
|
||||||
|
|
||||||
#ifdef WITHKPLIB
|
#ifdef WITHKPLIB
|
||||||
#include "kplib.h"
|
#include "kplib.h"
|
||||||
|
@ -681,7 +680,6 @@ static uint8_t groupfilgrp[MAXGROUPFILES];
|
||||||
static char *gfilelist[MAXGROUPFILES];
|
static char *gfilelist[MAXGROUPFILES];
|
||||||
static char *groupname[MAXGROUPFILES];
|
static char *groupname[MAXGROUPFILES];
|
||||||
static int32_t *gfileoffs[MAXGROUPFILES];
|
static int32_t *gfileoffs[MAXGROUPFILES];
|
||||||
static int32_t groupcrc[MAXGROUPFILES];
|
|
||||||
|
|
||||||
static uint8_t filegrp[MAXOPENFILES];
|
static uint8_t filegrp[MAXOPENFILES];
|
||||||
static int32_t filepos[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 int32_t klseek_grp(int32_t handle, int32_t offset, int32_t whence);
|
||||||
static void kclose_grp(int32_t handle);
|
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)
|
int initgroupfile(const char *filename)
|
||||||
{
|
{
|
||||||
char buf[70];
|
char buf[70];
|
||||||
|
@ -758,7 +737,7 @@ int initgroupfile(const char *filename)
|
||||||
|
|
||||||
kzaddstack(zfn);
|
kzaddstack(zfn);
|
||||||
Bfree(zfn);
|
Bfree(zfn);
|
||||||
return 0;
|
return MAXGROUPFILES;
|
||||||
}
|
}
|
||||||
klseek_grp(numgroupfiles,0,BSEEK_SET);
|
klseek_grp(numgroupfiles,0,BSEEK_SET);
|
||||||
|
|
||||||
|
@ -788,10 +767,8 @@ int initgroupfile(const char *filename)
|
||||||
j += k;
|
j += k;
|
||||||
}
|
}
|
||||||
gfileoffs[numgroupfiles][gnumfiles[numgroupfiles]] = j;
|
gfileoffs[numgroupfiles][gnumfiles[numgroupfiles]] = j;
|
||||||
initgroupfile_crc32(numgroupfiles);
|
|
||||||
groupname[numgroupfiles] = Xstrdup(filename);
|
groupname[numgroupfiles] = Xstrdup(filename);
|
||||||
numgroupfiles++;
|
return numgroupfiles++;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
klseek_grp(numgroupfiles, 0, BSEEK_SET);
|
klseek_grp(numgroupfiles, 0, BSEEK_SET);
|
||||||
|
|
||||||
|
@ -893,10 +870,8 @@ int initgroupfile(const char *filename)
|
||||||
klseek_grp(numgroupfiles, 104, BSEEK_CUR);
|
klseek_grp(numgroupfiles, 104, BSEEK_CUR);
|
||||||
}
|
}
|
||||||
gfileoffs[numgroupfiles][gnumfiles[numgroupfiles]] = j;
|
gfileoffs[numgroupfiles][gnumfiles[numgroupfiles]] = j;
|
||||||
initgroupfile_crc32(numgroupfiles);
|
|
||||||
groupname[numgroupfiles] = Xstrdup(filename);
|
groupname[numgroupfiles] = Xstrdup(filename);
|
||||||
numgroupfiles++;
|
return numgroupfiles++;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kclose_grp(numgroupfiles);
|
kclose_grp(numgroupfiles);
|
||||||
|
@ -1077,14 +1052,7 @@ gnumfiles_continue: ;
|
||||||
|
|
||||||
void krename(int32_t crcval, int32_t filenum, const char *newname)
|
void krename(int32_t crcval, int32_t filenum, const char *newname)
|
||||||
{
|
{
|
||||||
for (bssize_t k=numgroupfiles-1; k>=0; k--)
|
Bstrncpy((char *)&gfilelist[crcval][filenum<<4], newname, 12);
|
||||||
{
|
|
||||||
if (groupfil[k] >= 0 && groupcrc[k] == crcval)
|
|
||||||
{
|
|
||||||
Bstrncpy((char *)&gfilelist[k][filenum<<4], newname, 12);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * kfileparent(int32_t const handle)
|
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_MAPINFO, T_MAPFILE, T_MAPTITLE, T_MAPMD4, T_MHKFILE,
|
||||||
T_ECHO,
|
T_ECHO,
|
||||||
T_GLOBALFLAGS,
|
T_GLOBALFLAGS,
|
||||||
T_RENAMEFILE,
|
|
||||||
T_COPYTILE,
|
T_COPYTILE,
|
||||||
T_GLOBALGAMEFLAGS,
|
T_GLOBALGAMEFLAGS,
|
||||||
T_MULTIPSKY, T_HORIZFRAC, T_LOGNUMTILES,
|
T_MULTIPSKY, T_HORIZFRAC, T_LOGNUMTILES,
|
||||||
|
@ -391,7 +390,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
{ "mapinfo", T_MAPINFO },
|
{ "mapinfo", T_MAPINFO },
|
||||||
{ "echo", T_ECHO },
|
{ "echo", T_ECHO },
|
||||||
{ "globalflags", T_GLOBALFLAGS },
|
{ "globalflags", T_GLOBALFLAGS },
|
||||||
{ "renamefile", T_RENAMEFILE },
|
|
||||||
{ "copytile", T_COPYTILE },
|
{ "copytile", T_COPYTILE },
|
||||||
{ "globalgameflags", T_GLOBALGAMEFLAGS }, // dummy
|
{ "globalgameflags", T_GLOBALGAMEFLAGS }, // dummy
|
||||||
{ "multipsky", T_MULTIPSKY },
|
{ "multipsky", T_MULTIPSKY },
|
||||||
|
@ -2636,17 +2634,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case T_MULTIPSKY:
|
||||||
{
|
{
|
||||||
char *blockend;
|
char *blockend;
|
||||||
|
|
|
@ -9242,7 +9242,6 @@ enum
|
||||||
T_DEFINESOUND,
|
T_DEFINESOUND,
|
||||||
T_INCLUDEDEFAULT,
|
T_INCLUDEDEFAULT,
|
||||||
|
|
||||||
T_RENAMEFILE,
|
|
||||||
T_GLOBALGAMEFLAGS,
|
T_GLOBALGAMEFLAGS,
|
||||||
|
|
||||||
T_GAMESTARTUP,
|
T_GAMESTARTUP,
|
||||||
|
@ -9285,7 +9284,6 @@ static int32_t parsegroupfiles(scriptfile *script)
|
||||||
{ "#includedefault", T_INCLUDEDEFAULT },
|
{ "#includedefault", T_INCLUDEDEFAULT },
|
||||||
{ "loadgrp", T_LOADGRP },
|
{ "loadgrp", T_LOADGRP },
|
||||||
{ "noautoload", T_NOAUTOLOAD },
|
{ "noautoload", T_NOAUTOLOAD },
|
||||||
{ "renamefile", T_RENAMEFILE },
|
|
||||||
{ "globalgameflags", T_GLOBALGAMEFLAGS },
|
{ "globalgameflags", T_GLOBALGAMEFLAGS },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9335,16 +9333,6 @@ static int32_t parsegroupfiles(scriptfile *script)
|
||||||
case T_NOAUTOLOAD:
|
case T_NOAUTOLOAD:
|
||||||
NoAutoLoad = 1;
|
NoAutoLoad = 1;
|
||||||
break;
|
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:
|
case T_GLOBALGAMEFLAGS:
|
||||||
{
|
{
|
||||||
if (scriptfile_getnumber(script,&duke3d_m32_globalflags)) break;
|
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);
|
int32_t const i = G_TryLoadingGrp(grp->filename);
|
||||||
|
|
||||||
if (grp->type->postprocessing)
|
if (grp->type->postprocessing)
|
||||||
grp->type->postprocessing(grp->type->crcval);
|
grp->type->postprocessing(i);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5414,19 +5414,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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_GLOBALGAMEFLAGS: scriptfile_getnumber(pScript, &duke3d_globalflags); break;
|
||||||
case T_EOF: return 0;
|
case T_EOF: return 0;
|
||||||
default: break;
|
default: break;
|
||||||
|
|
Loading…
Reference in a new issue