From c2829e037742955e5efcb24891345deaa0fab93b Mon Sep 17 00:00:00 2001 From: Brian Dam Pedersen Date: Thu, 24 Apr 2025 21:45:25 +0200 Subject: [PATCH] Fixes required for MacOS and QT6 --- include/i_system.h | 1 + include/i_system_win.h | 2 ++ source/g_game.c | 49 +++++++++++++++++++++++++++++++++++++++++ source/i_system_e32.cpp | 3 ++- source/lprintf.c | 1 + source/r_data.c | 13 +++++++++++ 6 files changed, 68 insertions(+), 1 deletion(-) diff --git a/include/i_system.h b/include/i_system.h index 425eecb3..a76f9bf1 100644 --- a/include/i_system.h +++ b/include/i_system.h @@ -37,6 +37,7 @@ #ifdef __GNUG__ #pragma interface #endif +#include boolean I_StartDisplay(void); void I_EndDisplay(void); diff --git a/include/i_system_win.h b/include/i_system_win.h index 4624e639..4f026262 100644 --- a/include/i_system_win.h +++ b/include/i_system_win.h @@ -18,6 +18,8 @@ #define KEYD_START 9 #define KEYD_SELECT 10 +using std::byte; + extern "C" { diff --git a/source/g_game.c b/source/g_game.c index 2275c69e..332f5283 100644 --- a/source/g_game.c +++ b/source/g_game.c @@ -836,6 +836,55 @@ void G_ForcedLoadGame(void) _g->gameaction = ga_loadgame; } +#ifndef _MSC_VER +// Supports base 2 to 36 +char* itoa(int value, char* buffer, int base) { + if (base < 2 || base > 36) { + buffer[0] = '\0'; // invalid base + return buffer; + } + + int i = 0; + int isNegative = 0; + + if (value == 0) { + buffer[i++] = '0'; + buffer[i] = '\0'; + return buffer; + } + + if (value < 0 && base == 10) { + isNegative = 1; + value = -value; + } + + while (value != 0) { + int rem = value % base; + buffer[i++] = (rem > 9) ? (rem - 10) + 'a' : rem + '0'; + value = value / base; + } + + if (isNegative) { + buffer[i++] = '-'; + } + + buffer[i] = '\0'; + + // Inline reverse + int start = 0; + int end = i - 1; + while (start < end) { + char temp = buffer[start]; + buffer[start] = buffer[end]; + buffer[end] = temp; + start++; + end--; + } + + return buffer; +} +#endif + // // Update the strings displayed in the load-save menu. diff --git a/source/i_system_e32.cpp b/source/i_system_e32.cpp index 72a4b89d..8435d638 100644 --- a/source/i_system_e32.cpp +++ b/source/i_system_e32.cpp @@ -98,8 +98,9 @@ void I_CreateWindow_e32() window = new DoomWindow(); + #ifndef __APPLE__ window->setAttribute(Qt::WA_PaintOnScreen); - + #endif window->resize(vid_width * 8, vid_height * 4); diff --git a/source/lprintf.c b/source/lprintf.c index d5ef6bc2..91881c98 100644 --- a/source/lprintf.c +++ b/source/lprintf.c @@ -45,6 +45,7 @@ #include "doomtype.h" #include "lprintf.h" #include "i_main.h" +#include /* cphipps - enlarged message buffer and made non-static * We still have to be careful here, this function can be called after exit diff --git a/source/r_data.c b/source/r_data.c index 1aa36f91..e66bb0ea 100644 --- a/source/r_data.c +++ b/source/r_data.c @@ -221,6 +221,19 @@ const texture_t* R_GetTexture(int texture) return t; } +#ifndef _MSC_VER +#include + +char* strupr(char* str) { + char* p = str; + while (*p) { + *p = toupper((unsigned char)*p); + p++; + } + return str; +} +#endif + static int R_GetTextureNumForName(const char* tex_name) { const int *maptex1, *maptex2;