- replaced wadlist_t with an array of FStrings and added a list parameter to

everything that eventually calls D_AddFile. Also create the list of files
  loaded on the command line separately to allow further checks on them.


SVN r2072 (trunk)
This commit is contained in:
Christoph Oelckers 2010-01-01 12:40:47 +00:00
parent bf7ed6258b
commit 370eff9014
7 changed files with 93 additions and 86 deletions

View file

@ -1,4 +1,7 @@
January 1, 2010 (Changes by Graf Zahl) January 1, 2010 (Changes by Graf Zahl)
- replaced wadlist_t with an array of FStrings and added a list parameter to
everything that eventually calls D_AddFile. Also create the list of files
loaded on the command line separately to allow further checks on them.
- fixed: The node builder did not check if all segs could be split properly. - fixed: The node builder did not check if all segs could be split properly.
Also removed some fudging that tried to work around this case but produced Also removed some fudging that tried to work around this case but produced
a broken BSP tree on other maps. a broken BSP tree on other maps.

View file

@ -1376,6 +1376,7 @@ void FConsoleAlias::SafeDelete ()
static BYTE PullinBad = 2; static BYTE PullinBad = 2;
static const char *PullinFile; static const char *PullinFile;
extern TArray<FString> allwads;
int C_ExecFile (const char *file, bool usePullin) int C_ExecFile (const char *file, bool usePullin)
{ {
@ -1492,7 +1493,7 @@ CCMD (pullin)
FixPathSeperator (path); FixPathSeperator (path);
} }
} }
D_AddFile (path); D_AddFile (allwads, path);
if (path != argv[i]) if (path != argv[i])
{ {
delete[] path; delete[] path;

View file

@ -484,7 +484,7 @@ static int CheckIWAD (const char *doomwaddir, WadStuff *wads)
// //
//========================================================================== //==========================================================================
static EIWADType IdentifyVersion (const char *zdoom_wad) static EIWADType IdentifyVersion (TArray<FString> &wadfiles, const char *zdoom_wad)
{ {
WadStuff wads[countof(IWADNames)]; WadStuff wads[countof(IWADNames)];
size_t foundwads[NUM_IWAD_TYPES] = { 0 }; size_t foundwads[NUM_IWAD_TYPES] = { 0 };
@ -630,14 +630,14 @@ static EIWADType IdentifyVersion (const char *zdoom_wad)
exit (0); exit (0);
// zdoom.pk3 must always be the first file loaded and the IWAD second. // zdoom.pk3 must always be the first file loaded and the IWAD second.
D_AddFile (zdoom_wad); D_AddFile (wadfiles, zdoom_wad);
if (wads[pickwad].Type == IWAD_HexenDK) if (wads[pickwad].Type == IWAD_HexenDK)
{ // load hexen.wad before loading hexdd.wad { // load hexen.wad before loading hexdd.wad
D_AddFile (wads[foundwads[IWAD_Hexen]-1].Path); D_AddFile (wadfiles, wads[foundwads[IWAD_Hexen]-1].Path);
} }
D_AddFile (wads[pickwad].Path); D_AddFile (wadfiles, wads[pickwad].Path);
if (wads[pickwad].Type == IWAD_Strife) if (wads[pickwad].Type == IWAD_Strife)
{ // Try to load voices.wad along with strife1.wad { // Try to load voices.wad along with strife1.wad
@ -653,16 +653,16 @@ static EIWADType IdentifyVersion (const char *zdoom_wad)
path = FString (wads[pickwad].Path.GetChars(), lastslash + 1); path = FString (wads[pickwad].Path.GetChars(), lastslash + 1);
} }
path += "voices.wad"; path += "voices.wad";
D_AddFile (path); D_AddFile (wadfiles, path);
} }
return wads[pickwad].Type; return wads[pickwad].Type;
} }
const IWADInfo *D_FindIWAD(const char *basewad) const IWADInfo *D_FindIWAD(TArray<FString> &wadfiles, const char *basewad)
{ {
EIWADType iwadType = IdentifyVersion(basewad); EIWADType iwadType = IdentifyVersion(wadfiles, basewad);
gameiwad = iwadType; gameiwad = iwadType;
const IWADInfo *iwad_info = &IWADInfos[iwadType]; const IWADInfo *iwad_info = &IWADInfos[iwadType];
I_SetIWADInfo(iwad_info); I_SetIWADInfo(iwad_info);

View file

@ -118,7 +118,7 @@ extern void R_ExecuteSetViewSize ();
extern void G_NewInit (); extern void G_NewInit ();
extern void SetupPlayerClasses (); extern void SetupPlayerClasses ();
extern bool CheckCheatmode (); extern bool CheckCheatmode ();
extern const IWADInfo *D_FindIWAD(const char *basewad); const IWADInfo *D_FindIWAD(TArray<FString> &wadfiles, const char *basewad);
// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@ -182,7 +182,7 @@ CVAR (Int, wipetype, 1, CVAR_ARCHIVE);
CVAR (Int, snd_drawoutput, 0, 0); CVAR (Int, snd_drawoutput, 0, 0);
bool DrawFSHUD; // [RH] Draw fullscreen HUD? bool DrawFSHUD; // [RH] Draw fullscreen HUD?
wadlist_t *wadfiles; // [RH] remove limit on # of loaded wads TArray<FString> allwads;
bool devparm; // started game with -devparm bool devparm; // started game with -devparm
const char *D_DrawIcon; // [RH] Patch name of icon to draw on next refresh const char *D_DrawIcon; // [RH] Patch name of icon to draw on next refresh
int NoWipe; // [RH] Allow wipe? (Needs to be set each time) int NoWipe; // [RH] Allow wipe? (Needs to be set each time)
@ -204,7 +204,6 @@ cycle_t FrameCycles;
// PRIVATE DATA DEFINITIONS ------------------------------------------------ // PRIVATE DATA DEFINITIONS ------------------------------------------------
static wadlist_t **wadtail = &wadfiles;
static int demosequence; static int demosequence;
static int pagetic; static int pagetic;
@ -1242,7 +1241,7 @@ CCMD (endgame)
// //
//========================================================================== //==========================================================================
void D_AddFile (const char *file, bool check) void D_AddFile (TArray<FString> &wadfiles, const char *file, bool check)
{ {
if (file == NULL) if (file == NULL)
{ {
@ -1259,12 +1258,10 @@ void D_AddFile (const char *file, bool check)
} }
file = f; file = f;
} }
wadlist_t *wad = (wadlist_t *)M_Malloc (sizeof(*wad) + strlen(file));
*wadtail = wad; FString f = file;
wad->next = NULL; FixPathSeperator(f);
strcpy (wad->name, file); wadfiles.Push(f);
wadtail = &wad->next;
} }
//========================================================================== //==========================================================================
@ -1273,13 +1270,13 @@ void D_AddFile (const char *file, bool check)
// //
//========================================================================== //==========================================================================
void D_AddWildFile (const char *value) void D_AddWildFile (TArray<FString> &wadfiles, const char *value)
{ {
const char *wadfile = BaseFileSearch (value, ".wad"); const char *wadfile = BaseFileSearch (value, ".wad");
if (wadfile != NULL) if (wadfile != NULL)
{ {
D_AddFile (wadfile); D_AddFile (wadfiles, wadfile);
} }
else else
{ // Try pattern matching { // Try pattern matching
@ -1309,12 +1306,12 @@ void D_AddWildFile (const char *value)
{ {
if (sep == NULL) if (sep == NULL)
{ {
D_AddFile (I_FindName (&findstate)); D_AddFile (wadfiles, I_FindName (&findstate));
} }
else else
{ {
strcpy (sep+1, I_FindName (&findstate)); strcpy (sep+1, I_FindName (&findstate));
D_AddFile (path); D_AddFile (wadfiles, path);
} }
} }
} while (I_FindNext (handle, &findstate) == 0); } while (I_FindNext (handle, &findstate) == 0);
@ -1331,7 +1328,7 @@ void D_AddWildFile (const char *value)
// //
//========================================================================== //==========================================================================
void D_AddConfigWads (const char *section) void D_AddConfigWads (TArray<FString> &wadfiles, const char *section)
{ {
if (GameConfig->SetSection (section)) if (GameConfig->SetSection (section))
{ {
@ -1345,7 +1342,7 @@ void D_AddConfigWads (const char *section)
{ {
// D_AddWildFile resets GameConfig's position, so remember it // D_AddWildFile resets GameConfig's position, so remember it
GameConfig->GetPosition (pos); GameConfig->GetPosition (pos);
D_AddWildFile (value); D_AddWildFile (wadfiles, value);
// Reset GameConfig's position to get next wad // Reset GameConfig's position to get next wad
GameConfig->SetPosition (pos); GameConfig->SetPosition (pos);
} }
@ -1361,7 +1358,7 @@ void D_AddConfigWads (const char *section)
// //
//========================================================================== //==========================================================================
static void D_AddDirectory (const char *dir) static void D_AddDirectory (TArray<FString> &wadfiles, const char *dir)
{ {
char curdir[PATH_MAX]; char curdir[PATH_MAX];
@ -1391,7 +1388,7 @@ static void D_AddDirectory (const char *dir)
if (!(I_FindAttr (&findstate) & FA_DIREC)) if (!(I_FindAttr (&findstate) & FA_DIREC))
{ {
strcpy (skindir + stuffstart, I_FindName (&findstate)); strcpy (skindir + stuffstart, I_FindName (&findstate));
D_AddFile (skindir); D_AddFile (wadfiles, skindir);
} }
} while (I_FindNext (handle, &findstate) == 0); } while (I_FindNext (handle, &findstate) == 0);
I_FindClose (handle); I_FindClose (handle);
@ -1584,6 +1581,53 @@ void D_MultiExec (DArgs *list, bool usePullin)
} }
} }
static void GetCmdLineFiles(TArray<FString> &wadfiles)
{
DArgs *files = Args->GatherFiles ("-file", ".wad", true);
DArgs *files1 = Args->GatherFiles (NULL, ".zip", false);
DArgs *files2 = Args->GatherFiles (NULL, ".pk3", false);
DArgs *files3 = Args->GatherFiles (NULL, ".txt", false);
if (files->NumArgs() > 0 || files1->NumArgs() > 0 || files2->NumArgs() > 0 || files3->NumArgs() > 0)
{
// Check for -file in shareware
if (gameinfo.flags & GI_SHAREWARE)
{
I_FatalError ("You cannot -file with the shareware version. Register!");
}
// the files gathered are wadfile/lump names
for (int i = 0; i < files->NumArgs(); i++)
{
D_AddWildFile (wadfiles, files->GetArg (i));
}
for (int i = 0; i < files1->NumArgs(); i++)
{
D_AddWildFile (wadfiles, files1->GetArg (i));
}
for (int i = 0; i < files2->NumArgs(); i++)
{
D_AddWildFile (wadfiles, files2->GetArg (i));
}
for (int i = 0; i < files3->NumArgs(); i++)
{
D_AddWildFile (wadfiles, files3->GetArg (i));
}
}
files->Destroy();
files1->Destroy();
files2->Destroy();
files3->Destroy();
}
static void CopyFiles(TArray<FString> &to, TArray<FString> &from)
{
unsigned int ndx = to.Reserve(from.Size());
for(unsigned i=0;i<from.Size(); i++)
{
to[ndx+i] = from[i];
}
}
//========================================================================== //==========================================================================
// //
// D_DoomMain // D_DoomMain
@ -1596,6 +1640,7 @@ void D_DoomMain (void)
char *v; char *v;
const char *wad; const char *wad;
DArgs *execFiles; DArgs *execFiles;
TArray<FString> pwads;
// Set the FPU precision to 53 significant bits. This is the default // Set the FPU precision to 53 significant bits. This is the default
// for Visual C++, but not for GCC, so some slight math variances // for Visual C++, but not for GCC, so some slight math variances
@ -1640,7 +1685,7 @@ void D_DoomMain (void)
// Load zdoom.pk3 alone so that we can get access to the internal gameinfos before // Load zdoom.pk3 alone so that we can get access to the internal gameinfos before
// the IWAD is known. // the IWAD is known.
const IWADInfo *iwad_info = D_FindIWAD(wad); const IWADInfo *iwad_info = D_FindIWAD(allwads, wad);
gameinfo.gametype = iwad_info->gametype; gameinfo.gametype = iwad_info->gametype;
gameinfo.flags = iwad_info->flags; gameinfo.flags = iwad_info->flags;
@ -1657,7 +1702,7 @@ void D_DoomMain (void)
// it for something else, so this gets to stay here. // it for something else, so this gets to stay here.
wad = BaseFileSearch ("zvox.wad", NULL); wad = BaseFileSearch ("zvox.wad", NULL);
if (wad) if (wad)
D_AddFile (wad); D_AddFile (allwads, wad);
// [RH] Add any .wad files in the skins directory // [RH] Add any .wad files in the skins directory
#ifdef unix #ifdef unix
@ -1666,27 +1711,27 @@ void D_DoomMain (void)
file = progdir; file = progdir;
#endif #endif
file += "skins"; file += "skins";
D_AddDirectory (file); D_AddDirectory (allwads, file);
#ifdef unix #ifdef unix
file = NicePath("~/" GAME_DIR "/skins"); file = NicePath("~/" GAME_DIR "/skins");
D_AddDirectory (file); D_AddDirectory (allwads, file);
#endif #endif
// Add common (global) wads // Add common (global) wads
D_AddConfigWads ("Global.Autoload"); D_AddConfigWads (allwads, "Global.Autoload");
// Add game-specific wads // Add game-specific wads
file = GameNames[gameinfo.gametype]; file = GameNames[gameinfo.gametype];
file += ".Autoload"; file += ".Autoload";
D_AddConfigWads (file); D_AddConfigWads (allwads, file);
// Add IWAD-specific wads // Add IWAD-specific wads
if (iwad_info->Autoname != NULL) if (iwad_info->Autoname != NULL)
{ {
file = iwad_info->Autoname; file = iwad_info->Autoname;
file += ".Autoload"; file += ".Autoload";
D_AddConfigWads(file); D_AddConfigWads(allwads, file);
} }
} }
@ -1703,43 +1748,13 @@ void D_DoomMain (void)
C_ExecCmdLineParams (); // [RH] do all +set commands on the command line C_ExecCmdLineParams (); // [RH] do all +set commands on the command line
DArgs *files = Args->GatherFiles ("-file", ".wad", true); GetCmdLineFiles(pwads);
DArgs *files1 = Args->GatherFiles (NULL, ".zip", false);
DArgs *files2 = Args->GatherFiles (NULL, ".pk3", false);
DArgs *files3 = Args->GatherFiles (NULL, ".txt", false);
if (files->NumArgs() > 0 || files1->NumArgs() > 0 || files2->NumArgs() > 0 || files3->NumArgs() > 0)
{
// Check for -file in shareware
if (gameinfo.flags & GI_SHAREWARE)
{
I_FatalError ("You cannot -file with the shareware version. Register!");
}
// the files gathered are wadfile/lump names CopyFiles(allwads, pwads);
for (int i = 0; i < files->NumArgs(); i++)
{
D_AddWildFile (files->GetArg (i));
}
for (int i = 0; i < files1->NumArgs(); i++)
{
D_AddWildFile (files1->GetArg (i));
}
for (int i = 0; i < files2->NumArgs(); i++)
{
D_AddWildFile (files2->GetArg (i));
}
for (int i = 0; i < files3->NumArgs(); i++)
{
D_AddWildFile (files3->GetArg (i));
}
}
files->Destroy();
files1->Destroy();
files2->Destroy();
files3->Destroy();
Printf ("W_Init: Init WADfiles.\n"); Printf ("W_Init: Init WADfiles.\n");
Wads.InitMultipleFiles (&wadfiles); Wads.InitMultipleFiles (allwads);
allwads.Clear();
// [RH] Initialize localizable strings. // [RH] Initialize localizable strings.
GStrings.LoadStrings (false); GStrings.LoadStrings (false);
@ -2043,7 +2058,7 @@ void D_DoomMain (void)
V_Init2(); V_Init2();
files = Args->GatherFiles ("-playdemo", ".lmp", false); DArgs *files = Args->GatherFiles ("-playdemo", ".lmp", false);
if (files->NumArgs() > 0) if (files->NumArgs() > 0)
{ {
singledemo = true; // quit after one demo singledemo = true; // quit after one demo

View file

@ -49,7 +49,7 @@ void D_PageTicker (void);
void D_PageDrawer (void); void D_PageDrawer (void);
void D_AdvanceDemo (void); void D_AdvanceDemo (void);
void D_StartTitle (void); void D_StartTitle (void);
void D_AddFile (const char *file, bool check = true); void D_AddFile (TArray<FString> &wadfiles, const char *file, bool check = true);
// [RH] Set this to something to draw an icon during the next screen refresh. // [RH] Set this to something to draw an icon during the next screen refresh.

View file

@ -160,7 +160,7 @@ void FWadCollection::DeleteAll ()
// //
//========================================================================== //==========================================================================
void FWadCollection::InitMultipleFiles (wadlist_t **filenames) void FWadCollection::InitMultipleFiles (TArray<FString> &filenames)
{ {
int numfiles; int numfiles;
@ -168,13 +168,10 @@ void FWadCollection::InitMultipleFiles (wadlist_t **filenames)
DeleteAll(); DeleteAll();
numfiles = 0; numfiles = 0;
while (*filenames) for(unsigned i=0;i<filenames.Size(); i++)
{ {
wadlist_t *next = (*filenames)->next;
int baselump = NumLumps; int baselump = NumLumps;
AddFile ((*filenames)->name); AddFile (filenames[i]);
M_Free (*filenames);
*filenames = next;
} }
NumLumps = LumpInfo.Size(); NumLumps = LumpInfo.Size();
@ -222,7 +219,7 @@ int FWadCollection::AddExternalFile(const char *filename)
// [RH] Removed reload hack // [RH] Removed reload hack
//========================================================================== //==========================================================================
void FWadCollection::AddFile (char *filename, FileReader *wadinfo) void FWadCollection::AddFile (const char *filename, FileReader *wadinfo)
{ {
int startlump; int startlump;
bool isdir = false; bool isdir = false;
@ -252,7 +249,6 @@ void FWadCollection::AddFile (char *filename, FileReader *wadinfo)
return; return;
} }
} }
FixPathSeperator(filename);
} }
Printf (" adding %s", filename); Printf (" adding %s", filename);

View file

@ -49,14 +49,6 @@ struct wadlump_t
#define PWAD_ID MAKE_ID('P','W','A','D') #define PWAD_ID MAKE_ID('P','W','A','D')
// [RH] Remove limit on number of WAD files
struct wadlist_t
{
wadlist_t *next;
char name[1]; // +size of string
};
extern wadlist_t *wadfiles;
// [RH] Namespaces from BOOM. // [RH] Namespaces from BOOM.
typedef enum { typedef enum {
ns_global = 0, ns_global = 0,
@ -153,8 +145,8 @@ public:
// The wadnum for the IWAD // The wadnum for the IWAD
enum { IWAD_FILENUM = 1 }; enum { IWAD_FILENUM = 1 };
void InitMultipleFiles (wadlist_t **filenames); void InitMultipleFiles (TArray<FString> &filenames);
void AddFile (char *filename, FileReader *wadinfo = NULL); void AddFile (const char *filename, FileReader *wadinfo = NULL);
int CheckIfWadLoaded (const char *name); int CheckIfWadLoaded (const char *name);
const char *GetWadName (int wadnum) const; const char *GetWadName (int wadnum) const;