Extra grp file autoloading for grp files included via the command line or the def files

git-svn-id: https://svn.eduke32.com/eduke32@524 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2007-03-21 20:37:24 +00:00
parent 4b4d37cf3f
commit 2bf47cbbed
3 changed files with 58 additions and 45 deletions

View file

@ -4379,6 +4379,7 @@ int spawn(int j, int pn)
T1 = T2 = T3 = T4 = T5 = T6 = T7 = T8 = T9 = 0; T1 = T2 = T3 = T4 = T5 = T6 = T7 = T8 = T9 = 0;
ResetActorGameVars(i); // this shouldn't be necessary
actorspriteflags[i] = 0; actorspriteflags[i] = 0;
sprpos[i].x = sprite[i].x; sprpos[i].x = sprite[i].x;
@ -8403,6 +8404,49 @@ static void setup_rancid_net(const char *fn)
} }
} }
static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL;
static int numdirs=0, numfiles=0;
static int currentlist=0;
static void clearfilenames(void)
{
klistfree(finddirs);
klistfree(findfiles);
finddirs = findfiles = NULL;
numfiles = numdirs = 0;
}
static int getfilenames(const char *path, char kind[])
{
CACHE1D_FIND_REC *r;
clearfilenames();
finddirs = klistpath(path,"*",CACHE1D_FIND_DIR);
findfiles = klistpath(path,kind,CACHE1D_FIND_FILE);
for (r = finddirs; r; r=r->next) numdirs++;
for (r = findfiles; r; r=r->next) numfiles++;
finddirshigh = finddirs;
findfileshigh = findfiles;
currentlist = 0;
if (findfileshigh) currentlist = 1;
return(0);
}
static void autoloadgrps(const char *fn)
{
Bsprintf(tempbuf,"autoload/%s",fn);
getfilenames(tempbuf,"*.grp");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
Bsprintf(tempbuf,"autoload/%s",fn);
getfilenames(tempbuf,"*.zip");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
Bsprintf(tempbuf,"autoload/%s",fn);
getfilenames(tempbuf,"*.pk3");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
}
static int loadgroupfiles(const char *fn) static int loadgroupfiles(const char *fn)
{ {
int tokn; int tokn;
@ -8438,7 +8482,11 @@ static int loadgroupfiles(const char *fn)
if (j == -1) if (j == -1)
initprintf("Could not find group file '%s'.\n",fn); initprintf("Could not find group file '%s'.\n",fn);
else else
{
initprintf("Using group file '%s'.\n",fn); initprintf("Using group file '%s'.\n",fn);
autoloadgrps(fn);
}
} }
pathsearchmode = 0; pathsearchmode = 0;
} }
@ -9707,36 +9755,6 @@ int load_script(const char *szScript)
return 1; return 1;
} }
static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL;
static int numdirs=0, numfiles=0;
static int currentlist=0;
static void clearfilenames(void)
{
klistfree(finddirs);
klistfree(findfiles);
finddirs = findfiles = NULL;
numfiles = numdirs = 0;
}
static int getfilenames(const char *path, char kind[])
{
CACHE1D_FIND_REC *r;
clearfilenames();
finddirs = klistpath(path,"*",CACHE1D_FIND_DIR);
findfiles = klistpath(path,kind,CACHE1D_FIND_FILE);
for (r = finddirs; r; r=r->next) numdirs++;
for (r = findfiles; r; r=r->next) numfiles++;
finddirshigh = finddirs;
findfileshigh = findfiles;
currentlist = 0;
if (findfileshigh) currentlist = 1;
return(0);
}
void app_main(int argc,char **argv) void app_main(int argc,char **argv)
{ {
int i, j; int i, j;
@ -9967,17 +9985,11 @@ void app_main(int argc,char **argv)
if (initgroupfile(duke3dgrp) == -1) if (initgroupfile(duke3dgrp) == -1)
initprintf("Warning: could not find group file '%s'.\n",duke3dgrp); initprintf("Warning: could not find group file '%s'.\n",duke3dgrp);
else initprintf("Using group file '%s' as main group file.\n", duke3dgrp); else
{
Bsprintf(tempbuf,"autoload/%s",duke3dgrp); initprintf("Using group file '%s' as main group file.\n", duke3dgrp);
getfilenames(tempbuf,"*.grp"); autoloadgrps(duke3dgrp);
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",duke3dgrp,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } }
Bsprintf(tempbuf,"autoload/%s",duke3dgrp);
getfilenames(tempbuf,"*.zip");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",duke3dgrp,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
Bsprintf(tempbuf,"autoload/%s",duke3dgrp);
getfilenames(tempbuf,"*.pk3");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",duke3dgrp,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
getfilenames("autoload","*.grp"); getfilenames("autoload","*.grp");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
@ -10001,6 +10013,7 @@ while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",duke3dgrp,findfiles->name)
{ {
groupfile = j; groupfile = j;
initprintf("Using group file '%s'.\n",CommandGrps->str); initprintf("Using group file '%s'.\n",CommandGrps->str);
autoloadgrps(CommandGrps->str);
} }
free(CommandGrps->str); free(CommandGrps->str);

View file

@ -231,7 +231,7 @@ char *MV_ErrorString(int ErrorNumber)
Returns the buffer size for the given samplerate. Returns the buffer size for the given samplerate.
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
#define BASEBUFSZ (512+256) #define BASEBUFSZ (512+128)
static unsigned MV_GetBufferSize(unsigned samplerate) static unsigned MV_GetBufferSize(unsigned samplerate)
{ {
static unsigned lastsr = 0, lastbufsz = 0; static unsigned lastsr = 0, lastbufsz = 0;