From f38ca9aa28bbb7e9c80f36d2afa3b6b197dfa26b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 12:40:50 +0100 Subject: [PATCH 01/40] Signal Handler: Add button to report issues to github mostly based on what srb2 does with some stuff from srb2-legacy the button will attempt to open the issue page on the saturn git when a crash occurs --- src/sdl/i_system.cpp | 80 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 0c024a5bd..354eb0427 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1388,7 +1388,7 @@ void I_SleepDuration(precise_t duration) #endif } -static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg); +static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_ttl); #ifdef HAVE_LIBBACKTRACE #include @@ -1484,6 +1484,7 @@ static void bt_error_cb(void *data, const char *msg, int errnum) static void write_backtrace(bt_crash_reason_t reason) { char sig_msg[512]; + char sig_name[128]; const char *filename = va("%s" PATHSEP CRASH_LOGFILE_NAME, srb2home); FILE *out = fopen(filename, "a+"); @@ -1540,8 +1541,8 @@ static void write_backtrace(bt_crash_reason_t reason) switch (reason.type) { case BTCRASH_SIGNAL: - I_PrintSignal(reason.value.signal, false, sig_msg); - fprintf(out, "%s", sig_msg); + I_PrintSignal(reason.value.signal, false, sig_msg, sig_name); + fprintf(out, "%s - %s", sig_name, sig_msg); break; case BTCRASH_ERRORMSG: @@ -1577,42 +1578,49 @@ static std::thread::id g_main_thread_id; boolean g_in_exiting_signal_handler = false; -static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg) +static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_name) { - const char *sigmsg; + const char *sigmsg, *signame; switch (signal_num) { #ifdef SIGINT case SIGINT: - sigmsg = ("SIGINT - SRB2Kart-Saturn was interrupted prematurely by the user."); + sigmsg = ("SRB2Kart-Saturn was interrupted prematurely by the user."); + signame = "SIGINT"; break; #endif case SIGILL: // illegal instruction - invalid function image - sigmsg = ("SIGILL - SRB2Kart-Saturn has attempted to execute an illegal instruction and needs to close."); + sigmsg = ("SRB2Kart-Saturn has attempted to execute an illegal instruction and needs to close."); + signame = "SIGILL"; break; case SIGFPE: // mathematical exception - sigmsg = ("SIGFPE - SRB2Kart-Saturn has encountered a mathematical exception and needs to close."); + sigmsg = ("SRB2Kart-Saturn has encountered a mathematical exception and needs to close."); + signame = "SIGFPE"; break; case SIGSEGV: // segment violation - sigmsg = ("SIGSEGV - SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close."); + sigmsg = ("SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close."); + signame = "SIGSEGV"; break; #ifdef SIGTERM case SIGTERM: // Software termination signal from kill - sigmsg = ("SIGTERM - SRB2Kart-Saturn was terminated by a kill signal."); + sigmsg = ("SRB2Kart-Saturn was terminated by a kill signal."); + signame = "SIGTERM"; break; #endif #ifdef SIGBREAK case SIGBREAK: // Ctrl-Break sequence sigmsg =("SIGBREAK - SRB2Kart-Saturn was terminated by a Ctrl-Break sequence."); + signame = "SIGBREAK"; break; #endif case SIGABRT: // abnormal termination triggered by abort call - sigmsg = ("SIGABRT - SRB2Kart-Saturn was terminated by an abort signal."); + sigmsg = ("SRB2Kart-Saturn was terminated by an abort signal."); + signame = "SIGABRT"; break; default: - sprintf(signal_msg, "Signal number %d", signal_num); - sigmsg = (core_dumped ? "Unknown signal" : signal_msg); + sigmsg = "SRB2Kart-Saturn was terminated by an unknown signal."; + signame = core_dumped ? "Unknown signal" : va("Signal number %d", signal_num); break; } @@ -1627,18 +1635,58 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms { sprintf(signal_msg, "%s", sigmsg); } + + sprintf(signal_name, "%s", signame); +} + +static int I_OpenURL(const char *url) +{ +#if SDL_VERSION_ATLEAST(2,0,14) + return SDL_OpenURL(va("%s", url)); +#else + return -1; +#endif } static void I_ReportSignal(int num, int coredumped) { char sigmsg[512]; + char signame[128]; + char sigttl[512] = "Process killed by signal: "; + const char *reportmsg = "\n\n\nTo help us figure out the cause, please report the issue to our github page with " CRASH_LOGFILE_NAME " attached.\n\nSorry for the inconvenience!"; - I_PrintSignal(num, coredumped, sigmsg); + I_PrintSignal(num, coredumped, sigmsg, signame); size_t len = strlen(sigmsg); snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME); - I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Process killed by signal", sigmsg, NULL); + + strcat(sigttl, signame); + I_OutputMsg("\n%s\n\n", sigttl); + + if (M_CheckParm("-dedicated")) + return; + + const SDL_MessageBoxButtonData buttons[] = { + { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK" }, + { 0, 1, "Report Issue" }, + }; + + const SDL_MessageBoxData messageboxdata = { + SDL_MESSAGEBOX_ERROR, /* .flags */ + NULL, /* .window */ + sigttl, /* .title */ + va("%s %s", sigmsg, reportmsg), /* .message */ + SDL_arraysize(buttons), /* .numbuttons */ + buttons, /* .buttons */ + NULL /* .colorScheme */ + }; + + int buttonid; + + SDL_ShowMessageBox(&messageboxdata, &buttonid); + + if (buttonid == 1) + I_OpenURL("https://github.com/Indev450/SRB2Kart-Saturn/issues"); } #ifndef NEWSIGNALHANDLER From e1f0089627031b2f8f4f9e6e35d43e20cc6449e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:33:43 +0100 Subject: [PATCH 02/40] enable "Wzero-as-null-pointer-constant", fix cases of it prevent ambiguity shoutout blankart for making me aware this exists --- src/Makefile.d/versions.mk | 2 +- src/blua/lstrlib.c | 2 +- src/blua/luaconf.h | 6 +++--- src/d_clisrv.c | 14 +++++++------- src/d_main.c | 3 ++- src/d_netcmd.c | 14 +++++++------- src/f_finale.c | 2 +- src/g_demo.c | 2 +- src/g_game.c | 14 +++++++------- src/hardware/hw_batching.c | 2 +- src/hardware/hw_md2load.c | 28 ++++++++++++++-------------- src/hardware/hw_md3load.c | 24 ++++++++++++------------ src/hardware/hw_model.c | 18 +++++++++--------- src/hardware/r_opengl/r_opengl.c | 12 ++++++------ src/http-mserv.c | 8 ++++---- src/lua_mobjlib.c | 2 +- src/m_cheat.c | 8 ++++---- src/m_cond.c | 2 +- src/m_menu.c | 8 ++++---- src/m_perfstats.c | 18 +++++++++--------- src/p_enemy.c | 8 ++++---- src/p_mobj.c | 24 ++++++++++++------------ src/p_setup.c | 4 ++-- src/p_spec.c | 6 +++--- src/r_main.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 4 ++-- src/s_sound.c | 6 +++--- src/s_sound.h | 4 ++-- src/strcasestr.c | 8 ++++---- src/w_wad.c | 18 +++++++++--------- src/y_inter.c | 8 ++++---- 32 files changed, 142 insertions(+), 141 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 2a80cfa39..e57119fb9 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/blua/lstrlib.c b/src/blua/lstrlib.c index e2fd23604..6fe279bcb 100644 --- a/src/blua/lstrlib.c +++ b/src/blua/lstrlib.c @@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) { if (find) { lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, res-s); /* end */ - return push_captures(&ms, NULL, 0) + 2; + return push_captures(&ms, NULL, NULL) + 2; } else return push_captures(&ms, s1, res); diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 76a798751..22fa8bf53 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -772,10 +772,10 @@ union luai_Cast { double l_d; long l_l; }; #include #if defined(__GNUC__) -#define l_likely(x) (__builtin_expect(((x) != 0), 1)) -#define l_unlikely(x) (__builtin_expect(((x) != 0), 0)) +#define l_likely(x) (__builtin_expect(!!(x), 1)) +#define l_unlikely(x) (__builtin_expect(!!(x), 0)) #else -#define l_likely(x) (x) +#define l_likely(x) (x) #define l_unlikely(x) (x) #endif diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d4983daa2..68ab08c5a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -332,7 +332,7 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernu #ifdef PARANOIA if (id >= MAXNETXCMD) I_Error("Command id %d too big", id); - if (listnetxcmd[id] != 0) + if (listnetxcmd[id] != NULL) I_Error("Command id %d already used", id); #endif listnetxcmd[id] = cmd_f; @@ -1236,7 +1236,7 @@ static void CL_DrawConnectionStatus(void) va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va("%3.1fK/s ", ((double)getbps)/1024)); + va("%3.1fK/s ", ((double)getbps)/1024.0)); } else cltext = M_GetText("Waiting to download game state..."); @@ -1963,7 +1963,7 @@ static boolean SV_ResendingSavegameToAnyone(void) static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; - savebuffer_t save = {0}; + savebuffer_t save = {}; UINT8 *compressedsave; UINT8 *buffertosend; @@ -2033,7 +2033,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O static void SV_SavedGame(void) { size_t length; - savebuffer_t save = {0}; + savebuffer_t save = {}; char tmpsave[264]; if (!cv_dumpconsistency.value) @@ -2073,7 +2073,7 @@ static void SV_SavedGame(void) static void CL_LoadReceivedSavegame(boolean reloading) { - savebuffer_t save = {0}; + savebuffer_t save = {}; size_t length, decompressedlen; char tmpsave[264]; @@ -7237,7 +7237,7 @@ void CL_ClearRewinds(void) rewind_t *CL_SaveRewindPoint(size_t demopos) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime) @@ -7260,7 +7260,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) rewind_t *CL_RewindToTime(tic_t time) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; while (rewindhead && rewindhead->leveltime > time) diff --git a/src/d_main.c b/src/d_main.c index ab5fe7a10..3e474cec3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1865,7 +1865,8 @@ void D_SRB2Main(void) if (M_CheckParm("-warp") && M_IsNextParm()) { const char *word = M_GetNextParm(); - pstartmap = G_FindMapByNameOrCode(word, 0); + pstartmap = G_FindMapByNameOrCode(word, NULL); + if (! pstartmap) I_Error("Cannot find a map remotely named '%s'\n", word); else diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c669da59b..781120be2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -249,7 +249,7 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; -consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -458,16 +458,16 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0 static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}}; consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}}; -consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; @@ -2789,7 +2789,7 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { - if (!mapheaderinfo[newmapnum-1]) + if (mapheaderinfo[newmapnum-1] == NULL) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); return; diff --git a/src/f_finale.c b/src/f_finale.c index 801af8ab5..32ed8c3ec 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1318,7 +1318,7 @@ boolean F_ContinueResponder(event_t *event) keypressed = true; imcontinuing = true; continuetime = TICRATE; - S_StartSound(0, sfx_itemup); + S_StartSound(NULL, sfx_itemup); return true; } diff --git a/src/g_demo.c b/src/g_demo.c index 312e57530..ede5adf18 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -76,7 +76,7 @@ static tic_t demostarttime; // for comparative timing purposes //@TODO put these all in a struct for namespacing purposes? static char demoname[128]; -savebuffer_t demobuf = {0}; +savebuffer_t demobuf = {}; static UINT8 *demotime_p, *demoinfo_p; static UINT8 *demoend; static UINT8 demoflags; diff --git a/src/g_game.c b/src/g_game.c index 892579163..27a2922a8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3501,7 +3501,7 @@ void G_LoadGameData(void) INT32 i, j; UINT8 modded = false; UINT8 rtemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; //For records tic_t rectime; @@ -3634,7 +3634,7 @@ void G_SaveGameData(boolean force) size_t length; INT32 i, j; UINT8 btemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; (void)force; char backupfile[MAX_WADPATH+4]; @@ -3805,7 +3805,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) size_t length; char vcheck[VERSIONSIZE]; char savename[255]; - savebuffer_t save = {0}; + savebuffer_t save = {}; // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots memset(&savedata, 0, sizeof(savedata)); @@ -3891,7 +3891,7 @@ void G_SaveGame(UINT32 savegameslot) boolean saved; char savename[256] = ""; const char *backup; - savebuffer_t save = {0}; + savebuffer_t save = {}; sprintf(savename, savegamename, savegameslot); backup = va("%s",savename); @@ -4161,7 +4161,7 @@ static void measurekeywords(mapsearchfreq_t *fr, PU_STATIC, NULL); for (qp = strtok(va("%s", q), " "); qp && fr->total < 255; - qp = strtok(0, " ")) + qp = strtok(NULL, " ")) { if (( sp = strcasestr(s, qp) )) { @@ -4242,7 +4242,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { newmapnum = mapnum; newmapname = realmapname; - realmapname = 0; + realmapname = NULL; Z_Free(apromapname); if (!wanttable) break; @@ -4263,7 +4263,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { apromapnum = mapnum; apromapname = realmapname; - realmapname = 0; + realmapname = NULL; } } else/* ...match individual keywords */ diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 4d6b1ea6e..8bf7f7375 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -391,7 +391,7 @@ void HWR_RenderBatches(void) nextSurfaceInfo = nextEntry->surf; if (nextPolyFlags & PF_NoTexture) - nextTexture = 0; + nextTexture = NULL; if (useshader && currentShader != nextShader) { diff --git a/src/hardware/hw_md2load.c b/src/hardware/hw_md2load.c index 3805deffb..d28ebf058 100644 --- a/src/hardware/hw_md2load.c +++ b/src/hardware/hw_md2load.c @@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); //size_t fileLen; @@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) { texPos++; namelen = strlen(texPos) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, texPos); } else { namelen = strlen(fileName) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, fileName); } @@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) header = (md2header_t*)buffer; retModel->numMeshes = 1; // MD2 only has one mesh - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes[0].numFrames = header->numFrames; // const float WUNITS = 1.0f; // float dataScale = WUNITS; @@ -332,7 +332,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); // int t; for (t = 0; t < retModel->numMaterials; t++) @@ -409,9 +409,9 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) float *uvptr; dataScale = 0.015624f; // 1 / 64.0f - retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0); + retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].numVertices = header->numXYZ; - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); ptr = (char*)frames; for (i = 0; i < header->numFrames; i++, ptr += header->framesize) @@ -423,12 +423,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0); - retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0); + retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); + retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); - retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0); + retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); vertptr = retModel->meshes[0].tinyframes[i].vertices; normptr = retModel->meshes[0].tinyframes[i].normals; @@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) char *ptr; retModel->meshes[0].numVertices = header->numTris * 3; - retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0); - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); trisPtr = tris; uvptr = retModel->meshes[0].uvs; @@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); - retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); + retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); + retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); //float *vertptr, *normptr; diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index 53f6034c0..b536c7e73 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); // find length of file fseek(f, 0, SEEK_END); @@ -201,7 +201,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); for (t = 0; t < retModel->numMaterials; t++) { @@ -225,7 +225,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->materials[t].spheremap = false; } - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); matCount = 0; for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) @@ -298,9 +298,9 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) unsigned short *indexptr; md3Triangle *mdT; - retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0); + retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].numVertices = mdS->numVerts; - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { short *vertptr; @@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) // char *tanptr; int k; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0); - retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0); + retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); + retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); - retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0); + retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); vertptr = retModel->meshes[i].tinyframes[j].vertices; normptr = retModel->meshes[i].tinyframes[j].normals; @@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) int k; retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; - retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0); - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { float *vertptr; float *normptr; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); - retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); + retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); // if (retModel->materials[i].lightmap) // retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); vertptr = retModel->meshes[i].frames[j].vertices; diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 8698365e4..274c23394 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -189,7 +189,7 @@ model_t *LoadModel(const char *filename, int ztag) return NULL; } - model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0); + model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL); strcpy(model->mdlFilename, filename); Optimize(model); @@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model) { mdlframe_t *frame = &mesh->frames[j]; int memTag = PU_STATIC; - float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0); + float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL); int k; float *vertPtr = frame->vertices; float *oldNormals; @@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material) } // Didn't find it, so add to the list - newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0); + newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL); newMatNode->material = material; ListAdd(newMatNode, (listitem_t**)head); return true; @@ -351,7 +351,7 @@ void Optimize(model_t *model) } memTag = PU_STATIC; - newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0); + newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL); i = 0; for (node = matListHead; node; node = node->next) @@ -377,14 +377,14 @@ void Optimize(model_t *model) newMesh->numFrames = 1; newMesh->numTriangles = numTriangles; newMesh->numVertices = numTriangles * 3; - newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); - newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0); + newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL); + newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL); curFrame = &newMesh->frames[0]; curFrame->material = curMat; - curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0); + curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL); // Now traverse the meshes of the model, adding in // vertices/normals/uvs that match the current material diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index edd2f51a7..fab0a8a6d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -98,10 +98,10 @@ static size_t textureBufferSize = 0; static LTListItem *LightTablesTail = NULL; static LTListItem *LightTablesHead = NULL; -static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering +static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table -RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA +RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA static GLint gltexformat = GL_RGB5_A1; GLint screen_width = 0; // used by Draw2DLine() @@ -127,9 +127,9 @@ GLuint gl_num_extensions; int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -GLfloat modelMatrix[16] = {0}; -GLfloat projMatrix[16] = {0}; -static GLint viewport[4]; +GLfloat modelMatrix[16] = {}; +GLfloat projMatrix[16] = {}; +static GLint viewport[4]; #ifdef USE_FBO_OGL enum @@ -171,7 +171,7 @@ boolean supportstencil = false; // flush all of the stored textures, leaving them unavailable at times such as between levels // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs // can know when the textures aren't there, as textures are always considered resident in their virtual memory -static GLuint screenTextures[NUMSCREENTEXTURES] = {0}; +static GLuint screenTextures[NUMSCREENTEXTURES] = {}; #define byte2float(byte) (GLfloat)(byte / 255.0f) diff --git a/src/http-mserv.c b/src/http-mserv.c index 8e35f905d..fd63c5f69 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -189,7 +189,7 @@ HMS_connect (const char *format, ...) seek = strlen(hms_api) + 1;/* + '/' */ va_start (ap, format); - url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); + url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); va_end (ap); sprintf(url, "%s/", hms_api); @@ -471,8 +471,8 @@ HMS_fetch_servers (msg_server_t *list, int query_id) *end = '\0'; address = strtok(p, " "); - port = strtok(0, " "); - contact = strtok(0, ""); + port = strtok(NULL, " "); + contact = strtok(NULL, ""); if (address && port) { @@ -539,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size) if (HMS_do(hms)) { version = strtok(hms->buffer, " "); - version_name = strtok(0, "\n"); + version_name = strtok(NULL, "\n"); if (version && version_name) { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 45c3a9f19..9bd5f5203 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -475,7 +475,7 @@ int mobj_localskin_setter(lua_State *L) } else { - mo->localskin = 0; + mo->localskin = NULL; mo->skinlocal = false; } } diff --git a/src/m_cheat.c b/src/m_cheat.c index 2890c7196..58bc1401d 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -80,7 +80,7 @@ static UINT8 cheatf_warp(void) if (success) { G_SaveGameData(true); //G_SetGameModified(false); - S_StartSound(0, sfx_kc42); + S_StartSound(NULL, sfx_kc42); } // Refresh secrets menu existing. @@ -117,13 +117,13 @@ static UINT8 cheatf_devmode(void) #endif static cheatseq_t cheat_warp = { - 0, cheatf_warp, + NULL, cheatf_warp, //{ SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff } { SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff } }; static cheatseq_t cheat_warp_joy = { - 0, cheatf_warp, + NULL, cheatf_warp, /*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), @@ -136,7 +136,7 @@ static cheatseq_t cheat_warp_joy = { #ifdef DEVELOP static cheatseq_t cheat_devmode = { - 0, cheatf_devmode, + NULL, cheatf_devmode, { SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff } }; #endif diff --git a/src/m_cond.c b/src/m_cond.c index acf78e6ef..126d5a49a 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -235,7 +235,7 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1 wnum = conditionSets[set - 1].numconditions; num = ++conditionSets[set - 1].numconditions; - conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0); + conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, NULL); cond = conditionSets[set - 1].condition; diff --git a/src/m_menu.c b/src/m_menu.c index c2978fe82..55112356b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5385,7 +5385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na { CONS_Printf("custom settings menu initiation\n"); for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP) - OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX}; + OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", NULL, INT16_MAX}; } if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text))) @@ -7494,7 +7494,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR) mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/ - V_DrawFixedPatch((x+w)<>1), (staty+67)<>1, 0, statlr, flashcol); V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<>1, 0, statud, flashcol); // bg - V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, 0); + V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, NULL); for (i = 0; i < numskins; i++) // draw the stat dots { @@ -8218,7 +8218,7 @@ static void M_DrawSetupMultiPlayerMenu(void) V_DrawFixedPatch((statx+64)<flags2 & MF2_FRET) { P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1); - S_StartSound(0, sfx_s3k53); + S_StartSound(NULL, sfx_s3k53); actor->flags2 &= ~MF2_FRET; return; } @@ -6011,7 +6011,7 @@ void A_Boss7Chase(void *thing) { // Punch him! P_SetMobjState(actor, actor->info->meleestate); - S_StartSound(0, sfx_begrnd); // warning sound + S_StartSound(NULL, sfx_begrnd); // warning sound return; } } @@ -6057,7 +6057,7 @@ void A_Boss7Chase(void *thing) case 2: // Homing Missile A_FaceTarget(actor); P_SetMobjState(actor, actor->info->missilestate); - S_StartSound(0, sfx_beflap); + S_StartSound(NULL, sfx_beflap); break; } @@ -10739,7 +10739,7 @@ void A_BrakChase(void *thing) { actor->reactiontime--; if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON) - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } // modify target threshold diff --git a/src/p_mobj.c b/src/p_mobj.c index ad7982d87..581edf2f0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3606,10 +3606,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj) // Just the identification of a precip thinker. The thinker // should never actually be called! // -void P_NullPrecipThinker(precipmobj_t *mobj) +FUNCNORETURN void P_NullPrecipThinker(precipmobj_t *mobj) { (void)mobj; - I_Assert("P_NullPrecipThinker should not be called" == 0); + I_Error("P_NullPrecipThinker should not be called"); } boolean P_PrecipThinker(precipmobj_t *mobj) @@ -4012,7 +4012,7 @@ static void P_Boss3Thinker(mobj_t *mobj) if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime) { mobj->extravalue1 = (INT32)leveltime; - S_StartSound(0, sfx_buzz1); + S_StartSound(NULL, sfx_buzz1); } // If in the center, check to make sure @@ -4631,7 +4631,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (mobj->health > 0) mobj->health--; - S_StartSound(0, (mobj->health) ? sfx_behurt : sfx_bedie2); + S_StartSound(NULL, (mobj->health) ? sfx_behurt : sfx_bedie2); mobj->reactiontime /= 3; @@ -4670,7 +4670,7 @@ static void P_Boss7Thinker(mobj_t *mobj) INT32 i; mobj->state->nextstate = mobj->info->painstate; // Reset - S_StartSound(0, sfx_bedeen); + S_StartSound(NULL, sfx_bedeen); for (i = 0; i < MAXPLAYERS; i++) { @@ -4694,7 +4694,7 @@ static void P_Boss7Thinker(mobj_t *mobj) mobj->state->nextstate = mobj->info->spawnstate; // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } } } @@ -4714,7 +4714,7 @@ static void P_Boss7Thinker(mobj_t *mobj) var2 = 2*TICRATE + (80<<16); A_LobShot(mobj); - S_StartSound(0, sfx_begoop); + S_StartSound(NULL, sfx_begoop); } } else if (mobj->state == &states[S_BLACKEGG_SHOOT2]) @@ -4738,7 +4738,7 @@ static void P_Boss7Thinker(mobj_t *mobj) S_StopSound(missile); if (leveltime & 1) - S_StartSound(0, sfx_beshot); + S_StartSound(NULL, sfx_beshot); } else if (mobj->state == &states[S_BLACKEGG_JUMP1] && mobj->tics == 1) { @@ -4871,7 +4871,7 @@ static void P_Boss7Thinker(mobj_t *mobj) fixed_t x,y,z; mobj_t *mo2; - S_StartSound(0, sfx_befall); + S_StartSound(NULL, sfx_befall); z = mobj->floorz; for (j = 0; j < 2; j++) @@ -4910,13 +4910,13 @@ static void P_Boss7Thinker(mobj_t *mobj) P_DamageMobj(players[i].mo, mobj, mobj, 1); // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } P_SetMobjState(mobj, mobj->info->spawnstate); } else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics) - S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1)); + S_StartSound(NULL, sfx_bedie1 + (P_RandomFixed() & 1)); } // Metal Sonic battle boss @@ -10711,7 +10711,7 @@ void P_SpawnPlayer(INT32 playernum) // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; - mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0); + mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL); mobj->skinlocal = p->skinlocal; mobj->health = p->health; diff --git a/src/p_setup.c b/src/p_setup.c index bf40afe9d..612530882 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1022,7 +1022,7 @@ void P_WriteThings(lumpnum_t lumpnum) size_t i, length; mapthing_t *mt; UINT8 *data; - savebuffer_t save = {0}; + savebuffer_t save = {}; INT16 temp; data = W_CacheLumpNum(lumpnum, PU_LEVEL); @@ -1166,7 +1166,7 @@ static void P_LoadLineDefs2(void) for (; i--; ld++) { ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; // Repeat count for midtexture if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) diff --git a/src/p_spec.c b/src/p_spec.c index 66901d234..5045a8287 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4579,8 +4579,8 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) if (!sec->ffloors) { sec->ffloors = ffloor; - ffloor->next = 0; - ffloor->prev = 0; + ffloor->next = NULL; + ffloor->prev = NULL; return; } @@ -4588,7 +4588,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) rover->next = ffloor; ffloor->prev = rover; - ffloor->next = 0; + ffloor->next = NULL; } /** Adds a 3Dfloor. diff --git a/src/r_main.cpp b/src/r_main.cpp index fecfba580..e3bfb83fa 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1087,7 +1087,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) ret = &subsectors[nodenum & ~NF_SUBSECTOR]; for (i = 0; i < ret->numlines; i++) if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) - return 0; + return NULL; return ret; } diff --git a/src/r_skins.c b/src/r_skins.c index 538b8c38a..41971788c 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -302,7 +302,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) if (player->mo) { - player->mo->localskin = 0; + player->mo->localskin = NULL; player->mo->skinlocal = false; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index cab9512e3..77b02b78c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -532,8 +532,8 @@ void R_ClearSprites(void) visspritecount = numvisiblesprites = clippedvissprites = 0; } -static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; -static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; +static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; +static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; static void R_AllocVisSpriteChunkMemory(UINT32 chunk) { diff --git a/src/s_sound.c b/src/s_sound.c index e8075469c..7f931671d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -884,7 +884,7 @@ static void S_StopChannel(INT32 cnum) if (cnum != i && c->sfxinfo == channels[i].sfxinfo) break; - c->sfxinfo = 0; + c->sfxinfo = NULL; } c->origin = NULL; @@ -1271,7 +1271,7 @@ static musicdef_t *S_AddMusicCredit(void) return &musicdefs[chunk][i]; } -struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info +struct cursongcredit cursongcredit = {}; // Currently displayed song credit info static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp) { @@ -1704,7 +1704,7 @@ static void S_UnloadMusic(void) music.flags = 0; music.looping = false; - music_refade_cv = 0; + music_refade_cv = NULL; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) diff --git a/src/s_sound.h b/src/s_sound.h index 9e0296d2b..c7f487e92 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -253,9 +253,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 void S_ChangeMusicSpecial (const char *mmusic); -void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +void S_SetRestoreMusicFadeInCvar(consvar_t *cvar); #define S_ClearRestoreMusicFadeInCvar() \ - S_SetRestoreMusicFadeInCvar(0) + S_SetRestoreMusicFadeInCvar(NULL) int S_GetRestoreMusicFadeIn (void); // Stops the music. diff --git a/src/strcasestr.c b/src/strcasestr.c index d24a36e54..f50141dcf 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -73,8 +73,8 @@ nongnu_strcasestr (const char *s, const char *q) up = strchr(s, uc); lp = strchr(s, lc); - if (!( (intptr_t)up|(intptr_t)lp )) - return 0; + if (up == NULL || lp == NULL) + return NULL; if (!lp || ( up && up < lp )) { @@ -100,12 +100,12 @@ nongnu_strcasestr (const char *s, const char *q) if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); - if (!( (intptr_t)up|(intptr_t)lp )) + if (up == NULL || lp == NULL) break; if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) swapp(&ppa, &ppb, &cpa, &cpb); } - return 0; + return NULL; } diff --git a/src/w_wad.c b/src/w_wad.c index 7e1ec30df..432f1421f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -697,12 +697,12 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -1667,9 +1667,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; strm.total_in = strm.avail_in = rawSize; strm.total_out = strm.avail_out = decSize; @@ -2238,14 +2238,14 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -2483,14 +2483,14 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? diff --git a/src/y_inter.c b/src/y_inter.c index d35fa7825..27e794ffc 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -104,7 +104,7 @@ typedef struct } y_voteclient; // votescreen stuff -votescreen_t VoteScreen = {0}; +votescreen_t VoteScreen = {}; static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; @@ -1093,7 +1093,7 @@ void Y_VoteDrawer(void) V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic); else { - V_DrawFixedPatch((BASEVIDWIDTH-20)< Date: Thu, 8 Jan 2026 00:27:06 +0100 Subject: [PATCH 03/40] K_SpawnSparkleTrail: check for blend effect apply outside the loop tiny optimization --- src/k_kart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index bb4da62a5..342414738 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3595,6 +3595,8 @@ void K_SpawnSparkleTrail(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); + const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player)); + for (i = 0; i < 3; i++) { fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<color = mo->color; - if (mo->player && K_PlayerEffectsShouldBlend(mo->player)) + if (shouldblend) sparkle->blendmode = AST_ADD; } From d938e38ad3d00a8fb0797d1d489446e026a4ab83 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:26:02 +0100 Subject: [PATCH 04/40] Acessability: add basic "reducevfx" toggle to disable/reduce certain effects toggles certain effects, which may be troublesome to some players -disabled hyudoro flashing, instead makes player translucent - Makes rainbow colour effects, such as invul, change colours very slowly - Disables underwater and heatwave screen effects - Disables palette flashing - Disables vhs effect not the most pretty implementation, but im lazy and this works feel free to suggest more things --- src/g_game.h | 1 + src/hardware/hw_main.cpp | 24 ++++- src/hardware/hw_md2.c | 11 ++- src/k_kart.c | 11 ++- src/p_mobj.c | 3 +- src/r_things.cpp | 11 ++- src/v_video.c | 197 ++++++++++++++++++++------------------- 7 files changed, 150 insertions(+), 108 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 509749c5f..6ecc69dfa 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -130,6 +130,7 @@ extern consvar_t cv_spinoutroll; extern consvar_t cv_squishdance, cv_squishdancespeed; extern consvar_t cv_playerblendeffects; +extern consvar_t cv_reducevfx; extern consvar_t cv_cechotoggle; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 70a5a3a8d..1622a4528 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3786,8 +3786,15 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -4076,8 +4083,15 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -6100,7 +6114,7 @@ static void HWR_DoPostProcessor(void) const camera_t *thiscam = &camera[0]; // Not supported in splitscreen - someone want to add support? - const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); + const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); // Capture the screen for intermission and screen waving if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 763fb873c..e45a56cda 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1198,8 +1198,15 @@ void HWR_DrawMD2(gl_vissprite_t *spr) Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } - if (cv_playerfade.value && spr->mobj->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + if (spr->mobj->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && spr->mobj->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + } // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted diff --git a/src/k_kart.c b/src/k_kart.c index 342414738..59271a1e4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -47,6 +47,8 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_reducevfx = {"reducevfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // funn-E streeetch static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -482,7 +484,8 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = { // UINT8 K_RainbowColor(void) { - return (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + const INT32 time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; + return (UINT8)(1 + (time % (MAXSKINCOLORS-1))); } // Define for getting accurate color brightness readings according to how the human eye sees them. @@ -764,6 +767,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_playerblendeffects); + CV_RegisterVar(&cv_reducevfx); + CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); @@ -6768,7 +6773,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { if (splitscreen) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; @@ -6794,7 +6799,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (P_IsDisplayPlayer(player) || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; diff --git a/src/p_mobj.c b/src/p_mobj.c index 581edf2f0..d1b8b850a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12354,8 +12354,9 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai // void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration) { - if (!pl) + if (!pl || cv_reducevfx.value) // no palette flashing with reducevfx return; + pl->flashcount = duration; pl->flashpal = type; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 77b02b78c..d1c856238 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1588,8 +1588,15 @@ static void R_ProjectSprite(mobj_t *thing) else trans = 0; - if (cv_playerfade.value && thing->player) - trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + if (thing->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && thing->player->kartstuff[k_hyudorotimer] > 0) + trans = static_cast(R_GetThingTransTable(FRACUNIT/2, static_cast(trans))); + + if (cv_playerfade.value) + trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + } //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) diff --git a/src/v_video.c b/src/v_video.c index ac85715ef..bb118d269 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "d_main.h" +#include "g_game.h" #include "r_local.h" #include "p_local.h" #include "v_video.h" @@ -1755,6 +1756,9 @@ void V_DrawVhsEffect(boolean rewind) #endif SINT8 offs; + if (cv_reducevfx.value) + return; + barsize = vid.dup << 5; updistort = vid.dup << (rewind ? 5 : 3); downdistort = updistort >> 1; @@ -3639,127 +3643,130 @@ void V_DoPostProcessor(INT32 view, INT32 param) UINT8 *tmpscr = vid.screens[4]; UINT8 *srcscr = vid.screens[0]; - if (thiscam->postimg & POSTIMG_WATER) + if (!cv_reducevfx.value) { - INT32 y; - // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic - angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; - INT32 newpix; - INT32 sine; - //UINT8 *transme = transtables + ((tr_trans50-1)<postimg & POSTIMG_WATER) { - sine = (FINESINE(disStart)*5)>>FRACBITS; - newpix = abs(sine); + INT32 y; + // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic + angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; + INT32 newpix; + INT32 sine; + //UINT8 *transme = transtables + ((tr_trans50-1)<>FRACBITS; + newpix = abs(sine); - // Cleanup edge - while (newpix) + if (sine < 0) { - tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; - newpix--; - } - } - else - { - memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); - // Cleanup edge - while (newpix) + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; + newpix--; + } + } + else { - tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; - newpix--; + memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; + newpix--; + } } + + /* + Unoptimized version + for (x = 0; x < vid.width; x++) + { + newpix = (x + sine); + + if (newpix < 0) + newpix = 0; + else if (newpix >= vid.width) + newpix = vid.width-1; + + tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); + }*/ + + disStart += 22;//the offset into the displacement map, increment each game loop + disStart &= FINEMASK; //clip it to FINEMASK } - /* - Unoptimized version - for (x = 0; x < vid.width; x++) - { - newpix = (x + sine); - - if (newpix < 0) - newpix = 0; - else if (newpix >= vid.width) - newpix = vid.width-1; - - tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); - }*/ - - disStart += 22;//the offset into the displacement map, increment each game loop - disStart &= FINEMASK; //clip it to FINEMASK + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave - { - INT32 y; - - // Make sure table is built - if (heatshifter == NULL || lastheight != viewheight) + else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { - if (heatshifter) - Z_Free(heatshifter); + INT32 y; - heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); - - for (y = 0; y < viewheight; y++) + // Make sure table is built + if (heatshifter == NULL || lastheight != viewheight) { - if (M_RandomChance(FRACUNIT/8)) // 12.5% - heatshifter[y] = true; + if (heatshifter) + Z_Free(heatshifter); + + heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); + + for (y = 0; y < viewheight; y++) + { + if (M_RandomChance(FRACUNIT/8)) // 12.5% + heatshifter[y] = true; + } + + heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; + lastheight = viewheight; } - heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; - lastheight = viewheight; - } - - for (y = yoffset; y < yoffset+viewheight; y++) - { - if (heatshifter[heatindex[view]++]) + for (y = yoffset; y < yoffset+viewheight; y++) { - // Shift this row of pixels to the right by 2 - tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + if (heatshifter[heatindex[view]++]) + { + // Shift this row of pixels to the right by 2 + tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + } + else + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + + heatindex[view] %= viewheight; } - else - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); - heatindex[view] %= viewheight; + if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? + { + heatindex[view]++; + heatindex[view] %= vid.height; + } + + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? - { - heatindex[view]++; - heatindex[view] %= vid.height; - } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - #ifdef MOTIONBLUR - if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! - { - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_MOTION) // Motion Blur! { - for (x = xoffset; x < xoffset+viewwidth; x++) - tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))]; + INT32 x, y; + + // TODO: Add a postimg_param so that we can pick the translucency level... + UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down { From bdc326b14e49d73ff19784cc7ce391f8cb57a95e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:43:35 +0100 Subject: [PATCH 05/40] leveltime be tic_t :chaosleep: --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 59271a1e4..6496f3e8e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -484,7 +484,7 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = { // UINT8 K_RainbowColor(void) { - const INT32 time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; + const tic_t time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; return (UINT8)(1 + (time % (MAXSKINCOLORS-1))); } From 8fe3d13935370048eaf2b3c20bf750a876625848 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 9 Jan 2026 11:08:10 +0100 Subject: [PATCH 06/40] fix InitColorLUT --- src/v_video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index bb118d269..dbb3b385b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3821,7 +3821,7 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors) lut->init = true; memcpy(lut->palette, palette, palsize); - for (i = 0; i < 0xFFFF; i++) + for (i = 0; i < 0x10000; i++) lut->table[i] = 0xFFFF; if (makecolors) @@ -3834,7 +3834,9 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors) { for (b = 0; b < 0xFF; b++) { - lut->table[i] = GetColorLUT(lut, r, g, b); + i = CLUTINDEX(r, g, b); + if (lut->table[i] == 0xFFFF) + lut->table[i] = NearestPaletteColor(r, g, b, palette); } } } From 291a4dbb25472b459d6b74b3b40f378140322fd4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 9 Jan 2026 13:00:47 +0100 Subject: [PATCH 07/40] disable midnight channel border flicker with "reducevfx" --- src/st_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 99188e919..5ca3f9d91 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -720,7 +720,7 @@ void ST_DrawDemoTitleEntry(void) static void ST_MayonakaStatic(void) { INT32 flag; - if (cv_lessflicker.value) + if (cv_lessflicker.value || cv_reducevfx.value) flag = V_70TRANS; else flag = (leveltime%2) ? V_90TRANS : V_70TRANS; From 0914d5b8e29496a5662fb318f44739ffb7aa69d4 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Jan 2026 00:49:48 +0300 Subject: [PATCH 08/40] -Wzero-as-null-pointer-constant is valid for c only since GCC 15.2 (from what i see) --- src/Makefile.d/versions.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index e57119fb9..9a1706cc7 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,10 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +ifdef GCC152 +WFLAGS+-Wzero-as-null-pointer-constant +endif ifndef GCC295 #WFLAGS+=-Wno-packed endif From 310f67a06c20a8594d740b6b10a9feeaf70bc745 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Jan 2026 03:49:07 +0300 Subject: [PATCH 09/40] Fix smol mistake in strcasestr --- src/strcasestr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strcasestr.c b/src/strcasestr.c index f50141dcf..3eb6af60f 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -73,7 +73,7 @@ nongnu_strcasestr (const char *s, const char *q) up = strchr(s, uc); lp = strchr(s, lc); - if (up == NULL || lp == NULL) + if (up == NULL && lp == NULL) return NULL; if (!lp || ( up && up < lp )) @@ -100,7 +100,7 @@ nongnu_strcasestr (const char *s, const char *q) if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); - if (up == NULL || lp == NULL) + if (up == NULL && lp == NULL) break; if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) From e88773da4e81c51248666539c40d12be8b4f60aa Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Jan 2026 13:08:23 +0300 Subject: [PATCH 10/40] How did i miss the = --- src/Makefile.d/versions.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 9a1706cc7..c3989bb4f 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -22,7 +22,7 @@ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference ifdef GCC152 -WFLAGS+-Wzero-as-null-pointer-constant +WFLAGS+=-Wzero-as-null-pointer-constant endif ifndef GCC295 #WFLAGS+=-Wno-packed From 264c9e38ad81235f8b7855cebb43ce5d0ec44533 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Jan 2026 19:46:34 +0100 Subject: [PATCH 11/40] d_netfil: dont use zone memory in CURLGetFile --- src/d_netfil.c | 11 ++++++++--- src/d_netfil.h | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index a4478fcc9..ed186bba5 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -131,6 +131,8 @@ static UINT32 curl_origtotalfilesize; static char *curl_realname = NULL; fileneeded_t *curl_curfile = NULL; HTTP_login *curl_logins = NULL; + +static void CURLGetFile(void); #endif /** Fills a serverinfo packet with information about wad files loaded. @@ -1305,6 +1307,7 @@ void CURLPrepareFile(const char* url, int dfilenum) if (!multi_handle) { cc = curl_global_init(CURL_GLOBAL_ALL); + if (cc < 0) { I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc); @@ -1313,6 +1316,7 @@ void CURLPrepareFile(const char* url, int dfilenum) { multi_handle = curl_multi_init(); } + if (!multi_handle) { I_OutputMsg("libcurl: curl_multi_init() failed\n"); @@ -1441,7 +1445,7 @@ void CURLAbortFile(void) #endif } -void CURLGetFile(void) +static void CURLGetFile(void) { #ifdef HAVE_THREADS I_lock_mutex(&downloadmutex); @@ -1483,7 +1487,8 @@ void CURLGetFile(void) e = m->easy_handle; easyres = m->data.result; - char *filename = Z_StrDup(curl_realname); + char *filename = malloc(strlen(curl_realname)+1); + strcpy(filename, curl_realname); nameonly(filename); if (easyres != CURLE_OK) @@ -1521,7 +1526,7 @@ void CURLGetFile(void) } } - Z_Free(filename); + free(filename); curl_curfile->file = NULL; filedownload.remaining--; mc = curl_multi_remove_handle(multi_handle, e); diff --git a/src/d_netfil.h b/src/d_netfil.h index 3c7502451..268cd80be 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -119,7 +119,6 @@ size_t nameonlylength(const char *s); #ifdef HAVE_CURL void CURLPrepareFile(const char* url, int dfilenum); void CURLAbortFile(void); -void CURLGetFile(void); HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); #endif From b145d7fd0e351f89371f1071c544aa125cb49991 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 10:44:30 +0100 Subject: [PATCH 12/40] WIP: show 3d models in player setup this is incredibly ugly and hacked together theres some weird culling issues and shit doesent really "scale" with different resolutions which needs to be fixed but it kinda works --- src/hardware/hw_gl.h | 3 + src/hardware/hw_md2.c | 111 +++++++++++++++++++++++++++++++ src/hardware/hw_md2.h | 3 + src/hardware/r_opengl/r_opengl.c | 52 +++++++++++++++ src/m_menu.c | 51 +++++++++++--- 5 files changed, 212 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index 7e167485e..de5ac6338 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -80,6 +80,9 @@ UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable); void GL_ClearLightTables(void); void GL_SetScreenPalette(RGBA_t *palette); +void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, + FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index e45a56cda..2579a3cdb 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1475,4 +1475,115 @@ void HWR_DrawMD2(gl_vissprite_t *spr) } } +// mostly copy paste of HWR_DrawMD2 +// very ugly but our model code kinda sucks +void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t color, const UINT8 *colormap, fixed_t scale, INT32 frame, angle_t angle) +{ + patch_t *gpatch, *blendgpatch; + GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; + FTransform p; + FSurfaceInfo Surf; + + if (!md2->model) + { + char filename[64]; + CONS_Debug(DBG_RENDER, "Loading model... (%s)\n", md2->filename); + sprintf(filename, "mdls/%s", md2->filename); + md2->model = md2_readModel(filename); + + if (md2->model) + { + md2_printModelInfo(md2->model); + GL_CreateModelVBOs(md2->model); + } + else + { + md2->error = true; + return; + } + } + + if (md2->model->meshes[0].numFrames > 0) + frame = frame % md2->model->meshes[0].numFrames; + else + frame = 0; + + gpatch = static_cast(md2->glpatch); + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + if (!gpatch || !hwrPatch || + ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile)) + md2_loadTexture(md2); + + gpatch = static_cast(md2->glpatch); + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + blendgpatch = static_cast(md2->blendglpatch); + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + if ((gpatch && hwrPatch && hwrPatch->mipmap->format) && + (!blendgpatch || !hwrBlendPatch || + ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) + md2_loadBlendTexture(md2); + + blendgpatch = static_cast(md2->blendglpatch); + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + memset(&Surf, 0x00, sizeof(FSurfaceInfo)); + Surf.PolyColor.rgba = 0xFFFFFFFF; + Surf.PolyFlags = PF_Occlude | PF_Modulated; + + Surf.LightInfo.light_level = 255; + Surf.LightInfo.fade_start = 0; + Surf.LightInfo.fade_end = 31; + + if (color != SKINCOLOR_NONE && + blendgpatch && hwrBlendPatch->mipmap->format && + gpatch->width == blendgpatch->width && gpatch->height == blendgpatch->height) + { + INT32 tcskinnum = TC_DEFAULT; + + if (color) + tcskinnum = skinnum; + + HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, colormap, color); + } + else if (hwrPatch && hwrPatch->mipmap->format) + { + GL_SetTexture(hwrPatch->mipmap); + } + + memset(&p, 0x00, sizeof(FTransform)); + + p.x = x; + p.y = -400.0f; // idk man, but this makes the model not cull, kinda? + p.z = y; // for whatever reason y and z are switched here + + p.angley = FixedToFloat(AngleFixed(angle)); + p.anglex = 0.0f; + p.anglez = 0.0f; + + p.roll = false; + + p.fliptype = TRANSFORM_NONE; + + GL_Draw2DModel( + md2->model, + frame, + 0.0f, + 0.0f, + -1, + &p, + FixedToFloat(scale), + FixedToFloat(scale), + true, + false, + &Surf + ); +} + #endif //HWRENDER diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 62de1f35e..0f8bd5342 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -45,6 +45,9 @@ void HWR_InitMD2(void); void HWR_DrawMD2(gl_vissprite_t *spr); void HWR_AddPlayerMD2(INT32 skin, boolean local); void HWR_AddSpriteMD2(size_t spritenum); +void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, + skincolors_t color, const UINT8 *colormap, + fixed_t scale, INT32 frame, angle_t angle); #ifdef __cplusplus } // extern "C" diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index fab0a8a6d..c4c3fc47e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -404,6 +404,14 @@ static PFNglEnableClientState pglEnableClientState; typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap); static PFNglDisableClientState pglDisableClientState; +typedef void (APIENTRY * PFNglOrtho) (GLdouble left, + GLdouble right, + GLdouble bottom, + GLdouble top, + GLdouble nearVal, + GLdouble farVal); +static PFNglOrtho pglOrtho; + /* Lighting */ typedef void (APIENTRY * PFNglShadeModel) (GLenum mode); static PFNglShadeModel pglShadeModel; @@ -858,6 +866,8 @@ void SetupGLFunc4(void) GetGLfunc(glUniform3fv); GetGLfunc(glGetUniformLocation); + GetGLfunc(glOrtho); + #ifdef GLDEBUGMESSAGE GetGLfunc(glDebugMessageCallback); #endif @@ -3090,6 +3100,48 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics pglDisable(GL_NORMALIZE); } +void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, + FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) +{ + // save our matrix´s + pglMatrixMode(GL_PROJECTION); + pglPushMatrix(); + pglMatrixMode(GL_MODELVIEW); + pglPushMatrix(); + + pglMatrixMode(GL_PROJECTION); + pglLoadIdentity(); + + // switch to ortho mode to make our lives easier + // thisll make sure our coords will be remapped to pixel coords + // try to scale it to the base width and height + // shit still be weird, and needs accounting for diff resolutions + pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); + + pglMatrixMode(GL_MODELVIEW); + pglLoadIdentity(); + + //pglDepthRange(0.0f, 1.0f); + pglClearDepth(1.0f); //Hurdler: all that are permanen states + pglDepthRange(ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh + pglDepthFunc(GL_LEQUAL); + pglClear(GL_DEPTH_BUFFER_BIT); + //GL_ClearBuffer(false, true, false, NULL); + + // FIXME: theres some weird culling issues i cant wrap my head around + // so until then gotta disable depth testing until i can figure this out + //pglDisable(GL_DEPTH_TEST); + GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, + pos, hscale, vscale, flipped, hflipped, Surface); + //pglEnable(GL_DEPTH_TEST); + + // restore the matrix´s + pglMatrixMode(GL_PROJECTION); + pglPopMatrix(); + pglMatrixMode(GL_MODELVIEW); + pglPopMatrix(); +} + // -----------------+ // SetTransform : // -----------------+ diff --git a/src/m_menu.c b/src/m_menu.c index 55112356b..f94407284 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12,6 +12,8 @@ /// \file m_menu.c /// \brief XMOD's extremely revamped menu system. +#include "screen.h" +#include "tables.h" #ifdef __GNUC__ #include #endif @@ -8523,7 +8525,7 @@ static void M_DrawSetupMultiPlayerMenu(void) const INT32 skinnum = R_SkinAvailable(skins[skintodisplay].name); - if (skinnum != -1) + if (skinnum > 0 || skinnum < MAXSKINS) sprdef = &skins[skinnum].spritedef; else sprdef = &skins[0].spritedef; @@ -8549,23 +8551,56 @@ static void M_DrawSetupMultiPlayerMenu(void) // draw box around guy V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); +#undef charw // draw player sprite if (setupm_fakecolor) // inverse should never happen { UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); - if (skins[skintodisplay].flags & SF_HIRES) +#ifdef HWRENDER + md2_t *md2 = NULL; + + if (skinnum > 0 || skinnum < MAXSKINS) + md2 = &md2_playermodels[skinnum]; + else + md2 = &md2_playermodels[0]; + + // if we have 3d models enabled and a model exists + // try to show it instead of the sprite + if (rendermode == render_opengl && cv_glmdls.value + && !md2->error && !md2->notfound) { - V_DrawFixedPatch((mx+36)< Date: Mon, 12 Jan 2026 18:08:22 +0300 Subject: [PATCH 13/40] Make HWR_Draw2DModel not depend on resolution, make 3d skin select use skinselectspin cvar --- src/hardware/hw_md2.c | 6 +++--- src/hardware/r_opengl/r_opengl.c | 2 +- src/m_menu.c | 13 +++---------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2579a3cdb..00d4b955f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,7 +1559,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x; + p.x = x + (vid.width/vid.dup - BASEVIDWIDTH)/4; p.y = -400.0f; // idk man, but this makes the model not cull, kinda? p.z = y; // for whatever reason y and z are switched here @@ -1578,8 +1578,8 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c 0.0f, -1, &p, - FixedToFloat(scale), - FixedToFloat(scale), + FixedToFloat(scale) * (BASEVIDWIDTH / ((float)vid.width/vid.dup)), + FixedToFloat(scale) * (BASEVIDHEIGHT / ((float)vid.height/vid.dup)), true, false, &Surf diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index c4c3fc47e..773d19013 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3123,7 +3123,7 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics //pglDepthRange(0.0f, 1.0f); pglClearDepth(1.0f); //Hurdler: all that are permanen states - pglDepthRange(ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh + pglDepthRange(0.f, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh pglDepthFunc(GL_LEQUAL); pglClear(GL_DEPTH_BUFFER_BIT); //GL_ClearBuffer(false, true, false, NULL); diff --git a/src/m_menu.c b/src/m_menu.c index f94407284..ea2cdc9c6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8574,18 +8574,11 @@ static void M_DrawSetupMultiPlayerMenu(void) mx += 36; my += 131; - static angle_t angle = ANGLE_180; + const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - // idk but those magic numbers work, gotta figure out smth proper - //x += vid.width/3; - //y += vid.height/2; - mx += BASEVIDWIDTH/8; - my -= BASEVIDHEIGHT/10; + angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - // just for testing - angle += FRACUNIT * 3; - - HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 4*FRACUNIT/3, 0, angle); + HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 8*FRACUNIT/3, frame, angle); } else #endif From e17a8a505cb3fde85bdd47572246bcac27a58ce7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 16:48:50 +0100 Subject: [PATCH 14/40] fix the culling issues i hope this is right....... --- src/hardware/hw_md2.c | 4 ++-- src/hardware/r_opengl/r_opengl.c | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 00d4b955f..3cf3f060c 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,8 +1559,8 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x + (vid.width/vid.dup - BASEVIDWIDTH)/4; - p.y = -400.0f; // idk man, but this makes the model not cull, kinda? + p.x = x + (vid.width/(float)vid.dup - BASEVIDWIDTH)/4; + p.y = -100.0f; // idk man, but this makes the model not cull, kinda? p.z = y; // for whatever reason y and z are switched here p.angley = FixedToFloat(AngleFixed(angle)); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 773d19013..223cb359f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3116,23 +3116,22 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics // thisll make sure our coords will be remapped to pixel coords // try to scale it to the base width and height // shit still be weird, and needs accounting for diff resolutions - pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); + pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); pglMatrixMode(GL_MODELVIEW); pglLoadIdentity(); - //pglDepthRange(0.0f, 1.0f); - pglClearDepth(1.0f); //Hurdler: all that are permanen states - pglDepthRange(0.f, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh - pglDepthFunc(GL_LEQUAL); + pglEnable(GL_DEPTH_TEST); + pglDepthMask(GL_TRUE); pglClear(GL_DEPTH_BUFFER_BIT); - //GL_ClearBuffer(false, true, false, NULL); // FIXME: theres some weird culling issues i cant wrap my head around // so until then gotta disable depth testing until i can figure this out //pglDisable(GL_DEPTH_TEST); GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface); + + //pglDepthMask(GL_TRUE); //pglEnable(GL_DEPTH_TEST); // restore the matrix´s From c01818e2e393d4932dd7be2f3e52ba9b95b00f14 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 17:22:04 +0100 Subject: [PATCH 15/40] simplify skinnum bounds check lul --- src/m_menu.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ea2cdc9c6..f6145d205 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7948,6 +7948,7 @@ static void M_DrawSetupMultiPlayerMenu(void) UINT8 i; UINT8 s, w; const UINT8 *flashcol = V_GetStringColormap(highlightflags); + INT32 skinnum = 0; INT32 statx, staty; UINT32 speenframe; INT32 sltw, actw, hetw; @@ -8523,12 +8524,12 @@ static void M_DrawSetupMultiPlayerMenu(void) break; } - const INT32 skinnum = R_SkinAvailable(skins[skintodisplay].name); + skinnum = R_SkinAvailable(skins[skintodisplay].name); - if (skinnum > 0 || skinnum < MAXSKINS) - sprdef = &skins[skinnum].spritedef; - else - sprdef = &skins[0].spritedef; + if (skinnum < 0 || skinnum >= MAXSKINS) + skinnum = 0; + + sprdef = &skins[skinnum].spritedef; if (!sprdef->numframes) // No frames ?? return; // Can't render! @@ -8557,14 +8558,8 @@ static void M_DrawSetupMultiPlayerMenu(void) if (setupm_fakecolor) // inverse should never happen { UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); - #ifdef HWRENDER - md2_t *md2 = NULL; - - if (skinnum > 0 || skinnum < MAXSKINS) - md2 = &md2_playermodels[skinnum]; - else - md2 = &md2_playermodels[0]; + md2_t *md2 = &md2_playermodels[skinnum]; // if we have 3d models enabled and a model exists // try to show it instead of the sprite From 7a0fb016262f753acd745073b5cd136fb1bbf51d Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 12 Jan 2026 20:14:17 +0300 Subject: [PATCH 16/40] Make glOrtho remap coordinates to vid.width and vid.height, this makes calculating coordinates in HWR_Draw2DModel easier --- src/hardware/hw_md2.c | 10 +++++----- src/hardware/r_opengl/r_opengl.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 3cf3f060c..f971e1945 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,9 +1559,9 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x + (vid.width/(float)vid.dup - BASEVIDWIDTH)/4; - p.y = -100.0f; // idk man, but this makes the model not cull, kinda? - p.z = y; // for whatever reason y and z are switched here + p.x = x*vid.dup + (vid.width - BASEVIDWIDTH*vid.dup)/2; + p.y = -200.0f; // idk man, but this makes the model not cull, kinda? + p.z = y*vid.dup + (vid.height - BASEVIDHEIGHT*vid.dup)/2; // for whatever reason y and z are switched here p.angley = FixedToFloat(AngleFixed(angle)); p.anglex = 0.0f; @@ -1578,8 +1578,8 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c 0.0f, -1, &p, - FixedToFloat(scale) * (BASEVIDWIDTH / ((float)vid.width/vid.dup)), - FixedToFloat(scale) * (BASEVIDHEIGHT / ((float)vid.height/vid.dup)), + FixedToFloat(scale*vid.dup), + FixedToFloat(scale*vid.dup), true, false, &Surf diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 223cb359f..25d9c0431 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3116,7 +3116,7 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics // thisll make sure our coords will be remapped to pixel coords // try to scale it to the base width and height // shit still be weird, and needs accounting for diff resolutions - pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); + pglOrtho(0.0f, (float)vid.width, (float)vid.height, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); pglMatrixMode(GL_MODELVIEW); pglLoadIdentity(); From 0c091256f40faa6634fcc8bc9831309a3bd1f714 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 18:26:32 +0100 Subject: [PATCH 17/40] tiny cleanup + warning fix --- src/hardware/hw_md2.c | 23 ++++++++++++----------- src/hardware/r_opengl/r_opengl.c | 8 -------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index f971e1945..c00297ff8 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,28 +1559,29 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x*vid.dup + (vid.width - BASEVIDWIDTH*vid.dup)/2; - p.y = -200.0f; // idk man, but this makes the model not cull, kinda? - p.z = y*vid.dup + (vid.height - BASEVIDHEIGHT*vid.dup)/2; // for whatever reason y and z are switched here + p.x = x*vid.dup + (float)(vid.width - BASEVIDWIDTH*vid.dup)/2.f; + p.y = -200.f; // push it back to prevent wonky culling, idk lul + p.z = y*vid.dup + (float)(vid.height - BASEVIDHEIGHT*vid.dup)/2.f; p.angley = FixedToFloat(AngleFixed(angle)); - p.anglex = 0.0f; - p.anglez = 0.0f; + p.anglex = 0.f; + p.anglez = 0.f; p.roll = false; - p.fliptype = TRANSFORM_NONE; + const float fscale = FixedToFloat(scale*vid.dup); + GL_Draw2DModel( md2->model, frame, - 0.0f, - 0.0f, + 0.f, + 0.f, -1, &p, - FixedToFloat(scale*vid.dup), - FixedToFloat(scale*vid.dup), - true, + fscale, + fscale, + true, // flip it vertically lul false, &Surf ); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 25d9c0431..2d1f8e255 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3114,8 +3114,6 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics // switch to ortho mode to make our lives easier // thisll make sure our coords will be remapped to pixel coords - // try to scale it to the base width and height - // shit still be weird, and needs accounting for diff resolutions pglOrtho(0.0f, (float)vid.width, (float)vid.height, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); pglMatrixMode(GL_MODELVIEW); @@ -3125,15 +3123,9 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics pglDepthMask(GL_TRUE); pglClear(GL_DEPTH_BUFFER_BIT); - // FIXME: theres some weird culling issues i cant wrap my head around - // so until then gotta disable depth testing until i can figure this out - //pglDisable(GL_DEPTH_TEST); GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface); - //pglDepthMask(GL_TRUE); - //pglEnable(GL_DEPTH_TEST); - // restore the matrix´s pglMatrixMode(GL_PROJECTION); pglPopMatrix(); From faadd3e89fef20276833856c05479a5adc5ba657 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 18:39:52 +0100 Subject: [PATCH 18/40] support the uhhh localskin setup with 3d models --- src/m_menu.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f6145d205..3f0dca46d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9920,12 +9920,12 @@ static void M_DrawLocalSkinMenu(void) // skin 0 is default player sprite skintodisplay = R_AnySkinAvailable(cv_fakelocalskin.string); - if (skintodisplay == -1) + if (skintodisplay < 0) { // ATTEMPT TO FIND REAL SKIN skintodisplay = R_AnySkinAvailable(cv_skin.string); - if (skintodisplay == -1) // STILL NOTHIN? use sonic instead + if (skintodisplay < 0) // STILL NOTHIN? use sonic instead { skintodisplay = 0; } @@ -9958,6 +9958,7 @@ static void M_DrawLocalSkinMenu(void) // draw box around guy V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239); +#undef charw // draw player sprite UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin); @@ -9972,13 +9973,34 @@ static void M_DrawLocalSkinMenu(void) else V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname); - if (displayskin.flags & SF_HIRES) + // draw player sprite +#ifdef HWRENDER + md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[skintodisplay] : &md2_playermodels[skintodisplay]); + + // if we have 3d models enabled and a model exists + // try to show it instead of the sprite + if (rendermode == render_opengl && cv_glmdls.value + && !md2->error && !md2->notfound) { - V_DrawFixedPatch((mx+220)< Date: Mon, 12 Jan 2026 19:13:08 +0100 Subject: [PATCH 19/40] push back models even further bigger models still had parts being culled, hope this is generous enough idk --- src/hardware/hw_md2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index c00297ff8..0fdd62623 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1560,7 +1560,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); p.x = x*vid.dup + (float)(vid.width - BASEVIDWIDTH*vid.dup)/2.f; - p.y = -200.f; // push it back to prevent wonky culling, idk lul + p.y = -420.f; // push it back to prevent wonky culling, idk lul p.z = y*vid.dup + (float)(vid.height - BASEVIDHEIGHT*vid.dup)/2.f; p.angley = FixedToFloat(AngleFixed(angle)); From 6fd64383d3f9c413ea96ff7c4c80243089e2bfd5 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 12 Jan 2026 22:33:30 +0300 Subject: [PATCH 20/40] This isn't ceepeepee rn :SmolBuncle: --- src/hardware/hw_md2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 0fdd62623..0a79ba6ec 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1508,7 +1508,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c else frame = 0; - gpatch = static_cast(md2->glpatch); + gpatch = (patch_t *)(md2->glpatch); if (gpatch) hwrPatch = ((GLPatch_t *)gpatch->hardware); @@ -1516,11 +1516,11 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile)) md2_loadTexture(md2); - gpatch = static_cast(md2->glpatch); + gpatch = (patch_t*)(md2->glpatch); if (gpatch) hwrPatch = ((GLPatch_t *)gpatch->hardware); - blendgpatch = static_cast(md2->blendglpatch); + blendgpatch = (patch_t*)(md2->blendglpatch); if (blendgpatch) hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); @@ -1529,7 +1529,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) md2_loadBlendTexture(md2); - blendgpatch = static_cast(md2->blendglpatch); + blendgpatch = (patch_t*)(md2->blendglpatch); if (blendgpatch) hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); From 1b8d7b1541ccab0d796043e4596812b4ee79f4f6 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 16 Jan 2026 11:11:36 +0300 Subject: [PATCH 21/40] I_Error when dedi tries to go to main error This will not fix the issue entirely but will at least prevent server getting stuck and backtrace will show where did it try to go into menu from --- src/d_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 3e474cec3..81fd3d830 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -946,6 +946,9 @@ void D_ClearState(void) // void D_StartTitle(void) { + if (dedicated) + I_Error("D_StartTitle is called on dedicated server"); + D_ClearState(); multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao F_StartTitleScreen(); From ac3a1ad5eb841c78c0500b933bf2341b62864323 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 16 Jan 2026 12:02:21 +0300 Subject: [PATCH 22/40] Add gcc 13.3 into list of supported versions --- src/Makefile.d/detect.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 7ff978397..0816c5a03 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -66,7 +66,7 @@ endif gcc_versions:=\ 152 151 150 15\ 142 141 140 14\ - 132 131 130 13\ + 133 132 131 130 13\ 123 122 121 120 12\ 114 113 112 111 110 11\ 105 104 103 102 101 100 10\ From 29f187b751c3dbab1217704ce9efba9c0f4986c4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 16 Jan 2026 12:53:27 +0100 Subject: [PATCH 23/40] fix some windoze specific "-Wzero-as-null-pointer-constant" warnings --- src/win32/win_dbg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win32/win_dbg.c b/src/win32/win_dbg.c index a5d1adc3f..d47117698 100644 --- a/src/win32/win_dbg.c +++ b/src/win32/win_dbg.c @@ -187,13 +187,13 @@ static VOID ShowModuleInfo(HANDLE LogFile, HMODULE ModuleHandle) // Open the code module file so that we can get its file date // and size. ModuleFile = CreateFileA(ModName, GENERIC_READ, - FILE_SHARE_READ, 0, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, 0); + FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); if (ModuleFile != INVALID_HANDLE_VALUE) { FILETIME LastWriteTime; - FileSize = GetFileSize(ModuleFile, 0); - if (GetFileTime(ModuleFile, 0, 0, &LastWriteTime)) + FileSize = GetFileSize(ModuleFile, NULL); + if (GetFileTime(ModuleFile, NULL, NULL, &LastWriteTime)) { wsprintfA(TimeBuffer, " - file date is "); PrintTime(TimeBuffer + strlen(TimeBuffer), LastWriteTime); @@ -227,7 +227,7 @@ static VOID RecordModuleList(HANDLE LogFile) size_t PageSize; size_t NumPages; size_t pageNum = 0; - LPVOID LastAllocationBase = 0; + LPVOID LastAllocationBase = NULL; FPrintf(LogFile, "\r\n" "\tModule list: names, addresses, sizes, time stamps " @@ -385,7 +385,7 @@ LONG WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data/*, LPCSTR Message, LPST } // Append to the error log. - SetFilePointer(fileHandle, 0, 0, FILE_END); + SetFilePointer(fileHandle, 0, NULL, FILE_END); // Print out some blank lines to separate this error log from any previous ones. FPrintf(fileHandle, "Email Sonic Team Junior so we can fix the bugs\r\n"); // Tails From 08e7ce3b5ba27f2fe113d5c4c0268485664a0d9a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 16 Jan 2026 13:25:38 +0100 Subject: [PATCH 24/40] m_menu: clean up the skin display stuff a little --- src/m_menu.c | 114 +++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3f0dca46d..a98a230d5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7902,7 +7902,7 @@ static void M_HandleConnectIP(INT32 choice) if (exitmenu) { if (currentMenu->prevMenu) - M_SetupNextMenu (currentMenu->prevMenu); + M_SetupNextMenu(currentMenu->prevMenu); else M_ClearMenus(true); } @@ -8271,10 +8271,9 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 curx = (((setupm_skinselect % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH/2)) + SKINXSHIFT) + 20; INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ gridyoffset); - UINT8 cursorframe = (I_GetTime() / 4) % 7; - - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); - V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); + UINT8 cursorframe = (I_GetTime() / 4) % 7; + cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); + V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } break; @@ -8313,14 +8312,12 @@ static void M_DrawSetupMultiPlayerMenu(void) if (setupm_skinselect < numskins) { UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE); - cursor = facewantprefix[skinsorted[setupm_skinselect]]; V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap); } else { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } @@ -8384,7 +8381,6 @@ static void M_DrawSetupMultiPlayerMenu(void) else { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } @@ -8509,7 +8505,7 @@ static void M_DrawSetupMultiPlayerMenu(void) switch (cv_skinselectmenu.value) { case SKINMENUTYPE_2D: - skintodisplay = setupm_fakeskin; + skintodisplay = (UINT8)setupm_fakeskin; if (setupm_skinlockedselect) // show the skin we are trying to select skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) @@ -8517,13 +8513,16 @@ static void M_DrawSetupMultiPlayerMenu(void) break; case SKINMENUTYPE_EXTENDED: case SKINMENUTYPE_GRID: - skintodisplay = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin); + skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (UINT8)setupm_fakeskin); break; default: - skintodisplay = setupm_fakeskin; + skintodisplay = (UINT8)setupm_fakeskin; break; } + if (skintodisplay >= MAXSKINS) + skintodisplay = 0; + skinnum = R_SkinAvailable(skins[skintodisplay].name); if (skinnum < 0 || skinnum >= MAXSKINS) @@ -8538,18 +8537,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (frame >= sprdef->numframes) // Walking animation missing frame = 0; // Try to use standing frame - sprframe = &sprdef->spriteframes[frame]; - - // minenice's speen css, it's a piece of shit but hey - speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; - - // this is a very shitty solution for checking if a sprite needs flipping - // but it works - if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) - flags = V_FLIP; // This sprite is left/right flipped! - - patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); - // draw box around guy V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); #undef charw @@ -8560,33 +8547,47 @@ static void M_DrawSetupMultiPlayerMenu(void) UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); #ifdef HWRENDER md2_t *md2 = &md2_playermodels[skinnum]; - +#endif + mx += 36; + my += 131; +#ifdef HWRENDER // if we have 3d models enabled and a model exists // try to show it instead of the sprite if (rendermode == render_opengl && cv_glmdls.value && !md2->error && !md2->notfound) { - mx += 36; - my += 131; - const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 8*FRACUNIT/3, frame, angle); } else #endif { + sprframe = &sprdef->spriteframes[frame]; + + // minenice's speen css, it's a piece of shit but hey + speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; + + // this is a very shitty solution for checking if a sprite needs flipping + // but it works + if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) + { + flags = V_FLIP; // This sprite is left/right flipped! + } + + patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); + if (skins[skintodisplay].flags & SF_HIRES) { - V_DrawFixedPatch((mx+36)<= sprdef->numframes) // Walking animation missing frame = 0; // Try to use standing frame - sprframe = &sprdef->spriteframes[frame]; - - //minenice's speen css, it's a piece of shit but hey - //patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[1], PU_PATCH); - speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; - - //this is a very shitty solution for checking if a sprite needs flipping - //but it works - if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) - { - flags = V_FLIP; // This sprite is left/right flipped! - } - patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); - // draw box around guy V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239); #undef charw - // draw player sprite UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin); V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap); @@ -9974,6 +9960,9 @@ static void M_DrawLocalSkinMenu(void) V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname); // draw player sprite + mx += 220; + my += 120; + #ifdef HWRENDER md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[skintodisplay] : &md2_playermodels[skintodisplay]); @@ -9982,24 +9971,35 @@ static void M_DrawLocalSkinMenu(void) if (rendermode == render_opengl && cv_glmdls.value && !md2->error && !md2->notfound) { - mx += 220; - my += 120; - const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - HWR_Draw2DModel(md2, mx, my, skintodisplay, (skincolors_t)cv_playercolor.value, colormap, 8*FRACUNIT/3, frame, angle); } else #endif { + sprframe = &sprdef->spriteframes[frame]; + + // minenice's speen css, it's a piece of shit but hey + speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; + + // this is a very shitty solution for checking if a sprite needs flipping + // but it works + if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) + { + flags = V_FLIP; // This sprite is left/right flipped! + } + + patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); + if (displayskin.flags & SF_HIRES) { - V_DrawFixedPatch((mx+220)< Date: Sun, 18 Jan 2026 07:39:45 +0100 Subject: [PATCH 25/40] remove unused stuff from joyinfo --- src/g_input.c | 8 +++----- src/sdl/i_system.cpp | 41 ++++++++++++----------------------------- src/sdl/i_video.c | 2 +- src/sdl/sdlmain.h | 8 ++++---- 4 files changed, 20 insertions(+), 39 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 0082df273..1a420c996 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -945,6 +945,8 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color) static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) { + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); + if (cv_gamepadled[playernum].value == 0) { I_SetGamepadIndicatorColor(playernum, 0, 0, 255); @@ -973,13 +975,8 @@ void G_DeviceLEDTick(void) newcolor = G_GetSkinColorForGamepad(i); - // compiler be absolutely tripping - // delet this if this gets fixed within gcc -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" if (curcolor[i] == newcolor) // dont update if same colour continue; -#pragma GCC diagnostic pop G_SetPlayerGamepadIndicatorColor(i, newcolor); curcolor[i] = newcolor; @@ -994,6 +991,7 @@ void G_ResetDeviceLED(void) static void G_ResetPlayerDeviceRumble(INT32 playernum) { + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); I_GamepadRumble(playernum, 0, 0, 0); } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 36859ef54..15ba76917 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -727,12 +727,11 @@ static void JoyReset(SDLJoyInfo_t *JoySet) JoySet->dev = NULL; JoySet->oldjoy = -1; JoySet->id = -1; - JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0; } /** \brief SDL info about joystick */ -SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS]; +SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS] = {}; INT32 numcontrollers = 0; // @@ -740,26 +739,26 @@ INT32 numcontrollers = 0; // void I_JoyScale(void) { - Joystick[0].bGamepadStyle = cv_joyscale[0].value==0; - JoyInfo[0].scale = Joystick[0].bGamepadStyle?1:cv_joyscale[0].value; + Joystick[0].bGamepadStyle = cv_joyscale[0].value == 0; + JoyInfo[0].scale = Joystick[0].bGamepadStyle ? 1 : cv_joyscale[0].value; } void I_JoyScale2(void) { - Joystick[1].bGamepadStyle = cv_joyscale[1].value==0; - JoyInfo[1].scale = Joystick[1].bGamepadStyle?1:cv_joyscale[1].value; + Joystick[1].bGamepadStyle = cv_joyscale[1].value == 0; + JoyInfo[1].scale = Joystick[1].bGamepadStyle ? 1 : cv_joyscale[1].value; } void I_JoyScale3(void) { - Joystick[2].bGamepadStyle = cv_joyscale[2].value==0; - JoyInfo[2].scale = Joystick[2].bGamepadStyle?1:cv_joyscale[2].value; + Joystick[2].bGamepadStyle = cv_joyscale[2].value == 0; + JoyInfo[2].scale = Joystick[2].bGamepadStyle ? 1 : cv_joyscale[2].value; } void I_JoyScale4(void) { - Joystick[3].bGamepadStyle = cv_joyscale[3].value==0; - JoyInfo[3].scale = Joystick[3].bGamepadStyle?1:cv_joyscale[3].value; + Joystick[3].bGamepadStyle = cv_joyscale[3].value == 0; + JoyInfo[3].scale = Joystick[3].bGamepadStyle ? 1 : cv_joyscale[3].value; } // Cheat to get the device index for a joystick handle @@ -931,33 +930,18 @@ static int joy_open(int playerIndex, int joyIndex) } JoyInfo[playerIndex].dev = newdev; - JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); if (JoyInfo[playerIndex].dev == NULL) { CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError()); return -1; } - else - { - CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); - JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX; - if (JoyInfo[playerIndex].axises > JOYAXISSET*2) - JoyInfo[playerIndex].axises = JOYAXISSET*2; + CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); - JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX ; // dpad is 4 buttons - if (JoyInfo[playerIndex].buttons > JOYBUTTONS) - JoyInfo[playerIndex].buttons = JOYBUTTONS; + JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); - JoyInfo[playerIndex].hats = 4; - if (JoyInfo[playerIndex].hats > JOYHATS) - JoyInfo[playerIndex].hats = JOYHATS; - - JoyInfo[playerIndex].balls = 0; - - return JoyInfo[playerIndex].axises; - } + return SDL_CONTROLLER_AXIS_MAX; } // @@ -1002,7 +986,6 @@ void I_InitJoystick(UINT8 index) JoyInfo[index].dev = NULL; JoyInfo[index].oldjoy = -1; JoyInfo[index].id = -1; - JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0; if (cv_usejoystick[index].value) newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 72354ca1e..1c23af6cd 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -467,7 +467,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) } else { - raxis = JoyInfo[pid].scale!=1?((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale):raxis; + raxis = JoyInfo[pid].scale != 1 ? ((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale) : raxis; #ifdef SDL_JDEADZONE if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE) diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index e5bdca395..f7f4c011c 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -44,15 +44,15 @@ typedef struct SDLJoyInfo_s /// number of old joystick int oldjoy; /// number of axies - int axises; + //int axises; /// scale of axises INT32 scale; /// number of buttons - int buttons; + //int buttons; /// number of hats - int hats; + //int hats; /// number of balls - int balls; + //int balls; } SDLJoyInfo_t; /** \brief SDL info about controller 1 From 104b8260fb715102cd0b7f03761b09ffa7c07906 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Jan 2026 14:35:02 +0100 Subject: [PATCH 26/40] add reducevfx to accesability menu If there are things that should be handled by that toggle def feel free to suggest them! --- src/m_menudefs.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index e6129d2d8..0c4aef0d4 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1633,33 +1633,34 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation, 25}, {IT_SUBMENU|IT_STRING, NULL, "Video Color Settings...", &OP_ColorOptionsDef, 30}, - {IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 35}, + {IT_STRING|IT_CVAR, NULL, "Reduce Effects", &cv_reducevfx, 35}, + {IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 40}, // obsolete now? or still better be a seperate toggle? - {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 40}, + {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45}, #ifdef HWRENDER - {IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 45}, + {IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 50}, #endif - {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 50}, + {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 55}, - {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 55}, + {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 60}, - {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 60}, + {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 65}, - {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 65}, + {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 70}, - {IT_HEADER, NULL, "Audio", NULL, 75}, + {IT_HEADER, NULL, "Audio", NULL, 80}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85}, - {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90}, + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 90}, + {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 95}, - {IT_HEADER, NULL, "Controls", NULL, 100}, + {IT_HEADER, NULL, "Controls", NULL, 105}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 115}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 120}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 125}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 130}, }; static const char* OP_AccessibilityTooltips[] = @@ -1669,10 +1670,11 @@ static const char* OP_AccessibilityTooltips[] = "Gamma (brightness) of the game.", "Saturation of the game.", "Advanced color settings of the game.", + "Reduces or disables certain effects players might be sensitive to\nSuch as flashing, flickering, certain screen effects and more.", "Disables the flicker effect on Midnight Channel.", "Sets minimum sector brightness, useful for dark areas", #ifdef HWRENDER - "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", + "Disabling Screen Textures will disable the Underwater and Heat screen effects.", #endif "Toggles the ripple effect on water surfaces", "Fades other Players that are close to the camera in and out", From aa96f9ceb3f8a7d35218fd814485dab03c363baf Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 14:57:18 +0100 Subject: [PATCH 27/40] V_DrawVhsEffect: fix scaling with highreshudscale, fix downwards bar going out of screen bounds this shouldnt account for highreshudscale at all on very high resolutions the bars are still only half size, but atleast they dont become minuscule or just dont draw at all also ensures both bars are clamped, on some resolutions sometimes they just go out of visible screen range --- src/v_video.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index dbb3b385b..b5be19a97 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1742,6 +1742,7 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch) void V_DrawVhsEffect(boolean rewind) { fixed_t uby, dby; + // upbary is the bar going from top to bottom for some reason static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; UINT8 barsize, updistort, downdistort; @@ -1759,20 +1760,26 @@ void V_DrawVhsEffect(boolean rewind) if (cv_reducevfx.value) return; - barsize = vid.dup << 5; - updistort = vid.dup << (rewind ? 5 : 3); + const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT); + + barsize = dup << 5; + updistort = dup << (rewind ? 5 : 3); downdistort = updistort >> 1; if (rewind) V_DrawVhsEffect(false); // experimentation - upbary -= renderdeltatics * (vid.dup * (rewind ? 3 : 1.8f)); - downbary += renderdeltatics * (vid.dup * (rewind ? 2 : 1)); + upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f)); + downbary += renderdeltatics * (dup * (rewind ? 2 : 1)); if (upbary < -barsize*FRACUNIT) upbary = vid.height << FRACBITS; + if (upbary > vid.height << FRACBITS) + upbary = -barsize*FRACUNIT; if (downbary > vid.height << FRACBITS) downbary = -barsize*FRACUNIT; + if (downbary < -barsize*FRACUNIT) + downbary = vid.height << FRACBITS; uby = upbary >> FRACBITS; dby = downbary >> FRACBITS; From 43d3ac102d1273f7874b43b0a5e4477bd85165c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 15:42:37 +0100 Subject: [PATCH 28/40] HWR_RenderPlane: cleanup code that does nothing --- src/hardware/hw_main.cpp | 45 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 1622a4528..24d3af8ae 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -101,7 +101,8 @@ sector_t *gl_backsector = NULL; static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; // values for bsp culling // slightly higher than the far clipping plane to compensate for impreciseness -static constexpr INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, +static constexpr INT32 bsp_culling_distances[] = { + (1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; // Performance stats @@ -587,15 +588,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; // Get the slope pointer to simplify future code - if (sec->f_slope && !isceiling) + if (!isceiling && sec->f_slope) slope = sec->f_slope; - else if (sec->c_slope && isceiling) + else if (isceiling && sec->c_slope) slope = sec->c_slope; - // Set fixedheight to the slope's height from our viewpoint, if we have a slope - if (slope) - fixedheight = P_GetSlopeZAt(slope, viewx, viewy); - height = FixedToFloat(fixedheight); // Allocate plane-vertex buffer if we need to @@ -687,18 +684,19 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\ vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\ }\ +\ + if (slope)\ + {\ + fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\ + height = FixedToFloat(fixedheight);\ + }\ \ vert->x = (vx);\ vert->y = height;\ vert->z = (vy);\ \ - if (slope)\ - {\ - fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\ - vert->y = FixedToFloat(fixedheight);\ - }\ } - for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++) + for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++, pv++) SETUP3DVERT(v3d, pv->x, pv->y); if (slope) @@ -1785,10 +1783,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Single sided line... Deal only with the middletexture (if one exists) if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { - glTex = HWR_GetTexture(gl_midtexture, noencore); - fixed_t texturevpeg; + glTex = HWR_GetTexture(gl_midtexture, noencore); + // PEGGING if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset; @@ -1875,8 +1873,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //Hurdler: 3d-floors test if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors)) { - ffloor_t * rover; - fixed_t highcut = 0, lowcut = 0; + ffloor_t *rover; + fixed_t highcut = 0, lowcut = 0; fixed_t lowcutslope = 0, highcutslope = 0; // Used for height comparisons and etc across FOFs and slopes @@ -2947,7 +2945,7 @@ static void HWR_Subsector(size_t num) static sector_t tempsec; //SoM: 4/7/2000 INT32 floorlightlevel; INT32 ceilinglightlevel; - INT32 locFloorHeight, locCeilingHeight; + INT32 locFloorHeight = 0, locCeilingHeight = 0; INT32 cullFloorHeight, cullCeilingHeight; INT32 light = 0; extracolormap_t *floorcolormap; @@ -2993,11 +2991,12 @@ static void HWR_Subsector(size_t num) cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy); cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); - locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (gl_frontsector->ffloors) { + locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + boolean anyMoved = gl_frontsector->moved; if (anyMoved == false) @@ -3052,8 +3051,7 @@ static void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false)); HWR_RenderPlane(sub, &extrasubsectors[num], false, - // Hack to make things continue to work around slopes. - locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight, + gl_frontsector->floorheight, // We now return you to your regularly scheduled rendering. PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap); } @@ -3068,8 +3066,7 @@ static void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true)); HWR_RenderPlane(sub, &extrasubsectors[num], true, - // Hack to make things continue to work around slopes. - locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight, + gl_frontsector->ceilingheight, // We now return you to your regularly scheduled rendering. PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); } From 073b35690b52a9673bf62236cfdea66877358fc1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 16:25:07 +0100 Subject: [PATCH 29/40] dont attempt to show sdl message box on non dedicated builds running as dedicated --- src/sdl/i_system.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 15ba76917..b868d34c0 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1776,9 +1776,10 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) I_OutputMsg("%s\n", text); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Startup error", - text, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "Startup error", + text, NULL); I_ShutdownConsole(); exit(-1); @@ -1979,9 +1980,10 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Implement message box with SDL_ShowSimpleMessageBox, // which should fail gracefully if it can't put a message box up // on the target system - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2Kart " VERSIONSTRING " Recursive Error", - buffer, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "SRB2Kart " VERSIONSTRING " Recursive Error", + buffer, NULL); W_Shutdown(); exit(-1); // recursive errors detected @@ -2024,7 +2026,8 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Implement message box with SDL_ShowSimpleMessageBox, // which should fail gracefully if it can't put a message box up // on the target system - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SRB2Kart " VERSIONSTRING " Error", buffer, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SRB2Kart " VERSIONSTRING " Error", buffer, NULL); // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be // initialized at the time, so calling it after SDL_Quit() is // perfectly okay! In addition, we do this on purpose so the From 5289f138918a1f2b279dd06cdb1ebd1d2dc3a151 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 17:31:58 +0100 Subject: [PATCH 30/40] Show report issue button also on I_Error also make wrapper functions for everything, to reduce code dupe --- src/sdl/i_system.cpp | 84 ++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index b868d34c0..eeeb2373c 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1629,24 +1629,13 @@ static int I_OpenURL(const char *url) #endif } -static void I_ReportSignal(int num, int coredumped) +static void I_ShowErrorBox(const char *title, const char *msg) { - char sigmsg[512]; - char signame[128]; - char sigttl[512] = "Process killed by signal: "; - const char *reportmsg = "\n\n\nTo help us figure out the cause, please report the issue to our github page with " CRASH_LOGFILE_NAME " attached.\n\nSorry for the inconvenience!"; - - I_PrintSignal(num, coredumped, sigmsg, signame); - - size_t len = strlen(sigmsg); - snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME); - - strcat(sigttl, signame); - I_OutputMsg("\n%s\n\n", sigttl); - if (M_CheckParm("-dedicated")) return; + const char *reportmsg = "\n\n\nTo help us figure out the cause, please report the issue to our github page with " CRASH_LOGFILE_NAME " attached.\n\nSorry for the inconvenience!"; + const SDL_MessageBoxButtonData buttons[] = { { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK" }, { 0, 1, "Report Issue" }, @@ -1655,8 +1644,8 @@ static void I_ReportSignal(int num, int coredumped) const SDL_MessageBoxData messageboxdata = { SDL_MESSAGEBOX_ERROR, /* .flags */ NULL, /* .window */ - sigttl, /* .title */ - va("%s %s", sigmsg, reportmsg), /* .message */ + title, /* .title */ + va("%s %s", msg, reportmsg), /* .message */ SDL_arraysize(buttons), /* .numbuttons */ buttons, /* .buttons */ NULL /* .colorScheme */ @@ -1670,6 +1659,39 @@ static void I_ReportSignal(int num, int coredumped) I_OpenURL("https://github.com/Indev450/SRB2Kart-Saturn/issues"); } +static void I_ShowSimpleErrorBox(const char *title, char *msg) +{ + if (M_CheckParm("-dedicated")) + return; + + // Implement message box with SDL_ShowSimpleMessageBox, + // which should fail gracefully if it can't put a message box up + // on the target system + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, msg, NULL); + // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be + // initialized at the time, so calling it after SDL_Quit() is + // perfectly okay! In addition, we do this on purpose so the + // fullscreen window is closed before displaying the error message + // in case the fullscreen window blocks it for some absurd reason. +} + +static void I_ReportSignal(int num, int coredumped) +{ + char sigmsg[512]; + char signame[128]; + char sigttl[512] = "Process killed by signal: "; + + I_PrintSignal(num, coredumped, sigmsg, signame); + + size_t len = strlen(sigmsg); + snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME); + + strcat(sigttl, signame); + I_OutputMsg("\n%s\n\n", sigttl); + //I_ShowSimpleErrorBox(sigttl, sigmsg); + I_ShowErrorBox(sigttl, sigmsg); +} + #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { @@ -1775,11 +1797,7 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) ); I_OutputMsg("%s\n", text); - - if (!M_CheckParm("-dedicated")) - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Startup error", - text, NULL); + I_ShowSimpleErrorBox("Startup error", text); I_ShutdownConsole(); exit(-1); @@ -1941,6 +1959,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) { va_list argptr; char buffer[8192]; + const char *sigttl = ""; #ifdef HAVE_THREADS if (std::this_thread::get_id() != g_main_thread_id) @@ -1977,13 +1996,9 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) va_start(argptr, error); vsnprintf(buffer, 8192, error, argptr); va_end(argptr); - // Implement message box with SDL_ShowSimpleMessageBox, - // which should fail gracefully if it can't put a message box up - // on the target system - if (!M_CheckParm("-dedicated")) - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2Kart " VERSIONSTRING " Recursive Error", - buffer, NULL); + + sigttl = "SRB2Kart " VERSIONSTRING " Recursive Error"; + I_ShowSimpleErrorBox(sigttl, buffer); W_Shutdown(); exit(-1); // recursive errors detected @@ -2023,16 +2038,9 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) I_ShutdownSystem(); SDL_Quit(); - // Implement message box with SDL_ShowSimpleMessageBox, - // which should fail gracefully if it can't put a message box up - // on the target system - if (!M_CheckParm("-dedicated")) - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SRB2Kart " VERSIONSTRING " Error", buffer, NULL); - // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be - // initialized at the time, so calling it after SDL_Quit() is - // perfectly okay! In addition, we do this on purpose so the - // fullscreen window is closed before displaying the error message - // in case the fullscreen window blocks it for some absurd reason. + sigttl = "SRB2Kart " VERSIONSTRING " Error"; + //I_ShowSimpleErrorBox(sigttl, buffer); + I_ShowErrorBox(sigttl, buffer); W_Shutdown(); From c9fc3b48203935c6d3f250141959b7f85d200792 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 18:23:21 +0100 Subject: [PATCH 31/40] fixup cmake for macos mostly based on the patch from https://github.com/Bijman/srb2bld with some changes from https://github.com/Indev450/SRB2Kart-Saturn/pull/216 but doesent completely replace the build system with what blan has compiles fine on nix, but needs testing on mac --- CMakeLists.txt | 6 +++- src/CMakeLists.txt | 43 +++++++++++++++-------- src/command.h | 6 ++-- src/d_netcmd.c | 3 ++ src/dedicated/i_system.c | 4 --- src/doomdef.h | 41 +++++++++++++++++----- src/m_emotes.h | 8 ++--- src/p_local.h | 8 ++--- src/p_tick.h | 8 +++++ src/r_fps.h | 8 ++--- src/r_main.h | 8 ++--- src/r_segs.cpp | 2 ++ src/sdl/CMakeLists.txt | 4 +-- src/sdl/i_system.cpp | 7 ++-- src/sdl/i_threads.c | 4 +++ src/sdl/macosx/mac_alert.c | 64 ---------------------------------- src/sdl/macosx/mac_alert.h | 27 -------------- src/sdl/macosx/mac_resources.h | 8 ++++- src/strcasestr.c | 4 +++ 19 files changed, 115 insertions(+), 148 deletions(-) delete mode 100644 src/sdl/macosx/mac_alert.c delete mode 100644 src/sdl/macosx/mac_alert.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b7d280190..c5e12d93d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,11 @@ cmake_minimum_required(VERSION 3.5) # Version change is fine. project(SRB2 VERSION 1.6 - LANGUAGES C) + LANGUAGES C CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 361386622..251195414 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,8 @@ # Core sources set(SRB2_CORE_SOURCES + core/memory.cpp + core/thread_pool.cpp am_map.c b_bot.c command.c @@ -18,17 +20,21 @@ set(SRB2_CORE_SOURCES f_wipe.c filesrch.c g_game.c + g_demo.c g_input.c hu_stuff.c i_tcp.c info.c + k_hud.c lzf.c m_aatree.c m_anigif.c m_argv.c m_bbox.c m_cheat.c + m_curl.c m_cond.c + m_emotes.cpp m_fixed.c m_menu.c m_textinput.c @@ -40,19 +46,25 @@ set(SRB2_CORE_SOURCES mserv.c http-mserv.c qs22j.c + r_skins.c s_sound.c screen.c sounds.c st_stuff.c - #string.c + #strcasestr.c tables.c v_video.c w_wad.c y_inter.c - z_zone.c + z_zone.cpp ) set(SRB2_CORE_HEADERS + core/memory.h + core/thread_pool.h + m_curl.h + m_emotes.h + k_hud.h am_map.h b_bot.h byteptr.h @@ -78,6 +90,7 @@ set(SRB2_CORE_HEADERS fastcmp.h filesrch.h g_game.h + g_demo.h g_input.h g_state.h hu_stuff.h @@ -109,6 +122,7 @@ set(SRB2_CORE_HEADERS md5.h mserv.h qs22j.h + r_skins.h s_sound.h screen.h sounds.h @@ -123,18 +137,18 @@ set(SRB2_CORE_HEADERS ) set(SRB2_CORE_RENDER_SOURCES - r_bsp.c + r_bsp.cpp r_data.c - r_draw.c - r_fps.c - r_main.c - r_patch.c - r_patchrotation.c - r_plane.c - r_segs.c + r_draw.cpp + r_fps.cpp + r_main.cpp + r_patch.cpp + r_patchrotation.cpp + r_plane.cpp + r_segs.cpp r_sky.c r_splats.c - r_things.c + r_things.cpp r_portal.c r_bsp.h @@ -162,7 +176,7 @@ set(SRB2_CORE_GAME_SOURCES p_inter.c p_lights.c p_map.c - p_maputl.c + p_maputl.cpp p_mobj.c p_polyobj.c p_saveg.c @@ -475,10 +489,10 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c @@ -493,7 +507,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h diff --git a/src/command.h b/src/command.h index 7074158e1..d3bf09127 100644 --- a/src/command.h +++ b/src/command.h @@ -13,13 +13,13 @@ #ifndef __COMMAND_H__ #define __COMMAND_H__ +#include +#include "doomdef.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include "doomdef.h" - //=================================== // Command buffer & command execution //=================================== diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 781120be2..641a026fd 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -54,6 +54,9 @@ #include "fastcmp.h" #include "m_perfstats.h" +#include "r_data.h" +#include "r_skins.h" + #ifdef NETGAME_DEVMODE #define CV_RESTRICT CV_NETVAR #else diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 4d52ffa70..437439010 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -180,10 +180,6 @@ static char returnWadPath[256]; #include "../m_argv.h" -#ifdef MAC_ALERT -#include "macosx/mac_alert.h" -#endif - #include "../d_main.h" #if !defined(NOMUMBLE) && defined(HAVE_MUMBLE) diff --git a/src/doomdef.h b/src/doomdef.h index 492fa1185..23768d0f4 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -40,22 +40,45 @@ #define ASMCALL #endif -#ifdef __cplusplus -extern "C" { -#endif - #include "doomtype.h" +#ifdef __cplusplus /* Only when compiled as C++ */ + #include /* std::min, std::max, std::sort, … */ +#endif + +#ifdef __cplusplus +// Force libc++ to expose std::min/std::max even when is included first (Apple clang quirk) +#ifndef _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES +#define _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES +#endif +#ifndef _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + +// Optional: only try if it actually exists (newer Xcode) +#if __has_include() +#include +#endif + +#define _USE_MATH_DEFINES +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#else +#include #include #include #include +#include #include -#define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio -#ifdef __cplusplus -#include -#else -#include +#include #endif #include diff --git a/src/m_emotes.h b/src/m_emotes.h index 594e219f8..d87dd438f 100644 --- a/src/m_emotes.h +++ b/src/m_emotes.h @@ -12,14 +12,14 @@ #ifndef __M_EMOTES__ #define __M_EMOTES__ -#ifdef __cplusplus -extern "C" { -#endif - #include "doomdef.h" #include "m_fixed.h" #include "command.h" +#ifdef __cplusplus +extern "C" { +#endif + extern consvar_t cv_emotes; #define MAXEMOTENAME 32 diff --git a/src/p_local.h b/src/p_local.h index 3c16b5c62..82e3fb673 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -14,10 +14,6 @@ #ifndef __P_LOCAL__ #define __P_LOCAL__ -#ifdef __cplusplus -extern "C" { -#endif - #include "command.h" #include "d_player.h" #include "d_think.h" @@ -28,6 +24,10 @@ extern "C" { #include "p_maputl.h" #include "doomstat.h" // MAXSPLITSCREENPLAYERS +#ifdef __cplusplus +extern "C" { +#endif + #define FLOATSPEED (FRACUNIT*4) //#define VIEWHEIGHTS "41" diff --git a/src/p_tick.h b/src/p_tick.h index a903be0fd..e0fcd899c 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -20,6 +20,10 @@ #pragma interface #endif +#ifdef __cplusplus +extern "C" { +#endif + extern tic_t leveltime; // Called by G_Ticker. Carries out all thinking of enemies and players. @@ -38,6 +42,10 @@ mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target #endif ); +#ifdef __cplusplus +} +#endif + #ifdef PARANOIA #define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__) #else diff --git a/src/r_fps.h b/src/r_fps.h index 89efc6cfb..bf3f48362 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -15,16 +15,16 @@ #ifndef __R_FPS_H__ #define __R_FPS_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include "m_fixed.h" #include "p_local.h" #include "r_state.h" #include "r_things.h" #include "m_perfstats.h" +#ifdef __cplusplus +extern "C" { +#endif + extern consvar_t cv_fpscap, cv_fpscapbg; extern ps_metric_t ps_interp_frac; diff --git a/src/r_main.h b/src/r_main.h index d33d67606..e8b7393e3 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -14,14 +14,14 @@ #ifndef __R_MAIN__ #define __R_MAIN__ -#ifdef __cplusplus -extern "C" { -#endif - #include "d_player.h" #include "r_data.h" #include "m_perfstats.h" +#ifdef __cplusplus +extern "C" { +#endif + // // POV related. // diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 3fe8042ae..6751befc9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -15,6 +15,8 @@ #include "r_local.h" #include "r_sky.h" +#include + #include "r_portal.h" #include "r_splats.h" #include "r_fps.h" // newview diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index e4b0d4f37..fe29c5d2f 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -32,7 +32,7 @@ set(SRB2_SDL2_SOURCES hwsym_sdl.c i_main.c i_net.c - i_system.c + i_system.cpp i_ttf.c i_video.c i_threads.c @@ -123,8 +123,6 @@ if(${SDL2_FOUND}) set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns) set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") set(SRB2_SDL2_MAC_SOURCES - macosx/mac_alert.c - macosx/mac_alert.h macosx/mac_resources.c macosx/mac_resources.h macosx/Srb2mac.icns diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index eeeb2373c..48dfa9fd2 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -30,6 +30,7 @@ #endif #include +#include #ifdef _WIN32 #define RPC_NO_WINDOWS_H @@ -201,10 +202,6 @@ static char returnWadPath[256]; #include "../s_sound.h" -#ifdef MAC_ALERT -#include "macosx/mac_alert.h" -#endif - #include "../d_main.h" #if !defined(NOMUMBLE) && defined(HAVE_MUMBLE) @@ -2466,7 +2463,7 @@ static const char *locateWad(void) return NULL; } -const char *I_LocateWad(void) +extern "C" const char *I_LocateWad(void) { const char *waddir = NULL; diff --git a/src/sdl/i_threads.c b/src/sdl/i_threads.c index 078f4e0f4..26d3bbefe 100644 --- a/src/sdl/i_threads.c +++ b/src/sdl/i_threads.c @@ -9,6 +9,8 @@ /// \file i_threads.c /// \brief Multithreading abstraction +#ifdef HAVE_THREADS + #include "../doomdef.h" #include "../i_threads.h" @@ -354,3 +356,5 @@ I_wake_all_cond ( if (SDL_CondBroadcast(cond) == -1) abort(); } + +#endif // HAVE_THREADS diff --git a/src/sdl/macosx/mac_alert.c b/src/sdl/macosx/mac_alert.c deleted file mode 100644 index 2a139041a..000000000 --- a/src/sdl/macosx/mac_alert.c +++ /dev/null @@ -1,64 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Graphical Alerts for MacOSX -/// -/// Shows alerts, since we can't just print these to the screen when -/// launched graphically on a mac. - -#ifdef __APPLE_CC__ - -#include "mac_alert.h" -#include - -#define CFSTRINGIFY(x) CFStringCreateWithCString(NULL, x, kCFStringEncodingASCII) - -int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3) -{ - CFOptionFlags results; - - CFStringRef cf_title = CFSTRINGIFY(title); - CFStringRef cf_message = CFSTRINGIFY(message); - CFStringRef cf_button1 = NULL; - CFStringRef cf_button2 = NULL; - CFStringRef cf_button3 = NULL; - - if (button1 != NULL) - cf_button1 = CFSTRINGIFY(button1); - if (button2 != NULL) - cf_button2 = CFSTRINGIFY(button2); - if (button3 != NULL) - cf_button3 = CFSTRINGIFY(button3); - - CFOptionFlags alert_flags = kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag; - - CFUserNotificationDisplayAlert(0, alert_flags, NULL, NULL, NULL, cf_title, cf_message, - cf_button1, cf_button2, cf_button3, &results); - - if (cf_button1 != NULL) - CFRelease(cf_button1); - if (cf_button2 != NULL) - CFRelease(cf_button2); - if (cf_button3 != NULL) - CFRelease(cf_button3); - CFRelease(cf_message); - CFRelease(cf_title); - - return (int)results; -} - -#endif diff --git a/src/sdl/macosx/mac_alert.h b/src/sdl/macosx/mac_alert.h deleted file mode 100644 index 82a28d120..000000000 --- a/src/sdl/macosx/mac_alert.h +++ /dev/null @@ -1,27 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Graphical Alerts for MacOSX -/// -/// Shows alerts, since we can't just print these to the screen when -/// launched graphically on a mac. - -#ifdef __APPLE_CC__ - -extern int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3); - -#endif diff --git a/src/sdl/macosx/mac_resources.h b/src/sdl/macosx/mac_resources.h index 727ac9f6b..d63232dac 100644 --- a/src/sdl/macosx/mac_resources.h +++ b/src/sdl/macosx/mac_resources.h @@ -1,5 +1,11 @@ #ifndef __MAC_RESOURCES_H__ #define __MAC_RESOURCES_H__ +#ifdef __cplusplus +extern "C" { +#endif void OSX_GetResourcesPath(char * buffer); -#endif \ No newline at end of file +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/strcasestr.c b/src/strcasestr.c index 3eb6af60f..f05449778 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -23,6 +23,10 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include +#include + static inline int trycmp (char **pp, char *cp, const char *q, size_t qn) From f7bbde398237d395f0b1ff6895cf42a29e575521 Mon Sep 17 00:00:00 2001 From: cobalt2727 <60624944+cobalt2727@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:46:09 -0500 Subject: [PATCH 32/40] fix ARM builds being completely broken If merged, this is the quickest approach to resolve https://github.com/STJr/SRB2/issues/513 ...alternatively, we could just remove the option altogether but I don't have the time right now to test whether it's needed or not To the best of my knowledge, this covers all possible amd64 `CMAKE_SYSTEM_PROCESSOR` values based on what I'm seeing at https://stackoverflow.com/questions/70475665/what-are-the-possible-values-of-cmake-system-processor --- src/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 251195414..cc49bc0b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -549,8 +549,11 @@ endif() # Compatibility flag with later versions of GCC # We should really fix our code to not need this -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)") + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) + endif() + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") From cb2c65e9d93a30187166427b631446880a859c9e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:08:52 +0100 Subject: [PATCH 33/40] more cmake fixups - skip asset install for linux - pass fwrapv flag - fix asset hash stuff - pass rdynamic flag - add saturn specific stuff, saturnpak, saturnjoin, libbacktrace and fix screen fbo stuff --- CMakeLists.txt | 1 + assets/CMakeLists.txt | 5 +++ cmake/Modules/Findlibbacktrace.cmake | 33 +++++++++++++++++ src/CMakeLists.txt | 55 ++++++++++++++++++++++------ src/config.h.in | 41 ++------------------- src/d_main.c | 25 +++++++++++++ src/sdl/CMakeLists.txt | 5 +++ 7 files changed, 116 insertions(+), 49 deletions(-) create mode 100644 cmake/Modules/Findlibbacktrace.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c5e12d93d..7c55117ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ endif() # OS macros if (UNIX) add_definitions(-DUNIXCOMMON) + add_link_options(-rdynamic) # Use -rdynamic so a backtrace log shows function names endif() if(CMAKE_COMPILER_IS_GNUCC) diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 12be1c470..a34cf2dfc 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -1,5 +1,10 @@ ## Assets Target Configuration ## +if(${CMAKE_SYSTEM} MATCHES Linux) + # Asset installation isn't part of the Linux target + return() +endif() + # For prepending the current source path, later FUNCTION(PREPEND var prefix) SET(listVar "") diff --git a/cmake/Modules/Findlibbacktrace.cmake b/cmake/Modules/Findlibbacktrace.cmake new file mode 100644 index 000000000..81ebeb9dc --- /dev/null +++ b/cmake/Modules/Findlibbacktrace.cmake @@ -0,0 +1,33 @@ +include(LibFindMacros) + +libfind_pkg_check_modules(LIBBACKTRACE_PKGCONF LIBBACKTRACE) + +find_path(LIBBACKTRACE_INCLUDE_DIR + NAMES backtrace.h + PATHS + ${LIBBACKTRACE_PKGCONF_INCLUDE_DIRS} + "/usr/include" + "/usr/local/include" +) + +find_library(LIBBACKTRACE_LIBRARY + NAMES backtrace + PATHS + ${LIBBACKTRACE_PKGCONF_LIBRARY_DIRS} + "/usr/lib" + "/usr/local/lib" +) + +set(LIBBACKTRACE_PROCESS_INCLUDES LIBBACKTRACE_INCLUDE_DIR) +set(LIBBACKTRACE_PROCESS_LIBS LIBBACKTRACE_LIBRARY) +libfind_process(LIBBACKTRACE) + +if(LIBBACKTRACE_FOUND AND NOT TARGET libbacktrace) + add_library(libbacktrace UNKNOWN IMPORTED) + set_target_properties( + libbacktrace + PROPERTIES + IMPORTED_LOCATION "${LIBBACKTRACE_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBBACKTRACE_INCLUDE_DIR}" + ) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc49bc0b4..0d144ec4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -240,11 +240,19 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL "Enable hardware rendering through OpenGL.") set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL "Use statically linked OpenGL. NOT RECOMMENDED.") -set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL - "Enable OpenGL FBO Downsampling support.") +set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL + "Enable hardware renderer (OpenGL) FBO downsampling support") set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL "Build a dedicated server.") +set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL + "Enable Saturn specific special packet. Required for using the newer resynch system") +set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL + "Enable Saturn specific allowjoin toggle.") + +set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL + "Enable using libbacktrace for crashlogs") + if(${SRB2_CONFIG_DEDICATED}) set(SRB2_CONFIG_HAVE_GME NO) set(SRB2_CONFIG_HAVE_OPENMPT NO) @@ -483,6 +491,27 @@ if(${SRB2_CONFIG_HAVE_CURL}) endif() endif() +if(${SRB2_CONFIG_LIBBACKTRACE}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(LIBBACKTRACE_FOUND ON) + set(LIBBACKTRACE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libbacktrace/include) + set(LIBBACKTRACE_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libbacktrace/lib/x86_64 -lbacktrace") + else() # 32-bit + message(WARNING "libbacktrace is unsupported on 32-bit builds.") + endif() + else() + find_package(libbacktrace) + endif() + if(${LIBBACKTRACE_FOUND}) + set(SRB2_HAVE_LIBBACKTRACE ON) + add_definitions(-DHAVE_LIBBACKTRACE) + add_compile_options(-g) + else() + message(WARNING "You have specified that libbacktrace is available but it was not found.") + endif() +endif() + if(${SRB2_CONFIG_HWRENDER}) add_definitions(-DHWRENDER) set(SRB2_HWRENDER_SOURCES @@ -536,29 +565,33 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) else() message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") endif() -endif() -if(${SRB2_CONFIG_HWRENDER}) - if(${SRB2_CONFIG_USE_FBO_OGL}) - set(SRB2_USE_FBO_OGL ON) + if(${SRB2_CONFIG_SCREENFBO}) add_definitions(-DUSE_FBO_OGL) endif() endif() +if(${SRB2_CONFIG_SATURNPAK}) + add_definitions(-DDOSATURNPAK) +endif() + +if(${SRB2_CONFIG_SATURNJOIN}) + add_definitions(-DDOSATURNJOIN) +endif() + # Targets # Compatibility flag with later versions of GCC # We should really fix our code to not need this if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) + add_compile_options(-mno-ms-bitfields) endif() - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) + add_compile_options(-Wno-trigraphs) endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) -endif() +# TODO: fix prng and P_CreateBlockmap overflow at some point +add_compile_options(-fwrapv) add_definitions(-DCMAKECONFIG) diff --git a/src/config.h.in b/src/config.h.in index 5225c8b0b..4028ef2f0 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,21 +11,6 @@ #ifdef CMAKECONFIG -// Base SRB2 hashes -#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}" -#ifdef USE_PATCH_DTA -#define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}" -#endif - -// SRB2Kart-specific hashes -#define ASSET_HASH_GFX_KART "${SRB2_ASSET_gfx.kart_HASH}" -#define ASSET_HASH_TEXTURES_KART "${SRB2_ASSET_textures.kart_HASH}" -#define ASSET_HASH_CHARS_KART "${SRB2_ASSET_chars.kart_HASH}" -#define ASSET_HASH_MAPS_KART "${SRB2_ASSET_maps.kart_HASH}" -#ifdef USE_PATCH_KART -#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000" -#endif - #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" @@ -33,30 +18,10 @@ #else -/* Manually defined asset hashes for non-CMake builds - * Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb - * Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta - * Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets - * Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart - * Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets - * Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart - * Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart - */ +#define SRB2_COMP_REVISION "" +#define SRB2_COMP_BRANCH "" -// Base SRB2 hashes -#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7" -#ifdef USE_PATCH_DTA -#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4" -#endif - -// SRB2Kart-specific hashes -#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034" -#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80" -#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964" -#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98" -#ifdef USE_PATCH_KART -#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000" -#endif +#define CMAKE_ASSETS_DIR "" #endif #endif diff --git a/src/d_main.c b/src/d_main.c index 81fd3d830..c5499fb57 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -80,6 +80,31 @@ #include "lua_script.h" +/* Manually defined asset hashes for non-CMake builds + * Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb + * Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta + * Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets + * Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart + * Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets + * Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart + * Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart + */ + +// Base SRB2 hashes +#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7" +#ifdef USE_PATCH_DTA +#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4" +#endif + +// SRB2Kart-specific hashes +#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034" +#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80" +#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964" +#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98" +#ifdef USE_PATCH_KART +#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000" +#endif + #ifdef CMAKECONFIG #include "config.h" #else diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index fe29c5d2f..546b92fcd 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -165,6 +165,11 @@ if(${SDL2_FOUND}) ${DISCORDRPC_LIBRARIES} ) + if(${SRB2_HAVE_LIBBACKTRACE}) + target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES}) + endif() + + if(${CMAKE_SYSTEM} MATCHES Linux) target_link_libraries(SRB2SDL2 PRIVATE m From 4eeb0b4b20da403878df839d7e613f3415fa7c10 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:16:05 +0100 Subject: [PATCH 34/40] update readme to reflect this --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d538288bb..698f55a9c 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,14 @@ We also have a Flatpak available on [Flathub](https://flathub.org/en/apps/org.sr See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2. -Currently only the Makefile build system with GCC or Clang compiler is supported. -CMake is NOT supported at the moment, but will be availible again soon. - +For Windows only the Makefile build system with GCC or Clang compiler is supported. Visual C++ (MSVC) is unsupported. 64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed! The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages +MacOS and Linux can be build with CMake, but it is recommended to use the Makefile for Linux over CMake + Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell! ## Disclaimer From af952870c3f03ab272dc7e23516f401602f60606 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:22:40 +0100 Subject: [PATCH 35/40] fix fbo oopsie --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d144ec4c..07179882d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -565,10 +565,10 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) else() message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") endif() +endif() - if(${SRB2_CONFIG_SCREENFBO}) - add_definitions(-DUSE_FBO_OGL) - endif() +if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_SCREENFBO}) + add_definitions(-DUSE_FBO_OGL) endif() if(${SRB2_CONFIG_SATURNPAK}) From 186421fe85cae9a945fa9d3dd899e0cf6ce8b0a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:23:36 +0100 Subject: [PATCH 36/40] cmake: link with peethread --- src/sdl/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 546b92fcd..1c7d52344 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -174,6 +174,7 @@ if(${SDL2_FOUND}) target_link_libraries(SRB2SDL2 PRIVATE m rt + pthread ) endif() From 8e91c16e97636409399e0e6c4782d857634fa1bf Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:34:38 +0100 Subject: [PATCH 37/40] cmake: enable gnu extensions we rely on some of them like the cleanup macro dont want those breaking or smth --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c55117ad..1acd092bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,9 @@ project(SRB2 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ +#set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ +set(CMAKE_CXX_EXTENSIONS ON) +set(CMAKE_C_EXTENSIONS ON) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") From 4e75d9902653db35ba2349612479d977cfbf04bb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:49:26 +0100 Subject: [PATCH 38/40] simplify LUA_Alloc Z_Realloc already handles everything internally, no need to manually free anything --- src/lua_infolib.c | 2 +- src/lua_script.c | 39 ++++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 68ca6b4d0..4c84c48d5 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -25,7 +25,7 @@ #include "lua_hook.h" // cmd errors boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); -state_t *astate; +state_t *astate = NULL; boolean actionsoverridden[NUMACTIONS] = {false}; diff --git a/src/lua_script.c b/src/lua_script.c index 2aa88cd52..8982688a1 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -45,20 +45,20 @@ int hook_defrosting = 0; // List of internal libraries to load from SRB2 static lua_CFunction liblist[] = { - LUA_EnumLib, // global metatable for enums - LUA_SOCLib, // A_Action functions, freeslot - LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc. - LUA_MathLib, // fixed_t and angle_t math functions - LUA_HookLib, // hookAdd and hook-calling functions - LUA_ConsoleLib, // console command/variable functions and structs - LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[] - LUA_MobjLib, // mobj_t, mapthing_t - LUA_PlayerLib, // player_t - LUA_SkinLib, // skin_t, skins[] - LUA_ThinkerLib, // thinker_t - LUA_MapLib, // line_t, side_t, sector_t, subsector_t - LUA_BlockmapLib, // blockmap stuff - LUA_HudLib, // HUD stuff + LUA_EnumLib, // global metatable for enums + LUA_SOCLib, // A_Action functions, freeslot + LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc. + LUA_MathLib, // fixed_t and angle_t math functions + LUA_HookLib, // hookAdd and hook-calling functions + LUA_ConsoleLib, // console command/variable functions and structs + LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[] + LUA_MobjLib, // mobj_t, mapthing_t + LUA_PlayerLib, // player_t + LUA_SkinLib, // skin_t, skins[] + LUA_ThinkerLib, // thinker_t + LUA_MapLib, // line_t, side_t, sector_t, subsector_t + LUA_BlockmapLib, // blockmap stuff + LUA_HudLib, // HUD stuff NULL }; @@ -66,12 +66,8 @@ static lua_CFunction liblist[] = { static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; - if (nsize == 0) { - if (osize != 0) - Z_Free(ptr); - return NULL; - } else - return Z_Realloc(ptr, nsize, PU_LUA, NULL); + (void)osize; + return Z_Realloc(ptr, nsize, PU_LUA, NULL); } // Panic function Lua calls when there's an unprotected error. @@ -213,7 +209,8 @@ void LUA_ClearState(void) lua_setfield(L, LUA_REGISTRYINDEX, LREG_VALID); // open srb2 libraries - for(i = 0; liblist[i]; i++) { + for (i = 0; liblist[i]; i++) + { lua_pushcfunction(L, liblist[i]); lua_call(L, 0, 0); } From 59c9af97c2d9dbfcb5405acf7c6d6a5403132d28 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:53:49 +0100 Subject: [PATCH 39/40] joy_open: make debug prints actually print the player number --- src/sdl/i_system.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index eeeb2373c..ea10ed34c 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -885,13 +885,13 @@ static int joy_open(int playerIndex, int joyIndex) if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) { - CONS_Printf(M_GetText("Joystick subsystem not started\n")); + CONS_Printf("Joystick subsystem not started\n"); return -1; } if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) { - CONS_Printf(M_GetText("Game Controller subsystem not started\n")); + CONS_Printf("Game Controller subsystem not started\n"); return -1; } @@ -902,7 +902,7 @@ static int joy_open(int playerIndex, int joyIndex) if (num_joy == 0) { - CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); + CONS_Printf("%s", "Found no joysticks on this system\n"); return -1; } @@ -925,7 +925,7 @@ static int joy_open(int playerIndex, int joyIndex) return SDL_CONTROLLER_AXIS_MAX; // Else, we're changing devices, so send neutral joy events - CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n"); + CONS_Debug(DBG_GAMELOGIC, "Joystick %d device is changing; resetting events...\n", playerIndex+1); I_ShutdownJoystick(playerIndex); } @@ -933,11 +933,11 @@ static int joy_open(int playerIndex, int joyIndex) if (JoyInfo[playerIndex].dev == NULL) { - CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError()); + CONS_Debug(DBG_GAMELOGIC, "Joystick %d: Couldn't open device - %s\n", playerIndex+1, SDL_GetError()); return -1; } - CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); + CONS_Debug(DBG_GAMELOGIC, "Joystick %d: %s\n", playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev)); JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); From 276cf0a8cbfa143a31a874160db2cec993685c6f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 20:04:19 +0100 Subject: [PATCH 40/40] fix string.c include whoops, not sure why that was even done like that string.c will include strcasestr.c and SRB2_HAVE_STRLCPY will ensure eitherways we dont use the included strlcpy stuff --- src/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 07179882d..f09b95633 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,7 +51,7 @@ set(SRB2_CORE_SOURCES screen.c sounds.c st_stuff.c - #strcasestr.c + string.c tables.c v_video.c w_wad.c @@ -207,10 +207,6 @@ set(SRB2_CORE_GAME_SOURCES k_stats.h ) -if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c) -endif() - prepend_sources(SRB2_CORE_SOURCES) prepend_sources(SRB2_CORE_HEADERS) prepend_sources(SRB2_CORE_RENDER_SOURCES)