mirror of
https://github.com/ZDoom/Raze.git
synced 2025-06-03 10:41:24 +00:00
- cleanup of the old file system initialization.
The real fun part is yet to come, i.e. removing the remaining dependencies on the old file system code.
This commit is contained in:
parent
24edfbe03b
commit
2d7c0e26d2
30 changed files with 335 additions and 1402 deletions
|
@ -19,87 +19,6 @@
|
|||
|
||||
BEGIN_RR_NS
|
||||
|
||||
struct grpfile_t const *g_selectedGrp;
|
||||
|
||||
int32_t g_gameType = GAMEFLAG_DUKE;
|
||||
int g_addonNum = 0;
|
||||
|
||||
// g_gameNamePtr can point to one of: grpfiles[].name (string literal), string
|
||||
// literal, malloc'd block (XXX: possible leak)
|
||||
const char *g_gameNamePtr = NULL;
|
||||
|
||||
// grp/con handling
|
||||
|
||||
static const char *defaultconfilename = "GAME.CON";
|
||||
static const char *defaultgamegrp[GAMECOUNT] = { "DUKE3D.GRP", "REDNECK.GRP", "REDNECK.GRP", "NAM.GRP", "NAPALM.GRP" };
|
||||
static const char *defaultdeffilename[GAMECOUNT] = { "duke3d.def", "rr.def", "rrra.def", "nam.def", "napalm.grp" };
|
||||
static const char *defaultgameconfilename[GAMECOUNT] = { "GAME.CON", "GAME.CON", "GAME.CON", "NAM.CON", "NAPALM.CON" };
|
||||
|
||||
const char* G_DefaultGrpFile(void)
|
||||
{
|
||||
if (DUKE)
|
||||
return defaultgamegrp[GAME_DUKE];
|
||||
else if (RR)
|
||||
return defaultgamegrp[GAME_RR];
|
||||
|
||||
return defaultgamegrp[0];
|
||||
}
|
||||
|
||||
const char* G_DefaultDefFile(void)
|
||||
{
|
||||
if (DUKE)
|
||||
return defaultdeffilename[GAME_DUKE];
|
||||
else if (RRRA)
|
||||
return defaultdeffilename[GAME_RRRA];
|
||||
else if (RR)
|
||||
return defaultdeffilename[GAME_RR];
|
||||
|
||||
return defaultdeffilename[0];
|
||||
}
|
||||
const char *G_DefaultConFile(void)
|
||||
{
|
||||
/*if (DUKE && testkopen(defaultgameconfilename[GAME_DUKE],0))
|
||||
return defaultgameconfilename[GAME_DUKE];
|
||||
else if (WW2GI && testkopen(defaultgameconfilename[GAME_WW2GI],0))
|
||||
return defaultgameconfilename[GAME_WW2GI];
|
||||
else */if (NAPALM)
|
||||
{
|
||||
if (!testkopen(defaultgameconfilename[GAME_NAPALM],0))
|
||||
{
|
||||
if (testkopen(defaultgameconfilename[GAME_NAM],0))
|
||||
return defaultgameconfilename[GAME_NAM]; // NAM/NAPALM Sharing
|
||||
}
|
||||
else
|
||||
return defaultgameconfilename[GAME_NAPALM];
|
||||
}
|
||||
else if (NAM)
|
||||
{
|
||||
if (!testkopen(defaultgameconfilename[GAME_NAM],0))
|
||||
{
|
||||
if (testkopen(defaultgameconfilename[GAME_NAPALM],0))
|
||||
return defaultgameconfilename[GAME_NAPALM]; // NAM/NAPALM Sharing
|
||||
}
|
||||
else
|
||||
return defaultgameconfilename[GAME_NAM];
|
||||
}
|
||||
return defaultconfilename;
|
||||
}
|
||||
|
||||
const char *G_GrpFile(void)
|
||||
{
|
||||
return userConfig.gamegrp.IsNotEmpty()? userConfig.gamegrp.GetChars() : G_DefaultGrpFile();
|
||||
}
|
||||
|
||||
const char *G_DefFile(void)
|
||||
{
|
||||
return userConfig.DefaultDef.IsNotEmpty() ? userConfig.DefaultDef.GetChars() : G_DefaultDefFile();
|
||||
}
|
||||
|
||||
const char *G_ConFile(void)
|
||||
{
|
||||
return userConfig.DefaultCon.IsNotEmpty() ? userConfig.DefaultCon.GetChars() : G_DefaultConFile();
|
||||
}
|
||||
|
||||
//////////
|
||||
|
||||
// Set up new-style multi-psky handling.
|
||||
|
@ -183,187 +102,6 @@ void G_SetupGlobalPsky(void)
|
|||
|
||||
//////////
|
||||
|
||||
static void G_LoadAddon(void);
|
||||
int32_t g_groupFileHandle;
|
||||
struct strllist* CommandGrps;
|
||||
|
||||
static int32_t G_TryLoadingGrp(char const * const grpfile)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if ((i = initgroupfile(grpfile)) == -1)
|
||||
initprintf("Warning: could not find main data file \"%s\"!\n", grpfile);
|
||||
else
|
||||
initprintf("Using \"%s\" as main game data file.\n", grpfile);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int32_t G_LoadGrpDependencyChain(grpfile_t const * const grp)
|
||||
{
|
||||
if (!grp)
|
||||
return -1;
|
||||
|
||||
if (grp->type->dependency && grp->type->dependency != grp->type->crcval)
|
||||
G_LoadGrpDependencyChain(FindGroup(grp->type->dependency));
|
||||
|
||||
int32_t const i = G_TryLoadingGrp(grp->filename);
|
||||
|
||||
if (grp->type->postprocessing)
|
||||
grp->type->postprocessing(i);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void G_LoadGroups()
|
||||
{
|
||||
if (g_modDir[0] != '/')
|
||||
{
|
||||
char cwd[BMAX_PATH];
|
||||
|
||||
FString g_rootDir = progdir + g_modDir;
|
||||
addsearchpath(g_rootDir);
|
||||
// addsearchpath(mod_dir);
|
||||
|
||||
char path[BMAX_PATH];
|
||||
|
||||
if (getcwd(cwd, BMAX_PATH))
|
||||
{
|
||||
Bsnprintf(path, sizeof(path), "%s/%s", cwd, g_modDir);
|
||||
if (!Bstrcmp(g_rootDir, path))
|
||||
{
|
||||
if (addsearchpath(path) == -2)
|
||||
if (Bmkdir(path, S_IRWXU) == 0)
|
||||
addsearchpath(path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (g_addonNum)
|
||||
G_LoadAddon();
|
||||
|
||||
const char *grpfile;
|
||||
int32_t i;
|
||||
|
||||
if ((i = G_LoadGrpDependencyChain(g_selectedGrp)) != -1)
|
||||
{
|
||||
grpfile = g_selectedGrp->filename;
|
||||
|
||||
//clearGrpNamePtr();
|
||||
//g_grpNamePtr = dup_filename(grpfile);
|
||||
|
||||
grpinfo_t const * const type = g_selectedGrp->type;
|
||||
|
||||
g_gameType = type->game;
|
||||
g_gameNamePtr = type->name;
|
||||
|
||||
//if (type->scriptname && g_scriptNamePtr == NULL)
|
||||
// g_scriptNamePtr = dup_filename(type->scriptname);
|
||||
|
||||
if (type->defname && g_defNamePtr == NULL)
|
||||
g_defNamePtr = dup_filename(type->defname);
|
||||
|
||||
if (type->rtsname)
|
||||
RTS_Init(type->rtsname);
|
||||
}
|
||||
else
|
||||
{
|
||||
grpfile = G_GrpFile();
|
||||
i = G_TryLoadingGrp(grpfile);
|
||||
}
|
||||
|
||||
if (G_AllowAutoload())
|
||||
{
|
||||
G_LoadGroupsInDir("autoload");
|
||||
|
||||
if (i != -1)
|
||||
G_DoAutoload(grpfile);
|
||||
}
|
||||
|
||||
if (g_modDir[0] != '/')
|
||||
G_LoadGroupsInDir(g_modDir);
|
||||
|
||||
if (g_defNamePtr == NULL)
|
||||
{
|
||||
const char *tmpptr = getenv("DUKE3DDEF");
|
||||
if (tmpptr)
|
||||
{
|
||||
clearDefNamePtr();
|
||||
g_defNamePtr = dup_filename(tmpptr);
|
||||
initprintf("Using \"%s\" as definitions file\n", g_defNamePtr);
|
||||
}
|
||||
}
|
||||
|
||||
loaddefinitions_game(G_DefFile(), TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void G_LoadAddon(void)
|
||||
{
|
||||
int32_t crc = 0; // compiler-happy
|
||||
|
||||
switch (g_addonNum)
|
||||
{
|
||||
case ADDON_DUKEDC:
|
||||
crc = DUKEDC_CRC;
|
||||
break;
|
||||
case ADDON_NWINTER:
|
||||
crc = DUKENW_CRC;
|
||||
break;
|
||||
case ADDON_CARIBBEAN:
|
||||
crc = DUKECB_CRC;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!crc) return;
|
||||
|
||||
grpfile_t const * const grp = FindGroup(crc);
|
||||
|
||||
if (grp)
|
||||
g_selectedGrp = grp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////
|
||||
|
||||
|
||||
// loads all group (grp, zip, pk3/4) files in the given directory
|
||||
void G_LoadGroupsInDir(const char *dirname)
|
||||
{
|
||||
static const char *extensions[] = { "*.grp", "*.zip", "*.ssi", "*.pk3", "*.pk4" };
|
||||
char buf[BMAX_PATH];
|
||||
fnlist_t fnlist = FNLIST_INITIALIZER;
|
||||
|
||||
for (auto & extension : extensions)
|
||||
{
|
||||
CACHE1D_FIND_REC *rec;
|
||||
|
||||
fnlist_getnames(&fnlist, dirname, extension, -1, 0);
|
||||
|
||||
for (rec=fnlist.findfiles; rec; rec=rec->next)
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/%s", dirname, rec->name);
|
||||
initprintf("Using group file \"%s\".\n", buf);
|
||||
initgroupfile(buf);
|
||||
}
|
||||
|
||||
fnlist_clearnames(&fnlist);
|
||||
}
|
||||
}
|
||||
|
||||
void G_DoAutoload(const char *dirname)
|
||||
{
|
||||
char buf[BMAX_PATH];
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "autoload/%s", dirname);
|
||||
G_LoadGroupsInDir(buf);
|
||||
}
|
||||
|
||||
//////////
|
||||
|
||||
void G_LoadLookups(void)
|
||||
{
|
||||
int32_t j;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue