From ab6f04e3ccc3f31e416441b5b3686afe8a17f11d Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 07:24:18 -0400 Subject: [PATCH 1/2] Fix pixel scaling from fixed value to `WINDOW` --- ZSharp/graphics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZSharp/graphics.h b/ZSharp/graphics.h index 30649af..0ff0539 100644 --- a/ZSharp/graphics.h +++ b/ZSharp/graphics.h @@ -1032,7 +1032,7 @@ int initGraphics(std::string windowTitle, int width, int height, int pixelScale) gWindow = SDL_CreateWindow(windowTitle.c_str(), 40, 40, WINDOW_WIDTH * PIXEL_SCALE, WINDOW_HEIGHT * PIXEL_SCALE, SDL_WINDOW_SHOWN | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); gRenderer = SDL_CreateRenderer(gWindow, -1, 0); - SDL_RenderSetLogicalSize(gRenderer, 256 * PIXEL_SCALE, 224 * PIXEL_SCALE); + SDL_RenderSetLogicalSize(gRenderer, WINDOW_WIDTH * PIXEL_SCALE, WINDOW_HEIGHT * PIXEL_SCALE); SDL_RenderSetScale(gRenderer, PIXEL_SCALE, PIXEL_SCALE); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, 0); From 532d9831953321fd2ed3da61222df23c4fda2b9a Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 08:15:01 -0400 Subject: [PATCH 2/2] Add some error checking --- ZSharp/Main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ZSharp/Main.cpp b/ZSharp/Main.cpp index 024a7fa..c036c28 100644 --- a/ZSharp/Main.cpp +++ b/ZSharp/Main.cpp @@ -786,6 +786,8 @@ int main(int argc, char* argv[]) #if DEVELOPER_MESSAGES cout << scriptPath << endl; #endif + if (!fileExists(scriptPath) + LogCriticalError("Failed to load script from path: \"" + scriptPath + "\""); std::string projectDirectory = scriptPath.substr(0, scriptPath.find_last_of("/\\")); #if UNIX @@ -799,13 +801,14 @@ int main(int argc, char* argv[]) #endif // Change the current working directory to that of the script - chdir(projectDirectory.c_str()); + int chErr = chdir(projectDirectory.c_str()); + if(chErr < 0) + LogCriticalError("Failed to change directory to: \"" + projectDirectory.c_str() + "\", error num: " + chErr); #if DEVELOPER_MESSAGES - InterpreterLog("Change directory to " + projectDirectory + "..."); + InterpreterLog("Changed directory to " + projectDirectory + "..."); #endif #if DEVELOPER_MESSAGES string newPath = filesystem::current_path(); - InterpreterLog("Current working directory is " + newPath); #endif #elif WINDOWS // Get script contents as single string @@ -823,7 +826,7 @@ int main(int argc, char* argv[]) LPCWSTR s = wide.c_str(); SetCurrentDirectory(s); #if DEVELOPER_MESSAGES - InterpreterLog("Change directory to " + projectDirectory + "..."); + InterpreterLog("Changed directory to " + projectDirectory + "..."); #endif #endif }