Skip to content

Commit

Permalink
loadIWAD is now part of MasterDir
Browse files Browse the repository at this point in the history
  • Loading branch information
ioan-chera committed Nov 3, 2023
1 parent 2cd5290 commit 560db2b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/WadData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "WadData.h"
#include "m_config.h"
#include "m_loadsave.h"
#include "w_wad.h"

//
Expand Down Expand Up @@ -72,7 +73,7 @@ void WadData::reloadResources(const LoadingData &loading, const ConfigData &conf
newWad.master.MasterDir_CloseAll();

// TODO: check result
newWad.Main_LoadIWAD(loading);
newWad.master.loadIWAD(loading.iwadName);

// load all resource wads
for(const std::shared_ptr<Wad_file> &wad : resourceWads)
Expand Down
2 changes: 1 addition & 1 deletion src/WadData.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ struct LumpNameCompare
class MasterDir
{
public:
bool loadIWAD(const fs::path &iwadName);
void RemoveEditWad();
void ReplaceEditWad(const std::shared_ptr<Wad_file> &wad);
void MasterDir_Add(const std::shared_ptr<Wad_file> &wad);
Expand Down Expand Up @@ -191,7 +192,6 @@ struct WadData
return const_cast<Img_c *>(getSprite(config, type, loading));
}

bool Main_LoadIWAD(const LoadingData &loading);
void reloadResources(const LoadingData &loading, const ConfigData &config, const std::vector<std::shared_ptr<Wad_file>> &resourceWads);

ImageSet images;
Expand Down
13 changes: 6 additions & 7 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -804,20 +804,19 @@ void Main_Loop()
}


bool WadData::Main_LoadIWAD(const LoadingData &loading)
bool MasterDir::loadIWAD(const fs::path &iwadName)
{
// Load the IWAD (read only).
// The filename has been checked in DetermineIWAD().
std::shared_ptr<Wad_file> wad = Wad_file::Open(loading.iwadName,
WadOpenMode::read);
std::shared_ptr<Wad_file> wad = Wad_file::Open(iwadName, WadOpenMode::read);
if (!wad)
{
gLog.printf("Failed to open game IWAD: %s\n", loading.iwadName.u8string().c_str());
gLog.printf("Failed to open game IWAD: %s\n", iwadName.u8string().c_str());
return false;
}
master.game_wad = wad;
game_wad = wad;

master.MasterDir_Add(master.game_wad);
MasterDir_Add(game_wad);
return true;
}

Expand Down Expand Up @@ -1170,7 +1169,7 @@ int main(int argc, char *argv[])
// temporarily load the iwad, the following few functions need it.
// it will get loaded again in Main_LoadResources().
// TODO: check result
gInstance.wad.Main_LoadIWAD(gInstance.loaded);
gInstance.wad.master.loadIWAD(gInstance.loaded.iwadName);


// load the initial level
Expand Down

0 comments on commit 560db2b

Please sign in to comment.