From 3f8f7d7e00b4c0b4a24563c5366b8b77e5279860 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Wed, 2 Aug 2023 23:18:44 +0300 Subject: [PATCH] * Make the game not run if a texture couldn't be loaded. --- platforms/windows/AppPlatform_windows.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platforms/windows/AppPlatform_windows.cpp b/platforms/windows/AppPlatform_windows.cpp index 004fdff..cc1ab90 100644 --- a/platforms/windows/AppPlatform_windows.cpp +++ b/platforms/windows/AppPlatform_windows.cpp @@ -150,7 +150,15 @@ Texture AppPlatform_windows::loadTexture(const std::string& str, bool b) if (!f) { LogMsg("File %s couldn't be opened", realPath.c_str()); - return Texture(0, 0, nullptr, 1, 0); + + _error: + char buffer[1024]; + snprintf(buffer, sizeof buffer, "Error loading %s. Did you unzip the minecraft assets?", realPath.c_str()); + MessageBoxA(GetHWND(), buffer, g_GameTitle, MB_OK); + + if (f) + fclose(f); + ::exit(1); } int width = 0, height = 0, channels = 0; @@ -159,8 +167,7 @@ Texture AppPlatform_windows::loadTexture(const std::string& str, bool b) if (!img) { LogMsg("File %s couldn't be loaded via stb_image", realPath.c_str()); - fclose(f); - return Texture(0, 0, nullptr, 1, 0); + goto _error; } fclose(f);