diff --git a/src/audio/aldatasource.h b/src/audio/aldatasource.h index 779e624d..eb832599 100644 --- a/src/audio/aldatasource.h +++ b/src/audio/aldatasource.h @@ -23,6 +23,7 @@ #define ALDATASOURCE_H #include "al-util.h" +#include struct ALDataSource { diff --git a/src/display/bitmap.cpp b/src/display/bitmap.cpp index 00403fdf..ee1d3891 100644 --- a/src/display/bitmap.cpp +++ b/src/display/bitmap.cpp @@ -612,15 +612,24 @@ Bitmap::Bitmap(Exception &exception, const char *filename) if (shState->config().enableHires && filenameStd.compare(0, hiresPrefix.size(), hiresPrefix) != 0) { // Look for a high-res version of the file. std::string hiresFilename = hiresPrefix + filenameStd; - try { - hiresBitmap = new Bitmap(hiresFilename.c_str()); - hiresBitmap->setLores(this); - } - catch (const Exception &e) + Exception e; + hiresBitmap = new Bitmap(e, hiresFilename.c_str()); + if (e.is_error()) { Debug() << "No high-res Bitmap found at" << hiresFilename; + delete hiresBitmap; hiresBitmap = nullptr; } + else + { + hiresBitmap->setLores(e, this); + if (e.is_error()) + { + Debug() << "No high-res Bitmap found at" << hiresFilename; + delete hiresBitmap; + hiresBitmap = nullptr; + } + } } #endif // MKXPZ_RETRO @@ -2668,7 +2677,7 @@ void Bitmap::drawText(Exception &exception, const IntRect &rect, const char *str GUARD(font = p->font->getSdlFont(exception)); #else TTF_Font *font; - GUARD(font = p->font->getSdlFont()); + GUARD(font = p->font->getSdlFont(exception)); #endif // MKXPZ_RETRO const Color &fontColor = p->font->getColor(); const Color &outColor = p->font->getOutColor(); @@ -2863,7 +2872,8 @@ IntRect Bitmap::textSize(Exception &exception, const char *str) GUARD_V(IntRect(), rect = textRect(exception, str, p->font->isSolid())); return IntRect(0, 0, rect.w, rect.h); #else - TTF_Font *font = p->font->getSdlFont(); + TTF_Font *font; + GUARD_V(IntRect(), font = p->font->getSdlFont(exception)); int w, h; TTF_SizeUTF8(font, str, &w, &h); @@ -2899,7 +2909,7 @@ void Bitmap::setInitFont(Font *value) if (hiresFont && hiresFont != &shState->defaultFont()) { // Disable the illegal font size check when creating a high-res font. - hiresFont->setSize(hiresFont->getSize() * p->selfHires->width() / width(), false); + hiresFont->setSizeNoCheck(hiresFont->getSize() * p->selfHires->width() / width()); } } #endif // MKXPZ_RETRO diff --git a/src/main.cpp b/src/main.cpp index 92cbe9a0..8c5e78f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -138,9 +138,9 @@ int rgssThreadFun(void *userdata) { alcMakeContextCurrent(alcCtx); - try { - SharedState::initInstance(threadData); - } catch (const Exception &exc) { + Exception exc; + SharedState::initInstance(exc, threadData); + if (exc.is_error()) { rgssThreadError(threadData, exc.msg); alcDestroyContext(alcCtx); @@ -521,9 +521,9 @@ static SDL_GLContext initGL(SDL_Window *win, Config &conf, return 0; } - try { - initGLFunctions(); - } catch (const Exception &exc) { + Exception exc; + initGLFunctions(exc); + if (exc.is_error()) { GLINIT_SHOWERROR(exc.msg); SDL_GL_DeleteContext(glCtx); diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index cc98c0d3..4a179b6a 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -149,20 +149,38 @@ struct SharedStatePrivate std::string archPath = config.execName + gameArchExt(); for (size_t i = 0; i < config.patches.size(); ++i) - fileSystem.addPath(config.patches[i].c_str()); + { + Exception e; + fileSystem.addPath(e, config.patches[i].c_str()); + if (e.is_error()) + throw e; + } /* Check if a game archive exists */ FILE *tmp = fopen(archPath.c_str(), "rb"); if (tmp) { - fileSystem.addPath(archPath.c_str()); + Exception e; + fileSystem.addPath(e, archPath.c_str()); fclose(tmp); + if (e.is_error()) + throw e; } - fileSystem.addPath("."); + { + Exception e; + fileSystem.addPath(e, "."); + if (e.is_error()) + throw e; + } for (size_t i = 0; i < config.rtps.size(); ++i) - fileSystem.addPath(config.rtps[i].c_str()); + { + Exception e; + fileSystem.addPath(e, config.rtps[i].c_str()); + if (e.is_error()) + throw e; + } if (config.pathCache) fileSystem.createPathCache();