From 487ef6f1b98cec40a89c61247c26371ca931e4a2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 8 Jul 2025 17:04:00 +0100 Subject: [PATCH 01/19] fix windoze for the 50 trillionth time when do we finally remove windows support? those two things do absolutely fucking nothing but shit dies without em for whatever reason --- src/Makefile.d/features.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index 71624241f..ca789dbee 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -69,6 +69,7 @@ opts+=-DHAVE_MINIUPNPC endif ifndef NOLIBBACKTRACE +$(eval $(call Propogate_flags,LIBBACKTRACE)) libs+=-lbacktrace opts+=-DHAVE_LIBBACKTRACE endif @@ -81,6 +82,7 @@ endif endif ifdef HAVE_DISCORDRPC +$(eval $(call Propogate_flags,DISCORDRPC)) libs+=-ldiscord-rpc opts+=-DUSE_STUN sources+=discord.c stun.c From eee217deecded3b5443e61a5afd6d2edb11a4986 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 11 Jul 2025 22:43:36 +0300 Subject: [PATCH 02/19] Add server search --- src/m_menu.c | 99 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 14 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 99d4057cb..c0524b066 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -107,7 +107,7 @@ #define SMALLLINEHEIGHT 8 #define SLIDER_RANGE 10 #define SLIDER_WIDTH (8*SLIDER_RANGE+6) -#define SERVERS_PER_PAGE 11 +#define SERVERS_PER_PAGE 10 #define MAXSTAT 9 //Max number a stat can have typedef enum @@ -183,6 +183,8 @@ static char joystickInfo[8][29]; static UINT32 serverlistpage; static UINT32 oldserverlistpage; static float serverlistslidex; +static INT32 serverlistsearched[MAXSERVERLIST] = {0}; +static UINT32 serverlistsearchedcount = 0; #endif //static saveinfo_t savegameinfo[MAXSAVEGAMES]; // Extra info about the save games. @@ -211,6 +213,8 @@ static void M_StopMessage(INT32 choice); #ifndef NONET static void M_HandleServerPage(INT32 choice); +static void M_HandleServerSearch(INT32 choice); +static void M_SearchServerList(void); #endif // Prototyping is fun, innit? @@ -1110,11 +1114,11 @@ static menuitem_t MP_PlayerSetupMenu[] = #ifndef NONET static menuitem_t MP_ConnectMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 4}, - {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 12}, - {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 20}, + {IT_STRING | IT_KEYHANDLER, NULL, "", M_HandleServerSearch,0}, + {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 16}, + {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 24}, + {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 32}, - {IT_STRING | IT_SPACE, NULL, "", M_Connect, 36}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 48}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 60}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 72}, @@ -1129,6 +1133,7 @@ static menuitem_t MP_ConnectMenu[] = enum { + mp_connect_search, mp_connect_sort, mp_connect_page, mp_connect_refresh, @@ -4875,6 +4880,9 @@ void M_Init(void) //todo put this somewhere better... CV_RegisterVar(&cv_allcaps); + + memset(menu_text_input_buf, 0, sizeof menu_text_input_buf); + M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf); } void M_InitCharacterTables(void) @@ -9629,7 +9637,7 @@ Fetch_servers_thread (int *id) } #endif/*MASTERSERVER*/ -#define SERVERHEADERHEIGHT 36 +#define SERVERHEADERHEIGHT 48 #define SERVERLINEHEIGHT 12 #define S_LINEY(n) currentMenu->y + SERVERHEADERHEIGHT + (n * SERVERLINEHEIGHT) @@ -9637,6 +9645,55 @@ Fetch_servers_thread (int *id) #ifndef NONET static UINT32 localservercount; +static void M_SearchServerList(void) +{ + serverlistsearchedcount = 0; + + for (UINT32 i = 0; i < serverlistcount; ++i) + { + if (menuinput.length == 0 || strcasestr(serverlist[i].info.servername, menuinput.buffer) != NULL) + serverlistsearched[serverlistsearchedcount++] = i; + } + + if (menuinput.length > 0) + serverlistpage = 0; +} + +static void M_HandleServerSearch(INT32 choice) +{ + boolean exitmenu = false; // exit to previous menu + + switch (choice) + { + case KEY_DOWNARROW: + M_NextOpt(); + S_StartSound(NULL, sfx_menu1); + break; + case KEY_UPARROW: + M_PrevOpt(); + S_StartSound(NULL, sfx_menu1); + break; + case KEY_ESCAPE: + exitmenu = true; + break; + + default: + if (M_TextInputHandle(&menuinput, choice)) + { + S_StartSound(NULL, sfx_menu1); + M_SearchServerList(); + } + break; + } + if (exitmenu) + { + if (currentMenu->prevMenu) + M_SetupNextMenu(currentMenu->prevMenu); + else + M_ClearMenus(true); + } +} + static void M_HandleServerPage(INT32 choice) { boolean exitmenu = false; // exit to previous menu @@ -9659,7 +9716,7 @@ static void M_HandleServerPage(INT32 choice) case KEY_ENTER: case KEY_RIGHTARROW: S_StartSound(NULL, sfx_menu1); - if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistcount) + if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistsearchedcount) { oldserverlistpage = serverlistpage++; serverlistslidex = BASEVIDWIDTH; @@ -9690,7 +9747,7 @@ static void M_Connect(INT32 choice) { // do not call menuexitfunc M_ClearMenus(false); - COM_BufAddText(va("connect node %d\n", serverlist[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE].node)); + COM_BufAddText(va("connect node %d\n", serverlist[serverlistsearched[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE]].node)); } static void M_Refresh(INT32 choice) @@ -9748,11 +9805,11 @@ static void M_DrawServerCountAndHorizontalBar(void) radius = V_StringWidth(text, 0) / 2; - V_DrawCenteredString(center, currentMenu->y+28, 0, text); + V_DrawCenteredString(center, currentMenu->y+40, 0, text); // Horizontal line! - V_DrawFill(1, currentMenu->y+32, center - radius - 2, 1, 0); - V_DrawFill(center + radius + 2, currentMenu->y+32, BASEVIDWIDTH - 1, 1, 0); + V_DrawFill(1, currentMenu->y+44, center - radius - 2, 1, 0); + V_DrawFill(center + radius + 2, currentMenu->y+44, BASEVIDWIDTH - 1, 1, 0); } #endif @@ -9762,9 +9819,9 @@ static void M_DrawServerLines(INT32 x, INT32 page) const char *gt = "Unknown"; const char *spd = ""; - for (i = 0; i < min(serverlistcount - page * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++) + for (i = 0; i < min(serverlistsearchedcount - page * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++) { - INT32 slindex = i + page * SERVERS_PER_PAGE; + INT32 slindex = serverlistsearched[i + page * SERVERS_PER_PAGE]; UINT32 globalflags = ((serverlist[slindex].info.numberofplayer >= serverlist[slindex].info.maxplayer) ? V_TRANSLUCENT : 0) |((itemOn == FIRSTSERVERLINE+i) ? highlightflags : 0)|V_ALLOWLOWERCASE; @@ -9803,7 +9860,7 @@ static void M_DrawServerLines(INT32 x, INT32 page) static void M_DrawConnectMenu(void) { UINT16 i; - INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; + INT32 numPages = (serverlistsearchedcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; INT32 mservflags = V_ALLOWLOWERCASE; for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++) @@ -9853,6 +9910,16 @@ static void M_DrawConnectMenu(void) M_DrawServerLines(currentMenu->x, serverlistpage); } + V_DrawFill(currentMenu->x, currentMenu->y, MAXSTRINGLENGTH*8+6, 8+6, 239); + + const INT32 xoff = 3, yoff = 3; + + + if (itemOn != 0) + V_DrawString(currentMenu->x+xoff, currentMenu->y+yoff, V_ALLOWLOWERCASE, menuinput.buffer); + else + M_DrawTextInput(currentMenu->x+xoff, currentMenu->y+yoff, &menuinput, 0); + localservercount = serverlistcount; M_DrawGenericMenu(); @@ -9932,6 +9999,7 @@ void M_SortServerList(void) qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_gametype); break; } + M_SearchServerList(); #endif } @@ -9990,6 +10058,9 @@ static void M_ConnectMenu(INT32 choice) CL_UpdateServerList(); + // Reset + M_TextInputSetString(&menuinput, ""); + M_SetupNextMenu(&MP_ConnectDef); itemOn = 0; From 30f53f398f0f0102551ad8d9b263fe3082580632 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 12 Jun 2025 17:09:26 +0200 Subject: [PATCH 03/19] move CopyCaretColors to m_misc --- src/d_clisrv.c | 117 +------------------------------------------------ src/m_misc.c | 66 ++++++++++++++++++++++++++++ src/m_misc.h | 2 + 3 files changed, 69 insertions(+), 116 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 905a5bb74..178faf8a4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -570,58 +570,7 @@ void SendKick(UINT8 playernum, UINT8 msg) // end of extra data function // ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// extra data function for lmps -// ----------------------------------------------------------------- - -// if extradatabit is set, after the ziped tic you find this: -// -// type | description -// ---------+-------------- -// byte | size of the extradata -// byte | the extradata (xd) bits: see XD_... -// with this byte you know what parameter folow -// if (xd & XDNAMEANDCOLOR) -// byte | color -// char[MAXPLAYERNAME] | name of the player -// endif -// if (xd & XD_WEAPON_PREF) -// byte | original weapon switch: boolean, true if use the old -// | weapon switch methode -// char[NUMWEAPONS] | the weapon switch priority -// byte | autoaim: true if use the old autoaim system -// endif -/*boolean AddLmpExtradata(UINT8 **demo_point, INT32 playernum) -{ - UINT8 *textcmd = D_GetExistingTextcmd(gametic, playernum); - - if (!textcmd) - return false; - - M_Memcpy(*demo_point, textcmd, textcmd[0]+1); - *demo_point += textcmd[0]+1; - return true; -} - -void ReadLmpExtraData(UINT8 **demo_pointer, INT32 playernum) -{ - UINT8 nextra; - UINT8 *textcmd; - - if (!demo_pointer) - return; - - textcmd = D_GetTextcmd(gametic, playernum); - nextra = **demo_pointer; - M_Memcpy(textcmd, *demo_pointer, nextra + 1); - // increment demo pointer - *demo_pointer += nextra + 1; -}*/ - -// ----------------------------------------------------------------- -// end extra data function for lmps -// ----------------------------------------------------------------- - +// can we get rid of this finally lmao // ----------------------------------------------------------------- // resynch player data // ----------------------------------------------------------------- @@ -1583,70 +1532,6 @@ static boolean CL_SendJoin(void) return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); } -static void -CopyCaretColors (char *p, const char *s, int n) -{ - char *t; - int m; - int c; - if (!n) - return; - while (( t = strchr(s, '^') )) - { - m = ( t - s ); - - if (m >= n) - { - memcpy(p, s, n); - return; - } - else - memcpy(p, s, m); - - p += m; - n -= m; - s += m; - - if (!n) - return; - - if (s[1]) - { - c = toupper(s[1]); - if (isdigit(c)) - c = 0x80 + ( c - '0' ); - else if (c >= 'A' && c <= 'F') - c = 0x80 + ( c - 'A' ); - else - c = 0; - - if (c) - { - *p++ = c; - n--; - - if (!n) - return; - } - else - { - if (n < 2) - break; - - memcpy(p, s, 2); - - p += 2; - n -= 2; - } - - s += 2; - } - else - break; - } - strncpy(p, s, n); -} - static void SV_SendServerInfo(INT32 node, tic_t servertime) { UINT8 *p; diff --git a/src/m_misc.c b/src/m_misc.c index 8855ab945..61fb7caee 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1762,6 +1762,72 @@ INT32 axtoi(const char *hexStg) return intValue; } +void CopyCaretColors(char *p, const char *s, int n) +{ + char *t; + int m; + int c; + + if (!n) + return; + + while (( t = strchr(s, '^') )) + { + m = ( t - s ); + + if (m >= n) + { + memcpy(p, s, n); + return; + } + else + memcpy(p, s, m); + + p += m; + n -= m; + s += m; + + if (!n) + return; + + if (s[1]) + { + c = toupper(s[1]); + if (isdigit(c)) + c = 0x80 + ( c - '0' ); + else if (c >= 'A' && c <= 'F') + c = 0x80 + ( c - 'A' ); + else + c = 0; + + if (c) + { + *p++ = c; + n--; + + if (!n) + return; + } + else + { + if (n < 2) + break; + + memcpy(p, s, 2); + + p += 2; + n -= 2; + } + + s += 2; + } + else + break; + } + + strncpy(p, s, n); +} + /** Token parser for TEXTURES, ANIMDEFS, and potentially other lumps later down the line. * Was originally R_GetTexturesToken when I was coding up the TEXTURES parser, until I realized I needed it for ANIMDEFS too. * Parses up to the next whitespace character or comma. When finding the start of the next token, whitespace is skipped. diff --git a/src/m_misc.h b/src/m_misc.h index ae5eb3ba4..ad3b69c80 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -85,6 +85,8 @@ void M_SaveConfig(const char *filename); INT32 axtoi(const char *hexStg); +void CopyCaretColors(char *p, const char *s, int n); + const char *GetRevisionString(void); // Vector/matrix math From d31e9c5b55fbc68a72f6424193f81b3dc0e85d13 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 11 Jul 2025 23:15:19 +0300 Subject: [PATCH 04/19] Strip colors from server name when searching through server list --- src/m_menu.c | 4 +++- src/m_misc.c | 15 +++++++++++++++ src/m_misc.h | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index c0524b066..898ac30f9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9647,11 +9647,13 @@ static UINT32 localservercount; static void M_SearchServerList(void) { + char servername[MAXSERVERNAME+1] = {0}; serverlistsearchedcount = 0; for (UINT32 i = 0; i < serverlistcount; ++i) { - if (menuinput.length == 0 || strcasestr(serverlist[i].info.servername, menuinput.buffer) != NULL) + StripColors(servername, serverlist[i].info.servername, MAXSERVERNAME); + if (menuinput.length == 0 || strcasestr(servername, menuinput.buffer) != NULL) serverlistsearched[serverlistsearchedcount++] = i; } diff --git a/src/m_misc.c b/src/m_misc.c index 61fb7caee..7cfeca1b7 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1828,6 +1828,21 @@ void CopyCaretColors(char *p, const char *s, int n) strncpy(p, s, n); } +void StripColors(char *dst, char *src, size_t n) +{ + size_t j = 0; + + for (size_t i = 0; j < n && src[i] != 0; ++i) + { + char c = src[i]; + + if ((c & 0x80) == 0) + dst[j++] = c; + } + + dst[j] = 0; +} + /** Token parser for TEXTURES, ANIMDEFS, and potentially other lumps later down the line. * Was originally R_GetTexturesToken when I was coding up the TEXTURES parser, until I realized I needed it for ANIMDEFS too. * Parses up to the next whitespace character or comma. When finding the start of the next token, whitespace is skipped. diff --git a/src/m_misc.h b/src/m_misc.h index ad3b69c80..a189b31f2 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -87,6 +87,9 @@ INT32 axtoi(const char *hexStg); void CopyCaretColors(char *p, const char *s, int n); +// Remove color codes from string +void StripColors(char *dst, char *src, size_t n); + const char *GetRevisionString(void); // Vector/matrix math From 298fa36c5dc28a74849b8aa77d5ca220c414ff4f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Jul 2025 13:30:52 +0200 Subject: [PATCH 05/19] uninline R_IsPointInSubsector this gets used like once or twice, we dont need that inlined --- src/r_main.cpp | 27 +++++++++++++++++++++++++++ src/r_main.h | 37 ++++++------------------------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index ebea32638..b2b5ed73f 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1047,6 +1047,33 @@ void R_Init(void) framecount = 0; } +// +// R_IsPointInSubsector, same as above but returns 0 if not in subsector +// +subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) +{ + node_t *node; + INT32 side, i; + size_t nodenum; + subsector_t *ret; + + nodenum = numnodes - 1; + + while (!(nodenum & NF_SUBSECTOR)) + { + node = &nodes[nodenum]; + side = R_PointOnSide(x, y, node); + nodenum = node->children[side]; + } + + 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 ret; +} + // // R_SetupFrame // diff --git a/src/r_main.h b/src/r_main.h index 29a6b308e..2e27d6036 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -88,7 +88,7 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // // killough 5/2/98: reformatted // -FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t * restrict node) +FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t* restrict node) { if (!node->dx) return x <= node->x ? node->dy > 0 : node->dy < 0; @@ -117,10 +117,10 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideFast(fixed_t x, fixed_t FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) { - fixed_t lx = line->v1->x; - fixed_t ly = line->v1->y; - fixed_t ldx = line->v2->x - lx; - fixed_t ldy = line->v2->y - ly; + fixed_t lx = line->v1->x; + fixed_t ly = line->v1->y; + fixed_t ldx = line->v2->x - lx; + fixed_t ldy = line->v2->y - ly; // use cross product to determine side quickly INT64 v = ((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy; @@ -147,32 +147,7 @@ FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t return &subsectors[nodenum & ~NF_SUBSECTOR]; } -// -// R_IsPointInSubsector, same as above but returns 0 if not in subsector -// -FUNCINLINE static ATTRINLINE subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) -{ - node_t *node; - INT32 side, i; - size_t nodenum; - subsector_t *ret; - - nodenum = numnodes - 1; - - while (!(nodenum & NF_SUBSECTOR)) - { - node = &nodes[nodenum]; - side = R_PointOnSide(x, y, node); - nodenum = node->children[side]; - } - - 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 ret; -} +subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) #define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2)) From 24e7f5f864f6f6f7bd559ba24d39d71dae8bfbaf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Jul 2025 13:34:44 +0200 Subject: [PATCH 06/19] readd R_PointInSubsectorFast use it for camera, viewpoint, some precip and sound stuff and (visual) banana slope calc after profiling it a bit, this may be 2-4x faster in a bunch cases --- src/d_clisrv.c | 2 +- src/hardware/hw_main.cpp | 2 +- src/hardware/hw_portal.c | 2 +- src/k_kart.c | 2 +- src/p_map.c | 4 ++-- src/p_maputl.c | 2 +- src/p_mobj.c | 8 ++++---- src/p_setup.c | 4 ++-- src/p_spec.c | 2 +- src/p_user.c | 6 +++--- src/r_fps.c | 2 +- src/r_main.cpp | 6 ++---- src/r_main.h | 18 ++++++++++-------- src/s_sound.c | 4 ++-- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 178faf8a4..892ac14a0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2014,7 +2014,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); + camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y); } cl_redownloadinggamestate = false; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index bbb116250..1555cffda 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3316,7 +3316,7 @@ static gl_vissprite_t *HWR_NewVisSprite(void) // Finds a floor through which light does not pass. static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) { - const sector_t *sec = R_PointInSubsector(x, y)->sector; + const sector_t *sec = R_PointInSubsectorFast(x, y)->sector; fixed_t floorz = sec->floorheight; if (sec->ffloors) diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 909214171..db17d05bf 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -132,7 +132,7 @@ void HWR_PortalFrame(gl_portal_t* portal) { portalclipline = NULL; portalcullsector = NULL; - viewsector = R_PointInSubsector(viewx, viewy)->sector; + viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; } } diff --git a/src/k_kart.c b/src/k_kart.c index f02da77ea..84ef84e16 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4600,7 +4600,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z //sec = R_PointInSubsector(x, y)->sector; if (mobj->x != x || mobj->y != y || mobj->subsector == NULL) - sec = R_PointInSubsector(x, y)->sector; + sec = R_PointInSubsectorFast(x, y)->sector; else sec = mobj->subsector->sector; diff --git a/src/p_map.c b/src/p_map.c index 17263bfe9..f11a19fff 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1995,7 +1995,7 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) tmbbox[BOXLEFT] = x - thiscam->radius; if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) - newsubsec = R_PointInSubsector(x, y); + newsubsec = R_PointInSubsectorFast(x, y); else newsubsec = thiscam->subsector; @@ -2181,7 +2181,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) return false; if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) - s = R_PointInSubsector(x, y); + s = R_PointInSubsectorFast(x, y); else s = thiscam->subsector; diff --git a/src/p_maputl.c b/src/p_maputl.c index 7b748c22e..11e7a1050 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -908,7 +908,7 @@ void P_SetUnderlayPosition(mobj_t *thing) void P_SetPrecipitationThingPosition(precipmobj_t *thing) { - thing->subsector = R_PointInSubsector(thing->x, thing->y); + thing->subsector = R_PointInSubsectorFast(thing->x, thing->y); // NOTE: this works because bnext/bprev are at the same // offsets in precipmobj_t and mobj_t diff --git a/src/p_mobj.c b/src/p_mobj.c index 70f4dbacf..80615c608 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -777,7 +777,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsectorFast(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -856,7 +856,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsectorFast(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -3308,7 +3308,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } } - thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y); + thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; thiscam->ceilingz = tmceilingz; @@ -10319,7 +10319,7 @@ void P_PrecipitationEffects(void) for (y = yl; y <= yh; y += RADIUSSTEP) for (x = xl; x <= xh; x += RADIUSSTEP) { - if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! + if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! continue; newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0); diff --git a/src/p_setup.c b/src/p_setup.c index 118dbfc74..4c76478dc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2510,7 +2510,6 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->y = players[pnum].mo->y; cam->z = players[pnum].mo->z; cam->angle = players[pnum].mo->angle; - cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } else { @@ -2535,9 +2534,10 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->y = thing->y; cam->z = thing->z; cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS); - cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } + cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) + cam->chase = false; // tell camera to reset its position next tic } diff --git a/src/p_spec.c b/src/p_spec.c index 70fb19c20..224a55171 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2022,7 +2022,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) camera[i].y += y; camera[i].z += z; camera[i].reset = true; - camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); + camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y); R_RelativeTeleportViewInterpolation(i, x, y, z, 0); break; } diff --git a/src/p_user.c b/src/p_user.c index bbf3d2478..3dff40e0a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3402,7 +3402,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // update subsector to avoid crashes; - cam->subsector = R_PointInSubsector(cam->x, cam->y); + cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); } void P_ResetCamera(player_t *player, camera_t *thiscam) @@ -3446,7 +3446,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->relativex = 0; - thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y); + thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y); thiscam->radius = 20*FRACUNIT; thiscam->height = 16*FRACUNIT; @@ -3682,7 +3682,7 @@ static void P_MoveCameraToSpawn(UINT8 playernum) thiscam->angle = player->mo->angle; thiscam->aiming = 0; - thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y); + thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y); thiscam->reset_aiming = true; diff --git a/src/r_fps.c b/src/r_fps.c index 1d5cc1baf..0c3a58737 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -232,7 +232,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); viewplayer = newview->player; - viewsector = R_PointInSubsector(viewx, viewy)->sector; + viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; R_SetupFreelook(); } diff --git a/src/r_main.cpp b/src/r_main.cpp index b2b5ed73f..f6144c64e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -579,8 +579,6 @@ static void R_InitTextureMapping(void) doubleclipangle = clipangle*2; } - - // // R_InitLightTables // Only inits the zlight table, @@ -1093,7 +1091,7 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector) if (sector != NULL) newview->sector = sector; else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; + newview->sector = R_PointInSubsectorFast(newview->x, newview->y)->sector; R_InterpolateView(rendertimefrac_unpaused, false); } @@ -1333,7 +1331,7 @@ static void R_PortalFrame(portal_t *portal) { portalclipline = NULL; portalcullsector = NULL; - viewsector = R_PointInSubsector(viewx, viewy)->sector; + viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; } } diff --git a/src/r_main.h b/src/r_main.h index 2e27d6036..efe3fc31c 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -137,16 +137,18 @@ fixed_t R_ScaleFromGlobalAngle(angle_t visangle); // // R_PointInSubsector // -FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t y) -{ - size_t nodenum = numnodes-1; - - while (!(nodenum & NF_SUBSECTOR)) - nodenum = nodes[nodenum].children[R_PointOnSide(x, y, nodes+nodenum)]; - - return &subsectors[nodenum & ~NF_SUBSECTOR]; +#define R_POINTINSUBSECTOR(FUNCNAME, SIDEFUNC)\ +FUNCINLINE static ATTRINLINE subsector_t *FUNCNAME(fixed_t x, fixed_t y)\ +{\ + size_t nodenum = numnodes-1;\ + while (!(nodenum & NF_SUBSECTOR))\ + nodenum = nodes[nodenum].children[SIDEFUNC(x, y, nodes+nodenum)];\ + return &subsectors[nodenum & ~NF_SUBSECTOR];\ } +R_POINTINSUBSECTOR(R_PointInSubsector, R_PointOnSide) +R_POINTINSUBSECTOR(R_PointInSubsectorFast, R_PointOnSideFast) + subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) diff --git a/src/s_sound.c b/src/s_sound.c index 03a70cf89..c93570232 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -957,7 +957,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 INT64 x, y, yl, yh, xl, xh; fixed_t newdist; - if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsectorFast(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) approx_dist = 0; else { @@ -970,7 +970,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 for (y = yl; y <= yh; y += FRACUNIT*64) for (x = xl; x <= xh; x += FRACUNIT*64) { - if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsectorFast(x, y)->sector->ceilingpic == skyflatnum) { // Found the outdoors! newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0); From 455cb9ca2487e90941110c48b9e965ec9fa9a796 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Jul 2025 14:54:39 +0200 Subject: [PATCH 07/19] delet windoze users apparently this makes cross compile commit sudoku, need to test this on actual windoze and see if this breaks anything since idk how this file even works thx nep for the tip! --- src/win32/Srb2win.rc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index d7a26dc85..da6c64d82 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -1,5 +1,3 @@ -#include - //Microsoft Developer Studio generated resource script. // #include "resource.h" From b938c758921985b55f6de55b8fc3ab9be5c1c068 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Jul 2025 16:16:41 +0200 Subject: [PATCH 08/19] clean up i_video.c a little what a mess this is still far from tidy --- src/sdl/i_video.c | 838 ++++++++++++++++++++-------------------------- 1 file changed, 355 insertions(+), 483 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 26a6d84db..6ae37989a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -254,102 +254,6 @@ static void mousegrabOnChange(void) SDLdoUngrabMouse(); } -static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) -{ - static SDL_bool wasfullscreen = SDL_FALSE; - Uint32 rmask; - Uint32 gmask; - Uint32 bmask; - Uint32 amask; - int bpp = 16; - int sw_texture_format = SDL_PIXELFORMAT_ABGR8888; - - realwidth = vid.width; - realheight = vid.height; - - if (window) - { - if (fullscreen) - { - wasfullscreen = SDL_TRUE; - SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); - } - else // windowed mode - { - if (wasfullscreen) - { - wasfullscreen = SDL_FALSE; - SDL_SetWindowFullscreen(window, 0); - } - // Reposition window only in windowed mode - SDL_SetWindowSize(window, width, height); - SDL_SetWindowPosition(window, - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) - ); - } - } - else - { - Impl_CreateWindow(fullscreen); - wasfullscreen = fullscreen; - SDL_SetWindowSize(window, width, height); - if (fullscreen) - { - SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); - } - } - -#ifdef HWRENDER - if (rendermode == render_opengl) - { - I_CheckDesktopRes(); -#ifdef USE_FBO_OGL - I_DownSample(); -#endif - OglSdlSurface(vid.width, vid.height); - } -#endif - - if (rendermode == render_soft) - { - SDL_RenderClear(renderer); - SDL_RenderSetLogicalSize(renderer, width, height); - // Set up Texture - realwidth = width; - realheight = height; - if (texture != NULL) - { - SDL_DestroyTexture(texture); - } - - if (!usesdl2soft) - { - sw_texture_format = SDL_PIXELFORMAT_RGB565; - } - else - { - bpp = 32; - sw_texture_format = SDL_PIXELFORMAT_RGBA8888; - } - - texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height); - - // Set up SW surface - if (vidSurface != NULL) - { - SDL_FreeSurface(vidSurface); - } - if (vid.buffer) - { - free(vid.buffer); - vid.buffer = NULL; - } - SDL_PixelFormatEnumToMasks(sw_texture_format, &bpp, &rmask, &gmask, &bmask, &amask); - vidSurface = SDL_CreateRGBSurface(0, width, height, bpp, rmask, gmask, bmask, amask); - } -} - static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) { if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z) @@ -603,51 +507,11 @@ static void SurfaceInfo(const SDL_Surface *infoSurface, const char *SurfaceText) static void VID_Command_Info_f (void) { -#if 0 - SDL2STUB(); -#else -#if 0 - const SDL_VideoInfo *videoInfo; - videoInfo = SDL_GetVideoInfo(); //Alam: Double-Check - if (videoInfo) - { - CONS_Printf("%s", M_GetText("Video Interface Capabilities:\n")); - if (videoInfo->hw_available) - CONS_Printf("%s", M_GetText(" Hardware surfaces\n")); - if (videoInfo->wm_available) - CONS_Printf("%s", M_GetText(" Window manager\n")); - //UnusedBits1 :6 - //UnusedBits2 :1 - if (videoInfo->blit_hw) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW\n")); - if (videoInfo->blit_hw_CC) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW with Colorkey\n")); - if (videoInfo->wm_available) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW with Alpha\n")); - if (videoInfo->blit_sw) - { - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW\n")); - if (!M_CheckParm("-noblit")) videoblitok = SDL_TRUE; - } - if (videoInfo->blit_sw_CC) - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW with Colorkey\n")); - if (videoInfo->blit_sw_A) - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW with Alpha\n")); - if (videoInfo->blit_fill) - CONS_Printf("%s", M_GetText(" Accelerated Color filling\n")); - //UnusedBits3 :16 - if (videoInfo->video_mem) - CONS_Printf(M_GetText(" There is %i KB of video memory\n"), videoInfo->video_mem); - else - CONS_Printf("%s", M_GetText(" There no video memory for SDL\n")); - //*vfmt - } -#else - if (!M_CheckParm("-noblit")) videoblitok = SDL_TRUE; -#endif + if (!M_CheckParm("-noblit")) + videoblitok = SDL_TRUE; + SurfaceInfo(bufSurface, M_GetText("Current Engine Mode")); SurfaceInfo(vidSurface, M_GetText("Current Video Mode")); -#endif } static void VID_Command_ModeList_f(void) @@ -688,16 +552,23 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) INT32 raxis = axis/32; UINT8 pid; - if (which == ev_joystick) - pid = 0; - else if (which == ev_joystick2) - pid = 1; - else if (which == ev_joystick3) - pid = 2; - else if (which == ev_joystick4) - pid = 3; - else - return 0; + switch (which) + { + case ev_joystick: + pid = 0; + break; + case ev_joystick2: + pid = 1; + break; + case ev_joystick3: + pid = 2; + break; + case ev_joystick4: + pid = 3; + break; + default: + return 0; + } if (Joystick[pid].bGamepadStyle) { @@ -982,25 +853,37 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) { SDL_memset(&event, 0, sizeof(event_t)); - if (type == SDL_MOUSEBUTTONUP) + switch (type) { - event.type = ev_keyup; + case SDL_MOUSEBUTTONUP: + event.type = ev_keyup; + break; + case SDL_MOUSEBUTTONDOWN: + event.type = ev_keydown; + break; + default: + return; } - else if (type == SDL_MOUSEBUTTONDOWN) + + switch (evt.button) { - event.type = ev_keydown; + case SDL_BUTTON_MIDDLE: + event.data1 = KEY_MOUSE1+2; + break; + case SDL_BUTTON_RIGHT: + event.data1 = KEY_MOUSE1+1; + break; + case SDL_BUTTON_LEFT: + event.data1 = KEY_MOUSE1; + break; + case SDL_BUTTON_X1: + event.data1 = KEY_MOUSE1+3; + break; + case SDL_BUTTON_X2: + event.data1 = KEY_MOUSE1+4; + break; } - else return; - if (evt.button == SDL_BUTTON_MIDDLE) - event.data1 = KEY_MOUSE1+2; - else if (evt.button == SDL_BUTTON_RIGHT) - event.data1 = KEY_MOUSE1+1; - else if (evt.button == SDL_BUTTON_LEFT) - event.data1 = KEY_MOUSE1; - else if (evt.button == SDL_BUTTON_X1) - event.data1 = KEY_MOUSE1+3; - else if (evt.button == SDL_BUTTON_X2) - event.data1 = KEY_MOUSE1+4; + if (event.type == ev_keyup || event.type == ev_keydown) { D_PostEvent(&event); @@ -1069,7 +952,8 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt) { event.type = ev_joystick4; } - else return; + else + return; //axis if (evt.axis > JOYAXISSET*2) @@ -1121,7 +1005,7 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)); } - if (evt.button == SDL_CONTROLLER_BUTTON_DPAD_UP + if ( evt.button == SDL_CONTROLLER_BUTTON_DPAD_UP || evt.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN || evt.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT || evt.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) @@ -1146,35 +1030,180 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint { event.data1 = KEY_4JOY1; } - else return; + else + return; - if (type == SDL_CONTROLLERBUTTONUP) + switch (type) { - event.type = ev_keyup; + case SDL_CONTROLLERBUTTONUP: + event.type = ev_keyup; + break; + case SDL_CONTROLLERBUTTONDOWN: + event.type = ev_keydown; + break; + default: + return; } - else if (type == SDL_CONTROLLERBUTTONDOWN) - { - event.type = ev_keydown; - } - else return; if (evt.button < JOYBUTTONS) { event.data1 += evt.button; } - else return; + else + return; - if (event.type != ev_console) D_PostEvent(&event); + if (event.type != ev_console) + D_PostEvent(&event); +} + +static void Impl_HandleControllerAddedEvent(SDL_Event evt) +{ + INT32 i; + + // OH BOY are you in for a good time! #abominationstation + SDL_GameController *newcontroller = SDL_GameControllerOpen(evt.cdevice.which); + + CONS_Debug(DBG_GAMELOGIC, "Joystick device index %d added\n", evt.jdevice.which + 1); + + //////////////////////////////////////////////////////////// + // Because SDL's device index is unstable, we're going to cheat here a bit: + // For the first joystick setting that is NOT active: + // + // 1. Set cv_usejoystickX.value to the new device index (this does not change what is written to config.cfg) + // + // 2. Set OTHERS' cv_usejoystickX.value to THEIR new device index, because it likely changed + // * If device doesn't exist, switch cv_usejoystick back to default value (.string) + // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (newcontroller && (!JoyInfo[i].dev || !SDL_GameControllerGetAttached(JoyInfo[i].dev))) + { + UINT8 j; + + for (j = 0; j < MAXSPLITSCREENPLAYERS; j++) + { + if (i == j) + continue; + + if (JoyInfo[j].dev == newcontroller) + break; + } + + if (j == MAXSPLITSCREENPLAYERS) + { + // ensures we aren't overriding a currently active device + cv_usejoystick[i].value = evt.jdevice.which + 1; + I_UpdateJoystickDeviceIndices(0); + } + } + } + + //////////////////////////////////////////////////////////// + // Was cv_usejoystick disabled in settings? + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value) + cv_usejoystick[i].value = 0; + else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick[i].value) // update the cvar ONLY if a device exists + CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); + } + + //////////////////////////////////////////////////////////// + // Update all joysticks' init states + // This is a little wasteful since cv_usejoystick already calls this, but + // we need to do this in case CV_SetValue did nothing because the string was already same. + // if the device is already active, this should do nothing, effectively. + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + I_InitJoystick(i); + G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect + } + + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); + + // update the menu + if (currentMenu == &OP_JoystickSetDef) + M_SetupJoystickMenu(0); + + numcontrollers = I_NumJoys(); + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (JoyInfo[i].dev == newcontroller) + break; + } + + if (i == MAXSPLITSCREENPLAYERS) + SDL_GameControllerClose(newcontroller); +} + +static void Impl_HandleControllerRemovedEvent(void) +{ + INT32 i; + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (JoyInfo[i].dev && !SDL_GameControllerGetAttached(JoyInfo[i].dev)) + { + CONS_Debug(DBG_GAMELOGIC, "Joystick%d removed, device index: %d\n", i+1, JoyInfo[i].oldjoy); + I_ShutdownJoystick(i); + } + } + + //////////////////////////////////////////////////////////// + // Update the device indexes, because they likely changed + // * If device doesn't exist, switch cv_usejoystick back to default value (.string) + // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + I_UpdateJoystickDeviceIndex(i); + } + + //////////////////////////////////////////////////////////// + // Was cv_usejoystick disabled in settings? + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!strcmp(cv_usejoystick[i].string, "0")) + { + cv_usejoystick[i].value = 0; + } + else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick[i].value) // update the cvar ONLY if a device exists + { + CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); + } + } + + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); + + // update the menu + if (currentMenu == &OP_JoystickSetDef) + M_SetupJoystickMenu(0); + + numcontrollers = I_NumJoys(); } void I_GetEvent(void) { SDL_Event evt; char* dropped_filedir; - // We only want the first motion event, - // otherwise we'll end up catching the warp back to center. - //int mouseMotionOnce = 0; - INT32 i; if (!graphics_started) { @@ -1195,9 +1224,7 @@ void I_GetEvent(void) Impl_HandleKeyboardEvent(evt.key, evt.type); break; case SDL_MOUSEMOTION: - //if (!mouseMotionOnce) Impl_HandleMouseMotionEvent(evt.motion); - //mouseMotionOnce = 1; break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: @@ -1209,160 +1236,15 @@ void I_GetEvent(void) case SDL_CONTROLLERAXISMOTION: Impl_HandleControllerAxisEvent(evt.caxis); break; -#if 0 - case SDL_JOYHATMOTION: - Impl_HandleJoystickHatEvent(evt.jhat) - break; -#endif case SDL_CONTROLLERBUTTONUP: case SDL_CONTROLLERBUTTONDOWN: Impl_HandleControllerButtonEvent(evt.cbutton, evt.type); break; - - //////////////////////////////////////////////////////////// - case SDL_CONTROLLERDEVICEADDED: - { - // OH BOY are you in for a good time! #abominationstation - - SDL_GameController *newcontroller = SDL_GameControllerOpen(evt.cdevice.which); - - CONS_Debug(DBG_GAMELOGIC, "Joystick device index %d added\n", evt.jdevice.which + 1); - - //////////////////////////////////////////////////////////// - // Because SDL's device index is unstable, we're going to cheat here a bit: - // For the first joystick setting that is NOT active: - // - // 1. Set cv_usejoystickX.value to the new device index (this does not change what is written to config.cfg) - // - // 2. Set OTHERS' cv_usejoystickX.value to THEIR new device index, because it likely changed - // * If device doesn't exist, switch cv_usejoystick back to default value (.string) - // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (newcontroller && (!JoyInfo[i].dev || !SDL_GameControllerGetAttached(JoyInfo[i].dev))) - { - UINT8 j; - - for (j = 0; j < MAXSPLITSCREENPLAYERS; j++) - { - if (i == j) - continue; - - if (JoyInfo[j].dev == newcontroller) - break; - } - - if (j == MAXSPLITSCREENPLAYERS) - { - // ensures we aren't overriding a currently active device - cv_usejoystick[i].value = evt.jdevice.which + 1; - I_UpdateJoystickDeviceIndices(0); - } - } - } - - //////////////////////////////////////////////////////////// - // Was cv_usejoystick disabled in settings? - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value) - cv_usejoystick[i].value = 0; - else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys - && cv_usejoystick[i].value) // update the cvar ONLY if a device exists - CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); - } - - //////////////////////////////////////////////////////////// - // Update all joysticks' init states - // This is a little wasteful since cv_usejoystick already calls this, but - // we need to do this in case CV_SetValue did nothing because the string was already same. - // if the device is already active, this should do nothing, effectively. - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - I_InitJoystick(i); - G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect - } - - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); - - // update the menu - if (currentMenu == &OP_JoystickSetDef) - M_SetupJoystickMenu(0); - - numcontrollers = I_NumJoys(); - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (JoyInfo[i].dev == newcontroller) - break; - } - - if (i == MAXSPLITSCREENPLAYERS) - SDL_GameControllerClose(newcontroller); - } + Impl_HandleControllerAddedEvent(evt); break; - - //////////////////////////////////////////////////////////// - case SDL_CONTROLLERDEVICEREMOVED: - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (JoyInfo[i].dev && !SDL_GameControllerGetAttached(JoyInfo[i].dev)) - { - CONS_Debug(DBG_GAMELOGIC, "Joystick%d removed, device index: %d\n", i+1, JoyInfo[i].oldjoy); - I_ShutdownJoystick(i); - } - } - - //////////////////////////////////////////////////////////// - // Update the device indexes, because they likely changed - // * If device doesn't exist, switch cv_usejoystick back to default value (.string) - // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - I_UpdateJoystickDeviceIndex(i); - } - - //////////////////////////////////////////////////////////// - // Was cv_usejoystick disabled in settings? - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!strcmp(cv_usejoystick[i].string, "0")) - { - cv_usejoystick[i].value = 0; - } - else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys - && cv_usejoystick[i].value) // update the cvar ONLY if a device exists - { - CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); - } - } - - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); - - // update the menu - if (currentMenu == &OP_JoystickSetDef) - M_SetupJoystickMenu(0); - - numcontrollers = I_NumJoys(); - + Impl_HandleControllerRemovedEvent(); break; case SDL_DROPFILE: dropped_filedir = evt.drop.file; @@ -1382,7 +1264,6 @@ void I_GetEvent(void) event_t event; int wwidth, wheight; SDL_GetWindowSize(window, &wwidth, &wheight); - //SDL_memset(&event, 0, sizeof(event_t)); event.type = ev_mouse; event.data1 = 0; event.data2 = (INT32)lround(mousemovex * ((float)wwidth / (float)realwidth)); @@ -1408,6 +1289,7 @@ void I_StartupMouse(void) } else firsttimeonmouse = SDL_FALSE; + if (cv_usemouse.value || cv_alwaysgrabmouse.value) SDLdoGrabMouse(); else @@ -1424,9 +1306,11 @@ void I_OsPolling(void) if (consolevent) I_GetConsoleEvents(); + if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)) { SDL_GameControllerUpdate(); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) I_GetJoystickEvents(i); } @@ -1446,6 +1330,105 @@ void I_OsPolling(void) if (mod & KMOD_CAPS) capslock = true; } +static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) +{ + static SDL_bool wasfullscreen = SDL_FALSE; + Uint32 rmask, gmask, bmask, amask; + int bpp = 16; + int sw_texture_format = SDL_PIXELFORMAT_ABGR8888; + + realwidth = vid.width; + realheight = vid.height; + + if (window) + { + if (fullscreen) + { + wasfullscreen = SDL_TRUE; + SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); + } + else // windowed mode + { + if (wasfullscreen) + { + wasfullscreen = SDL_FALSE; + SDL_SetWindowFullscreen(window, 0); + } + + // Reposition window only in windowed mode + SDL_SetWindowSize(window, width, height); + SDL_SetWindowPosition(window, + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) + ); + } + } + else + { + Impl_CreateWindow(fullscreen); + wasfullscreen = fullscreen; + SDL_SetWindowSize(window, width, height); + + if (fullscreen) + { + SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); + } + } + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + I_CheckDesktopRes(); +#ifdef USE_FBO_OGL + I_DownSample(); +#endif + OglSdlSurface(vid.width, vid.height); + } +#endif + + if (rendermode == render_soft) + { + SDL_RenderClear(renderer); + SDL_RenderSetLogicalSize(renderer, width, height); + + // Set up Texture + realwidth = width; + realheight = height; + + if (texture != NULL) + { + SDL_DestroyTexture(texture); + } + + if (!usesdl2soft) + { + sw_texture_format = SDL_PIXELFORMAT_RGB565; + } + else + { + bpp = 32; + sw_texture_format = SDL_PIXELFORMAT_RGBA8888; + } + + texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height); + + // Set up SW surface + if (vidSurface != NULL) + { + SDL_FreeSurface(vidSurface); + } + + if (vid.buffer) + { + free(vid.buffer); + vid.buffer = NULL; + } + + SDL_PixelFormatEnumToMasks(sw_texture_format, &bpp, &rmask, &gmask, &bmask, &amask); + vidSurface = SDL_CreateRGBSurface(0, width, height, bpp, rmask, gmask, bmask, amask); + } +} + // // I_UpdateNoBlit // @@ -1453,6 +1436,7 @@ void I_UpdateNoBlit(void) { if (rendermode == render_none) return; + if (exposevideo) { #ifdef HWRENDER @@ -1468,6 +1452,7 @@ void I_UpdateNoBlit(void) SDL_RenderPresent(renderer); } } + exposevideo = SDL_FALSE; } @@ -1517,7 +1502,6 @@ void I_FinishUpdate(void) SDL_RenderCopy(renderer, texture, &src_rect, NULL); SDL_RenderPresent(renderer); } - #ifdef HWRENDER else if (rendermode == render_opengl) { @@ -1556,12 +1540,14 @@ void I_ReadScreen(UINT8 *scr) void I_SetPalette(RGBA_t *palette) { size_t i; + for (i=0; i<256; i++) { localPalette[i].r = palette[i].s.red; localPalette[i].g = palette[i].s.green; localPalette[i].b = palette[i].s.blue; } + //if (vidSurface) SDL_SetPaletteColors(vidSurface->format->palette, localPalette, 0, 256); // Fury -- SDL2 vidSurface is a 32-bit surface buffer copied to the texture. It's not palletized, like bufSurface. if (bufSurface) SDL_SetPaletteColors(bufSurface->format->palette, localPalette, 0, 256); @@ -1578,37 +1564,25 @@ INT32 VID_NumModes(void) const char *VID_GetModeName(INT32 modeNum) { -#if 0 - if (USE_FULLSCREEN && numVidModes != -1) // fullscreen modes - { - modeNum += firstEntry; - if (modeNum >= numVidModes) - return NULL; - - sprintf(&vidModeName[modeNum][0], "%dx%d", - modeList[modeNum]->w, - modeList[modeNum]->h); - } - else // windowed modes - { -#endif if (modeNum == -1) { return fallback_resolution_name; } - if (modeNum > MAXWINMODES) - return NULL; - sprintf(&vidModeName[modeNum][0], "%dx%d", - windowedModes[modeNum][0], - windowedModes[modeNum][1]); - //} + if (modeNum > MAXWINMODES) + return NULL; + + sprintf(&vidModeName[modeNum][0], "%dx%d", + windowedModes[modeNum][0], + windowedModes[modeNum][1]); + return &vidModeName[modeNum][0]; } INT32 VID_GetModeForSize(INT32 w, INT32 h) { int i; + for (i = 0; i < MAXWINMODES; i++) { if (windowedModes[i][0] == w && windowedModes[i][1] == h) @@ -1616,6 +1590,7 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h) return i; } } + // did not find mode from list, make custom resolution if the values somewhat make sense // opengl mode does not mind about max resolution defined in screen.h // if not using opengl, check against the maximum as well @@ -1626,104 +1601,14 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h) custom_height = h; return CUSTOMMODENUM; } + return -1; -#if 0 - INT32 matchMode = -1, i; - VID_PrepareModeList(); - if (USE_FULLSCREEN && numVidModes != -1) - { - for (i=firstEntry; iw == w && - modeList[i]->h == h) - { - matchMode = i; - break; - } - } - if (-1 == matchMode) // use smaller mode - { - w -= w%BASEVIDWIDTH; - h -= h%BASEVIDHEIGHT; - for (i=firstEntry; iw == w && - modeList[i]->h == h) - { - matchMode = i; - break; - } - } - if (-1 == matchMode) // use smallest mode - matchMode = numVidModes-1; - } - matchMode -= firstEntry; - } - else - { - for (i=0; iw <= MAXVIDWIDTH && - modeList[i]->h <= MAXVIDHEIGHT) - { - firstEntry = i; - break; - } - } - } - } - allow_fullscreen = true; -#endif } static UINT32 refresh_rate; @@ -1783,7 +1668,6 @@ INT32 VID_SetMode(INT32 modeNum) } vid.modenum = -1; } - //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); Impl_VideoSetupBuffer(); @@ -1815,11 +1699,13 @@ static SDL_bool Impl_CreateContext(void) { if (!sdlglcontext) sdlglcontext = SDL_GL_CreateContext(window); + if (sdlglcontext == NULL) { SDL_DestroyWindow(window); I_Error("Failed to create a GL context: %s\n", SDL_GetError()); } + SDL_GL_MakeCurrent(window, sdlglcontext); } else @@ -1912,24 +1798,13 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) return Impl_CreateContext(); } -/* -static void Impl_SetWindowName(const char *title) -{ - if (window == NULL) - { - return; - } - SDL_SetWindowTitle(window, title); -} -*/ - static void Impl_SetWindowIcon(void) { if (window == NULL || icoSurface == NULL) { return; } - //SDL2STUB(); // Monster Iestyn: why is this stubbed? + SDL_SetWindowIcon(window, icoSurface); } @@ -1957,19 +1832,16 @@ static void Impl_VideoSetupSDLBuffer(void) static void Impl_VideoSetupBuffer(void) { // Set up game's software render buffer - //if (rendermode == render_soft) + vid.rowbytes = vid.width; + + if (vid.buffer) + free(vid.buffer); + + vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS); + + if (!vid.buffer) { - vid.rowbytes = vid.width; - - if (vid.buffer) - free(vid.buffer); - - vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS); - - if (!vid.buffer) - { - I_Error("%s", M_GetText("Not enough memory for video buffer\n")); - } + I_Error("%s", M_GetText("Not enough memory for video buffer\n")); } } @@ -1987,6 +1859,7 @@ void I_StartupGraphics(void) rendermode = render_none; return; } + if (graphics_started) return; @@ -2053,6 +1926,7 @@ void I_StartupGraphics(void) char line[16]; char * word; FILE * file = OpenRendererFile("r"); + if (file != NULL) { while (fgets(line, sizeof line, file) != NULL) @@ -2169,8 +2043,6 @@ void I_StartupGraphics(void) // SDL_GL_LoadLibrary to work well on Windows // Create window - //Impl_CreateWindow(USE_FULLSCREEN); - //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); VID_SetMode(VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT)); vid.width = BASEVIDWIDTH; // Default size for startup @@ -2190,16 +2062,7 @@ void I_StartupGraphics(void) if (M_CheckParm("-nomousegrab")) mousegrabok = SDL_FALSE; -#if 0 // defined (_DEBUG) - else - { - char videodriver[4] = {'S','D','L',0}; - if (!M_CheckParm("-mousegrab") && - *strncpy(videodriver, SDL_GetCurrentVideoDriver(), 4) != '\0' && - strncasecmp("x11",videodriver,4) == 0) - mousegrabok = SDL_FALSE; //X11's XGrabPointer not good - } -#endif + realwidth = (Uint16)vid.width; realheight = (Uint16)vid.height; @@ -2221,15 +2084,23 @@ void I_ShutdownGraphics(void) const rendermode_t oldrendermode = rendermode; rendermode = render_none; - if (icoSurface) SDL_FreeSurface(icoSurface); + + if (icoSurface) + SDL_FreeSurface(icoSurface); icoSurface = NULL; + if (oldrendermode == render_soft) { - if (vidSurface) SDL_FreeSurface(vidSurface); + if (vidSurface) + SDL_FreeSurface(vidSurface); vidSurface = NULL; - if (vid.buffer) free(vid.buffer); + + if (vid.buffer) + free(vid.buffer); vid.buffer = NULL; - if (bufSurface) SDL_FreeSurface(bufSurface); + + if (bufSurface) + SDL_FreeSurface(bufSurface); bufSurface = NULL; } @@ -2241,6 +2112,7 @@ void I_ShutdownGraphics(void) I_OutputMsg("graphics never started\n"); return; } + graphics_started = false; I_OutputMsg("shut down\n"); From eec4443c95bbd5563861e5bb0c49d11c89182d5c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Jul 2025 16:31:45 +0200 Subject: [PATCH 09/19] smol stuff i missed i_video --- src/sdl/i_video.c | 65 ++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 6ae37989a..f4a2c288c 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -122,7 +122,7 @@ static void KeyboardLayout_OnChange(void) boolean I_UseNativeKeyboard(void) { - return cv_keyboardlayout.value == 2 && (chat_on || CON_Ready() || (menu_text_input && menuactive)); + return (cv_keyboardlayout.value == 2) && (chat_on || CON_Ready() || (menu_text_input && menuactive)); } static CV_PossibleValue_t keyboardlayout_cons_t[] = {{1,"Default US"}, {2, "Native"}, {3, "AZERTY"}, {0, NULL}}; @@ -222,7 +222,6 @@ static INT32 custom_height = 0; static void Impl_VideoSetupSDLBuffer(void); static void Impl_VideoSetupBuffer(void); static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); -//static void Impl_SetWindowName(const char *title); static void Impl_SetWindowIcon(void); static void SDLdoGrabMouse(void); @@ -261,6 +260,7 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) // get lowercase ASCII return code - SDL_SCANCODE_A + 'a'; } + if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9) { return code - SDL_SCANCODE_1 + '1'; @@ -269,10 +269,12 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) { return '0'; } + if (code >= SDL_SCANCODE_F1 && code <= SDL_SCANCODE_F10) { return KEY_F1 + (code - SDL_SCANCODE_F1); } + switch (code) { // F11 and F12 are separated from the rest of the function keys @@ -340,6 +342,7 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) case SDL_SCANCODE_RGUI: return KEY_RIGHTWIN; default: break; } + return 0; } @@ -349,19 +352,18 @@ static INT32 GetTypedChar(SDL_Keysym keysym) SDL_Event next_event; SDL_Keycode keycode = keysym.sym; SDL_Scancode scancode = keysym.scancode; - const boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); // only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) - // Special cases, where we always return a fixed value. - switch (keycode) + if (I_UseNativeKeyboard()) // only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) { - case SDLK_BACKSPACE: return KEY_BACKSPACE; - case SDLK_RETURN: return KEY_ENTER; - default: - break; - } + // Special cases, where we always return a fixed value. + switch (keycode) + { + case SDLK_BACKSPACE: return KEY_BACKSPACE; + case SDLK_RETURN: return KEY_ENTER; + default: + break; + } - if (Text_Input_Only) - { if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1 && next_event.type == SDL_TEXTINPUT) { if (next_event.text.text[1] == '\0') // limit to ASCII @@ -369,7 +371,7 @@ static INT32 GetTypedChar(SDL_Keysym keysym) } } - return Impl_SDL_Scancode_To_Keycode(scancode); // fallback + return Impl_SDL_Scancode_To_Keycode(scancode); // fallback to scancodes } static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) @@ -446,6 +448,7 @@ static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) default: break; } + return Impl_SDL_Scancode_To_Keycode(scancode); } @@ -453,6 +456,7 @@ static void SDLdoGrabMouse(void) { SDL_ShowCursor(SDL_DISABLE); SDL_SetWindowGrab(window, SDL_TRUE); + if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore? } @@ -518,14 +522,15 @@ static void VID_Command_ModeList_f(void) { // List windowed modes INT32 i = 0; + CONS_Printf("NOTE: Under SDL2, all modes are supported on all platforms.\n"); CONS_Printf("Under opengl, fullscreen only supports native desktop resolution.\n"); CONS_Printf("Under software, the mode is stretched up to desktop resolution.\n"); + for (i = 0; i < MAXWINMODES; i++) { CONS_Printf("%2d: %dx%d\n", i, windowedModes[i][0], windowedModes[i][1]); } - } static void VID_Command_Mode_f (void) @@ -592,6 +597,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) return raxis; } +// Get the desktop resolution from the current display the gamewindow resides on static void I_CheckDesktopRes(void) { int currentDisplayIndex = -1; @@ -617,6 +623,7 @@ static void I_CheckDesktopRes(void) desktopheight = curmode.h; } +// Check if the game resolution matches the desktop resolution boolean I_CheckNativeRes(void) { return (vid.width == desktopwidth && vid.height == desktopheight); @@ -720,15 +727,15 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { if (cv_usemouse.value) I_StartupMouse(); } - //else firsttimeonmouse = SDL_FALSE; } else if (!mousefocus && !kbfocus) { // Tell game we lost focus, pause music window_notinfocus = true; - if (! cv_playmusicifunfocused.value) + + if (!cv_playmusicifunfocused.value) I_SetMusicVolume(0); - if (! cv_playsoundifunfocused.value) + if (!cv_playsoundifunfocused.value) S_StopSounds(); if (!disable_mouse) @@ -750,17 +757,16 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) { event_t event; - if (type == SDL_KEYUP) + switch (type) { - event.type = ev_keyup; - } - else if (type == SDL_KEYDOWN) - { - event.type = ev_keydown; - } - else - { - return; + case SDL_KEYUP: + event.type = ev_keyup; + break; + case SDL_KEYDOWN: + event.type = ev_keydown; + break; + default: + return; } switch (cv_keyboardlayout.value) @@ -776,7 +782,8 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) break; } - if (event.data1) D_PostEvent(&event); + if (event.data1) + D_PostEvent(&event); } static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) @@ -1541,7 +1548,7 @@ void I_SetPalette(RGBA_t *palette) { size_t i; - for (i=0; i<256; i++) + for (i = 0; i < 256; i++) { localPalette[i].r = palette[i].s.red; localPalette[i].g = palette[i].s.green; From d4f912e3b07223945b65ee43e30b1f8d03823c9f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Jul 2025 19:41:42 +0200 Subject: [PATCH 10/19] add toggable player close to camera fade similar to some other kartracers only takes other players into account --- src/hardware/hw_main.cpp | 4 ++++ src/hardware/hw_md2.c | 6 +++++- src/r_main.cpp | 15 +++++++++------ src/r_main.h | 1 + src/r_things.cpp | 34 ++++++++++++++++++++++++++++++++++ src/r_things.h | 3 +++ 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 1555cffda..2b14a2250 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3732,6 +3732,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } + Surf.PolyColor.s.alpha = FixedMul(R_GetThingFade(spr->mobj), Surf.PolyColor.s.alpha); + if (HWR_UseShader()) { shader = SHADER_SPRITE; @@ -4018,6 +4020,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } + Surf.PolyColor.s.alpha = FixedMul(R_GetThingFade(spr->mobj), Surf.PolyColor.s.alpha); + if (HWR_UseShader()) { shader = SHADER_SPRITE; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index e1b31bda0..50a58e607 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1227,6 +1227,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr) Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } + Surf.PolyColor.s.alpha = FixedMul(R_GetThingFade(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 @@ -1241,7 +1243,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) else { md2s = md2_playermodels; - skinnum = (skin_t *)spr->mobj->localskin - skins; + skinnum = (skin_t *)spr->mobj->localskin - skins; } } else @@ -1266,6 +1268,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) if (md2->error) return; // we already failed loading this before :( + if (!md2->model) { CONS_Debug(DBG_RENDER, "Loading model... (%s, %s)", sprnames[spr->mobj->sprite], md2->filename); @@ -1284,6 +1287,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) return; } } + //Hurdler: arf, I don't like that implementation at all... too much crappy gpatch = md2->glpatch; if (gpatch) diff --git a/src/r_main.cpp b/src/r_main.cpp index f6144c64e..dc6bbe684 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -141,10 +141,10 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = { #endif static CV_PossibleValue_t maxinterpdist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; + /*{256, "256"},*/ {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; static CV_PossibleValue_t fov_cons_t[] = {{MINFOV*FRACUNIT, "MIN"}, {MAXFOV*FRACUNIT, "MAX"}, {0, NULL}}; @@ -170,14 +170,14 @@ consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnO consvar_t cv_precachetextures = {"precachetextures", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS] = { - {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"chasecam3", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"chasecam4", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS] = { - {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}, {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}, {"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}, {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL} @@ -195,6 +195,7 @@ consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE|CV_CALL|CV_NO consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_maxinterpdist = {"maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playerfade = {"playerfade", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Okay, whoever said homremoval causes a performance hit should be shot. @@ -211,6 +212,7 @@ consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_uncappedhud = {"uncappedhud", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_soniccd = {"soniccd", "Off", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1594,6 +1596,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_randomdirlight); CV_RegisterVar(&cv_maxinterpdist); + CV_RegisterVar(&cv_playerfade); CV_RegisterVar(&cv_ripplewater); diff --git a/src/r_main.h b/src/r_main.h index efe3fc31c..295e6e34d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -195,6 +195,7 @@ extern consvar_t cv_fov, cv_fovchange; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; extern consvar_t cv_maxinterpdist; +extern consvar_t cv_playerfade; extern consvar_t cv_ripplewater; extern consvar_t cv_randomdirlight; diff --git a/src/r_things.cpp b/src/r_things.cpp index 542b271a7..58d9746b5 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -737,6 +737,13 @@ static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column) dc->texturemid = basetexturemid; } + +// Based off of R_GetLinedefTransTable +transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap) +{ + return static_cast((20*(FRACUNIT - ((alpha * (10 - transmap))/10) - 1) + FRACUNIT) >> (FRACBITS+1)); +} + // // R_DrawVisSprite // mfloorclip and mceilingclip should also be set. @@ -1596,6 +1603,8 @@ static void R_ProjectSprite(mobj_t *thing) else trans = 0; + trans = static_cast(R_GetThingTransTable(R_GetThingFade(oldthing), static_cast(trans))); + //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) { @@ -2931,6 +2940,31 @@ boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist) return true; } +fixed_t R_GetThingFade(mobj_t *thing) +{ + fixed_t fadealpha = FRACUNIT; + + if (!cv_playerfade.value || leveltime < starttime-(3*TICRATE) || !thing->player || thing->player == viewplayer) + return fadealpha; + + const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS; + const INT32 viewplayerdist = (FixedMul((viewplayer->mo->x - viewx), viewcos) + FixedMul((viewplayer->mo->y - viewy), viewsin)) >> FRACBITS; + + if (playerdist < viewplayerdist) + { + if (playerdist < viewplayerdist / 2) // stronger fade when very close + { + fadealpha = (playerdist * FRACUNIT) / (viewplayerdist / 2) / 3; + } + else + { + fadealpha = (playerdist * FRACUNIT) / viewplayerdist; + } + } + + return fadealpha; +} + boolean R_CheckInterpDist(mobj_t *thing) { if (!cv_maxinterpdist.value) diff --git a/src/r_things.h b/src/r_things.h index e7afe7498..156c2d9d3 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -87,9 +87,12 @@ typedef struct void R_DrawMasked(maskcount_t* masks, INT32 nummasks); +transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap); + boolean R_ThingVisible(mobj_t *thing); boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist); boolean R_CheckInterpDist(mobj_t *thing); +fixed_t R_GetThingFade(mobj_t *thing); boolean R_ThingIsFullBright(mobj_t *thing); boolean R_ThingIsSemiBright(mobj_t *thing); From e4e40cf0496ecc80f7643592271900245444bba8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Jul 2025 19:42:28 +0200 Subject: [PATCH 11/19] remove prob pointless check viewplayer will be the currently viewed displayplayer lel --- src/r_bsp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 0e81a4198..b71a6db19 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -196,9 +196,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, mobj_t *pviewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; - UINT8 i = R_GetViewNumber(); - if (viewplayer == &players[displayplayers[i]] && camera[i].chase) + if (camera[R_GetViewNumber()].chase) heightsec = camera->subsector->sector->heightsec; else if (viewmobj) heightsec = pviewmobj->subsector->sector->heightsec; From 3ca42ce42f7a766bba8a2b7b69da41ddea8a3cf5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Jul 2025 21:45:26 +0200 Subject: [PATCH 12/19] register chasecam with the other cam vars why dupe a loop --- src/r_main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index dc6bbe684..fa4425f19 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -402,7 +402,8 @@ angle_t R_PlayerSliptideAngle(player_t *player) sprframe = &sprdef->spriteframes[rot]; // No sprite frame? I guess it is possible - if (!sprframe) return 0; + if (!sprframe) + return 0; if (sprframe->rotate != SRF_SINGLE || (mo->frame & FF_PAPERSPRITE)) ang = R_PointToAngle(mo->x, mo->y) - mo->angle; @@ -462,6 +463,7 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe return false; cullplane = cullheight->frontsector->floorheight; + if (cullheight->flags & ML_NOCLIMB) // Group culling { if (!viewcullheight) @@ -1194,7 +1196,7 @@ void R_SkyboxFrame(int s) { player_t *player = &players[displayplayers[s]]; camera_t *thiscam = &camera[s]; - subsector_t * subsector = NULL; + subsector_t *subsector = NULL; mapheader_t *mh = mapheaderinfo[gamemap-1]; R_SetViewContext(static_cast(VIEWCONTEXT_SKY1 + s)); @@ -1549,11 +1551,6 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_fovchange); CV_RegisterVar(&cv_fov); - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - CV_RegisterVar(&cv_chasecam[i]); - } - CV_RegisterVar(&cv_shadow); CV_RegisterVar(&cv_shadowoffs); CV_RegisterVar(&cv_skybox); @@ -1563,6 +1560,8 @@ void R_RegisterEngineStuff(void) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { + CV_RegisterVar(&cv_chasecam[i]); + CV_RegisterVar(&cv_cam_dist[i]); CV_RegisterVar(&cv_cam_still[i]); CV_RegisterVar(&cv_cam_height[i]); From 7d6e2106256c8306c5b0b07ae78749c5149349e2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Jul 2025 23:11:43 +0200 Subject: [PATCH 13/19] use c++ template for HWR_DrawSprites works just as well without code dupe --- src/hardware/hw_main.cpp | 83 +++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 2b14a2250..809d4aeae 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4454,6 +4454,15 @@ static void HWR_RenderDrawNodes(void) // -------------------------------------------------------------------------- // Draw all vissprites // -------------------------------------------------------------------------- +namespace +{ + enum class DrawSpritesType + { + kSprites, + kModels, + }; + +template static void HWR_DrawSprites(void) { UINT32 i; @@ -4468,56 +4477,44 @@ static void HWR_DrawSprites(void) continue; } - HWR_DrawSprite(spr); - } -} - -static void HWR_DrawModels(void) -{ - UINT32 i; - - for (i = 0; i < gl_visspritecount; i++) - { - gl_vissprite_t *spr = gl_vsprorder[i]; - - if (spr->precip) + if constexpr (Type == DrawSpritesType::kModels) { - HWR_DrawPrecipitationSprite(spr); - continue; - } - - if (!spr->mobj) - continue; - - if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - { - md2_t *md2; - - if (spr->mobj->localskin) + if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { - if (spr->mobj->skinlocal) - md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins]; + md2_t *md2; + + if (spr->mobj->localskin) + { + if (spr->mobj->skinlocal) + md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins]; + else + md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins]; + } else - md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins]; + md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins]; + + // 8/1/19: Only don't display player models if no default SPR_PLAY is found. + if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) + HWR_DrawSprite(spr); + else + HWR_DrawMD2(spr); } else - md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins]; - - // 8/1/19: Only don't display player models if no default SPR_PLAY is found. - if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) - HWR_DrawSprite(spr); - else - HWR_DrawMD2(spr); + { + if (md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) + HWR_DrawSprite(spr); + else + HWR_DrawMD2(spr); + } } - else + + if constexpr (Type == DrawSpritesType::kSprites) { - if (md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) - HWR_DrawSprite(spr); - else - HWR_DrawMD2(spr); + HWR_DrawSprite(spr); } } } +} // -------------------------------------------------------------------------- // HWR_AddSprites @@ -5567,10 +5564,10 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_ HWR_SortVisSprites(); PS_STOP_TIMING(ps_hw_spritesorttime); PS_START_TIMING(ps_hw_spritedrawtime); - if (LIKELY(!cv_glmdls.value)) - HWR_DrawSprites(); + if (UNLIKELY(cv_glmdls.value)) + HWR_DrawSprites(); else - HWR_DrawModels(); + HWR_DrawSprites(); PS_STOP_TIMING(ps_hw_spritedrawtime); ps_numdrawnodes.value.i = 0; From 2e4fb32dac437490375569ad77c7035948dfbe89 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Jul 2025 13:55:16 +0200 Subject: [PATCH 14/19] dont apply player camfade when exiting or in freecam mode also renames it and moves the check outside --- src/hardware/hw_main.cpp | 6 ++++-- src/hardware/hw_md2.c | 3 ++- src/r_things.cpp | 8 +++++--- src/r_things.h | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 809d4aeae..196a67194 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3732,7 +3732,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - Surf.PolyColor.s.alpha = FixedMul(R_GetThingFade(spr->mobj), Surf.PolyColor.s.alpha); + if (cv_playerfade.value && spr->mobj->player) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); if (HWR_UseShader()) { @@ -4020,7 +4021,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - Surf.PolyColor.s.alpha = FixedMul(R_GetThingFade(spr->mobj), Surf.PolyColor.s.alpha); + if (cv_playerfade.value && spr->mobj->player) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); if (HWR_UseShader()) { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 50a58e607..e39c0e6b8 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1227,7 +1227,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr) Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } - Surf.PolyColor.s.alpha = FixedMul(R_GetThingFade(spr->mobj), Surf.PolyColor.s.alpha); + if (cv_playerfade.value && spr->mobj->player) + 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/r_things.cpp b/src/r_things.cpp index 58d9746b5..9c8b1036c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1603,7 +1603,8 @@ static void R_ProjectSprite(mobj_t *thing) else trans = 0; - trans = static_cast(R_GetThingTransTable(R_GetThingFade(oldthing), static_cast(trans))); + if (cv_playerfade.value && oldthing->player) + trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(oldthing), static_cast(trans))); //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) @@ -2940,11 +2941,12 @@ boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist) return true; } -fixed_t R_GetThingFade(mobj_t *thing) +fixed_t R_DoPlayerFade(mobj_t *thing) { fixed_t fadealpha = FRACUNIT; + static constexpr tic_t countdownstarttime = (15 * TICRATE) / 4; // starttime - (3*TICRATE) - if (!cv_playerfade.value || leveltime < starttime-(3*TICRATE) || !thing->player || thing->player == viewplayer) + if (thing->player == viewplayer || viewplayer->exiting || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime) return fadealpha; const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS; diff --git a/src/r_things.h b/src/r_things.h index 156c2d9d3..5eb383e93 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -92,7 +92,7 @@ transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap); boolean R_ThingVisible(mobj_t *thing); boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist); boolean R_CheckInterpDist(mobj_t *thing); -fixed_t R_GetThingFade(mobj_t *thing); +fixed_t R_DoPlayerFade(mobj_t *thing); boolean R_ThingIsFullBright(mobj_t *thing); boolean R_ThingIsSemiBright(mobj_t *thing); From ddd192fad0cc85ae27e179a42c1fd13365e42978 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Jul 2025 13:56:44 +0200 Subject: [PATCH 15/19] declare all the kart "time" stuff as const as far as i can see those never get overwritten and cant be overwritten --- src/doomstat.h | 26 +++++++++++++------------- src/g_game.c | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 171b49edc..5a501f8c3 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -446,19 +446,19 @@ extern UINT16 spacetimetics; extern UINT16 extralifetics; // SRB2kart -extern tic_t introtime; -extern tic_t starttime; -extern tic_t raceexittime; -extern tic_t battleexittime; -extern INT32 hyudorotime; -extern INT32 stealtime; -extern INT32 sneakertime; -extern INT32 itemtime; -extern INT32 comebacktime; -extern INT32 bumptime; -extern INT32 wipeoutslowtime; -extern INT32 wantedreduce; -extern INT32 wantedfrequency; +extern const tic_t introtime; +extern const tic_t starttime; +extern const tic_t raceexittime; +extern const tic_t battleexittime; +extern const INT32 hyudorotime; +extern const INT32 stealtime; +extern const INT32 sneakertime; +extern const INT32 itemtime; +extern const INT32 comebacktime; +extern const INT32 bumptime; +extern const INT32 wipeoutslowtime; +extern const INT32 wantedreduce; +extern const INT32 wantedfrequency; extern UINT8 introtoplay; extern UINT8 creditscutscene; diff --git a/src/g_game.c b/src/g_game.c index bedec3335..201d0e013 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -196,19 +196,19 @@ UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; // SRB2kart -tic_t introtime = 108+5; // plus 5 for white fade -tic_t starttime = 6*TICRATE + (3*TICRATE/4); -tic_t raceexittime = 5*TICRATE + (2*TICRATE/3); -tic_t battleexittime = 8*TICRATE; -INT32 hyudorotime = 7*TICRATE; -INT32 stealtime = TICRATE/2; -INT32 sneakertime = TICRATE + (TICRATE/3); -INT32 itemtime = 8*TICRATE; -INT32 comebacktime = 10*TICRATE; -INT32 bumptime = 6; -INT32 wipeoutslowtime = 20; -INT32 wantedreduce = 5*TICRATE; -INT32 wantedfrequency = 10*TICRATE; +const tic_t introtime = 108+5; // plus 5 for white fade +const tic_t starttime = 6*TICRATE + (3*TICRATE/4); +const tic_t raceexittime = 5*TICRATE + (2*TICRATE/3); +const tic_t battleexittime = 8*TICRATE; +const INT32 hyudorotime = 7*TICRATE; +const INT32 stealtime = TICRATE/2; +const INT32 sneakertime = TICRATE + (TICRATE/3); +const INT32 itemtime = 8*TICRATE; +const INT32 comebacktime = 10*TICRATE; +const INT32 bumptime = 6; +const INT32 wipeoutslowtime = 20; +const INT32 wantedreduce = 5*TICRATE; +const INT32 wantedfrequency = 10*TICRATE; INT32 gameovertics = 15*TICRATE; From 1a6f775cc3a436ac8d4e605b01d7b8caf3305a7a Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 14 Jul 2025 16:05:43 +0200 Subject: [PATCH 16/19] bruh Let's try that again, this time putting the camera in a local... --- src/r_bsp.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index b71a6db19..a05bf70c4 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -196,9 +196,10 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, mobj_t *pviewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; + camera_t *thiscam = &camera[R_GetViewNumber()]; - if (camera[R_GetViewNumber()].chase) - heightsec = camera->subsector->sector->heightsec; + if (thiscam->chase) + heightsec = thiscam->subsector->sector->heightsec; else if (viewmobj) heightsec = pviewmobj->subsector->sector->heightsec; else From aea3b49a5166dc34138cb99885a8bdb8b8a59970 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Jul 2025 13:59:17 +0200 Subject: [PATCH 17/19] :skull: fix menu screentex toggle lel thx neppy! --- src/m_menu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/m_menu.c b/src/m_menu.c index 898ac30f9..fd8f83e84 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1527,6 +1527,7 @@ enum //op_exp_dirlight, op_exp_skybox, op_exp_accuratefps, + op_exp_votescrn, #ifdef HWRENDER op_exp_glscrtx, #ifdef USE_FBO_OGL From 0159b8d0a32e5a067bf3a08a2fc60d5345271a20 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Jul 2025 14:58:14 +0200 Subject: [PATCH 18/19] use the tooltips array in the menu_t struct for tooltips so this was always there lel gets rid of massively duplicated tooltip calls and is generally cleaner --- src/m_menu.c | 185 +++++++++++++++++++++++---------------------------- src/m_menu.h | 45 +++++-------- 2 files changed, 102 insertions(+), 128 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index fd8f83e84..1553cb6ef 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2742,7 +2742,7 @@ menu_t MISC_AddonsDef = 50, 28, 0, NULL, - {NULL} + NULL }; menu_t MISC_ReplayHutDef = @@ -2755,7 +2755,7 @@ menu_t MISC_ReplayHutDef = 30, 80, 0, M_QuitReplayHut, - {NULL} + NULL }; menu_t MISC_ReplayOptionsDef = @@ -2768,7 +2768,7 @@ menu_t MISC_ReplayOptionsDef = 27, 40, 0, NULL, - {NULL} + NULL }; menu_t MISC_ReplayStartDef = @@ -2781,7 +2781,7 @@ menu_t MISC_ReplayStartDef = 30, 90, 0, NULL, - {NULL} + NULL }; menu_t PlaybackMenuDef = { @@ -2794,12 +2794,12 @@ menu_t PlaybackMenuDef = { BASEVIDWIDTH/2 - 88, 2, 0, NULL, - {NULL} + NULL }; menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72); -menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72); -menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72); +menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72); +menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72); #ifdef HAVE_DISCORDRPC menu_t MISC_DiscordRequestsDef = { @@ -2811,16 +2811,16 @@ menu_t MISC_DiscordRequestsDef = { 0, 0, 0, NULL, - {NULL} + NULL }; #endif // Misc Main Menu -menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeSpectateDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeSpectateMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeLevelDef = MAPICONMENUSTYLE(NULL, MISC_ChangeLevelMenu, &MPauseDef); -menu_t MISC_HelpDef = IMAGEDEF(MISC_HelpMenu); +menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40, NULL); +menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40, NULL); +menu_t MISC_ChangeSpectateDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeSpectateMenu, &MPauseDef, 27, 40, NULL); +menu_t MISC_ChangeLevelDef = MAPICONMENUSTYLE(NULL, MISC_ChangeLevelMenu, &MPauseDef); +menu_t MISC_HelpDef = IMAGEDEF(MISC_HelpMenu); // // M_GetGametypeColor @@ -2907,7 +2907,7 @@ menu_t SR_PandoraDef = 60, 40, 0, M_ExitPandorasBox, - {NULL} + NULL }; menu_t SR_MainDef = CENTERMENUSTYLE(NULL, SR_MainMenu, &MainDef, 72); @@ -2923,7 +2923,7 @@ menu_t SR_UnlockChecklistDef = 280, 185, 0, NULL, - {NULL} + NULL }; menu_t SR_MusicTestDef = @@ -2936,7 +2936,7 @@ menu_t SR_MusicTestDef = 60, 150, 0, NULL, - {NULL} + NULL }; menu_t SR_EmblemHintDef = @@ -2949,7 +2949,7 @@ menu_t SR_EmblemHintDef = 60, 150, 0, NULL, - {NULL} + NULL }; // Single Player @@ -2965,7 +2965,7 @@ menu_t SP_LevelStatsDef = 280, 185, 0, NULL, - {NULL} + NULL }; static menu_t SP_TimeAttackDef = @@ -2978,7 +2978,7 @@ static menu_t SP_TimeAttackDef = 34, 40, 0, M_QuitTimeAttackMenu, - {NULL} + NULL }; static menu_t SP_ReplayDef = { @@ -2990,7 +2990,7 @@ static menu_t SP_ReplayDef = 34, 40, 0, NULL, - {NULL} + NULL }; static menu_t SP_GuestReplayDef = { @@ -3002,7 +3002,7 @@ static menu_t SP_GuestReplayDef = 34, 40, 0, NULL, - {NULL} + NULL }; static menu_t SP_GhostDef = { @@ -3014,7 +3014,7 @@ static menu_t SP_GhostDef = 34, 40, 0, NULL, - {NULL} + NULL }; // Multiplayer @@ -3032,7 +3032,7 @@ menu_t MP_MainDef = #else NULL, #endif - {NULL} + NULL }; menu_t MP_OfflineServerDef = MAPICONMENUSTYLE("M_MULTI", MP_OfflineServerMenu, &MP_MainDef); @@ -3050,7 +3050,7 @@ menu_t MP_ConnectDef = 27,24, 0, M_CancelConnect, - {NULL} + NULL }; #endif menu_t MP_PlayerSetupDef = @@ -3063,7 +3063,7 @@ menu_t MP_PlayerSetupDef = 36, 14, 0, M_QuitMultiPlayerMenu, - {NULL} + NULL }; // Options @@ -3077,18 +3077,18 @@ menu_t OP_MainDef = 60, 25, 0, NULL, - {NULL} + NULL }; -menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30); +menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30, OP_ControlsTooltips); //WTF -menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30); -menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); -menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_JoystickSetDef = +menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips); +menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); +menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_JoystickSetDef = { "M_CONTRO", sizeof (OP_JoystickSetMenu)/sizeof (menuitem_t), @@ -3098,7 +3098,7 @@ menu_t OP_JoystickSetDef = 50, 40, 0, NULL, - {NULL} + NULL }; menu_t OP_VideoOptionsDef = @@ -3111,7 +3111,7 @@ menu_t OP_VideoOptionsDef = 30, 15, 0, NULL, - {NULL} + OP_VideoTooltips }; menu_t OP_VideoModeDef = @@ -3124,7 +3124,7 @@ menu_t OP_VideoModeDef = 48, 26, 0, NULL, - {NULL} + NULL }; menu_t OP_ColorOptionsDef = @@ -3137,7 +3137,7 @@ menu_t OP_ColorOptionsDef = 30, 30, 0, NULL, - {NULL} + NULL }; menu_t OP_SoundOptionsDef = @@ -3150,7 +3150,7 @@ menu_t OP_SoundOptionsDef = 30, 20, 0, NULL, - {NULL} + OP_SoundTooltips }; @@ -3164,25 +3164,25 @@ menu_t OP_HUDOptionsDef = 30, 20, 0, NULL, - {NULL} + NULL }; -menu_t OP_CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_CamOptionsMenu, &OP_MainDef, 30, 30); -menu_t OP_Player1CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player1CamOptionsMenu, &OP_CamOptionsDef, 30, 30); -menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu, &OP_CamOptionsDef, 30, 30); -menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30); -menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30); +menu_t OP_CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_CamOptionsMenu, &OP_MainDef, 30, 30, OP_CamOptionsTooltips); +menu_t OP_Player1CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player1CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); +menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); +menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); +menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); -menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30); +menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30, OP_ChatOptionsTooltips); -menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); +menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30, OP_SoundAdvancedTooltips); -menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 17, 30); +menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 17, 30, OP_FocusOptionsTooltips); -menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20); -menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20); +menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20, OP_GameTooltips); +menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20, OP_ServerOptionsTooltips); #ifndef NONET -menu_t OP_AdvServerOptionsDef = DEFAULTSCROLLSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 30); +menu_t OP_AdvServerOptionsDef = DEFAULTSCROLLSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 30, OP_AdvServerOptionsTooltips); #endif //menu_t OP_NetgameOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_NetgameOptionsMenu, &OP_ServerOptionsDef, 30, 30); @@ -3198,38 +3198,38 @@ menu_t OP_MonitorToggleDef = 47, 30, 0, NULL, - {NULL} + NULL }; #ifdef HWRENDER -menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30); +menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30, OP_OpenGLTooltips); #endif -menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25); +menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25, OP_ExpTooltips); -menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); -menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30); -menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30); -menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30, NULL); +menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL); +menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL); +menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30, NULL); #ifdef HAVE_DISCORDRPC -menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30); #endif -menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30, NULL); -menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30); -menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30); -menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30); -menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30); +menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30, OP_SaturnTooltips); +menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0, NULL); // OP_CreditTooltips no space :c -menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0); +menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30, OP_SaturnHudTooltips); +menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30, OP_PlayerDistortTooltips); +menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30, NULL); -menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); +menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30, OP_BirdTooltips); -menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnHudDef, 30, 40); -menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnHudDef, 30, 40); +menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnHudDef, 30, 40, OP_NametagTooltips); +menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnHudDef, 30, 40, OP_DriftGaugeTooltips); -menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60); -menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60); +menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60, OP_TiltTooltips); +menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60, OP_AdvancedBirdTooltips); INT16 ccvarposition = 0; @@ -3246,7 +3246,7 @@ static void M_CustomCvarMenu(INT32 choice) /*menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLMENUSTYLE( MTREE3(MN_OP_MAIN, MN_OP_DATA, MN_OP_ADDONS), "M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 30, 30);*/ -menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLSTYLE("M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 10, 30); +menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLSTYLE("M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 10, 30, NULL); menu_t OP_ForkedBirdDef = { NULL, @@ -3257,10 +3257,10 @@ menu_t OP_ForkedBirdDef = { 30, 6, 0, NULL, - {NULL} + NULL }; -menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60); +menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60, NULL); // ========================================================================== @@ -5200,6 +5200,16 @@ static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT free(clines); } +static void M_DoToolTips(menu_t* menu) +{ + if (!menu->tooltips || itemOn == -1 || !menu->tooltips[itemOn]) + return; + + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, menu->tooltips[itemOn], coolalphatimer); + + if ((coolalphatimer > 0) && interpTimerHackAllow) + coolalphatimer--; +} static void M_DrawGenericMenu(void) { @@ -5346,23 +5356,7 @@ static void M_DrawGenericMenu(void) // dumb hack // tooltips - // replaced with macro so it doesent look as terrible anymore lol - DoToolTips(OP_ControlsDef, OP_ControlsTooltips); - DoToolTips(OP_MouseOptionsDef, OP_MouseTooltips); - DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips); - DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips); - DoToolTips(OP_FocusOptionsDef, OP_FocusOptionsTooltips); - DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); - DoToolTips(OP_GameOptionsDef, OP_GameTooltips); - DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); - //DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: - DoToolTips(OP_BirdDef, OP_BirdTooltips); - DoToolTips(OP_TiltDef, OP_TiltTooltips); - DoToolTips(OP_AdvancedBirdDef, OP_AdvancedBirdTooltips); - DoToolTips(OP_NametagDef, OP_NametagTooltips); - DoToolTips(OP_DriftGaugeDef, OP_DriftGaugeTooltips); - DoToolTips(OP_CamOptionsDef, OP_CamOptionsTooltips); - DoToolTips(OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef, OP_PlayerCamOptionsTooltips); // god this one is still terrible lmao + M_DoToolTips(currentMenu); } static void M_DrawGenericBackgroundMenu(void) @@ -5493,16 +5487,7 @@ static void M_DrawGenericScrollMenu(void) // dumb hack // tooltips - // same macro here - DoToolTips(OP_ExpOptionsDef, OP_ExpTooltips); -#ifdef HWRENDER - DoToolTips(OP_OpenGLOptionsDef, OP_OpenGLTooltips); -#endif - DoToolTips(OP_SaturnDef, OP_SaturnTooltips); - DoToolTips(OP_SaturnHudDef, OP_SaturnHudTooltips); - DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips); - DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); - DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips); + M_DoToolTips(currentMenu); } static void M_DrawPauseMenu(void) diff --git a/src/m_menu.h b/src/m_menu.h index 4cea66d2c..06e0273fe 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -212,14 +212,14 @@ extern menuitem_t PlayerMenu[MAXSKINS]; typedef struct menu_s { const char *menutitlepic; - INT16 numitems; // # of menu items - struct menu_s *prevMenu; // previous menu - menuitem_t *menuitems; // menu items - void (*drawroutine)(void); // draw routine - INT16 x, y; // x, y of menu - INT16 lastOn; // last item user was on in menu - boolean (*quitroutine)(void); // called before quit a menu return true if we can - const char* tooltips[MAXTOOLTIPS]; // tooltips! give me that info bitch + INT16 numitems; // # of menu items + struct menu_s *prevMenu; // previous menu + menuitem_t *menuitems; // menu items + void (*drawroutine)(void); // draw routine + INT16 x, y; // x, y of menu + INT16 lastOn; // last item user was on in menu + boolean (*quitroutine)(void); // called before quit a menu return true if we can + const char* *tooltips; // tooltips! give me that info bitch } menu_t; void M_SetupNextMenu(menu_t *menudef); @@ -335,7 +335,7 @@ void M_PopupMasterServerConnectError(void); void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* name); // These defines make it a little easier to make menus -#define DEFAULTMENUSTYLE(header, source, prev, x, y)\ +#define DEFAULTMENUSTYLE(header, source, prev, x, y, tooltip)\ {\ header,\ sizeof(source)/sizeof(menuitem_t),\ @@ -345,10 +345,10 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - {NULL}\ + tooltip\ } -#define DEFAULTSCROLLSTYLE(header, source, prev, x, y)\ +#define DEFAULTSCROLLSTYLE(header, source, prev, x, y, tooltip)\ {\ header,\ sizeof(source)/sizeof(menuitem_t),\ @@ -358,7 +358,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - {NULL}\ + tooltip\ } @@ -372,7 +372,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define CENTERMENUSTYLE(header, source, prev, y)\ @@ -385,7 +385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na BASEVIDWIDTH/2, y,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define MAPICONMENUSTYLE(header, source, prev)\ @@ -398,7 +398,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 24,40,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define CONTROLMENUSTYLE(source, prev)\ @@ -411,7 +411,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 26, 40,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define IMAGEDEF(source)\ @@ -424,18 +424,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 0, 0,\ 0,\ NULL,\ - {NULL}\ -} - -#define DoToolTips(menu, tooltip)\ -if (currentMenu == &menu)\ -{\ - if (!(tooltip[itemOn] == NULL))\ - {\ - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, tooltip[itemOn], coolalphatimer);\ - if (coolalphatimer > 0 && interpTimerHackAllow)\ - coolalphatimer--;\ - }\ + NULL\ } #ifdef __cplusplus From 0411c40faeff605492c5636e4deee8e26c8c6a18 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 15 Jul 2025 17:04:06 +0200 Subject: [PATCH 19/19] discord rpc my butt --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 1553cb6ef..44626421d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3212,7 +3212,7 @@ menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOpt menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL); menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30, NULL); #ifdef HAVE_DISCORDRPC -menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL); #endif menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30, NULL); @@ -5802,7 +5802,7 @@ menu_t MessageDef = 0, 0, // x, y (TO HACK) 0, // lastOn, flags (TO HACK) NULL, - {0}, + NULL, };