From 749e97eebdee32b958da310faa7a1de682c11edc Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Thu, 28 May 2026 18:19:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B4=D0=B2=D0=B8=D0=B6=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bitmap.cpp | 14 ++++++++------ src/filesystem.cpp | 23 +++++++++-------------- src/graphics.cpp | 4 +--- src/main.cpp | 16 ++++++---------- src/screen.cpp | 4 ---- src/settingsmenu.cpp | 7 ++----- src/shader.h | 8 ++------ src/soundemitter.cpp | 5 +---- src/soundemitter.h | 4 +--- src/tileatlas.cpp | 3 +-- src/tilemap-common.h | 3 +-- src/tilemap.cpp | 4 +--- src/tilequad.h | 6 ++---- 13 files changed, 35 insertions(+), 66 deletions(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 10a36c5..c096466 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -47,9 +47,9 @@ #define GUARD_MEGA \ { \ - if (p->megaSurface) { \ - crash("Operation not supported for mega surfaces", Exception::MKXPError, true); \ - } \ + if (p->megaSurface) \ + throw Exception(Exception::MKXPError, \ + "Operation not supported for mega surfaces"); \ } #define OUTLINE_SIZE 1 @@ -229,7 +229,7 @@ Bitmap::Bitmap(const char *filename){ if (!imgSurf){ snprintf(msg, sizeof msg, "Error loading image '%s': %s", filename, SDL_GetError()); - crash(msg, Exception::SDLError, true); + throw Exception(Exception::SDLError, msg); } p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888); @@ -265,7 +265,8 @@ Bitmap::Bitmap(const char *filename){ Bitmap::Bitmap(int width, int height){ if (width <= 0 || height <= 0){ - crash("failed to create bitmap", Exception::RGSSError, true); + //rash("failed to create bitmap"); + throw Exception(Exception::RGSSError, "failed to create bitmap"); } TEXFBO tex = shState->texPool().request(width, height); @@ -410,7 +411,8 @@ void Bitmap::stretchBlt(const IntRect &destRect, const Bitmap &source, const Int } else{ /* Clipped blit */ - GLMeta::subRectImageUpload(blitTemp->w, bltRect.x - dstRect.x, bltRect.y - dstRect.y, bltRect.x, bltRect.y, bltRect.w, bltRect.h, blitTemp, GL_RGBA); + GLMeta::subRectImageUpload(blitTemp->w, bltRect.x - dstRect.x, bltRect.y - dstRect.y, + bltRect.x, bltRect.y, bltRect.w, bltRect.h, blitTemp, GL_RGBA); GLMeta::subRectImageEnd(); } diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 73805b5..5233277 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -54,7 +54,7 @@ struct SDLRWIoContext{ filename(filename) { if (!ops) - crash("Failed to open file", Exception::SDLError, true); + throw Exception(Exception::SDLError, "Failed to open file: %s", SDL_GetError()); } ~SDLRWIoContext(){ @@ -69,6 +69,7 @@ static SDL_IOStream *getSDLRWops(PHYSFS_Io *io){ } static PHYSFS_sint64 SDLRWIoRead(struct PHYSFS_Io *io, void *buf, PHYSFS_uint64 len){ + // return SDL_ReadIO(getSDLRWops(io), buf, 1, len); return SDL_ReadIO(getSDLRWops(io), buf, len); } @@ -118,7 +119,6 @@ static PHYSFS_Io *createSDLRWIo(const char *filename){ try{ ctx = new SDLRWIoContext(filename); }catch (const Exception &e){ - Debug() << "Failed mounting" << filename; return 0; } @@ -562,7 +562,6 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename){ void FileSystem::openRead(OpenHandler &handler, const char *filename){ char buffer[512]; - char msg[512]; size_t len = strcpySafe(buffer, filename, sizeof(buffer), -1); char *delim; @@ -588,7 +587,8 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename){ dir = buffer; } - OpenReadEnumData data(handler, file, len + buffer - delim - !root, p->havePathCache ? &p->pathCache : 0); + OpenReadEnumData data(handler, file, len + buffer - delim - !root, + p->havePathCache ? &p->pathCache : 0); if (p->havePathCache){ /* Get the list of files contained in this directory @@ -601,22 +601,17 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename){ PHYSFS_enumerate(dir, openReadEnumCB, &data); } - if (data.physfsError){ - snprintf(msg, sizeof msg, "PhysFS: %s", data.physfsError); - crash(msg, Exception::PHYSFSError, true); - } + if (data.physfsError) + throw Exception(Exception::PHYSFSError, "PhysFS: %s", data.physfsError); - if (data.matchCount == 0){ - snprintf(msg, sizeof msg, "NoFileError: %s", data.physfsError); - crash(msg, Exception::NoFileError, true); - } + if (data.matchCount == 0) + throw Exception(Exception::NoFileError, "%s", filename); } void FileSystem::openReadRaw(SDL_IOStream* &stream, const char *filename){ PHYSFS_File *handle = PHYSFS_openRead(filename); - if (!handle){ + if (!handle) throw Exception(Exception::NoFileError, "%s", filename); - } initReadOps(handle, stream); } diff --git a/src/graphics.cpp b/src/graphics.cpp index 863e2e2..ad44dc2 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -564,9 +564,7 @@ struct GraphicsPrivate{ } void metaBlitBufferFlippedScaled(){ - GLMeta::blitRectangle(IntRect(0, 0, scRes.x, scRes.y), - IntRect(scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y), - threadData->config.smoothScaling); + GLMeta::blitRectangle(IntRect(0, 0, scRes.x, scRes.y), IntRect(scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y), threadData->config.smoothScaling); } void redrawScreen(){ diff --git a/src/main.cpp b/src/main.cpp index 0090d6a..baee77e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -160,10 +160,6 @@ int rgssThreadFun(void *userdata){ return 0; } -static void showInitError(const std::string &msg){ - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error :(", msg.c_str(), 0); -} - static void setupWindowIcon(const Config &conf, SDL_Window *win){ SDL_IOStream *iconSrc; @@ -241,13 +237,13 @@ int main(int argc, char *argv[]){ #ifdef STEAM if (!STEAMSHIM_init()){ - crash("Could not initialize Steamworks API", Exception::MEOW, true); - return 0 + crash("Could not initialize Steamworks API", Exception::MEOW, false); + return 0; } #endif if (!EventThread::allocUserEvents()){ - crash("Error allocating SDL user events", Exception::MEOW, true); + crash("Error allocating SDL user events", Exception::MEOW, false); return 0; } @@ -281,7 +277,7 @@ int main(int argc, char *argv[]){ if (!conf.gameFolder.empty()){ if (chdir(conf.gameFolder.c_str()) != 0){ snprintf(msg, sizeof msg, "Unable to switch into gameFolder %s", conf.gameFolder); - crash(msg, Exception::MEOW, true); + crash(msg, Exception::MEOW, false); return 0; } } @@ -337,7 +333,7 @@ int main(int argc, char *argv[]){ if (!alcDev){ SDL_DestroyWindow(win); - crash("Error opening OpenAL device", Exception::MEOW, true); + crash("Error opening OpenAL device", Exception::MEOW, false); TTF_Quit(); SDL_Quit(); @@ -391,7 +387,7 @@ int main(int argc, char *argv[]){ if (rtData.rqTermAck) SDL_WaitThread(rgssThread, 0); else - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and OneShot: Sunshine will now force quit", win); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and Sunshine will now force quit", win); if (!rtData.rgssErrorMsg.empty()) crash(rtData.rgssErrorMsg.c_str(), Exception::MEOW, false); diff --git a/src/screen.cpp b/src/screen.cpp index d9ccc8c..6c8d959 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -11,10 +11,6 @@ #include "pipe.h" #include "meow.h" -static void showInitError(const std::string &msg){ - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Sunshine Error", msg.c_str(), 0); -} - static bool readMessage(Pipe &ipc, char *buf, size_t size){ size_t index = 0; while (index < size - 1) { diff --git a/src/settingsmenu.cpp b/src/settingsmenu.cpp index 7775cf6..2042b82 100644 --- a/src/settingsmenu.cpp +++ b/src/settingsmenu.cpp @@ -970,8 +970,7 @@ SettingsMenu::SettingsMenu(RGSSThreadData &rtData){ p->hasFocus = false; p->destroyReq = false; - p->window = SDL_CreateWindow(findtext(TRSTR_KEYBIND_TITLE, "Key bindings"), - winSize.x, winSize.y, SDL_WINDOW_INPUT_FOCUS); + p->window = SDL_CreateWindow(findtext(TRSTR_KEYBIND_TITLE, "Key bindings"), winSize.x, winSize.y, SDL_WINDOW_INPUT_FOCUS); p->winSurf = SDL_GetWindowSurface(p->window); p->winID = SDL_GetWindowID(p->window); @@ -1045,9 +1044,7 @@ SettingsMenu::~SettingsMenu() { delete p; } -bool SettingsMenu::onEvent(const SDL_Event &event, - const std::map &joysticks) -{ +bool SettingsMenu::onEvent(const SDL_Event &event, const std::map &joysticks) { switch (event.window.type) { case SDL_EVENT_WINDOW_SHOWN : // SDL is bugged and doesn't give us a first FOCUS_GAINED event case SDL_EVENT_WINDOW_FOCUS_GAINED : diff --git a/src/shader.h b/src/shader.h index 5e50885..dd0c09d 100644 --- a/src/shader.h +++ b/src/shader.h @@ -41,12 +41,8 @@ protected: Shader(); ~Shader(); - void init(const unsigned char *vert, int vertSize, - const unsigned char *frag, int fragSize, - const char *vertName, const char *fragName, - const char *programName); - void initFromFile(const char *vertFile, const char *fragFile, - const char *programName); + void init(const unsigned char *vert, int vertSize, const unsigned char *frag, int fragSize, const char *vertName, const char *fragName, const char *programName); + void initFromFile(const char *vertFile, const char *fragFile, const char *programName); static void setVec4Uniform(GLint location, const Vec4 &vec); static void setTexUniform(GLint location, unsigned unitIndex, TEX::ID texture); diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp index 985ffab..f46a802 100644 --- a/src/soundemitter.cpp +++ b/src/soundemitter.cpp @@ -73,8 +73,7 @@ private: }; /* Before: [a][b][c][d], After (index=1): [a][c][d][b] */ -static void -arrayPushBack(std::vector &array, size_t size, size_t index){ +static void arrayPushBack(std::vector &array, size_t size, size_t index){ size_t v = array[index]; for (size_t t = index; t < size-1; ++t) @@ -227,8 +226,6 @@ SoundBuffer *SoundEmitter::allocateBuffer(const std::string &filename){ char buf[512]; snprintf(buf, sizeof(buf), "Unable to decode sound: %s: %s", filename.c_str(), Sound_GetError()); crash(msg, Exception::MEOW, false); - Debug() << buf; - return 0; } diff --git a/src/soundemitter.h b/src/soundemitter.h index 63dcca6..b11da6c 100644 --- a/src/soundemitter.h +++ b/src/soundemitter.h @@ -51,9 +51,7 @@ struct SoundEmitter{ SoundEmitter(const Config &conf); ~SoundEmitter(); - void play(const std::string &filename, - int volume, - int pitch); + void play(const std::string &filename, int volume, int pitch); void stop(); diff --git a/src/tileatlas.cpp b/src/tileatlas.cpp index b3521d0..ff73043 100644 --- a/src/tileatlas.cpp +++ b/src/tileatlas.cpp @@ -141,8 +141,7 @@ static BlitVec calcBlitsInt(ColumnVec &srcCols, ColumnVec &dstCols){ } else{ /* srcCol fits perfectly into dstCol */ - blits.push_back(Blit(srcCol.x, srcCol.y, - dstCol.x, dstCol.y, dstCol.h)); + blits.push_back(Blit(srcCol.x, srcCol.y, dstCol.x, dstCol.y, dstCol.h)); } } } diff --git a/src/tilemap-common.h b/src/tilemap-common.h index 1c0883c..393bc18 100644 --- a/src/tilemap-common.h +++ b/src/tilemap-common.h @@ -69,8 +69,7 @@ enum AtSubPos{ BottomRightTable = 5 }; -static inline void -atSelectSubPos(FloatRect &pos, int i){ +static inline void atSelectSubPos(FloatRect &pos, int i){ switch (i){ case TopLeft: return; diff --git a/src/tilemap.cpp b/src/tilemap.cpp index d19d77b..b26f585 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -38,7 +38,6 @@ #include "vertex.h" #include "tileatlas.h" #include "tilemap-common.h" -#include "meow.h" #include @@ -401,7 +400,7 @@ struct TilemapPrivate { atlas.size = TileAtlas::minSize(atlas.efTilesetH, glState.caps.maxTexSize); if (atlas.size.x < 0) - crash("Cannot allocate big enough texture for tileset atlas", Exception::MKXPError, true); + throw Exception(Exception::MKXPError, "Cannot allocate big enough texture for tileset atlas"); } void updateAutotileInfo(){ @@ -1168,4 +1167,3 @@ void Tilemap::releaseResources(){ delete p; atProxy.p = 0; } - diff --git a/src/tilequad.h b/src/tilequad.h index 0ac8075..da40ae4 100644 --- a/src/tilequad.h +++ b/src/tilequad.h @@ -54,11 +54,9 @@ namespace TileQuads{ Vertex *verts); /* Build a quad "frame" (see Window cursor_rect) */ - int buildFrame(const IntRect &rect, - Vertex vert[36]); + int buildFrame(const IntRect &rect, Vertex vert[36]); - int buildFrameSource(const IntRect &rect, - Vertex vert[36]); + int buildFrameSource(const IntRect &rect, Vertex vert[36]); } #endif // TILEQUAD_H