Adjust PhysFS and OpenAL errors a bit

This commit is contained in:
Struma 2023-05-08 00:18:26 -04:00
parent 486e0b68d4
commit eb300a9ef1
2 changed files with 10 additions and 3 deletions

View file

@ -282,7 +282,14 @@ struct FileSystemPrivate {
static void throwPhysfsError(const char *desc) { static void throwPhysfsError(const char *desc) {
PHYSFS_ErrorCode ec = PHYSFS_getLastErrorCode(); PHYSFS_ErrorCode ec = PHYSFS_getLastErrorCode();
const char *englishStr = PHYSFS_getErrorByCode(ec); const char *englishStr;
if (ec == 0) {
// Sometimes on Windows PHYSFS_init can return null
// but the error code never changes
englishStr = "unknown error";
} else {
englishStr = PHYSFS_getErrorByCode(ec);
}
throw Exception(Exception::PHYSFSError, "%s: %s", desc, englishStr); throw Exception(Exception::PHYSFSError, "%s: %s", desc, englishStr);
} }

View file

@ -395,7 +395,7 @@ int main(int argc, char *argv[]) {
ALCdevice *alcDev = alcOpenDevice(0); ALCdevice *alcDev = alcOpenDevice(0);
if (!alcDev) { if (!alcDev) {
showInitError("Error opening OpenAL device"); showInitError("Could not detect an available audio device.");
SDL_DestroyWindow(win); SDL_DestroyWindow(win);
TTF_Quit(); TTF_Quit();
IMG_Quit(); IMG_Quit();
@ -517,7 +517,7 @@ static SDL_GLContext initGL(SDL_Window *win, Config &conf,
glCtx = SDL_GL_CreateContext(win); glCtx = SDL_GL_CreateContext(win);
if (!glCtx) { if (!glCtx) {
GLINIT_SHOWERROR(std::string("Error creating context: ") + SDL_GetError()); GLINIT_SHOWERROR(std::string("Could not create OpenGL context: ") + SDL_GetError());
return 0; return 0;
} }