Fix some compilation errors in standalone builds

This commit is contained in:
刘皓 2025-05-17 13:03:57 -04:00
parent 3fec509568
commit aef7eff511
No known key found for this signature in database
GPG key ID: 7901753DB465B711
4 changed files with 47 additions and 18 deletions

View file

@ -23,6 +23,7 @@
#define ALDATASOURCE_H
#include "al-util.h"
#include <string>
struct ALDataSource
{

View file

@ -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

View file

@ -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);

View file

@ -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();