Support for automatically loading all grp/zip/pk3 files in a directory. Files go into the "autoload" directory if they're to be loaded by all main grp files that are supported, or into autoload/grpname to be loaded only if a specific grp is used. For example, autoload/duke3d.grp/hrp.zip would only be loaded if duke3d.grp was specified as the main group file (and not nam.grp, et cetera).

git-svn-id: https://svn.eduke32.com/eduke32@507 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2007-02-25 21:11:59 +00:00
parent 0dfc03afa0
commit f889e552b2
6 changed files with 119 additions and 4 deletions

View file

@ -147,6 +147,36 @@ static inline long GetTime(void)
return totalclock;
}
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 ExtLoadMap(const char *mapname)
{
long i;
@ -4528,6 +4558,23 @@ int ExtInit(void)
}
initgroupfile(duke3dgrp);
Bsprintf(tempbuf,"autoload/%s",duke3dgrp);
getfilenames(tempbuf,"*.grp");
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");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
getfilenames("autoload","*.zip");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
getfilenames("autoload","*.pk3");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
if (getenv("DUKE3DDEF"))
{
defsfilename = getenv("DUKE3DDEF");

View file

@ -9672,6 +9672,36 @@ int load_script(const char *szScript)
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)
{
int i, j;
@ -9899,8 +9929,28 @@ void app_main(int argc,char **argv)
Bsprintf(gametype_names[2],"GRUNTMATCH (NO SPAWN)");
}
initprintf("Main GRP file: %s.\n", duke3dgrp);
initgroupfile(duke3dgrp);
if (initgroupfile(duke3dgrp) == -1)
initprintf("Warning: could not find group file '%s'.\n",duke3dgrp);
else initprintf("Using group file '%s' as main group file.\n", duke3dgrp);
Bsprintf(tempbuf,"autoload/%s",duke3dgrp);
getfilenames(tempbuf,"*.grp");
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");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
getfilenames("autoload","*.zip");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
getfilenames("autoload","*.pk3");
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
loadgroupfiles(duke3ddef);
{

View file

@ -812,6 +812,8 @@ LABELS userdefslabels[]=
{ "automsg", USERDEFS_AUTOMSG, 0, 0 },
{ "idplayers", USERDEFS_IDPLAYERS, 0, 0 },
{ "team", USERDEFS_TEAM, 0, 0 },
{ "viewbob", USERDEFS_VIEWBOB, 0, 0 },
{ "weaponsway", USERDEFS_WEAPONSWAY, 0, 0 },
{ "", -1, 0, 0 } // END OF LIST
};

View file

@ -314,7 +314,9 @@ enum userdefslabels {
USERDEFS_AUTOVOTE,
USERDEFS_AUTOMSG,
USERDEFS_IDPLAYERS,
USERDEFS_TEAM
USERDEFS_TEAM,
USERDEFS_VIEWBOB,
USERDEFS_WEAPONSWAY
};
enum sectorlabels {

View file

@ -665,6 +665,20 @@ static void DoUserDef(int iSet, int lLabelID, int lVar2)
SetGameVarID(lVar2, ud.team, g_i, g_p);
break;
case USERDEFS_VIEWBOB:
if (iSet)
ud.viewbob = lValue;
else
SetGameVarID(lVar2, ud.viewbob, g_i, g_p);
break;
case USERDEFS_WEAPONSWAY:
if (iSet)
ud.weaponsway = lValue;
else
SetGameVarID(lVar2, ud.weaponsway, g_i, g_p);
break;
default:
break;
}

View file

@ -154,5 +154,5 @@ extern double msens;
void ContextHelp(short spritenum);
void ResetKeys();
extern void clearfilenames(void), fixspritesectors(void);
extern void fixspritesectors(void);
#define KEY_PRESSED(sc) KB_KeyPressed((sc))