Skip to content

Commit

Permalink
Preparing to drop Error()
Browse files Browse the repository at this point in the history
  • Loading branch information
captainurist committed Oct 31, 2023
1 parent b437a00 commit b7beec8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
25 changes: 10 additions & 15 deletions src/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,31 +670,26 @@ void FinalInitialization() {
pIcons_LOD->reserveLoadedTextures();
}

bool MM7_LoadLods() {
void MM7_LoadLods() {
engine->_gameResourceManager = std::make_unique<GameResourceManager>();
engine->_gameResourceManager->openGameResources();

pIcons_LOD = new LodTextureCache;
if (!pIcons_LOD->open(makeDataPath("data", "icons.lod"), "icons")) {
Error(localization->GetString(LSTR_PLEASE_REINSTALL), localization->GetString(LSTR_REINSTALL_NECESSARY));
return false;
}
pIcons_LOD->open(makeDataPath("data", "icons.lod"), "icons");

pBitmaps_LOD = new LodTextureCache;
if (!pBitmaps_LOD->open(makeDataPath("data", "bitmaps.lod"), "bitmaps")) {
Error(localization->GetString(LSTR_PLEASE_REINSTALL), localization->GetString(LSTR_REINSTALL_NECESSARY));
return false;
}
pBitmaps_LOD->open(makeDataPath("data", "bitmaps.lod"), "bitmaps");

pSprites_LOD = new LodSpriteCache;
if (!pSprites_LOD->open(makeDataPath("data", "sprites.lod"), "sprites08")) {
Error(localization->GetString(LSTR_PLEASE_REINSTALL), localization->GetString(LSTR_REINSTALL_NECESSARY));
return false;
}
pSprites_LOD->open(makeDataPath("data", "sprites.lod"), "sprites08");

pPaletteManager->load(pBitmaps_LOD);
// TODO(captainurist):
// on error in `open` we had this:
// Error(localization->GetString(LSTR_PLEASE_REINSTALL), localization->GetString(LSTR_REINSTALL_NECESSARY));
// however, at this point localization isn't initialized yet, so this was a guaranteed crash.
// Implement proper user-facing error reporting!

return true;
pPaletteManager->load(pBitmaps_LOD);
}

//----- (004651F4) --------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/Engine/LodTextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ LodTextureCache::~LodTextureCache() {
}
}

bool LodTextureCache::open(const std::string &pFilename, const std::string &pFolderName) {
void LodTextureCache::open(const std::string &pFilename, const std::string &pFolderName) {
_reader.open(pFilename);
return true;
}

void LodTextureCache::reserveLoadedTextures() {
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/LodTextureCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LodTextureCache {
LodTextureCache();
~LodTextureCache();

bool open(const std::string &pFilename, const std::string &pFolderName);
void open(const std::string &pFilename, const std::string &pFolderName);

void reserveLoadedTextures();
void releaseUnreserved();
Expand Down

0 comments on commit b7beec8

Please sign in to comment.