Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load extras.wad before IWAD #2078

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,8 +1829,20 @@ void D_DoomMain(void)

LoadBaseFile();

boolean extras_wad = false;
const char *extras_path = D_FindWADByName("extras.wad");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to free() this after use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7c7d285

if (extras_path)
{
extras_wad = W_ExtrasWad(extras_path);
}

IdentifyVersion();

if (extras_wad)
{
array_push(wadfiles, "extras.wad");
}

// [FG] emulate a specific version of Doom
InitGameVersion();

Expand Down
11 changes: 11 additions & 0 deletions src/w_wad.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ static void AddDirs(w_module_t *module, w_handle_t handle, const char *base)
}
}

boolean W_ExtrasWad(const char *path)
{
w_handle_t handle = {0};
if (w_file_module.Open(path, &handle) == W_FILE)
{
array_clear(wadfiles); // don't register it before IWAD
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This screams "bug!" all over the place. I don't even understand what happens here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual lump table is in lumpinfo. wadfiles is just a list of WAD names, for wadfiles[0] checks or save/autoload directories, not that important.

In w_file.Open() the name of the WAD is recorded in the wadfiles array, so we delete it and add it back after IWAD, so that other checks work. Ugly hack, but if we decide to implement an in-game launcher, we will have to redo this system anyway to load WADs on the fly.

return true;
}
return false;
}

boolean W_AddPath(const char *path)
{
static int priority;
Expand Down
1 change: 1 addition & 0 deletions src/w_wad.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ extern void **lumpcache;
extern const char **wadfiles;

boolean W_InitBaseFile(const char *path);
boolean W_ExtrasWad(const char *path);
void W_AddBaseDir(const char *path);
boolean W_AddPath(const char *path);

Expand Down