mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-07 08:52:01 +00:00
Don't I_Error on startup files only if a file was added twice
This commit is contained in:
parent
ce3a79e51a
commit
57492347ed
4 changed files with 28 additions and 29 deletions
|
@ -1205,12 +1205,7 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
// load wad, including the main wad file
|
// load wad, including the main wad file
|
||||||
CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
|
CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
|
||||||
if (!W_InitMultipleFiles(startupwadfiles, mainwads))
|
W_InitMultipleFiles(startupwadfiles, mainwads);
|
||||||
#ifdef _DEBUG
|
|
||||||
CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
|
|
||||||
#else
|
|
||||||
I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
|
|
||||||
#endif
|
|
||||||
D_CleanFile();
|
D_CleanFile();
|
||||||
|
|
||||||
#ifndef DEVELOP // md5s last updated 06/12/19 (ddmmyy)
|
#ifndef DEVELOP // md5s last updated 06/12/19 (ddmmyy)
|
||||||
|
|
|
@ -3393,10 +3393,9 @@ boolean P_AddWadFile(const char *wadfilename)
|
||||||
// UINT16 mapPos, mapNum = 0;
|
// UINT16 mapPos, mapNum = 0;
|
||||||
|
|
||||||
// Init file.
|
// Init file.
|
||||||
if ((numlumps = W_InitFile(wadfilename, false)) == INT16_MAX)
|
if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX)
|
||||||
{
|
{
|
||||||
refreshdirmenu |= REFRESHDIR_NOTLOADED;
|
refreshdirmenu |= REFRESHDIR_NOTLOADED;
|
||||||
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
40
src/w_wad.c
40
src/w_wad.c
|
@ -637,6 +637,21 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
|
||||||
return lumpinfo;
|
return lumpinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static UINT16 W_InitFileError (const char *filename, boolean exitworthy)
|
||||||
|
{
|
||||||
|
if (exitworthy)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
|
||||||
|
#else
|
||||||
|
I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), filename);
|
||||||
|
return INT16_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate a wadfile, setup the lumpinfo (directory) and
|
// Allocate a wadfile, setup the lumpinfo (directory) and
|
||||||
// lumpcache, add the wadfile to the current active wadfiles
|
// lumpcache, add the wadfile to the current active wadfiles
|
||||||
//
|
//
|
||||||
|
@ -648,7 +663,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
|
||||||
//
|
//
|
||||||
// Can now load dehacked files (.soc)
|
// Can now load dehacked files (.soc)
|
||||||
//
|
//
|
||||||
UINT16 W_InitFile(const char *filename, boolean mainfile)
|
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
|
||||||
{
|
{
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
lumpinfo_t *lumpinfo = NULL;
|
lumpinfo_t *lumpinfo = NULL;
|
||||||
|
@ -681,12 +696,12 @@ UINT16 W_InitFile(const char *filename, boolean mainfile)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n"));
|
CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n"));
|
||||||
refreshdirmenu |= REFRESHDIR_MAX;
|
refreshdirmenu |= REFRESHDIR_MAX;
|
||||||
return INT16_MAX;
|
return W_InitFileError(filename, startup);
|
||||||
}
|
}
|
||||||
|
|
||||||
// open wad file
|
// open wad file
|
||||||
if ((handle = W_OpenWadFile(&filename, true)) == NULL)
|
if ((handle = W_OpenWadFile(&filename, true)) == NULL)
|
||||||
return INT16_MAX;
|
return W_InitFileError(filename, startup);
|
||||||
|
|
||||||
// Check if wad files will overflow fileneededbuffer. Only the filename part
|
// Check if wad files will overflow fileneededbuffer. Only the filename part
|
||||||
// is send in the packet; cf.
|
// is send in the packet; cf.
|
||||||
|
@ -701,7 +716,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile)
|
||||||
refreshdirmenu |= REFRESHDIR_MAX;
|
refreshdirmenu |= REFRESHDIR_MAX;
|
||||||
if (handle)
|
if (handle)
|
||||||
fclose(handle);
|
fclose(handle);
|
||||||
return INT16_MAX;
|
return W_InitFileError(filename, startup);
|
||||||
}
|
}
|
||||||
|
|
||||||
packetsizetally = packetsize;
|
packetsizetally = packetsize;
|
||||||
|
@ -722,7 +737,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile)
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename);
|
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename);
|
||||||
if (handle)
|
if (handle)
|
||||||
fclose(handle);
|
fclose(handle);
|
||||||
return INT16_MAX;
|
return W_InitFileError(filename, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -750,7 +765,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile)
|
||||||
if (lumpinfo == NULL)
|
if (lumpinfo == NULL)
|
||||||
{
|
{
|
||||||
fclose(handle);
|
fclose(handle);
|
||||||
return INT16_MAX;
|
return W_InitFileError(filename, startup);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -822,10 +837,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile)
|
||||||
* backwards, so a later file overrides all earlier ones.
|
* backwards, so a later file overrides all earlier ones.
|
||||||
*
|
*
|
||||||
* \param filenames A null-terminated list of files to use.
|
* \param filenames A null-terminated list of files to use.
|
||||||
* \return 1 if base files were loaded, 0 if at least one was missing or
|
|
||||||
* invalid.
|
|
||||||
*/
|
*/
|
||||||
INT32 W_InitMultipleFiles(char **filenames, UINT16 mainfiles)
|
void W_InitMultipleFiles(char **filenames, UINT16 mainfiles)
|
||||||
{
|
{
|
||||||
// open all the files, load headers, and count lumps
|
// open all the files, load headers, and count lumps
|
||||||
numwadfiles = 0;
|
numwadfiles = 0;
|
||||||
|
@ -834,15 +847,8 @@ INT32 W_InitMultipleFiles(char **filenames, UINT16 mainfiles)
|
||||||
for (; *filenames; filenames++)
|
for (; *filenames; filenames++)
|
||||||
{
|
{
|
||||||
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
|
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
|
||||||
if (W_InitFile(*filenames, numwadfiles < mainfiles) == INT16_MAX)
|
W_InitFile(*filenames, numwadfiles < mainfiles, true);
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames);
|
|
||||||
if (numwadfiles < mainfiles)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make sure a lump number is valid.
|
/** Make sure a lump number is valid.
|
||||||
|
|
|
@ -127,11 +127,10 @@ void W_Shutdown(void);
|
||||||
// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened
|
// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened
|
||||||
FILE *W_OpenWadFile(const char **filename, boolean useerrors);
|
FILE *W_OpenWadFile(const char **filename, boolean useerrors);
|
||||||
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
|
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
|
||||||
UINT16 W_InitFile(const char *filename, boolean mainfile);
|
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup);
|
||||||
|
|
||||||
// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise,
|
// W_InitMultipleFiles exits if a file was not found, but not if all is okay.
|
||||||
// so that it stops with a message if a file was not found, but not if all is okay.
|
void W_InitMultipleFiles(char **filenames, UINT16 mainfiles);
|
||||||
INT32 W_InitMultipleFiles(char **filenames, UINT16 mainfiles);
|
|
||||||
|
|
||||||
const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
|
const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
|
||||||
const char *W_CheckNameForNum(lumpnum_t lumpnum);
|
const char *W_CheckNameForNum(lumpnum_t lumpnum);
|
||||||
|
|
Loading…
Reference in a new issue