P_AddWadFile: Remove useless firstmapname param, clean up map searching code

This commit is contained in:
Monster Iestyn 2018-01-04 20:15:44 +00:00
parent 29d605a104
commit b0d0738fb6
4 changed files with 10 additions and 17 deletions

View File

@ -3066,7 +3066,7 @@ static void Command_Addfile(void)
// Add file on your client directly if it is trivial, or you aren't in a netgame.
if (!(netgame || multiplayer) || musiconly)
{
P_AddWadFile(fn, NULL);
P_AddWadFile(fn);
return;
}
@ -3235,7 +3235,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
ncs = findfile(filename,md5sum,true);
if (ncs != FS_FOUND || !P_AddWadFile(filename, NULL))
if (ncs != FS_FOUND || !P_AddWadFile(filename))
{
Command_ExitGame_f();
if (ncs == FS_FOUND)

View File

@ -423,7 +423,7 @@ void CL_LoadServerFiles(void)
continue; // Already loaded
else if (fileneeded[i].status == FS_FOUND)
{
P_AddWadFile(fileneeded[i].filename, NULL);
P_AddWadFile(fileneeded[i].filename);
G_SetGameModified(true);
fileneeded[i].status = FS_OPEN;
}

View File

@ -3133,7 +3133,7 @@ boolean P_RunSOC(const char *socfilename)
lumpnum_t lump;
if (strstr(socfilename, ".soc") != NULL)
return P_AddWadFile(socfilename, NULL);
return P_AddWadFile(socfilename);
lump = W_CheckNumForName(socfilename);
if (lump == LUMPERROR)
@ -3214,13 +3214,13 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l
// Add a wadfile to the active wad files,
// replace sounds, musics, patches, textures, sprites and maps
//
boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
boolean P_AddWadFile(const char *wadfilename)
{
size_t i, j, sreplaces = 0, mreplaces = 0, digmreplaces = 0;
UINT16 numlumps, wadnum;
INT16 firstmapreplaced = 0, num;
char *name;
lumpinfo_t *lumpinfo;
boolean mapsadded = false;
boolean replacedcurrentmap = false;
// Vars to help us with the position start and amount of each resource type.
@ -3354,10 +3354,9 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
for (i = 0; i < numlumps; i++, lumpinfo++)
{
name = lumpinfo->name;
num = firstmapreplaced;
if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers
{
INT16 num;
if (name[5]!='\0')
continue;
num = (INT16)M_MapNumber(name[3], name[4]);
@ -3367,16 +3366,10 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
replacedcurrentmap = true;
CONS_Printf("%s\n", name);
}
if (num && (num < firstmapreplaced || !firstmapreplaced))
{
firstmapreplaced = num;
if (firstmapname)
*firstmapname = name;
mapsadded = true;
}
}
if (!firstmapreplaced)
if (!mapsadded)
CONS_Printf(M_GetText("No maps added\n"));
// reload status bar (warning should have valid player!)

View File

@ -59,7 +59,7 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum);
#endif
void P_LoadThingsOnly(void);
boolean P_SetupLevel(boolean skipprecip);
boolean P_AddWadFile(const char *wadfilename, char **firstmapname);
boolean P_AddWadFile(const char *wadfilename);
boolean P_RunSOC(const char *socfilename);
void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num);
void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num);