From c432e83d18dba4aa4404c4ace4f933e733076c8d Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Fri, 10 Apr 2026 19:12:57 -0700 Subject: [PATCH] fix: make it build on windows --- meson.build | 2 +- targets/app/common/Game_XuiActions.cpp | 1 + targets/app/common/Iggy/gdraw/gdraw.c | 50 +++++++++++-------- targets/app/common/Iggy/include/iggy.h | 13 ++++- targets/app/common/LocalizationManager.cpp | 1 + targets/app/common/MenuController.cpp | 1 + targets/app/common/NetworkController.cpp | 1 + .../UIScene_MainMenu.cpp | 23 +++++---- targets/app/common/UI/UIController.h | 4 +- targets/app/desktop/main.cpp | 1 - targets/app/meson.build | 1 + .../client/gui/SelectWorldScreen.cpp | 2 - .../minecraft/client/player/LocalPlayer.cpp | 1 + .../minecraft/client/title/TitleScreen.cpp | 21 ++++---- targets/minecraft/meson.build | 1 + targets/minecraft/world/Container.h | 1 + targets/platform/renderer/gl/GLRenderer.cpp | 2 - targets/platform/renderer/gl/GLRenderer.h | 1 - targets/platform/renderer/gl/gl_compat.h | 34 ++++--------- targets/platform/stubs.h | 1 - 20 files changed, 85 insertions(+), 77 deletions(-) diff --git a/meson.build b/meson.build index 0e9f62b38..a90574ce0 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ project( 'warning_level=0', 'unity=on', # merge source files per target 'unity_size=8', # TODO: mess around with this - 'buildtype=debugoptimized', # needed for _FORTIFY_SOURCE + # 'buildtype=debugoptimized', # needed for _FORTIFY_SOURCE 'b_pch=true', # precompiled headers # 'b_lto=true', # link-time optimisation (ThinLTO under clang+lld) # 'b_ndebug=if-release', # drop assert() in --buildtype=release diff --git a/targets/app/common/Game_XuiActions.cpp b/targets/app/common/Game_XuiActions.cpp index 2e244ea1b..3b100537c 100644 --- a/targets/app/common/Game_XuiActions.cpp +++ b/targets/app/common/Game_XuiActions.cpp @@ -32,6 +32,7 @@ #include "platform/profile/profile.h" #include "platform/storage/storage.h" #include "util/StringHelpers.h" +#include "strings.h" void Game::HandleXuiActions(void) { eXuiAction eAction; diff --git a/targets/app/common/Iggy/gdraw/gdraw.c b/targets/app/common/Iggy/gdraw/gdraw.c index add6fd2b4..45fc181a7 100644 --- a/targets/app/common/Iggy/gdraw/gdraw.c +++ b/targets/app/common/Iggy/gdraw/gdraw.c @@ -1,8 +1,12 @@ #define GDRAW_ASSERTS #include "gdraw.h" - -#include +#if defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#include +#endif +#include #include #include #include @@ -128,33 +132,33 @@ typedef gdraw_gl_resourcetype gdraw_resourcetype; GDRAW_GL_EXTENSION_LIST #undef GLE -typedef const GLubyte*(APIENTRYP PFNGLGETSTRINGIPROC_)(GLenum name, +typedef const GLubyte*(APIENTRY* PFNGLGETSTRINGIPROC_)(GLenum name, GLuint index); static PFNGLGETSTRINGIPROC_ gdraw_glGetStringi = NULL; -typedef void(APIENTRYP PFNGLGENVERTEXARRAYSPROC_)(GLsizei n, GLuint* arrays); -typedef void(APIENTRYP PFNGLBINDVERTEXARRAYPROC_)(GLuint array); +typedef void(APIENTRY* PFNGLGENVERTEXARRAYSPROC_)(GLsizei n, GLuint* arrays); +typedef void(APIENTRY* PFNGLBINDVERTEXARRAYPROC_)(GLuint array); static PFNGLGENVERTEXARRAYSPROC_ gdraw_glGenVertexArrays = NULL; static PFNGLBINDVERTEXARRAYPROC_ gdraw_glBindVertexArray = NULL; static GLuint gdraw_vao = 0; -typedef void(APIENTRYP gdraw_vtxattrib_fn)(GLuint, GLint, GLenum, GLboolean, +typedef void(APIENTRY* gdraw_vtxattrib_fn)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*); static gdraw_vtxattrib_fn gdraw_real_vtxattrib = NULL; static GLuint gdraw_screenvbo = 0; static const void* gdraw_screenvbo_base = NULL; static size_t gdraw_expected_vbo_size = 0; -typedef void(APIENTRYP gdraw_drawelements_fn)(GLenum mode, GLsizei count, +typedef void(APIENTRY* gdraw_drawelements_fn)(GLenum mode, GLsizei count, GLenum type, const void* indices); static gdraw_drawelements_fn gdraw_real_drawelements = NULL; static GLuint gdraw_screenibo = 0; -typedef GLuint(APIENTRYP gdraw_createshader_fn)(GLenum); -typedef void(APIENTRYP gdraw_shadersource_fn)(GLuint, GLsizei, const GLchar**, +typedef GLuint(APIENTRY* gdraw_createshader_fn)(GLenum); +typedef void(APIENTRY* gdraw_shadersource_fn)(GLuint, GLsizei, const GLchar**, const GLint*); -typedef void(APIENTRYP gdraw_compileshader_fn)(GLuint); -typedef void(APIENTRYP gdraw_linkprogram_fn)(GLuint); +typedef void(APIENTRY* gdraw_compileshader_fn)(GLuint); +typedef void(APIENTRY* gdraw_linkprogram_fn)(GLuint); static gdraw_createshader_fn gdraw_real_createshader = NULL; static gdraw_shadersource_fn gdraw_real_shadersource = NULL; static gdraw_compileshader_fn gdraw_real_compileshader = NULL; @@ -162,24 +166,24 @@ static gdraw_linkprogram_fn gdraw_real_linkprogram = NULL; // some core reject p0 -typedef void(APIENTRYP gdraw_useprogram_fn)(GLuint); +typedef void(APIENTRY* gdraw_useprogram_fn)(GLuint); static gdraw_useprogram_fn gdraw_real_useprogram = NULL; static GLuint gdraw_null_program = 0; -typedef void(APIENTRYP gdraw_teximage2d_fn)(GLenum, GLint, GLint, GLsizei, +typedef void(APIENTRY* gdraw_teximage2d_fn)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*); -typedef void(APIENTRYP gdraw_texsubimage2d_fn)(GLenum, GLint, GLint, GLint, +typedef void(APIENTRY* gdraw_texsubimage2d_fn)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void*); static gdraw_teximage2d_fn gdraw_real_teximage2d = NULL; static gdraw_texsubimage2d_fn gdraw_real_texsubimage2d = NULL; -#define TRY(ptr, arb, core) \ - do { \ +#define TRY(ptr, arb, core) \ + do { \ void* _p = SDL_GL_GetProcAddress(core); \ if (!_p) _p = SDL_GL_GetProcAddress(arb); \ - *(void**)&(ptr) = _p; \ + *(void**)&(ptr) = _p; \ } while (0) static void load_extensions(void) { @@ -254,15 +258,19 @@ static void load_extensions(void) { (gdraw_shadersource_fn)SDL_GL_GetProcAddress("glShaderSource"); gdraw_real_compileshader = (gdraw_compileshader_fn)SDL_GL_GetProcAddress("glCompileShader"); - gdraw_real_linkprogram = (gdraw_linkprogram_fn)SDL_GL_GetProcAddress("glLinkProgram"); - gdraw_real_teximage2d = (gdraw_teximage2d_fn)SDL_GL_GetProcAddress("glTexImage2D"); + gdraw_real_linkprogram = + (gdraw_linkprogram_fn)SDL_GL_GetProcAddress("glLinkProgram"); + gdraw_real_teximage2d = + (gdraw_teximage2d_fn)SDL_GL_GetProcAddress("glTexImage2D"); gdraw_real_texsubimage2d = (gdraw_texsubimage2d_fn)SDL_GL_GetProcAddress("glTexSubImage2D"); - gdraw_real_useprogram = (gdraw_useprogram_fn)SDL_GL_GetProcAddress("glUseProgram"); + gdraw_real_useprogram = + (gdraw_useprogram_fn)SDL_GL_GetProcAddress("glUseProgram"); gdraw_real_drawelements = (gdraw_drawelements_fn)SDL_GL_GetProcAddress("glDrawElements"); - gdraw_glGetStringi = (PFNGLGETSTRINGIPROC_)SDL_GL_GetProcAddress("glGetStringi"); + gdraw_glGetStringi = + (PFNGLGETSTRINGIPROC_)SDL_GL_GetProcAddress("glGetStringi"); gdraw_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC_)SDL_GL_GetProcAddress("glGenVertexArrays"); gdraw_glBindVertexArray = diff --git a/targets/app/common/Iggy/include/iggy.h b/targets/app/common/Iggy/include/iggy.h index 5d4d43027..3af8392d3 100644 --- a/targets/app/common/Iggy/include/iggy.h +++ b/targets/app/common/Iggy/include/iggy.h @@ -10,6 +10,15 @@ #include "rrCore.h" // base data types, macros +// on windows, these will cause MSVC to shit itself due to thinking +// the stubbed iggy symbols are DLL-exported. +#ifndef _ENABLEIGGY +#undef RADEXPFUNC +#undef RADEXPLINK +#define RADEXPFUNC +#define RADEXPLINK +#endif + RADDEFSTART #ifndef IGGY_GDRAW_SHARED_TYPEDEF @@ -123,8 +132,8 @@ typedef enum IggyDatatype { /* Describes an AS3 datatype visible through iggy interface. */ #ifdef __RADWIN__ -#include -IDOCN typedef char IggyUTF16; +#include +IDOCN typedef char16_t IggyUTF16; #else #include typedef const char16_t IggyUTF16; diff --git a/targets/app/common/LocalizationManager.cpp b/targets/app/common/LocalizationManager.cpp index c84713ef4..6bb202513 100644 --- a/targets/app/common/LocalizationManager.cpp +++ b/targets/app/common/LocalizationManager.cpp @@ -21,6 +21,7 @@ #include "platform/renderer/renderer.h" #include "strings.h" #include "util/StringHelpers.h" +#include "app/common/ui/ConsoleUIController.h" int LocalizationManager::s_iHTMLFontSizesA[eHTMLSize_COUNT] = {20, 13, 20, 26}; diff --git a/targets/app/common/MenuController.cpp b/targets/app/common/MenuController.cpp index 5b1257e7e..b19059bc9 100644 --- a/targets/app/common/MenuController.cpp +++ b/targets/app/common/MenuController.cpp @@ -24,6 +24,7 @@ #include "minecraft/world/level/tile/entity/HopperTileEntity.h" #include "platform/profile/profile.h" #include "platform/storage/storage.h" +#include "strings.h" unsigned char MenuController::m_szPNG[8] = {137, 80, 78, 71, 13, 10, 26, 10}; diff --git a/targets/app/common/NetworkController.cpp b/targets/app/common/NetworkController.cpp index e7e309a03..c8936af11 100644 --- a/targets/app/common/NetworkController.cpp +++ b/targets/app/common/NetworkController.cpp @@ -21,6 +21,7 @@ #include "platform/input/input.h" #include "platform/profile/profile.h" #include "platform/storage/storage.h" +#include "strings.h" unsigned int NetworkController::m_uiLastSignInData = 0; diff --git a/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp b/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp index a0ea8582f..ef4788ffb 100644 --- a/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp +++ b/targets/app/common/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp @@ -176,21 +176,22 @@ void UIScene_MainMenu::handleGainFocus(bool navBack) { random->nextInt((int)m_splashes.size() - (eSplashRandomStart + 1)); // Override splash text on certain dates - const std::time_t now = - std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - std::tm localTime; - localtime_r(&now, &localTime); - const int month = localTime.tm_mon + 1; // tm_mon is 0-based - const int day = localTime.tm_mday; - if (month == 11 && day == 9) { + auto now = std::chrono::system_clock::now(); + auto dp = std::chrono::floor(now); + std::chrono::year_month_day ymd{dp}; + const auto month = ymd.month(); + const uint32_t day = static_cast(ymd.day()); + + if (month == std::chrono::November && day == 9) { splashIndex = eSplashHappyBirthdayEx; - } else if (month == 6 && day == 1) { + } else if (month == std::chrono::June && day == 1) { splashIndex = eSplashHappyBirthdayNotch; - } else if (month == 12 && day == 24) // the Java game shows this on - // Christmas Eve, so we will too + } else if (month == std::chrono::December && + day == 24) // the Java game shows this on + // Christmas Eve, so we will too { splashIndex = eSplashMerryXmas; - } else if (month == 1 && day == 1) { + } else if (month == std::chrono::January && day == 1) { splashIndex = eSplashHappyNewYear; } // splashIndex = 47; // Very short string diff --git a/targets/app/common/UI/UIController.h b/targets/app/common/UI/UIController.h index 90b08f3dc..3082fe34a 100644 --- a/targets/app/common/UI/UIController.h +++ b/targets/app/common/UI/UIController.h @@ -36,7 +36,7 @@ class UIScene; // 4jcraft, used to be D3D11_RECT. // This was the only class that used it, so it's here now. -struct 4J_RECT { +struct RECT_4J { long left; long top; long right; @@ -190,7 +190,7 @@ private: int m_accumulatedTicks; uint64_t m_lastUiSfx; // Tracks time (ms) of last UI sound effect - 4J_RECT m_customRenderingClearRect; + RECT_4J m_customRenderingClearRect; std::unordered_map m_registeredCallbackScenes; // A collection of scenes and unique id's diff --git a/targets/app/desktop/main.cpp b/targets/app/desktop/main.cpp index 478f68959..5799856be 100644 --- a/targets/app/desktop/main.cpp +++ b/targets/app/desktop/main.cpp @@ -40,7 +40,6 @@ static void sigsegv_handler(int sig) { _exit(139); } #endif -#include #include #include #include diff --git a/targets/app/meson.build b/targets/app/meson.build index de62035fc..ec3a3b41f 100644 --- a/targets/app/meson.build +++ b/targets/app/meson.build @@ -27,6 +27,7 @@ app_dependencies += [ dependency('miniaudio'), # todo: remove once PlatformSound is used dependency('stb'), dependency('simdutf'), + dependency('glew'), # TODO remove java_dep, nbt_dep, util_dep, diff --git a/targets/minecraft/client/gui/SelectWorldScreen.cpp b/targets/minecraft/client/gui/SelectWorldScreen.cpp index b73c00162..310826442 100644 --- a/targets/minecraft/client/gui/SelectWorldScreen.cpp +++ b/targets/minecraft/client/gui/SelectWorldScreen.cpp @@ -279,8 +279,6 @@ void SelectWorldScreen::WorldSelectionList::renderItem(int i, int x, int y, (unsigned)ymd.month(), (int)ymd.year(), (int)hms.hours().count(), (int)hms.minutes().count()); - id = id + " (" + buffer; - int64_t size = levelSummary->getSizeOnDisk(); id = id + ", " + toWString(size / 1024 * 100 / 1024 / 100.0f) + " MB)"; diff --git a/targets/minecraft/client/player/LocalPlayer.cpp b/targets/minecraft/client/player/LocalPlayer.cpp index 45a09d9fb..0febaf741 100644 --- a/targets/minecraft/client/player/LocalPlayer.cpp +++ b/targets/minecraft/client/player/LocalPlayer.cpp @@ -65,6 +65,7 @@ #include "minecraft/world/entity/player/Abilities.h" #include "minecraft/world/entity/player/Inventory.h" #include "minecraft/world/entity/player/Player.h" +#include "minecraft/world/entity/item/MinecartHopper.h" #include "minecraft/world/food/FoodConstants.h" #include "minecraft/world/food/FoodData.h" #include "minecraft/world/item/BowItem.h" diff --git a/targets/minecraft/client/title/TitleScreen.cpp b/targets/minecraft/client/title/TitleScreen.cpp index 43ca00fb9..eaeb70359 100644 --- a/targets/minecraft/client/title/TitleScreen.cpp +++ b/targets/minecraft/client/title/TitleScreen.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "java/InputOutputStream/BufferedReader.h" #include "java/InputOutputStream/ByteArrayInputStream.h" @@ -68,20 +69,20 @@ TitleScreen::TitleScreen() { random->nextInt((int)splashes.size() - (eSplashRandomStart + 1)); // Override splash text on certain dates - const auto now = std::chrono::system_clock::now(); - const auto t = std::chrono::system_clock::to_time_t(now); - std::tm localTime; - localtime_r(&t, &localTime); - const int month = localTime.tm_mon + 1; // tm_mon is 0-based - const int day = localTime.tm_mday; - if (month == 11 && day == 9) { + auto now = std::chrono::system_clock::now(); + auto dp = std::chrono::floor(now); + std::chrono::year_month_day ymd{dp}; + const auto month = ymd.month(); + const uint32_t day = static_cast(ymd.day()); + + if (month == std::chrono::November && day == 9) { splashIndex = eSplashHappyBirthdayEx; - } else if (month == 6 && day == 1) { + } else if (month == std::chrono::June && day == 1) { splashIndex = eSplashHappyBirthdayNotch; - } else if (month == 12 && day == 24) { + } else if (month == std::chrono::December && day == 24) { // the Java game shows this on Christmas Eve, so we will too splashIndex = eSplashMerryXmas; - } else if (month == 1 && day == 1) { + } else if (month == std::chrono::January && day == 1) { splashIndex = eSplashHappyNewYear; } diff --git a/targets/minecraft/meson.build b/targets/minecraft/meson.build index 6c3708106..b8f25499c 100644 --- a/targets/minecraft/meson.build +++ b/targets/minecraft/meson.build @@ -12,6 +12,7 @@ lib_minecraft = static_library('minecraft', # dependency('libcrypto'), # for MD5 in Hasher.cpp on Linux dependency('zlib'), dependency('glm'), + dependency('glew'), # TODO remove nbt_dep, java_dep, util_dep, diff --git a/targets/minecraft/world/Container.h b/targets/minecraft/world/Container.h index b86b9de8e..82ec0632c 100644 --- a/targets/minecraft/world/Container.h +++ b/targets/minecraft/world/Container.h @@ -2,6 +2,7 @@ #include #include +#include class ItemInstance; class Player; diff --git a/targets/platform/renderer/gl/GLRenderer.cpp b/targets/platform/renderer/gl/GLRenderer.cpp index 1e1ef038d..c4c0555be 100644 --- a/targets/platform/renderer/gl/GLRenderer.cpp +++ b/targets/platform/renderer/gl/GLRenderer.cpp @@ -24,8 +24,6 @@ #undef glNormalPointer #undef glColorPointer #undef glVertexPointer -#undef glGenQueriesARB -#undef glGetQueryObjectuARB #undef glEnable #undef glDisable #undef glBlendFunc diff --git a/targets/platform/renderer/gl/GLRenderer.h b/targets/platform/renderer/gl/GLRenderer.h index ab32e75b7..d5084c24b 100644 --- a/targets/platform/renderer/gl/GLRenderer.h +++ b/targets/platform/renderer/gl/GLRenderer.h @@ -2,7 +2,6 @@ #include "gl3_loader.h" // NOTE: gl3_loader.h must be included before these two -#include #include diff --git a/targets/platform/renderer/gl/gl_compat.h b/targets/platform/renderer/gl/gl_compat.h index 296030895..752151538 100644 --- a/targets/platform/renderer/gl/gl_compat.h +++ b/targets/platform/renderer/gl/gl_compat.h @@ -16,7 +16,7 @@ // #include "gl3_loader.h" // NOTE: gl3_loader.h must be included before these two -#include +#include #include #include @@ -261,6 +261,16 @@ #define GL_RESCALE_NORMAL 0x803A #endif +#ifndef GL_BGRA +#define GL_BGRA 0x80E1 +#endif +#ifndef GL_RGBA +#define GL_RGBA 0x1908 +#endif + +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif // glCallList / display list macros #undef glNewList @@ -460,7 +470,6 @@ #define glActiveTexture(tex) \ do { \ PlatformRenderer.StateSetActiveTexture(tex); \ - ::glActiveTexture(tex); \ } while (0) #undef glClientActiveTexture @@ -478,11 +487,6 @@ void glTexImage2D_4J(int target, int level, int internalformat, int width, int height, int border, int format, int type, void* pixels); -// helprs -void glGenQueries_4J_Helper(unsigned int* id); -void glGetQueryObjectu_4J_Helper(unsigned int id, unsigned int pname, - unsigned int* val); - template inline void glGenTextures_4J(T* buf) { unsigned int id = 0; @@ -523,20 +527,6 @@ inline void glCallLists_4J(T* lists) { } } template -inline void glGenQueries_4J(T* buf) { - unsigned int id = 0; - glGenQueries_4J_Helper(&id); - buf->put((int)id); - buf->flip(); -} -template -inline void glGetQueryObjectu_4J(int id, int pname, T* params) { - unsigned int val = 0; - glGetQueryObjectu_4J_Helper((unsigned int)id, (unsigned int)pname, &val); - params->put((int)val); - params->flip(); -} -template inline void glFog_4J(int pname, T* params) { float* p = params->_getDataPointer(); if (pname == 0x0B66 /* GL_FOG_COLOR */) @@ -589,8 +579,6 @@ inline void glReadPixels_4J(int x, int y, int width, int height, int format, #define glTexImage2D(a, b, c, d, e, f, g, h, i) \ glTexImage2D_4J(a, b, c, d, e, f, g, h, i) #define glCallLists(x) glCallLists_4J(x) -#define glGenQueriesARB(x) glGenQueries_4J(x) -#define glGetQueryObjectuARB(a, b, c) glGetQueryObjectu_4J(a, b, c) #define glReadPixels(a, b, c, d, e, f, g) glReadPixels_4J(a, b, c, d, e, f, g) #define glFog(a, b) glFog_4J(a, b) #define glLight(a, b, c) glLight_4J(a, b, c) diff --git a/targets/platform/stubs.h b/targets/platform/stubs.h index 0c4c87021..a84615d90 100644 --- a/targets/platform/stubs.h +++ b/targets/platform/stubs.h @@ -8,7 +8,6 @@ #include #endif -#include #include #include "java/File.h"