From fe7677c5c87a59079239225f96bbfca16831feb8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 19:56:14 +0200 Subject: [PATCH 01/43] Revert "Do not access memory on misaligned addresses" This reverts commit 112716dae58ee75794948f456241795308ef3c26. --- src/byteptr.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/byteptr.h b/src/byteptr.h index 0b3935e63..9756e7d95 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -11,12 +11,17 @@ /// \brief Macros to read/write from/to a UINT8 *, /// used for packet creation and such +#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__) +#define DEALIGNED +#endif + #include "endian.h" #ifndef SRB2_BIG_ENDIAN // // Little-endian machines // +#ifdef DEALIGNED #define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0) @@ -26,8 +31,20 @@ #define WRITECHAR(p,b) do { char *p_tmp = (void *)p; const char tv = ( char)(b); memcpy(p, &tv, sizeof( char)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEFIXED(p,b) do { fixed_t *p_tmp = (void *)p; const fixed_t tv = (fixed_t)(b); memcpy(p, &tv, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEANGLE(p,b) do { angle_t *p_tmp = (void *)p; const angle_t tv = (angle_t)(b); memcpy(p, &tv, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; } while (0) +#else +#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITECHAR(p,b) do { char *p_tmp = ( char *)p; *p_tmp = ( char)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (fixed_t *)p; *p_tmp = (fixed_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEANGLE(p,b) do { angle_t *p_tmp = (angle_t *)p; *p_tmp = (angle_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#endif #ifdef __GNUC__ +#ifdef DEALIGNED #define READUINT8(p) ({ UINT8 *p_tmp = (void *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READSINT8(p) ({ SINT8 *p_tmp = (void *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READINT16(p) ({ INT16 *p_tmp = (void *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; b; }) @@ -38,6 +55,17 @@ #define READFIXED(p) ({ fixed_t *p_tmp = (void *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; b; }) #define READANGLE(p) ({ angle_t *p_tmp = (void *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; b; }) #else +#define READUINT8(p) ({ UINT8 *p_tmp = ( UINT8 *)p; UINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READSINT8(p) ({ SINT8 *p_tmp = ( SINT8 *)p; SINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT16(p) ({ INT16 *p_tmp = ( INT16 *)p; INT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT16(p) ({ UINT16 *p_tmp = ( UINT16 *)p; UINT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT32(p) ({ INT32 *p_tmp = ( INT32 *)p; INT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT32(p) ({ UINT32 *p_tmp = ( UINT32 *)p; UINT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#endif +#else #define READUINT8(p) *(( UINT8 *)p)++ #define READSINT8(p) *(( SINT8 *)p)++ #define READINT16(p) *(( INT16 *)p)++ @@ -120,6 +148,8 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; }) #endif //SRB2_BIG_ENDIAN +#undef DEALIGNED + #define WRITESTRINGN(p, s, n) ({ \ size_t tmp_i; \ \ From d5388e8dadba16cd81b4f4f1c1440cac29bf0240 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:01:46 +0200 Subject: [PATCH 02/43] fix NOHW compile --- src/p_slopes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 2b52d6153..38201ad86 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -40,7 +40,11 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) if (slope->normal.z == 0) { - slope->lightOffset = slope->hwLightOffset = 0; + + slope->lightOffset = 0; +#ifdef HWRENDER + slope->hwLightOffset = 0; +#endif return; } From 87a2b74a88fbec2933c607c3012c9c11f8a88f33 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:03:35 +0200 Subject: [PATCH 03/43] this should not be in HWRENDER ifdef --- src/m_menu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 53d53254d..e9b8120a3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5337,6 +5337,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } +#endif if (currentMenu == &OP_ExpOptionsDef) { @@ -5347,7 +5348,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } -#endif + if (currentMenu == &OP_SaturnDef) { From 9d359ef8c5d07ad6693c28aec8e79665e68f2658 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 18 Aug 2024 20:46:07 +0200 Subject: [PATCH 04/43] use qsort instead of qs22j for vissprite sorting seems to be actually faster in this case --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8223f7527..5c35dd8f6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4241,7 +4241,7 @@ static void HWR_SortVisSprites(void) gr_vsprorder[i] = HWR_GetVisSprite(i); } - qs22j(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); + qsort(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); } // A drawnode is something that points to a 3D floor, 3D side, or masked From b2129011c2f61c6f4415785454dd163151a90550 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 19 Aug 2024 01:17:13 -0400 Subject: [PATCH 05/43] Fix gamepad menus for green reses via scrolling --- src/m_menu.c | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e9b8120a3..039a88cf1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1214,89 +1214,89 @@ static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_Joystick1Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 100}, }; static menuitem_t OP_Joystick2Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis2 , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis2 , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis2 , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis2 , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis2 , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis2 , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis2 , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis2 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis2 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis2 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis2 , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone2 , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis2 , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis2 , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis2 , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis2 , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis2 , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis2 , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis2 , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis2 , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis2 , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis2 , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis2 , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone2 , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 100}, }; static menuitem_t OP_Joystick3Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis3 , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis3 , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis3 , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis3 , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis3 , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis3 , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis3 , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis3 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis3 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis3 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis3 , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone3 , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis3 , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis3 , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis3 , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis3 , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis3 , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis3 , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis3 , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis3 , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis3 , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis3 , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis3 , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone3 , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 100}, }; static menuitem_t OP_Joystick4Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis4 , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis4 , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis4 , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis4 , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis4 , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis4 , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis4 , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis4 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis4 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis4 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis4 , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone4 , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis4 , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis4 , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis4 , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis4 , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis4 , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis4 , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis4 , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis4 , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis4 , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis4 , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis4 , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone4 , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 100}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -2823,10 +2823,10 @@ menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDe //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 = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 16); -menu_t OP_Joystick2Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 16); -menu_t OP_Joystick3Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 60, 16); -menu_t OP_Joystick4Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 60, 16); +menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 36); +menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 36); +menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 60, 36); +menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 60, 36); menu_t OP_JoystickSetDef = { "M_CONTRO", From 84a1f86037f8628ff3c229fe07f171533e3c54f6 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 19 Aug 2024 01:24:04 -0400 Subject: [PATCH 06/43] Allow the control binds menu to use lower case --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 039a88cf1..677489efc 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12452,7 +12452,7 @@ static void M_DrawControl(void) if (currentMenu->menuitems[i].status == IT_CONTROL) { - V_DrawString(x, y, ((i == itemOn) ? highlightflags : 0), currentMenu->menuitems[i].text); + V_DrawString(x, y, ((i == itemOn) ? highlightflags|V_ALLOWLOWERCASE : V_ALLOWLOWERCASE), currentMenu->menuitems[i].text); keys[0] = setupcontrols[currentMenu->menuitems[i].alphaKey][0]; keys[1] = setupcontrols[currentMenu->menuitems[i].alphaKey][1]; @@ -12473,14 +12473,14 @@ static void M_DrawControl(void) strcat (tmp, G_KeynumToString (keys[1])); } - V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, y, highlightflags, tmp); + V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, y, highlightflags|V_ALLOWLOWERCASE, tmp); } /*else if (currentMenu->menuitems[i].status == IT_GRAYEDOUT2) V_DrawString(x, y, V_TRANSLUCENT, currentMenu->menuitems[i].text);*/ else if ((currentMenu->menuitems[i].status == IT_HEADER) && (i != max-1)) - V_DrawString(19, y+6, highlightflags, currentMenu->menuitems[i].text); + V_DrawString(19, y+6, highlightflags|V_ALLOWLOWERCASE, currentMenu->menuitems[i].text); else if (currentMenu->menuitems[i].status & IT_STRING) - V_DrawString(x, y, ((i == itemOn) ? highlightflags : 0), currentMenu->menuitems[i].text); + V_DrawString(x, y, ((i == itemOn) ? highlightflags|V_ALLOWLOWERCASE : V_ALLOWLOWERCASE), currentMenu->menuitems[i].text); y += SMALLLINEHEIGHT; } From 707448193b453f4751737adbe12de1434d1523c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 11:52:14 +0200 Subject: [PATCH 07/43] Fix some tooltips so they don't go offscreen grr git not crediting neppy for some reason --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 677489efc..2f76c53ef 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1505,7 +1505,7 @@ static const char* OP_ExpTooltips[] = #ifdef HWRENDER "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", #ifdef USE_FBO_OGL - "Allows the game to downsample from a higher resolution than your display in OpenGL renderer mode\nrequires a GPU with atleast OpenGL 3.0 support.", + "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode requires a GPU with atleast OpenGL 3.0 support.", #endif "Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", @@ -1605,7 +1605,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} #else {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70}, @@ -1620,7 +1620,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 145}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 155}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 175} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} #endif }; @@ -2086,7 +2086,7 @@ static const char* OP_SaturnTooltips[] = "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", - "The color to use instead of the player color when colourized hud is enabled.", + "The color to use instead of the player color when\ncolourized hud is enabled.", "Show the big 'LAP' text on a lap change.", "Show player names on the minimap.", "Minimize the player icons on the minimap.", From fcc5c132748a16a65bd67379460814395380cd1b Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:28:46 -0400 Subject: [PATCH 08/43] Fix Compile without with out of date SDL --- src/sdl/i_system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index eabe017c4..66ce038f5 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2670,8 +2670,8 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; - (void)left_strength; - (void)right_strength; + (void)low_strength; + (void)high_strength; #else I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher From cfebe422d3d1fa349c0edd257ff8842649f1ceff Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 12:00:27 +0200 Subject: [PATCH 09/43] Fix typo --- 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 2f76c53ef..b7829fe31 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1505,9 +1505,9 @@ static const char* OP_ExpTooltips[] = #ifdef HWRENDER "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", #ifdef USE_FBO_OGL - "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode requires a GPU with atleast OpenGL 3.0 support.", + "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.", #endif - "Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", + "Change the depth of the Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", #endif }; From 54d897fc33d6a9bc10ad076ccb7e5131e9cac87f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 12:15:47 +0200 Subject: [PATCH 10/43] smol i_video cleanup --- src/sdl/i_video.c | 120 ++++++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 46 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index da055265e..258c34898 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -225,7 +225,7 @@ void RefreshOGLSDLSurface(void) } #endif -static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) +static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool reposition) { static SDL_bool wasfullscreen = SDL_FALSE; Uint32 rmask; @@ -254,16 +254,18 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) } // 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)) - ); + if (reposition) + { + SDL_SetWindowPosition(window, + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) + ); + } } } else { Impl_CreateWindow(fullscreen); - Impl_SetWindowIcon(); wasfullscreen = fullscreen; SDL_SetWindowSize(window, width, height); if (fullscreen) @@ -1942,7 +1944,7 @@ INT32 VID_SetMode(INT32 modeNum) I_DownSample(); #endif - SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); + SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (setmodeneeded ? SDL_TRUE : SDL_FALSE)); Impl_VideoSetupBuffer(); if (rendermode == render_soft) @@ -1962,6 +1964,63 @@ INT32 VID_SetMode(INT32 modeNum) return SDL_TRUE; } + +static SDL_bool Impl_CreateContext(void) +{ + // Renderer-specific stuff +#ifdef HWRENDER + if ((rendermode == render_opengl) + && (vid.glstate != VID_GL_LIBRARY_ERROR)) + { + 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 +#endif + if (rendermode == render_soft) + { + int flags = 0; // Use this to set SDL_RENDERER_* flags now + if (usesdl2soft) + flags |= SDL_RENDERER_SOFTWARE; + else if (cv_vidwait.value) + { +#if SDL_VERSION_ATLEAST(2, 0, 18) + // If SDL is new enough, we can turn off vsync later. + flags |= SDL_RENDERER_PRESENTVSYNC; +#else + // However, if it isn't, we should just silently turn vid_wait off + // This is because the renderer will be created before the config + // is read and vid_wait is set from the user's preferences, and thus + // vid_wait will have no effect. + CV_StealthSetValue(&cv_vidwait, 0); +#endif + } + +#ifdef _WIN32 + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d11"); +#else + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif + + if (!renderer) + renderer = SDL_CreateRenderer(window, -1, flags); + if (renderer == NULL) + { + CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); + return SDL_FALSE; + } + SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); + } + + return SDL_TRUE; +} + static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) { int flags = 0; @@ -2009,45 +2068,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) return SDL_FALSE; } - // Renderer-specific stuff -#ifdef HWRENDER - if ((rendermode == render_opengl) - && (vid.glstate != VID_GL_LIBRARY_ERROR)) - { - 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 -#endif - if (rendermode == render_soft) - { - flags = 0; // Use this to set SDL_RENDERER_* flags now - if (usesdl2soft) - flags |= SDL_RENDERER_SOFTWARE; - else if (cv_vidwait.value) - flags |= SDL_RENDERER_PRESENTVSYNC; - -#ifdef _WIN32 - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d11"); -#else - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); -#endif - - renderer = SDL_CreateRenderer(window, -1, flags); - if (renderer == NULL) - { - CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); - return SDL_FALSE; - } - SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); - } - - return SDL_TRUE; + return Impl_CreateContext(); } /* @@ -2459,6 +2480,13 @@ static void Impl_SetVsync(void) #if SDL_VERSION_ATLEAST(2,0,18) if (renderer) SDL_RenderSetVSync(renderer, cv_vidwait.value); +#endif + } +#ifdef HWRENDER + else if (rendermode == render_opengl && sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) + { + SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); + } #endif } #endif From 5b480be6dcb30df8aefa3f4b8d2faa604fc19b4b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 12:16:32 +0200 Subject: [PATCH 11/43] smol cleanup for downsample stuff --- src/sdl/i_video.c | 29 ++++++++++++++--------------- src/sdl/ogl_sdl.c | 3 --- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 258c34898..bf7c30c7b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -277,6 +277,9 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool #ifdef HWRENDER if (rendermode == render_opengl) { +#ifdef USE_FBO_OGL + I_DownSample(); +#endif OglSdlSurface(vid.width, vid.height); } #endif @@ -751,7 +754,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) #ifdef USE_FBO_OGL void I_DownSample(void) { - if (!cv_grframebuffer.value || !(rendermode == render_opengl) || (!supportFBO)) //no sense to do this crap if we cant benefit from it + if (!cv_grframebuffer.value || !supportFBO) //no sense to do this crap if we cant benefit from it { downsample = false; return; @@ -760,18 +763,19 @@ void I_DownSample(void) int currentDisplayIndex = SDL_GetWindowDisplayIndex(window); SDL_DisplayMode curmode; - if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) == 0) + if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) { - if ((vid.width > curmode.w) || (vid.height > curmode.h)) //check if current resolution is higher than current display resolution - { - downsample = true; - RefreshOGLSDLSurface(); - } - else - downsample = false; // its not so no need to do crap + downsample = false; // couldnt get display info so turn the thing off + return; + } + + if ((vid.width > curmode.w) || (vid.height > curmode.h)) //check if current resolution is higher than current display resolution + { + downsample = true; + RefreshOGLSDLSurface(); } else - downsample = false; // couldnt get display info so turn the thing off + downsample = false; // its not so no need to do crap } #endif @@ -1939,11 +1943,6 @@ INT32 VID_SetMode(INT32 modeNum) } //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); -#ifdef USE_FBO_OGL - if (rendermode == render_opengl) - I_DownSample(); -#endif - SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (setmodeneeded ? SDL_TRUE : SDL_FALSE)); Impl_VideoSetupBuffer(); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 5bb6b7347..e5d0a4441 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -166,9 +166,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) maximumAnisotropy = 1; granisotropicmode_cons_t[1].value = maximumAnisotropy; -#ifdef USE_FBO_OGL - I_DownSample(); -#endif } first_init = true; From 9e8d79f2469f6e52954e4d261b6a84e8032b524e Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 19 Aug 2024 14:14:17 +0300 Subject: [PATCH 12/43] Fix compilation when SDL_VERSION_ATLEAST(2,0,18) is false (if its false then 'else' statement would not be valid) --- src/sdl/i_video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index bf7c30c7b..a467187bc 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2480,9 +2480,8 @@ static void Impl_SetVsync(void) if (renderer) SDL_RenderSetVSync(renderer, cv_vidwait.value); #endif - } #ifdef HWRENDER - else if (rendermode == render_opengl && sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) + if (!renderer && rendermode == render_opengl && sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) { SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); } From af18e2b7d10c78f684cecc45deb21a8d103ff4eb Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 19 Aug 2024 14:14:59 +0300 Subject: [PATCH 13/43] Don't execute exitgame command on dedicated servers --- src/d_netcmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 790bc2850..62072d9ee 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5693,6 +5693,12 @@ void Command_ExitGame_f(void) { INT32 i; + if (dedicated) + { + CONS_Printf("This command cannot be used on dedicated server\n"); + return; + } + D_QuitNetGame(); CL_Reset(); CV_ClearChangedFlags(); From 2259ef3f71f6bb28b9245d8f99a7a2a9c4bcf38e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 14:58:01 +0200 Subject: [PATCH 14/43] Update LUASTUFF idk i suck at explaining lmao but atleast those should be mentioned --- LUASTUFF.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index e72ae4c2a..a8f285692 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -130,8 +130,24 @@ if rawget(_G, "S_StopSoundByNum") ~= nil then ... -- Can use it end ``` - ## addHook("ServerJoin", function()) ServerJoin hook called when client joins server (starting a listen server also calls it for host). Generally it was made to make loading custom config files less hacky, but can be used for anything else too. + +## player.viewrollangle field + +Returns player's current view roll angle for the Screen Tilting feature, useful for HUD elements. + +## G_SetPlayerGamepadIndicatorColor(player, skincolor) + +Set a custom color for Supported Gamepads with RGB LED functionality. +To be used with Displayplayers. +Only takes Skincolors. +Best to be used in a Loop to ensure the color wont get overwritten by the game. + +## G_PlayerDeviceRumble(player, low_strength, high_strength, -optional- duration) + +Add Gamepad Rumble support for things. +To be used with Displayplayers. +Duration is in milliseconds and is optional to set, default value is 84ms. From 4d03fa06e1042e951c3a5e422001796b4b03d5e2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 17:16:48 +0200 Subject: [PATCH 15/43] raise maxpng res --- src/screen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screen.h b/src/screen.h index a6a0eb477..4f3b0b1ff 100644 --- a/src/screen.h +++ b/src/screen.h @@ -45,8 +45,8 @@ #define BASEVIDHEIGHT 200 // resolution of the graphics. // max res for png capture; seperated it so both MAXVID values can be lower for software performance reasons; OpenGL does not care about those anyways -#define MAXPNGWIDTH 3840 -#define MAXPNGHEIGHT 2160 +#define MAXPNGWIDTH 7680 +#define MAXPNGHEIGHT 4320 // global video state typedef struct viddef_s From a38aee7fe31f20e5a81e65c8085a20e1326fc604 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:25:25 -0400 Subject: [PATCH 16/43] Appimage compile pt1 --- AppImage_build.sh | 344 ++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile | 18 +++ 2 files changed, 362 insertions(+) create mode 100755 AppImage_build.sh diff --git a/AppImage_build.sh b/AppImage_build.sh new file mode 100755 index 000000000..31f8086a7 --- /dev/null +++ b/AppImage_build.sh @@ -0,0 +1,344 @@ +#!/bin/bash +set -e # Enable auto-exit for debugging :)) + +# Make Linux AppImage program data +# https://docs.appimage.org/reference/appdir.html + +# PWD: {repo_root}/build +# See deployer.sh for usage + +# Terminal stuff +RESET="$(tput sgr0)" #"\e[0m" # Resets terminal colors + +# Colors for various information types +FAILURE="$(tput setaf 1)" #"\e[91m" +SUCCESS="$(tput setaf 2)" #"\e[92m" +NOTICE="$(tput setaf 3)" #"\e[93m" +VERBOSE="$(tput setaf 4)" #"\e[94m" + +verbosity=0 # By default don't print anything unless it's *ultra* important. +quiet=0 # Also don't print anything if they supplied the quiet argument + +# URL from which to download appimagetool if there isn't one available in your $PATH +# at time of writing only aarch64, armhf, i686, and x86_64 versions are available via this method +# in those cases, and honestly even outside of those cases, it's better to just put a working one in your $PATH yourself.. +url="https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$(uname -m).AppImage" + +# A whitelist of libraries to include into SRB2's AppImage if SRB2 is dynamically linked. +# please don't add a newline at the end of this or i will cry :( +libraryWhitelist=" +libnsl +libSDL2 +libSDL2_mixer +libgme +libopenmpt +libpng +libfluidsynth +libpulse +libmodplug +libvorbisfile +libopusfile +libFLAC +libmad +libmpg123 +libvorbis +libpulsecommon +libsndfile +libsndio +libogg +libvorbisenc +libjson +libreadline +libwrap +libtinfo +libtirpc +libpng16" + +# these kinda look like macros don't they +function print { (( "$quiet" == 0 )) && echo "$@" || :; } # echo if not quiet +function coloredText { printf "$1"; print "${@:2}"; printf "$RESET"; } # use print to inherit quiet +function success { coloredText "$SUCCESS" "$@"; } # use coloredText to inherit quiet +function important { coloredText "$NOTICE" "$@"; } # use coloredText to inherit quiet +function verboseOnly { (( "$verbosity" >= $1 )) && (coloredText "$VERBOSE" "${@:2}") || :; } # use coloredText to inherit quiet + +# Parses an argument with a single dash +function parseSingleDashArg() { + while read -n 1 char; do + if [[ "$char" == '-' || "$char" == '' ]]; then + : + elif [[ "$char" == 'h' ]]; then + helppassed=1 + elif [[ "$char" == 'q' ]]; then + quiet=1 + elif [[ "$char" == 'v' ]]; then + verbosity="$((verbosity + 1))" + elif [[ "$char" == 'd' ]]; then + dry=1 + elif [[ "$char" == 's' ]]; then + small=1 + else + echo "$0: invalid option -- '$1'" + echo "Try '$0 --help' for more information." + return 1 + fi + done <<<"$1" +} + +# Simple help argument checker. +currentarg=1; # Which argument is --help... + +# For $arg in the argument array... +for arg in "$@"; do + # Is it a help argument? + if [[ "$arg" == "--help" ]]; then + helppassed=1; # Help is passed, set $helppassed! + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" # Remove argument from list + elif [[ "$arg" == "--quiet" ]]; then + quiet=1 + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ "$arg" == "--verbose" ]]; then + verbosity="$((verbosity + 1))" # Increase verbosity! + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ "$arg" == "--dry" ]]; then + dry=1; # Show parameters instead of using them. + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ "$arg" == "--small" ]]; then + small=1; # Don't copy assets to save on bandwidth. + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ ! "$arg" == *'--'* && "$arg" == *'-'* ]]; then + parseSingleDashArg "$arg" + + if [[ "$?" == 0 ]]; then + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" # Remove argument from list + fi + elif [[ $arg == *'--'* ]]; then + print "$0: invalid option -- '$1'" + print "Try '$0 --help' for more information." + return 1 + else + currentarg="$((currentarg+1))" # Increment current argument number otherwise... + fi +done + +important "SRB2 AppImage Packager v1.0, by mazmazz and Golden." + +# Get root directory from the full path of this script. +__ROOT_DIR="$3" + +if [[ -z "$3" ]]; then + # finds out where this script is and goes to that directory and goes up one for the root + + scriptdir="$(dirname "${BASH_SOURCE[0]}")" + scriptbase="$(basename "${BASH_SOURCE[0]}")" + + __ROOT_DIR="$(cd "$scriptdir" && pwd -P)" +fi + +# If it starts with '.', put the current working directory behind it so things work. +if [[ "$__ROOT_DIR" == '.' || "$__ROOT_DIR" == '..' ]]; then + __ROOT_DIR="$PWD/$__ROOT_DIR" +fi + +# Set up defaults +__PROGRAM_NAME="${PROGRAM_NAME:-"SRB2Kart Neptune"}" +__PROGRAM_DESCRIPTION="${PROGRAM_DESCRIPTION:-"Modded version of SRB2kart with more features."}" +__PROGRAM_FILENAME="${PROGRAM_FILENAME:-"srb2kart-neptune"}" +__PROGRAM_ASSETS="${PROGRAM_ASSETS:-"$__ROOT_DIR/assets/installer"}" + +__BUILD_DIR="${1:-"$__ROOT_DIR/bin"}" +__OUTPUT_FILENAME="${2:-"$__PROGRAM_FILENAME.AppImage"}" + +__APPIMAGETOOL="${4:-"appimagetool"}" + +if (! command -v "$__APPIMAGETOOL" &> /dev/null); then + __APPIMAGETOOL= +fi + +# Stuff that prints and exits. + +# Prints setup text using method given by arguments. +# Example: printSetup "print" # print "Setup for AppImage... +function printSetup { + $@ "Setup for AppImage in BUILD_DIR: '$__BUILD_DIR'..." + $@ "With the OUTPUT_FILENAME: '$__OUTPUT_FILENAME'" + $@ "And SRB2 Repository Root ROOT_DIR: '$__ROOT_DIR'" + $@ "Using APPIMAGETOOL: '$([ -z "$__APPIMAGETOOL" ] && echo '(download)' || echo $__APPIMAGETOOL)'" + $@ "" + $@ "This should be run from a Makefile or from the directory of the build. If it is not, then change to that directory or specify that directory as an argument." + $@ "If ROOT_DIR isn't SRB2's repository root, specify that as an argument too." + $@ "Make must have built the program before you run this script." + $@ "" + $@ "Make sure these Environment Variables are correct." + $@ "If not, then enter: export PROGRAM_VARIABLE=value" + $@ "PROGRAM_NAME: $__PROGRAM_NAME" + $@ "PROGRAM_DESCRIPTION: $__PROGRAM_DESCRIPTION" + $@ "PROGRAM_FILENAME: $__PROGRAM_FILENAME" + $@ "PROGRAM_ASSETS: $__PROGRAM_ASSETS" +} + +if [[ "$helppassed" ]]; then + print "Usage: $(basename "$0") [OPTION]... [BUILD_DIR] [OUTPUT_NAME] [ROOT_DIR] [APPIMAGETOOL]" + print "Packages a SRB2 binary into an AppImage." + print "OPTIONs may be included anywhere within the arguments." + print "" + print "Arguments:" + print " -h, --help display this help and exit." + print " -q, --quiet don't display any text." + print " -v, --verbose make commands more verbose, will always print." + print " -s, --small don't copy SRB2 assets to save on bandwidth." + print " parameters regardless of --dry." + print " -d, --dry print parameters and exit." + print "" + if (( "$verbosity" > 0 )) || [[ "$dry" ]]; then + printSetup "print" + else + print "This should be run from a Makefile or from the directory of the build." + print "Make must have built the program before you run this script." + fi + exit; +fi + +if (( "$verbosity" > 0 )) || [[ "$dry" ]]; then + printSetup "verboseOnly" "0" + verboseOnly 0 "" + + if [[ "$dry" ]]; then + set -n # Enable debug mode and verbose for dry run. + fi +fi + +# End stuff that prints and exits. + +if (( "$verbosity" >= 4 )); then + set -v # Really verbose? Print *everything*! +fi + +# Define AppDir structure +mkdir -p "$__BUILD_DIR/AppDir/usr/bin" +mkdir -p "$__BUILD_DIR/AppDir/lib" +mkdir -p "$__BUILD_DIR/AppDir/usr/share/applications" +mkdir -p "$__BUILD_DIR/AppDir/usr/share/icons/hicolor/256x256/apps" + +# Copy program data +if [[ ! $small ]]; then + verboseOnly 1 "Packaging program assets..." + cp -r "$__PROGRAM_ASSETS"/* "$__BUILD_DIR/AppDir/usr/bin/" + cp -r "$__BUILD_DIR/$__PROGRAM_FILENAME" "$__BUILD_DIR/AppDir/usr/bin" +else + verboseOnly 1 "Skipping program asset packing, --small or -s passed..." +fi + +verboseOnly 1 "Packaging SRB2..." +verboseOnly 1 "Assuming executable name $__PROGRAM_FILENAME" +cp -r "$__BUILD_DIR/$__PROGRAM_FILENAME" "$__BUILD_DIR/AppDir/usr/bin" + +# Copy required dependencies, but only if the program is dynamically linked. +verboseOnly 1 "Testing if this build is dynamically linked..." + +set +e # Disable auto-exit for ldd. + +srb2Libraries="$(ldd "$__BUILD_DIR/$__PROGRAM_FILENAME")" +exitcode="$?" + +set -e # Enable it again! + +if (( $exitcode == 0 )); then + verboseOnly 1 "This build *is* dynamically linked! Packaging dependencies." + + # read the dynamic libraries of srb2, trim off beginning whitespace, and get the third field seperated by spaces + # this gives us a newline-seperated list of libraries with their full paths. + srb2Libraries="$(echo "$srb2Libraries" | cut -f 2 | cut -d ' ' -f 3)" + + # remove any extraneous newlines around the string + libraryWhitelist="$(echo $libraryWhitelist | head -c -1 | tr ' ' '\n')" + + # replace e.g. 'abc' with '(/abc\b)', and replace newlines with '|'. + # this converts it into a grep regular expression to check for any whitelisted library names. + libraryWhitelist="$(printf "%s" "$libraryWhitelist" | sed 's|.*|(/\0\\b)|' | tr '\n' '|')" + + # grab only the entries that match the regex + __LDD_LIST="$(printf "%s" "$srb2Libraries" | grep -E "$libraryWhitelist")" + + # use echo to convert the newline-seperated list into an argument list + __LDD_LIST="$(echo $__LDD_LIST)" + + # read into an array because i can't be bothered iterating the lines of a string today + # there's so many other things in this file that'd need to be adjusted to be POSIX-compliant anyway + IFS=' ' read -r -a paths <<< "$__LDD_LIST" + + for path in "${paths[@]}"; do + if [ -f "$path" ]; then + verboseOnly 2 "Packaging dependency $(basename "$path")..." + cp "$path" $__BUILD_DIR/AppDir/lib/ + else + verboseOnly 2 "Dependency $(basename "$path") not found" + fi + done +else + verboseOnly 1 "This SRB2 build is statically linked, skipping dependency packing." +fi + +cd "$__BUILD_DIR/AppDir" + +# Copy icons +verboseOnly 1 "Packaging resources..." +cp "$__ROOT_DIR/srb2.png" "./usr/share/icons/hicolor/256x256/apps/$__PROGRAM_FILENAME.png" +ln -sf "./usr/share/icons/hicolor/256x256/apps/$__PROGRAM_FILENAME.png" "./.DirIcon" +ln -sf "./usr/share/icons/hicolor/256x256/apps/$__PROGRAM_FILENAME.png" "./$__PROGRAM_FILENAME.png" + +# Make desktop descriptor +cat > "./usr/share/applications/$__PROGRAM_FILENAME.desktop" < ./AppRun +echo -e 'HERE="$(dirname "$(readlink -f "${0}")")"' >> ./AppRun +echo -e 'SRB2WADDIR=$HERE/usr/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HERE/lib exec $HERE/usr/bin/'"$__PROGRAM_FILENAME"' "$@"' >> ./AppRun +chmod +x ./AppRun + +cd .. # now in $__BUILD_DIR + +# Package AppImage +if [ -z "$__APPIMAGETOOL" ]; then + verboseOnly 1 "No valid appimagetool path given or detected, downloading appimagetool..." + + # Print notice for internet connection. + important "If the command hangs here, check your internet connection, or download appimagetool and add it to your \$PATH and try compiling again." + + (( "$verbosity" >= 3 )) && wget "$url" || wget -q "$url" + + APPIMAGETOOL="./$(basename "$url")" + chmod a+x "$APPIMAGETOOL" +else + verboseOnly 1 "appimagetool path given or detected, no download required." + APPIMAGETOOL="$__APPIMAGETOOL" +fi + +verboseOnly 1 "Packing AppImage $__OUTPUT_FILENAME" + +if (( verbosity >= 3 )); then + "$APPIMAGETOOL" ./AppDir "$__OUTPUT_FILENAME" +elif (( verbosity >= 2 )); then + "$APPIMAGETOOL" ./AppDir "$__OUTPUT_FILENAME" >/dev/null +else + "$APPIMAGETOOL" ./AppDir "$__OUTPUT_FILENAME" >/dev/null 2>&1 +fi + +success "AppImage ready!" +verboseOnly 1 "Cleaning up files..." +rm -r ./AppDir + +if [ -z "$__APPIMAGETOOL" ]; then + rm "$APPIMAGETOOL" +fi + +cd "$__ROOT_DIR" # snap back to reality diff --git a/src/Makefile b/src/Makefile index 78dfdd4f7..f1d879ce2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -157,6 +157,12 @@ NONX86=1 # LINUX64 does not imply X86_64=1; could mean ARM64 or Itanium endif +ifdef APPIMAGE +appimage:=$(EXENAME).AppImage +else +appimage:= +endif + ifdef MINGW64 MINGW=1 NONX86=1 @@ -633,6 +639,18 @@ ifndef NOUPX -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) endif endif + +ifdef APPIMAGE +$(appimage) : $(EXENAME) + @echo Building AppImage... +ifdef APPIMAGE_NOASSETS + $(.)../AppImage_build.sh --small $(BIN) $(EXENAME).AppImage .. appimagetool +else + $(.)../AppImage_build.sh $(BIN) $(EXENAME).AppImage .. appimagetool +endif + @echo AppImage build complete!, please look for $(EXENAME).AppImage in $(BIN) +endif + @echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\) reobjdump: From fffa7e44c51944cf24547a4dd132275b5ed76bf8 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:55:27 -0400 Subject: [PATCH 17/43] Appimage compile pt2 --- AppImage_build.sh | 3 ++- src/Makefile | 13 +++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/AppImage_build.sh b/AppImage_build.sh index 31f8086a7..ed668708c 100755 --- a/AppImage_build.sh +++ b/AppImage_build.sh @@ -120,7 +120,8 @@ for arg in "$@"; do fi done -important "SRB2 AppImage Packager v1.0, by mazmazz and Golden." +important "SRB2Kart AppImage Packager v1.0 modified for kart by NepDisk." +important "Orignal for SRB2 my mazmazz and Golden." # Get root directory from the full path of this script. __ROOT_DIR="$3" diff --git a/src/Makefile b/src/Makefile index f1d879ce2..72f82265b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -157,12 +157,6 @@ NONX86=1 # LINUX64 does not imply X86_64=1; could mean ARM64 or Itanium endif -ifdef APPIMAGE -appimage:=$(EXENAME).AppImage -else -appimage:= -endif - ifdef MINGW64 MINGW=1 NONX86=1 @@ -641,14 +635,13 @@ endif endif ifdef APPIMAGE -$(appimage) : $(EXENAME) @echo Building AppImage... ifdef APPIMAGE_NOASSETS - $(.)../AppImage_build.sh --small $(BIN) $(EXENAME).AppImage .. appimagetool + $(.)../AppImage_build.sh --small --quiet $(BIN)/ else - $(.)../AppImage_build.sh $(BIN) $(EXENAME).AppImage .. appimagetool + $(.)../AppImage_build.sh -q $(BIN)/ endif - @echo AppImage build complete!, please look for $(EXENAME).AppImage in $(BIN) + @echo AppImage build complete, please look for $(EXENAME).AppImage in $(BIN) endif @echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\) From cded0af06195c7d7055653606353da3552e92945 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 17:38:01 +0200 Subject: [PATCH 18/43] change some stuff for saturn --- AppImage_build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AppImage_build.sh b/AppImage_build.sh index ed668708c..2822d00d3 100755 --- a/AppImage_build.sh +++ b/AppImage_build.sh @@ -27,6 +27,7 @@ url="https://github.com/AppImage/AppImageKit/releases/download/continuous/appima # A whitelist of libraries to include into SRB2's AppImage if SRB2 is dynamically linked. # please don't add a newline at the end of this or i will cry :( libraryWhitelist=" +libbacktrace libnsl libSDL2 libSDL2_mixer @@ -141,9 +142,9 @@ if [[ "$__ROOT_DIR" == '.' || "$__ROOT_DIR" == '..' ]]; then fi # Set up defaults -__PROGRAM_NAME="${PROGRAM_NAME:-"SRB2Kart Neptune"}" +__PROGRAM_NAME="${PROGRAM_NAME:-"SRB2Kart Saturn"}" __PROGRAM_DESCRIPTION="${PROGRAM_DESCRIPTION:-"Modded version of SRB2kart with more features."}" -__PROGRAM_FILENAME="${PROGRAM_FILENAME:-"srb2kart-neptune"}" +__PROGRAM_FILENAME="${PROGRAM_FILENAME:-"lsdl2srb2kart"}" __PROGRAM_ASSETS="${PROGRAM_ASSETS:-"$__ROOT_DIR/assets/installer"}" __BUILD_DIR="${1:-"$__ROOT_DIR/bin"}" From 0f94a26dc65ccae96a9911202b974406b746d3b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 19:36:22 +0200 Subject: [PATCH 19/43] dumbass workaround for issues on xwayland with nvidia this will run automatically when it detects an nvidia gpu even with gr_framebuffer disabled lol we have safeguards everywhere so shouldnt be an issue --- src/hardware/r_opengl/r_opengl.c | 4 ++-- src/i_video.h | 4 ++++ src/sdl/i_video.c | 24 ++++++++++++++++++++++++ src/sdl/ogl_sdl.c | 25 +++++++++++++++++++++++-- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index c3d0daf0d..ef8cc6395 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -775,8 +775,8 @@ static boolean GLFramebuffer_IsFuncAvailible(void) if (majorGL < 3) return false; - return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) && - (isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) && + return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) && + (isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) && (isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions))); return false; diff --git a/src/i_video.h b/src/i_video.h index 708fde03c..6a60f8036 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -140,6 +140,10 @@ UINT32 I_GetRefreshRate(void); boolean I_UseNativeKeyboard(void); #ifdef USE_FBO_OGL +#if defined (__unix__) +extern boolean xwaylandcrap; +#endif + void RefreshOGLSDLSurface(void); void I_DownSample(void); extern boolean downsample; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index a467187bc..9f6080266 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -217,6 +217,10 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); static void Impl_SetWindowIcon(void); #ifdef USE_FBO_OGL +#if defined (__unix__) +static void I_FixXwaylandNvidia(void); +boolean xwaylandcrap = false; +#endif boolean downsample = false; void RefreshOGLSDLSurface(void) { @@ -278,6 +282,9 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool if (rendermode == render_opengl) { #ifdef USE_FBO_OGL +#if defined (__unix__) + I_FixXwaylandNvidia(); +#endif I_DownSample(); #endif OglSdlSurface(vid.width, vid.height); @@ -777,6 +784,23 @@ void I_DownSample(void) else downsample = false; // its not so no need to do crap } + +#if defined (__unix__) +static void I_FixXwaylandNvidia(void) //dumbass crap, fix ur shit nvidia +{ + if (!supportFBO) + { + xwaylandcrap = false; + return; + } + + // enable fbo resize shit, update the ogl surface and turn crap back off lol + xwaylandcrap = true; + RefreshOGLSDLSurface(); + xwaylandcrap = false; + RefreshOGLSDLSurface(); +} +#endif #endif static void Impl_HandleWindowEvent(SDL_WindowEvent evt) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index e5d0a4441..2a6b80e95 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -68,6 +68,12 @@ PFNglGetIntegerv pglGetIntegerv; PFNglGetString pglGetString; #endif +#if defined (__unix__) +#ifdef USE_FBO_OGL +static boolean isnvidiagpu = false; +#endif +#endif + /** \brief SDL video display surface */ INT32 oglflags = 0; @@ -166,6 +172,13 @@ boolean OglSdlSurface(INT32 w, INT32 h) maximumAnisotropy = 1; granisotropicmode_cons_t[1].value = maximumAnisotropy; + +#if defined (__unix__) +#ifdef USE_FBO_OGL + if (strstr((const char*)gl_renderer, "NVIDIA")) + isnvidiagpu = true; +#endif +#endif } first_init = true; @@ -191,7 +204,11 @@ boolean OglSdlSurface(INT32 w, INT32 h) RenderToFramebuffer = FrameBufferEnabled; GLFramebuffer_Disable(); - if (RenderToFramebuffer && downsample) + if ((RenderToFramebuffer && downsample) +#if defined (__unix__) + || (isnvidiagpu && xwaylandcrap) +#endif + ) GLFramebuffer_Enable(); #endif @@ -229,7 +246,11 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_DrawScreenFinalTexture(sdlw, sdlh); #ifdef USE_FBO_OGL - if (RenderToFramebuffer && downsample) + if ((RenderToFramebuffer && downsample) +#if defined (__unix__) + || (isnvidiagpu && xwaylandcrap) +#endif + ) GLFramebuffer_Enable(); #endif From f0d91a970826a72c328bd591ff73d0e6363f737a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 21:48:56 +0200 Subject: [PATCH 20/43] do not constantly query ogl extensions --- src/hardware/r_opengl/r_opengl.c | 28 +++++++++++----------------- src/hardware/r_opengl/r_opengl.h | 1 + src/sdl/ogl_sdl.c | 2 ++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ef8cc6395..cca1b12b8 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -120,8 +120,6 @@ GLfloat projMatrix[16]; static GLint viewport[4]; #ifdef USE_FBO_OGL -static boolean GLFramebuffer_IsFuncAvailible(void); - GLuint FramebufferObject, FramebufferTexture, RenderbufferObject; GLboolean FrameBufferEnabled = GL_FALSE, RenderToFramebuffer = GL_FALSE; @@ -752,7 +750,7 @@ void SetupGLFunc4(void) pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); #ifdef USE_FBO_OGL - if (GLFramebuffer_IsFuncAvailible()) + if (supportFBO) { pglGenFramebuffers = GetGLFunc("glGenFramebuffers"); pglBindFramebuffer = GetGLFunc("glBindFramebuffer"); @@ -769,17 +767,14 @@ void SetupGLFunc4(void) } #ifdef USE_FBO_OGL -static boolean GLFramebuffer_IsFuncAvailible(void) +void GLFramebuffer_IsFuncAvailible(void) { //this stuff needs atleast OGL 3.0 if (majorGL < 3) - return false; + supportFBO = false; - return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) && - (isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) && - (isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions))); - - return false; + if (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)) + supportFBO = true; } #endif @@ -1045,7 +1040,7 @@ EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo) #ifdef USE_FBO_OGL void GLFramebuffer_Generate(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Generate the framebuffer @@ -1058,7 +1053,7 @@ void GLFramebuffer_Generate(void) void GLFramebuffer_Delete(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Unbind the framebuffer @@ -1073,7 +1068,7 @@ void GLFramebuffer_Delete(void) void GLFramebuffer_GenerateAttachments(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Bind the framebuffer @@ -1114,7 +1109,7 @@ void GLFramebuffer_GenerateAttachments(void) void GLFramebuffer_DeleteAttachments(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Unbind the framebuffer @@ -1132,7 +1127,7 @@ void GLFramebuffer_DeleteAttachments(void) void GLFramebuffer_Enable(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; if (FramebufferObject == 0) @@ -1146,7 +1141,7 @@ void GLFramebuffer_Enable(void) void GLFramebuffer_Disable(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; pglBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -2343,7 +2338,6 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) #ifdef USE_FBO_OGL case HWD_SET_FRAMEBUFFER: FrameBufferEnabled = Value ? GL_TRUE : GL_FALSE; - supportFBO = GLFramebuffer_IsFuncAvailible(); if (!supportFBO) { diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 255969d5a..29759b0a9 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -105,6 +105,7 @@ static PFNglEnableClientState pglEnableClientState; #endif #ifdef USE_FBO_OGL +void GLFramebuffer_IsFuncAvailible(void); void GLFramebuffer_Generate(void); void GLFramebuffer_Delete(void); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 2a6b80e95..a4d401248 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -157,6 +157,8 @@ boolean OglSdlSurface(INT32 w, INT32 h) "- GPU drivers are missing or broken. You may need to update your drivers."); } + GLFramebuffer_IsFuncAvailible(); + SetupGLInfo(); SetupGLFunc4(); From cf5c0ca5f7b79dfc24ae61dbe72b5c427eef5d11 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 21:54:15 +0200 Subject: [PATCH 21/43] forgor return --- src/hardware/r_opengl/r_opengl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index cca1b12b8..3298a04c5 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -771,7 +771,10 @@ void GLFramebuffer_IsFuncAvailible(void) { //this stuff needs atleast OGL 3.0 if (majorGL < 3) + { supportFBO = false; + return; + } if (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)) supportFBO = true; From 31c64b63de65fbfe1d9202d6ae22561ba42889c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 03:57:43 +0200 Subject: [PATCH 22/43] make this more robust ig --- src/hardware/r_opengl/r_opengl.c | 21 +++++++++++---------- src/hardware/r_opengl/r_opengl.h | 1 - src/sdl/ogl_sdl.c | 8 +++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3298a04c5..573a52c24 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -705,6 +705,7 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; +static boolean GLFramebuffer_IsFuncAvailible(void); void SetupGLFunc4(void) { @@ -750,7 +751,7 @@ void SetupGLFunc4(void) pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); #ifdef USE_FBO_OGL - if (supportFBO) + if (GLFramebuffer_IsFuncAvailible()) { pglGenFramebuffers = GetGLFunc("glGenFramebuffers"); pglBindFramebuffer = GetGLFunc("glBindFramebuffer"); @@ -762,22 +763,22 @@ void SetupGLFunc4(void) pglDeleteRenderbuffers = GetGLFunc("glDeleteRenderbuffers"); pglRenderbufferStorage = GetGLFunc("glRenderbufferStorage"); pglFramebufferRenderbuffer = GetGLFunc("glFramebufferRenderbuffer"); + + supportFBO = true; } #endif } #ifdef USE_FBO_OGL -void GLFramebuffer_IsFuncAvailible(void) +static boolean GLFramebuffer_IsFuncAvailible(void) { //this stuff needs atleast OGL 3.0 if (majorGL < 3) - { - supportFBO = false; - return; - } + return false; - if (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)) - supportFBO = true; + return (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)); + + return false; } #endif @@ -1128,7 +1129,7 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } -void GLFramebuffer_Enable(void) +inline void GLFramebuffer_Enable(void) { if (!supportFBO) return; @@ -1142,7 +1143,7 @@ void GLFramebuffer_Enable(void) pglBindRenderbuffer(GL_RENDERBUFFER, RenderbufferObject); } -void GLFramebuffer_Disable(void) +inline void GLFramebuffer_Disable(void) { if (!supportFBO) return; diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 29759b0a9..255969d5a 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -105,7 +105,6 @@ static PFNglEnableClientState pglEnableClientState; #endif #ifdef USE_FBO_OGL -void GLFramebuffer_IsFuncAvailible(void); void GLFramebuffer_Generate(void); void GLFramebuffer_Delete(void); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index a4d401248..13751da83 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -157,8 +157,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) "- GPU drivers are missing or broken. You may need to update your drivers."); } - GLFramebuffer_IsFuncAvailible(); - SetupGLInfo(); SetupGLFunc4(); @@ -203,10 +201,10 @@ boolean OglSdlSurface(INT32 w, INT32 h) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); #ifdef USE_FBO_OGL - RenderToFramebuffer = FrameBufferEnabled; + RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); GLFramebuffer_Disable(); - if ((RenderToFramebuffer && downsample) + if (RenderToFramebuffer #if defined (__unix__) || (isnvidiagpu && xwaylandcrap) #endif @@ -242,7 +240,7 @@ void OglSdlFinishUpdate(boolean waitvbl) #ifdef USE_FBO_OGL GLFramebuffer_Disable(); - RenderToFramebuffer = FrameBufferEnabled; + RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); #endif HWR_DrawScreenFinalTexture(sdlw, sdlh); From 9f8eb074420ac6c5fdd562f4f7458dfc886aa445 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 20:39:26 +0200 Subject: [PATCH 23/43] revert this in y_inter --- src/y_inter.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 8527ff799..ac05c6360 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -728,17 +728,11 @@ void Y_Ticker(void) return; } - if (intertic < TICRATE || endtic != -1) + if (intertic < TICRATE || intertic & 1 || endtic != -1) { return; } - if (data.match.rankingsmode && intertic & 1) - { - memset(data.match.jitter, 0, sizeof (data.match.jitter)); - return; - } - if (intertype == int_race || intertype == int_match) { if (netgame || multiplayer) From 3d827570e64a14714dabedb887f0a95fe1d965b5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 23:17:26 +0200 Subject: [PATCH 24/43] more changes to FBO stuff now it wont ever do anything when disabled also properly deletes the FBO when disabling it --- src/hardware/r_opengl/r_opengl.c | 19 ++++++++++++++----- src/hardware/r_opengl/r_opengl.h | 2 +- src/sdl/i_video.c | 4 ++++ src/sdl/ogl_sdl.c | 30 +++++++++++++++++------------- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 573a52c24..2f94f83cd 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1055,14 +1055,11 @@ void GLFramebuffer_Generate(void) GLFramebuffer_GenerateAttachments(); } -void GLFramebuffer_Delete(void) +static void GLFramebuffer_Delete(void) { if (!supportFBO) return; - // Unbind the framebuffer - pglBindFramebuffer(GL_FRAMEBUFFER, 0); - if (FramebufferObject) pglDeleteFramebuffers(1, &FramebufferObject); @@ -1118,6 +1115,7 @@ void GLFramebuffer_DeleteAttachments(void) // Unbind the framebuffer pglBindFramebuffer(GL_FRAMEBUFFER, 0); + pglBindRenderbuffer(GL_RENDERBUFFER, 0); if (FramebufferTexture) pglDeleteTextures(1, &FramebufferTexture); @@ -1129,6 +1127,15 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } +inline void GLFramebuffer_Unbind(void) +{ + if (!supportFBO) + return; + + pglBindFramebuffer(GL_FRAMEBUFFER, 0); + pglBindRenderbuffer(GL_RENDERBUFFER, 0); +} + inline void GLFramebuffer_Enable(void) { if (!supportFBO) @@ -1143,13 +1150,15 @@ inline void GLFramebuffer_Enable(void) pglBindRenderbuffer(GL_RENDERBUFFER, RenderbufferObject); } -inline void GLFramebuffer_Disable(void) +void GLFramebuffer_Disable(void) { if (!supportFBO) return; pglBindFramebuffer(GL_FRAMEBUFFER, 0); pglBindRenderbuffer(GL_RENDERBUFFER, 0); + + GLFramebuffer_Delete(); } #endif diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 255969d5a..f916c950d 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -106,11 +106,11 @@ static PFNglEnableClientState pglEnableClientState; #ifdef USE_FBO_OGL void GLFramebuffer_Generate(void); -void GLFramebuffer_Delete(void); void GLFramebuffer_GenerateAttachments(void); void GLFramebuffer_DeleteAttachments(void); +void GLFramebuffer_Unbind(void); void GLFramebuffer_Enable(void); void GLFramebuffer_Disable(void); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 9f6080266..495c96e18 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -773,6 +773,7 @@ void I_DownSample(void) if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) { downsample = false; // couldnt get display info so turn the thing off + RefreshOGLSDLSurface(); return; } @@ -782,7 +783,10 @@ void I_DownSample(void) RefreshOGLSDLSurface(); } else + { downsample = false; // its not so no need to do crap + RefreshOGLSDLSurface(); + } } #if defined (__unix__) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 13751da83..4adc3dae8 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -188,6 +188,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) if (screen_width != w || screen_height != h) { FlushScreenTextures(); + #ifdef USE_FBO_OGL GLFramebuffer_DeleteAttachments(); #endif @@ -201,15 +202,16 @@ boolean OglSdlSurface(INT32 w, INT32 h) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); #ifdef USE_FBO_OGL - RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); - GLFramebuffer_Disable(); - - if (RenderToFramebuffer + RenderToFramebuffer = ((FrameBufferEnabled && supportFBO && downsample) #if defined (__unix__) - || (isnvidiagpu && xwaylandcrap) + || (isnvidiagpu && xwaylandcrap) #endif - ) + ); + + if (RenderToFramebuffer) GLFramebuffer_Enable(); + else + GLFramebuffer_Disable(); #endif HWR_Startup(); @@ -239,18 +241,20 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_MakeScreenFinalTexture(); #ifdef USE_FBO_OGL - GLFramebuffer_Disable(); - RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); + RenderToFramebuffer = ((FrameBufferEnabled && supportFBO && downsample) +#if defined (__unix__) + || (isnvidiagpu && xwaylandcrap) +#endif + ); + + if (RenderToFramebuffer) + GLFramebuffer_Unbind(); #endif HWR_DrawScreenFinalTexture(sdlw, sdlh); #ifdef USE_FBO_OGL - if ((RenderToFramebuffer && downsample) -#if defined (__unix__) - || (isnvidiagpu && xwaylandcrap) -#endif - ) + if (RenderToFramebuffer) GLFramebuffer_Enable(); #endif From 6a14543e9e6008359e63454df6902d7ff8cc63b3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 23:26:11 +0200 Subject: [PATCH 25/43] cleanup FBO on shutdown + make some stuff static --- src/hardware/hw_main.c | 3 ++ src/hardware/r_opengl/r_opengl.c | 52 ++++++++++++++++---------------- src/hardware/r_opengl/r_opengl.h | 3 -- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5c35dd8f6..72c232c1f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -26,6 +26,8 @@ #include "hw_md2.h" #include "hw_clip.h" +#include "r_opengl/r_opengl.h" + #include "../i_video.h" // for rendermode == render_glide #include "../v_video.h" #include "../p_local.h" @@ -5877,6 +5879,7 @@ void HWR_Shutdown(void) HWR_FreeMipmapCache(); HWR_FreeTextureCache(); HWD.pfnFlushScreenTextures(); + GLFramebuffer_Disable(); } void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 2f94f83cd..a5a1fc9f1 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1042,32 +1042,7 @@ EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo) } #ifdef USE_FBO_OGL -void GLFramebuffer_Generate(void) -{ - if (!supportFBO) - return; - - // Generate the framebuffer - if (FramebufferObject == 0) - pglGenFramebuffers(1, &FramebufferObject); - - if (pglCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) - GLFramebuffer_GenerateAttachments(); -} - -static void GLFramebuffer_Delete(void) -{ - if (!supportFBO) - return; - - if (FramebufferObject) - pglDeleteFramebuffers(1, &FramebufferObject); - - GLFramebuffer_DeleteAttachments(); - FramebufferObject = 0; -} - -void GLFramebuffer_GenerateAttachments(void) +static void GLFramebuffer_GenerateAttachments(void) { if (!supportFBO) return; @@ -1127,6 +1102,31 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } +static void GLFramebuffer_Generate(void) +{ + if (!supportFBO) + return; + + // Generate the framebuffer + if (FramebufferObject == 0) + pglGenFramebuffers(1, &FramebufferObject); + + if (pglCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) + GLFramebuffer_GenerateAttachments(); +} + +static void GLFramebuffer_Delete(void) +{ + if (!supportFBO) + return; + + if (FramebufferObject) + pglDeleteFramebuffers(1, &FramebufferObject); + + GLFramebuffer_DeleteAttachments(); + FramebufferObject = 0; +} + inline void GLFramebuffer_Unbind(void) { if (!supportFBO) diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index f916c950d..baab44637 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -105,9 +105,6 @@ static PFNglEnableClientState pglEnableClientState; #endif #ifdef USE_FBO_OGL -void GLFramebuffer_Generate(void); - -void GLFramebuffer_GenerateAttachments(void); void GLFramebuffer_DeleteAttachments(void); void GLFramebuffer_Unbind(void); From af6393af503c8f9b95d235ca75d7fa01d88ab60e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Aug 2024 15:38:40 +0200 Subject: [PATCH 26/43] forgor --- src/hardware/hw_main.c | 2 ++ src/hardware/r_opengl/r_opengl.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 72c232c1f..fb566e0ea 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5879,7 +5879,9 @@ void HWR_Shutdown(void) HWR_FreeMipmapCache(); HWR_FreeTextureCache(); HWD.pfnFlushScreenTextures(); +#ifdef USE_FBO_OGL GLFramebuffer_Disable(); +#endif } void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a5a1fc9f1..96a608df6 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -705,7 +705,9 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; +#ifdef USE_FBO_OGL static boolean GLFramebuffer_IsFuncAvailible(void); +#endif void SetupGLFunc4(void) { From 4a6635f8a83e55b521384950b85d5c99315b8e0d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Aug 2024 14:54:43 +0200 Subject: [PATCH 27/43] Revert "smol interp fixes" This reverts commit 77a2976d05f02dfcc5124c0b27d815deab9f8b1f. --- src/d_clisrv.c | 16 +--------------- src/g_game.c | 43 ++++++++++++++++++------------------------- src/p_spec.c | 9 --------- src/p_tick.c | 1 + src/p_user.c | 1 + src/y_inter.c | 2 -- 6 files changed, 21 insertions(+), 51 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2bc316c64..10d46689a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -49,7 +49,6 @@ #include "s_sound.h" // sfx_syfail #include "m_perfstats.h" #include "d_main.h" -#include "r_fps.h" #ifdef CLIENT_LOADINGSCREEN // cl loading screen @@ -6110,8 +6109,6 @@ boolean TryRunTics(tic_t realtics) if (ticking) { - boolean tickInterp = true; - // run the count * tics while (neededtic > gametic) { @@ -6122,18 +6119,7 @@ boolean TryRunTics(tic_t realtics) if (update_stats) PS_START_TIMING(ps_tictime); - boolean run = (gametic % NEWTICRATERATIO) == 0; - - if (run && tickInterp) - { - // Update old view state BEFORE ticking so resetting - // the old interpolation state from game logic works. - R_UpdateViewInterpolation(); - tickInterp = false; // do not update again in sped-up tics - } - - G_Ticker(run); - + G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; consistancy[gametic%TICQUEUE] = Consistancy(); diff --git a/src/g_game.c b/src/g_game.c index 743fa52d5..c15216a91 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -525,8 +525,6 @@ consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static void G_FixCamera(UINT8 view); - #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" #endif @@ -2085,6 +2083,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) UINT8 viewd; INT32 *displayplayerp; + camera_t *camerap; INT32 olddisplayplayer; INT32 playersviewable; @@ -2123,15 +2122,29 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = playernum; if ((*displayplayerp) != olddisplayplayer) { - G_FixCamera(viewnum); + camerap = &camera[viewnum-1]; + P_ResetCamera(&players[(*displayplayerp)], camerap); + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewnum); } if (viewnum > splits) { for (viewd = splits+1; viewd < viewnum; ++viewd) { - displayplayers[viewd-1] = G_FindView(displayplayers[viewd-1], viewd, onlyactive, playernum < olddisplayplayer); - G_FixCamera(viewd); + displayplayerp = (&displayplayers[viewd-1]); + camerap = &camera[viewd]; + + (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); + + P_ResetCamera(&players[(*displayplayerp)], camerap); + + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewd); } } @@ -2189,26 +2202,6 @@ void G_ResetViews(void) } } -// -// G_FixCamera -// Reset camera position, angle and interpolation on a view -// after changing state. -// -static void G_FixCamera(UINT8 view) -{ - player_t *player = &players[displayplayers[view - 1]]; - - // The order of displayplayers can change, which would - // invalidate localangle. - //localangle[view - 1] = player->cmd.angleturn; - - P_ResetCamera(player, &camera[view - 1]); - - // Make sure the viewport doesn't interpolate at all into - // its new position -- just snap instantly into place. - R_ResetViewInterpolation(view); -} - // // G_Ticker // Make ticcmd_ts for the players. diff --git a/src/p_spec.c b/src/p_spec.c index 69d27270b..82372fc90 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2483,7 +2483,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 422: // Cut away to another view { mobj_t *altview; - INT32 i; if (!mo || !mo->player) // only players have views return; @@ -2498,14 +2497,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&mo->player->awayviewmobj, altview); mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; - for (i = 0; i <= splitscreen; i++) - { - if (displayplayers[i] == (mo->player - players)) - { - R_ResetViewInterpolation(i + 1); - } - } - if (line->flags & ML_NOCLIMB) // lets you specify a vertical angle { INT32 aim; diff --git a/src/p_tick.c b/src/p_tick.c index cc2600f17..cf603af1d 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -645,6 +645,7 @@ void P_Ticker(boolean run) if (run) { R_UpdateLevelInterpolators(); + R_UpdateViewInterpolation(); // Hack: ensure newview is assigned every tic. // Ensures view interpolation is T-1 to T in poor network conditions diff --git a/src/p_user.c b/src/p_user.c index bdb03e86e..63c63b448 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3983,6 +3983,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { P_MoveChaseCamera(player, thiscam, false); R_ResetViewInterpolation(num + 1); + R_ResetViewInterpolation(num + 1); } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); diff --git a/src/y_inter.c b/src/y_inter.c index ac05c6360..5d292f36c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -729,9 +729,7 @@ void Y_Ticker(void) } if (intertic < TICRATE || intertic & 1 || endtic != -1) - { return; - } if (intertype == int_race || intertype == int_match) { From 3b500add73b3d71f1d7928a5269cc2bda1c2f194 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:29:36 +0200 Subject: [PATCH 28/43] cleanup birdmusic crap again music_resync_powerups_only literally didnt do shit lol removed some other unused crap changed some conditions to better check for stuff etc idk i just rather remove this whole thing at this point but oh well --- src/g_game.c | 5 ++--- src/i_sound.h | 1 - src/m_menu.c | 1 - src/p_inter.c | 4 ++-- src/p_spec.c | 4 +++- src/p_user.c | 14 +++++--------- src/s_sound.c | 22 ++++------------------ src/s_sound.h | 9 --------- src/sdl/mixer_sound.c | 21 ++++++--------------- src/sdl/sdl_sound.c | 1 - 10 files changed, 22 insertions(+), 60 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c15216a91..0025782ed 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2705,8 +2705,7 @@ void G_PlayerReborn(INT32 player) } /* I'm putting this here because lol */ - - fade = (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(p)); + fade = (cv_birdmusic.value && cv_fading.value && P_IsLocalPlayer(p)); if (fade) { @@ -2716,7 +2715,7 @@ void G_PlayerReborn(INT32 player) Fade it in with the same call to avoid max volume for a few milliseconds (?). */ - if (! playing) + if (!playing) S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); } diff --git a/src/i_sound.h b/src/i_sound.h index d0542cfb5..925be7596 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -159,7 +159,6 @@ boolean I_SetSongPosition(UINT32 position); UINT32 I_GetSongPosition(void); void I_UpdateSongLagThreshold (void); -void I_UpdateSongLagConditions (void); /// ------------------------ // MUSIC PLAYBACK diff --git a/src/m_menu.c b/src/m_menu.c index b7829fe31..5dee26366 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2437,7 +2437,6 @@ static menuitem_t OP_AdvancedBirdMenu[] = {IT_STRING | IT_CVAR, NULL, "Fade Back In While Respawning", &cv_respawnfademusicback, 40}, {IT_STRING | IT_CVAR, NULL, "Resync Threshold", &cv_music_resync_threshold, 60}, - {IT_STRING | IT_CVAR, NULL, "Resync Special Music Only", &cv_music_resync_powerups_only, 70}, }; static const char* OP_AdvancedBirdTooltips[] = diff --git a/src/p_inter.c b/src/p_inter.c index d22f99112..5ffaf6dba 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1737,7 +1737,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; - if (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(target->player)) + if (cv_birdmusic.value && cv_fading.value && P_IsLocalPlayer(target->player)) { if (netgame || multiplayer) ms = cv_respawntime.value * 1000; @@ -1748,7 +1748,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) If the time spent with the music paused is less than half a second, continue playing the song (just mute it). */ - if (( ms - cv_respawnfademusicout.value ) < 500) + if ((ms - cv_respawnfademusicout.value) < 500) S_FadeMusic(0, cv_respawnfademusicout.value); else S_FadeOutStopMusic(cv_respawnfademusicout.value); diff --git a/src/p_spec.c b/src/p_spec.c index 82372fc90..97ad38015 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2179,7 +2179,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mapmusflags |= MUSIC_FORCERESET; mapmusposition = position; - mapmusresume = 0; + + if (cv_birdmusic.value) + mapmusresume = 0; S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, diff --git a/src/p_user.c b/src/p_user.c index 63c63b448..599312475 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -593,6 +593,7 @@ void P_PlayLivesJingle(player_t *player) void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) { sfxenum_t key = P_RandomKey(2); + if (cv_kartvoices.value) { if (cv_karthitemdialog.value && source != damager && damager && damager->player && P_IsLocalPlayer(damager->player)) @@ -815,17 +816,13 @@ void P_RestoreMusic(player_t *player) if (wantedmus == 2 && cv_growmusic.value == 1) { S_ChangeMusicInternal("kgrow", true); - - if (cv_birdmusic.value) - S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); + S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1 && cv_supermusic.value == 1) { S_ChangeMusicInternal("kinvnc", true); - - if (cv_birdmusic.value) - S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); + S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else { @@ -842,13 +839,12 @@ void P_RestoreMusic(player_t *player) else position = mapmusposition; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, - S_GetRestoreMusicFadeIn()); + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); S_ClearRestoreMusicFadeInCvar(); } else S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); - + mapmusresume = 0; } } diff --git a/src/s_sound.c b/src/s_sound.c index 0bc76bce2..f3450b6f4 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -109,8 +109,6 @@ static CV_PossibleValue_t music_resync_threshold_cons_t[] = { }; consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagConditions, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -289,7 +287,6 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_pausemusic); CV_RegisterVar(&cv_music_resync_threshold); - CV_RegisterVar(&cv_music_resync_powerups_only); CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); @@ -1308,7 +1305,6 @@ static void *music_data; static UINT16 music_flags; static boolean music_looping; static consvar_t *music_refade_cv; -static int music_usage; static char queue_name[7]; static UINT16 queue_flags; @@ -1928,7 +1924,6 @@ static void S_UnloadMusic(void) music_looping = false; music_refade_cv = 0; - music_usage = 0; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) @@ -1936,8 +1931,7 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) if (S_MusicDisabled()) return false; - if (cv_birdmusic.value) - I_UpdateSongLagConditions(); + I_UpdateSongLagThreshold(); if ((!fadeinms && !I_PlaySong(looping)) || (fadeinms && !I_FadeInPlaySong(fadeinms, looping))) @@ -2132,6 +2126,9 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) void S_SetRestoreMusicFadeInCvar (consvar_t *cv) { + if (!cv_birdmusic.value) + return; + music_refade_cv = cv; } @@ -2143,17 +2140,6 @@ int S_GetRestoreMusicFadeIn (void) return 0; } -void S_SetMusicUsage (int type) -{ - music_usage = type; - I_UpdateSongLagConditions(); -} - -int S_MusicUsage (void) -{ - return music_usage; -} - /// ------------------------ /// Music Fading /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 538e8713e..8787ea5e5 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -55,7 +55,6 @@ extern consvar_t cv_amigatype; //bird music stuff extern consvar_t cv_music_resync_threshold; -extern consvar_t cv_music_resync_powerups_only; extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; @@ -218,11 +217,6 @@ UINT32 S_GetMusicPosition(void); // Music Playback // -enum -{ - MUS_SPECIAL = 1,/* powerups--invincibility, grow */ -}; - // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet @@ -238,9 +232,6 @@ void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); S_SetRestoreMusicFadeInCvar(0) int S_GetRestoreMusicFadeIn (void); -void S_SetMusicUsage (int type); -int S_MusicUsage (void); - // Stops the music. void S_StopMusic(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 806c77e47..12abb7c65 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -93,8 +93,6 @@ static UINT16 SAMPLERATE = 44100; /// ------------------------ UINT8 sound_started = false; - -static UINT32 stutter_threshold_user; static UINT32 stutter_threshold; static Mix_Music *music; @@ -626,9 +624,10 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) return; + music_bytes += len; - if ((gamestate == GS_LEVEL) && (cv_birdmusic.value)) + if (cv_birdmusic.value && gamestate == GS_LEVEL) Countstutter(len); } @@ -1042,20 +1041,12 @@ UINT32 I_GetSongPosition(void) // 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4 } -void -I_UpdateSongLagThreshold (void) +void I_UpdateSongLagThreshold (void) { - stutter_threshold_user = cv_music_resync_threshold.value/1000.0*(4*44100); - I_UpdateSongLagConditions(); -} + if (!cv_birdmusic.value) + return; -void -I_UpdateSongLagConditions (void) -{ - if (! cv_music_resync_powerups_only.value || S_MusicUsage() == MUS_SPECIAL) - stutter_threshold = stutter_threshold_user; - else - stutter_threshold = 0; + stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100); } /// ------------------------ diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 503e7205a..33714f32a 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1410,7 +1410,6 @@ UINT32 I_GetSongPosition(void) } void I_UpdateSongLagThreshold (void) {} -void I_UpdateSongLagConditions (void) {} /// ------------------------ // MUSIC PLAYBACK From 5ddd2e4fbcf81c7fd3bf7ff8dd13a1dfbbe5c1ba Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:31:00 +0200 Subject: [PATCH 29/43] cleanup P_DoSuperTransformation its still exposed to lua for whatever reason so cant really remove crap kek --- src/p_user.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 599312475..6aa3ee7a7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -499,44 +499,12 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) // Transform into Super Sonic! void P_DoSuperTransformation(player_t *player, boolean giverings) { + (void)player; + (void)giverings; + return; // SRB2kart - this is not a thing we need - player->powers[pw_super] = 1; - if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC) && P_IsLocalPlayer(player)) - { - S_StopMusic(); - S_ChangeMusicInternal("supers", true); - } - - S_StartSound(NULL, sfx_supert); //let all players hear it -mattw_cfi - - // Transformation animation - //P_SetPlayerMobjState(player->mo, S_PLAY_SUPERTRANS1); - - player->mo->momx = player->mo->momy = player->mo->momz = 0; - - if (giverings) - { - player->mo->health = 51; - player->health = player->mo->health; - } - - // Just in case. - if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) - { - player->powers[pw_extralife] = 0; - player->powers[pw_invulnerability] = 0; - player->powers[pw_sneakers] = 0; - } - - if (gametype != GT_COOP) - { - HU_SetCEchoFlags(0); - HU_SetCEchoDuration(5); - HU_DoCEcho(va("%s\\is now super.\\\\\\\\", player_names[player-players])); - } - - P_PlayerFlagBurst(player, false); } + // Adds to the player's score void P_AddPlayerScore(player_t *player, UINT32 amount) { From 9022e02ccda63deda399099aecb06dd54e5821b8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:31:35 +0200 Subject: [PATCH 30/43] fix potential crash in P_TryCameraMove for dedi servers --- src/p_map.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 6051d5d1c..cb2997552 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2245,6 +2245,9 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) floatok = false; + if (dedicated) // this crashes so don't even try it + return false; + if (twodlevel) itsatwodlevel = true; else From aac89f270bcfd72cc9414d1d8749e9e03f0132d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 05:44:13 +0200 Subject: [PATCH 31/43] Reapply "optimize precip thinker" This reverts commit dd73787c8b6bb8216fc646d4f7ce102347d713e5. --- src/hardware/hw_main.c | 16 ++--- src/info.c | 20 +++--- src/m_perfstats.c | 5 -- src/p_local.h | 1 + src/p_mobj.c | 157 +++++++++++++++++++++-------------------- src/p_mobj.h | 33 ++++----- src/p_spec.c | 5 +- src/p_tick.c | 58 ++++++++------- src/r_things.c | 20 ++---- 9 files changed, 155 insertions(+), 160 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fb566e0ea..1684bd6fe 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5112,6 +5112,12 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) // uncapped/interpolation interpmobjstate_t interp = {0}; + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!P_PrecipThinker(thing)) + { + return; + } + // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -5205,16 +5211,6 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); vis->precip = true; - - // okay... this is a hack, but weather isn't networked, so it should be ok - if (!(thing->precipflags & PCF_THUNK)) - { - if (thing->precipflags & PCF_RAIN) - P_RainThinker(thing); - else - P_SnowThinker(thing); - thing->precipflags |= PCF_THUNK; - } } static boolean drewsky = false; diff --git a/src/info.c b/src/info.c index b417c1135..f8cb9a6f1 100644 --- a/src/info.c +++ b/src/info.c @@ -1822,7 +1822,7 @@ state_t states[NUMSTATES] = // Rain {SPR_RAIN, FF_TRANS50, -1, {NULL}, 0, 0, S_NULL}, // S_RAIN1 - {SPR_RAIN, FF_TRANS50, 1, {NULL}, 0, 0, S_RAIN1}, // S_RAINRETURN + {SPR_NULL, 0, -1, {NULL}, 0, 0, S_NULL}, // S_RAINRETURN // Snowflake {SPR_SNO1, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SNOW1 @@ -1841,9 +1841,9 @@ state_t states[NUMSTATES] = {SPR_SPLH, FF_TRANS50|8, 2, {NULL}, 0, 0, S_NULL}, // S_SPLISH9 // Water Splash - {SPR_SPLA, FF_TRANS50 , 3, {NULL}, 0, 0, S_SPLASH2}, // S_SPLASH1 - {SPR_SPLA, FF_TRANS70|1, 3, {NULL}, 0, 0, S_SPLASH3}, // S_SPLASH2 - {SPR_SPLA, FF_TRANS90|2, 3, {NULL}, 0, 0, S_RAINRETURN}, // S_SPLASH3 + {SPR_SPLA, FF_TRANS50 , 3, {NULL}, 0, 0, S_SPLASH2}, // S_SPLASH1 + {SPR_SPLA, FF_TRANS70|1, 3, {NULL}, 0, 0, S_SPLASH3}, // S_SPLASH2 + {SPR_SPLA, FF_TRANS90|2, 3, {NULL}, 0, 0, S_NULL}, // S_SPLASH3 // Smoke {SPR_SMOK, FF_TRANS50 , 4, {NULL}, 0, 0, S_SMOKE2}, // S_SMOKE1 @@ -11198,22 +11198,22 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_RAIN1, // spawnstate 1000, // spawnhealth S_NULL, // seestate - sfx_None, // seesound - 8, // reactiontime + sfx_rainin, // seesound + 0, // reactiontime sfx_None, // attacksound S_NULL, // painstate 0, // painchance sfx_None, // painsound S_NULL, // meleestate S_NULL, // missilestate - S_NULL, // deathstate + S_SPLASH1, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound -72*FRACUNIT, // speed -- -24*FRACUNIT originally, srb2kart x3 (nya) 1*FRACUNIT, // radius 8*FRACUNIT, // height 0, // display offset - 4, // mass + 80, // mass 0, // damage sfx_None, // activesound MF_NOBLOCKMAP, // flags @@ -11226,7 +11226,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 1000, // spawnhealth S_NULL, // seestate sfx_None, // seesound - 8, // reactiontime + 0, // reactiontime sfx_None, // attacksound S_NULL, // painstate 0, // painchance @@ -11240,7 +11240,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 4*FRACUNIT, // radius 4*FRACUNIT, // height 0, // display offset - 4, // mass + 0, // mass 0, // damage sfx_None, // activesound MF_NOBLOCKMAP, // flags diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 04e51a657..a8f9550f4 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -58,7 +58,6 @@ static ps_metric_t ps_regularcount = {0}; static ps_metric_t ps_scenerycount = {0}; static ps_metric_t ps_nothinkcount = {0}; static ps_metric_t ps_otherthcount = {0}; -static ps_metric_t ps_precipcount = {0}; static ps_metric_t ps_removecount = {0}; ps_metric_t ps_checkposition_calls = {0}; @@ -173,7 +172,6 @@ perfstatrow_t thinkercount_rows[] = { {" scenery", " Scenery: ", &ps_scenerycount, PS_LEVEL}, {" nothink", " Nothink: ", &ps_nothinkcount, PS_HIDE_ZERO|PS_LEVEL}, {" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, - {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, {0} }; @@ -572,7 +570,6 @@ static void PS_CountThinkers(void) ps_scenerycount.value.i = 0; ps_nothinkcount.value.i = 0; ps_otherthcount.value.i = 0; - ps_precipcount.value.i = 0; ps_removecount.value.i = 0; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { @@ -590,8 +587,6 @@ static void PS_CountThinkers(void) else ps_regularcount.value.i++; } - else if (thinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - ps_precipcount.value.i++; else ps_otherthcount.value.i++; } diff --git a/src/p_local.h b/src/p_local.h index fed4a2d34..725aa20d1 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -70,6 +70,7 @@ extern thinker_t thinkercap; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); void P_RemoveThinker(thinker_t *thinker); +void P_UnlinkThinker(thinker_t *thinker); // // P_USER diff --git a/src/p_mobj.c b/src/p_mobj.c index a156edd43..a69742842 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -338,7 +338,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) if (state == S_NULL) { // Remove mobj - P_RemovePrecipMobj(mobj); + P_FreePrecipMobj(mobj); return false; } st = &states[state]; @@ -3603,67 +3603,86 @@ void P_RecalcPrecipInSector(sector_t *sector) // // P_NullPrecipThinker // -// For "Blank" precipitation +// Just the identification of a precip thinker. The thinker +// should never actually be called! // void P_NullPrecipThinker(precipmobj_t *mobj) { - //(void)mobj; - mobj->precipflags &= ~PCF_THUNK; - R_ResetPrecipitationMobjInterpolationState(mobj); + (void)mobj; + I_Assert("P_NullPrecipThinker should not be called" == 0); } -void P_SnowThinker(precipmobj_t *mobj) +boolean P_PrecipThinker(precipmobj_t *mobj) { + if (mobj->lastThink == leveltime) + return true; // already thinked this tick + + mobj->lastThink = leveltime; + + R_ResetPrecipitationMobjInterpolationState(mobj); P_CycleStateAnimation((mobj_t *)mobj); + if (mobj->state == &states[S_RAINRETURN]) + { + // Reset to ceiling! + if (!P_SetPrecipMobjState(mobj, mobj->info->spawnstate)) + return false; + + mobj->z = mobj->ceilingz; + mobj->momz = mobj->info->speed; + mobj->precipflags &= ~PCF_SPLASH; + } + + if (mobj->tics != -1) + { + if (mobj->tics) + { + mobj->tics--; + } + + if (mobj->tics == 0) + { + if ((mobj->precipflags & PCF_SPLASH) && (mobj->state->nextstate == S_NULL)) + { + // HACK: sprite changes are 1 tic late, so you would see splashes on the ceiling if not for this state. + // We need to use the settings from the previous state, since some of those are NOT 1 tic late. + INT32 frame = (mobj->frame & ~FF_FRAMEMASK); + + if (!P_SetPrecipMobjState(mobj, S_RAINRETURN)) + return false; + + mobj->frame = frame; + return true; + } + else + { + if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) + return false; + } + } + } + + if (mobj->precipflags & PCF_SPLASH) + return true; + // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) { - mobj->z = mobj->ceilingz; - R_ResetPrecipitationMobjInterpolationState(mobj); - } -} + if ((mobj->info->deathstate == S_NULL) || (mobj->precipflags & PCF_PIT)) // no splashes on sky or bottomless pits + { + mobj->z = mobj->ceilingz; + } + else + { + if (!P_SetPrecipMobjState(mobj, mobj->info->deathstate)) + return false; -void P_RainThinker(precipmobj_t *mobj) -{ - P_CycleStateAnimation((mobj_t *)mobj); - - if (mobj->state != &states[S_RAIN1]) - { - // cycle through states, - // calling action functions at transitions - if (mobj->tics <= 0) - return; - - if (--mobj->tics) - return; - - if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) - return; - - if (mobj->state != &states[S_RAINRETURN]) - return; - - mobj->z = mobj->ceilingz; - R_ResetPrecipitationMobjInterpolationState(mobj); - P_SetPrecipMobjState(mobj, S_RAIN1); - - return; + mobj->z = mobj->floorz; + mobj->precipflags |= PCF_SPLASH; + } } - // adjust height - if ((mobj->z += mobj->momz) > mobj->floorz) - return; - - // no splashes on sky or bottomless pits - if (mobj->precipflags & PCF_PIT) - { - mobj->z = mobj->ceilingz; - return; - } - - mobj->z = mobj->floorz; - P_SetPrecipMobjState(mobj, S_SPLASH1); + return true; } static void P_RingThinker(mobj_t *mobj) @@ -9903,17 +9922,21 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { + const mobjinfo_t *info = &mobjinfo[type]; state_t *st; precipmobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); fixed_t starting_floorz; + mobj->type = type; + mobj->info = info; + mobj->x = x; mobj->y = y; - mobj->flags = mobjinfo[type].flags; + mobj->flags = info->flags; // do not set the state with P_SetMobjState, // because action routines can not be called yet - st = &states[mobjinfo[type].spawnstate]; + st = &states[info->spawnstate]; mobj->state = st; mobj->tics = st->tics; @@ -9928,7 +9951,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); mobj->z = z; - mobj->momz = mobjinfo[type].speed; + mobj->momz = info->speed; mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; P_AddThinker(&mobj->thinker); @@ -9947,21 +9970,6 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype return mobj; } -static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) -{ - precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - mo->precipflags |= PCF_RAIN; - //mo->thinker.function.acp1 = (actionf_p1)P_RainThinker; - return mo; -} - -static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) -{ - precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - //mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker; - return mo; -} - // // P_RemoveMobj // @@ -10109,7 +10117,7 @@ boolean P_MobjWasRemoved(mobj_t *mobj) return true; } -void P_RemovePrecipMobj(precipmobj_t *mobj) +void P_FreePrecipMobj(precipmobj_t *mobj) { // unlink from sector and block lists P_UnsetPrecipThingPosition(mobj); @@ -10121,7 +10129,9 @@ void P_RemovePrecipMobj(precipmobj_t *mobj) } // free block - P_RemoveThinker((thinker_t *)mobj); + // Precipmobjs don't actually think using their thinker, + // so the free cannot be delayed. + P_UnlinkThinker((thinker_t*)mobj); } // Clearing out stuff for savegames @@ -10157,12 +10167,7 @@ void P_RemoveSavegameMobj(mobj_t *mobj) // free block // Here we use the same code as R_RemoveThinkerDelayed, but without reference counting (we're removing everything so it shouldn't matter) and without touching currentthinker since we aren't in P_RunThinkers - { - thinker_t *thinker = (thinker_t *)mobj; - thinker_t *next = thinker->next; - (next->prev = thinker->prev)->next = next; - Z_Free(thinker); - } + P_UnlinkThinker((thinker_t*)mobj); } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; @@ -10216,7 +10221,7 @@ void P_SpawnPrecipitation(void) if (curWeather == PRECIP_SNOW) { - rainmo = P_SpawnSnowMobj(x, y, height, MT_SNOWFLAKE); + rainmo = P_SpawnPrecipMobj(x, y, height, MT_SNOWFLAKE); mrand = M_RandomByte(); if (mrand < 64) P_SetPrecipMobjState(rainmo, S_SNOW3); @@ -10224,7 +10229,7 @@ void P_SpawnPrecipitation(void) P_SetPrecipMobjState(rainmo, S_SNOW2); } else // everything else. - rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN); + rainmo = P_SpawnPrecipMobj(x, y, height, MT_RAIN); floorz = rainmo->floorz >> FRACBITS; ceilingz = rainmo->ceilingz >> FRACBITS; diff --git a/src/p_mobj.h b/src/p_mobj.h index a824edc6a..f6b27ae49 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -254,24 +254,21 @@ typedef enum // PRECIPITATION flags ?! ?! ?! // typedef enum { - // Don't draw. - PCF_INVISIBLE = 1, - // Above pit. - PCF_PIT = 2, - // Above FOF. - PCF_FOF = 4, - // Above MOVING FOF (this means we need to keep floorz up to date...) - PCF_MOVINGFOF = 8, - // Is rain. - PCF_RAIN = 16, - // Ran the thinker this tic. - PCF_THUNK = 32, + PCF_INVISIBLE = 1, // Don't draw. + PCF_PIT = 1<<1, // Above pit. + PCF_FOF = 1<<2, // Above FOF. + PCF_MOVINGFOF = 1<<3, // Above MOVING FOF (this means we need to keep floorz up to date...) + PCF_SPLASH = 1<<4, // Splashed on the ground, return to the ceiling after the animation's over + PCF_THUNK = 1<<5, // Ran the thinker this tic. } precipflag_t; // Map Object definition. typedef struct mobj_s { // List: thinker links. thinker_t thinker; + + mobjtype_t type; + const mobjinfo_t *info; // &mobjinfo[mobj->type] // Info for drawing: position. fixed_t x, y, z; @@ -345,9 +342,6 @@ typedef struct mobj_s struct mobj_s *hnext; struct mobj_s *hprev; - mobjtype_t type; - const mobjinfo_t *info; // &mobjinfo[mobj->type] - INT32 health; // for player this is rings + 1 // Movement direction, movement generation (zig-zagging). @@ -426,6 +420,9 @@ typedef struct precipmobj_s // List: thinker links. thinker_t thinker; + mobjtype_t type; + const mobjinfo_t *info; // &mobjinfo[mobj->type] + // Info for drawing: position. fixed_t x, y, z; fixed_t old_x, old_y, old_z; // position interpolation @@ -479,6 +476,7 @@ typedef struct precipmobj_s INT32 tics; // state tic counter state_t *state; INT32 flags; // flags from mobjinfo tables + tic_t lastThink; } precipmobj_t; typedef struct actioncache_s @@ -518,10 +516,9 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb boolean P_BossTargetPlayer(mobj_t *actor, boolean closest); boolean P_SupermanLook4Players(mobj_t *actor); void P_DestroyRobots(void); -void P_SnowThinker(precipmobj_t *mobj); -void P_RainThinker(precipmobj_t *mobj); +boolean P_PrecipThinker(precipmobj_t *mobj); void P_NullPrecipThinker(precipmobj_t *mobj); -void P_RemovePrecipMobj(precipmobj_t *mobj); +void P_FreePrecipMobj(precipmobj_t *mobj); void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); void P_EmeraldManager(void); diff --git a/src/p_spec.c b/src/p_spec.c index 97ad38015..0051a5fcf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1782,7 +1782,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj = (precipmobj_t *)think; - P_RemovePrecipMobj(precipmobj); + P_FreePrecipMobj(precipmobj); } } else if (swap && !((swap == PRECIP_BLANK && curWeather == PRECIP_STORM_NORAIN) || (swap == PRECIP_STORM_NORAIN && curWeather == PRECIP_BLANK))) // Rather than respawn all that crap, reuse it! @@ -1809,7 +1809,6 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->precipflags &= ~PCF_INVISIBLE; - precipmobj->precipflags |= PCF_RAIN; //think->function.acp1 = (actionf_p1)P_RainThinker; } else if (swap == PRECIP_SNOW) // Rain To Snow @@ -1833,7 +1832,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; - precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_RAIN); + precipmobj->precipflags &= ~(PCF_INVISIBLE); //think->function.acp1 = (actionf_p1)P_SnowThinker; } diff --git a/src/p_tick.c b/src/p_tick.c index cf603af1d..453818257 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -68,8 +68,6 @@ void Command_Numthinkers_f(void) CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n")); CONS_Printf( "\t1: P_MobjThinker\n" - /*"\t2: P_RainThinker\n" - "\t3: P_SnowThinker\n"*/ "\t2: P_NullPrecipThinker\n" "\t3: T_Friction\n" "\t4: T_Pusher\n" @@ -85,14 +83,6 @@ void Command_Numthinkers_f(void) action = (actionf_p1)P_MobjThinker; CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker"); break; - /*case 2: - action = (actionf_p1)P_RainThinker; - CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker"); - break; - case 3: - action = (actionf_p1)P_SnowThinker; - CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker"); - break;*/ case 2: action = (actionf_p1)P_NullPrecipThinker; CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker"); @@ -228,21 +218,39 @@ static thinker_t *currentthinker; // void P_RemoveThinkerDelayed(void *pthinker) { - thinker_t *thinker = pthinker; - if (!thinker->references) - { - { - /* Remove from main thinker list */ - thinker_t *next = thinker->next; - /* Note that currentthinker is guaranteed to point to us, - * and since we're freeing our memory, we had better change that. So - * point it to thinker->prev, so the iterator will correctly move on to - * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - } - R_DestroyLevelInterpolators(thinker); - Z_Free(thinker); - } +#ifdef PARANOIA + if (thinker->next) + thinker->next = NULL; + else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); +#endif + if (thinker->references) + return; + + R_DestroyLevelInterpolators(thinker); + + /* Note that currentthinker is guaranteed to point to us, + * and since we're freeing our memory, we had better change that. So + * point it to thinker->prev, so the iterator will correctly move on to + * thinker->prev->next = thinker->next */ + currentthinker = thinker->prev; + /* Remove from main thinker list */ + P_UnlinkThinker(thinker); +} + +// +// P_UnlinkThinker() +// +// Actually removes thinker from the list and frees its memory. +// +void P_UnlinkThinker(thinker_t *thinker) +{ + thinker_t *next = thinker->next; + + I_Assert(thinker->references == 0); + + (next->prev = thinker->prev)->next = next; + Z_Free(thinker); } // diff --git a/src/r_things.c b/src/r_things.c index 0f5da1873..d1cb66c1e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1754,6 +1754,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // uncapped/interpolation interpmobjstate_t interp = {0}; + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!P_PrecipThinker(thing)) + { + return; + } + // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -1846,7 +1852,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) if (thing->subsector->sector->cullheight) { if (R_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, viewz, gz, gzt)) - goto weatherthink; + return; } // store information in a vissprite @@ -1911,18 +1917,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->precip = true; vis->vflip = false; vis->isScaled = false; - -weatherthink: - // okay... this is a hack, but weather isn't networked, so it should be ok - if (!(thing->precipflags & PCF_THUNK)) - { - if (thing->precipflags & PCF_RAIN) - P_RainThinker(thing); - else - P_SnowThinker(thing); - thing->precipflags |= PCF_THUNK; - } - } // R_AddSprites From a8e4f6e2ea59f75e6678d4de3269fc1979968f01 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 31 Jul 2024 06:07:49 +0200 Subject: [PATCH 32/43] Reapply "lol" This reverts commit 340450a67ed7b0f72ef22a817828264f5ccba132. --- src/p_mobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index a69742842..23a19e1d6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3631,6 +3631,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) mobj->z = mobj->ceilingz; mobj->momz = mobj->info->speed; mobj->precipflags &= ~PCF_SPLASH; + R_ResetPrecipitationMobjInterpolationState(mobj); } if (mobj->tics != -1) @@ -3671,6 +3672,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) if ((mobj->info->deathstate == S_NULL) || (mobj->precipflags & PCF_PIT)) // no splashes on sky or bottomless pits { mobj->z = mobj->ceilingz; + R_ResetPrecipitationMobjInterpolationState(mobj); } else { @@ -3679,6 +3681,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) mobj->z = mobj->floorz; mobj->precipflags |= PCF_SPLASH; + R_ResetPrecipitationMobjInterpolationState(mobj); } } From a2f4430378116a42d8829342d2519f18b9eb5668 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 31 Jul 2024 07:37:17 +0200 Subject: [PATCH 33/43] stuff --- src/p_spec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0051a5fcf..3a86970ae 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1773,15 +1773,17 @@ void P_SwitchWeather(INT32 weathernum) if (purge) { thinker_t *think; + thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thinkercap.next; think != &thinkercap; think = next) { + next = think->next; + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); } } @@ -1795,6 +1797,7 @@ void P_SwitchWeather(INT32 weathernum) { if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker + precipmobj = (precipmobj_t *)think; if (swap == PRECIP_RAIN) // Snow To Rain From 31c5d8d67cdb70a569dad4c433c7006b4be3b566 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 05:42:36 +0200 Subject: [PATCH 34/43] fix precip switching --- src/p_spec.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 3a86970ae..e5068f99b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1802,6 +1802,8 @@ void P_SwitchWeather(INT32 weathernum) if (swap == PRECIP_RAIN) // Snow To Rain { + precipmobj->type = MT_RAIN; // proper set the type + precipmobj->info = &mobjinfo[MT_RAIN]; precipmobj->flags = mobjinfo[MT_RAIN].flags; st = &states[mobjinfo[MT_RAIN].spawnstate]; precipmobj->state = st; @@ -1810,14 +1812,14 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_RAIN].speed; - precipmobj->precipflags &= ~PCF_INVISIBLE; - - //think->function.acp1 = (actionf_p1)P_RainThinker; + precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to } else if (swap == PRECIP_SNOW) // Rain To Snow { INT32 z; + precipmobj->type = MT_SNOWFLAKE; // proper set the type + precipmobj->info = &mobjinfo[MT_SNOWFLAKE]; precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags; z = M_RandomByte(); @@ -1835,14 +1837,10 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; - precipmobj->precipflags &= ~(PCF_INVISIBLE); - - //think->function.acp1 = (actionf_p1)P_SnowThinker; + precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to } else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. { - //think->function.acp1 = (actionf_p1)P_NullPrecipThinker; - precipmobj->precipflags |= PCF_INVISIBLE; } } From b8038130b8fcdf5883da9555a53c451e84c2dcd0 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 05:51:35 +0200 Subject: [PATCH 35/43] fix conflict --- src/p_tick.c | 4 ++-- src/p_tick.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 453818257..7cf876188 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -216,7 +216,7 @@ static thinker_t *currentthinker; // remove it, and set currentthinker to one node preceeding it, so // that the next step in P_RunThinkers() will get its successor. // -void P_RemoveThinkerDelayed(void *pthinker) +void P_RemoveThinkerDelayed(thinker_t *thinker) { #ifdef PARANOIA if (thinker->next) @@ -268,7 +268,7 @@ void P_UnlinkThinker(thinker_t *thinker) void P_RemoveThinker(thinker_t *thinker) { LUA_InvalidateUserdata(thinker); - thinker->function.acp1 = P_RemoveThinkerDelayed; + thinker->function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; } /* diff --git a/src/p_tick.h b/src/p_tick.h index d22995a11..11b5889ed 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -28,7 +28,7 @@ void P_RunChaseCameras(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -void P_RemoveThinkerDelayed(void *pthinker); //killed +void P_RemoveThinkerDelayed(thinker_t *thinker); mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 #endif From fe853d4beea87058f9395508f919a059a89245c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:43:21 +0200 Subject: [PATCH 36/43] fix compileur warnings idk if this is right lol --- src/p_inter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 5ffaf6dba..39babc14d 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -463,8 +463,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } else if (special->target->player->kartstuff[k_comebackmode] == 1 && P_CanPickupItem(player, 1)) { - mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); - S_StartSound(poof, special->info->seesound); + mobj_t *poof2 = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); + S_StartSound(poof2, special->info->seesound); // Karma fireworks for (i = 0; i < 5; i++) @@ -490,10 +490,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } else if (special->target->player->kartstuff[k_comebackmode] == 2 && P_CanPickupItem(player, 2)) { - mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); + mobj_t *poof3 = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); UINT8 ptadd = 1; // No WANTED bonus for tricking - S_StartSound(poof, special->info->seesound); + S_StartSound(poof3, special->info->seesound); if (player->kartstuff[k_bumper] == 1) // If you have only one bumper left, and see if it's a 1v1 { From 8581d87e414870a6ebedfc895c6256bcbac0cbd4 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 16:27:28 +0200 Subject: [PATCH 37/43] toggle to scale weather with mobjscale toggle since it may tank performance on certain maps for some + may make visability worse --- src/hardware/hw_main.c | 5 +-- src/m_menu.c | 15 +++++---- src/p_mobj.c | 72 ++++++++++++++++++++++++------------------ src/r_main.c | 2 ++ src/r_main.h | 2 +- src/r_things.c | 2 +- 6 files changed, 58 insertions(+), 40 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1684bd6fe..d75c9b17e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4684,14 +4684,15 @@ static void HWR_AddPrecipitationSprites(void) { //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; fixed_t drawdist; + fixed_t precipscale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th; if (current_bsp_culling_distance) - drawdist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * mapobjectscale); + drawdist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * precipscale); else - drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale; + drawdist = (fixed_t)(cv_drawdist_precip.value) * precipscale; // No to infinite precipitation draw distance. if (drawdist == 0) diff --git a/src/m_menu.c b/src/m_menu.c index 5dee26366..4c2f9b9af 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1479,19 +1479,20 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_HEADER, NULL, "Advanced Options", NULL, 10}, {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 20}, {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35}, + {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 35}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 40}, - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 45}, + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 50}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 55}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 60}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 60}, + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 65}, #endif - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 70}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 75}, - {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 80}, + {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 85}, #endif }; @@ -1500,6 +1501,7 @@ static const char* OP_ExpTooltips[] = NULL, "How far Mobj interpolation should take effect.", "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", + "Should weather be scaled with Mapobjectscale?.", "When weather is on this will cut the object amount used in half.", "Toggle being able to see the sky.", #ifdef HWRENDER @@ -1517,6 +1519,7 @@ enum op_exp_header, op_exp_interpdist, op_exp_precipinter, + op_exp_precipmoscale, op_exp_lessprecip, op_exp_skybox, #ifdef HWRENDER diff --git a/src/p_mobj.c b/src/p_mobj.c index 23a19e1d6..390035c8a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10182,8 +10182,9 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHE void P_SpawnPrecipitation(void) { - INT32 i, mrand; - fixed_t basex, basey, x, y, height; + INT32 i, j, k, mrand; + fixed_t basex, basey, x, y, z, height; + fixed_t precipscale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; @@ -10196,10 +10197,9 @@ void P_SpawnPrecipitation(void) basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; - //for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for kart always + for (j = 0; j < FRACUNIT; j += precipscale) { - INT32 floorz; - INT32 ceilingz; + UINT16 numparticles = 0; x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); @@ -10215,37 +10215,49 @@ void P_SpawnPrecipitation(void) if (precipsector->sector->ceilingpic != skyflatnum) continue; + height = precipsector->sector->ceilingheight - precipsector->sector->floorheight; + height = FixedDiv(height, precipscale); + // Exists, but is too small for reasonable precipitation. - if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingheight; + // Hack around a quirk of this entire system, where taller sectors look like they get less precipitation. + numparticles = 1 + (height / (MAPBLOCKUNITS<<4<sector->ceilingheight; - floorz = rainmo->floorz >> FRACBITS; - ceilingz = rainmo->ceilingz >> FRACBITS; + for (k = 0; k < numparticles; k++) + { + INT32 floorz; + INT32 ceilingz; - if (floorz < ceilingz) - { - // Randomly assign a height, now that floorz is set. - rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS; - } - else - { - // ...except if the floor is above the ceiling. - rainmo->z = ceilingz << FRACBITS; + if (curWeather == PRECIP_SNOW) + { + rainmo = P_SpawnPrecipMobj(x, y, z, MT_SNOWFLAKE); + mrand = M_RandomByte(); + if (mrand < 64) + P_SetPrecipMobjState(rainmo, S_SNOW3); + else if (mrand < 144) + P_SetPrecipMobjState(rainmo, S_SNOW2); + } + else // everything else. + rainmo = P_SpawnPrecipMobj(x, y, z, MT_RAIN); + + floorz = rainmo->floorz >> FRACBITS; + ceilingz = rainmo->ceilingz >> FRACBITS; + + if (floorz < ceilingz) + { + // Randomly assign a height, now that floorz is set. + rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS; + } + else + { + // ...except if the floor is above the ceiling. + rainmo->z = ceilingz << FRACBITS; + } } } } diff --git a/src/r_main.c b/src/r_main.c index fb3ca1c1c..a92fd8f43 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -210,6 +210,7 @@ consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, N consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1841,6 +1842,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_drawdist); CV_RegisterVar(&cv_drawdist_precip); CV_RegisterVar(&cv_lessprecip); + CV_RegisterVar(&cv_mobjscaleprecip); CV_RegisterVar(&cv_fov); CV_RegisterVar(&cv_chasecam); diff --git a/src/r_main.h b/src/r_main.h index a271a3b1d..490f793f9 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -117,7 +117,7 @@ extern consvar_t cv_flipcam, cv_flipcam2, cv_flipcam3, cv_flipcam4; extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_ffloorclip, cv_spriteclip; extern consvar_t cv_translucency; -extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip; +extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip, cv_mobjscaleprecip; extern consvar_t cv_fov; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; diff --git a/src/r_things.c b/src/r_things.c index d1cb66c1e..ad1e3ca05 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2052,7 +2052,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // void R_AddPrecipitationSprites(void) { - const fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale; + fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th, *next; From e2c3d5b20d6c20728f22a6a31936308eba7e2b62 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 16:28:45 +0200 Subject: [PATCH 38/43] respawn precip when toggling any of its settings --- src/r_main.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index a92fd8f43..f4867d63e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -16,6 +16,7 @@ #include "doomdef.h" #include "g_game.h" #include "g_input.h" +#include "g_state.h" #include "r_local.h" #include "r_splats.h" // faB(21jan): testing #include "r_sky.h" @@ -185,6 +186,8 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); +static void Precipstuff_OnChange(void); + consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasecam = {"chasecam", "On", CV_CALL, CV_OnOff, ChaseCam_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasecam2 = {"chasecam2", "On", CV_CALL, CV_OnOff, ChaseCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -208,9 +211,9 @@ consvar_t cv_uncappedhud = {"uncappedhud", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NU consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE|CV_CALL|CV_NOINIT, drawdist_precip_cons_t, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; +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_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -330,6 +333,29 @@ static void FlipCam4_OnChange(void) SendWeaponPref4(); } +static void Precipstuff_OnChange(void) +{ + if (gamestate != GS_LEVEL) + return; + + thinker_t *think; + thinker_t *next; + precipmobj_t *precipmobj; + + for (think = thinkercap.next; think != &thinkercap; think = next) + { + next = think->next; + + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) + continue; // not a precipmobj thinker + + precipmobj = (precipmobj_t *)think; + P_FreePrecipMobj(precipmobj); + } + + P_SpawnPrecipitation(); +} + // // R_PointOnSide // Traverse BSP (sub) tree, From d7c1b12dbd7811574ebd50116ff874777a76bc7c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 18:26:18 +0200 Subject: [PATCH 39/43] changes to saturn menu -Add new Saturn Hud options menu to declutter normal saturn options - If in any of the hud options the game will force display the kart hud and disable the fade background - i hate m_menu --- src/k_kart.c | 18 +++-- src/m_menu.c | 183 ++++++++++++++++++++++++++++++------------------- src/m_menu.h | 6 +- src/st_stuff.c | 4 +- 4 files changed, 133 insertions(+), 78 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 2ef1ffa68..ad175397a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -88,7 +88,7 @@ consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //Colourized HUD -consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, Saturn_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, SaturnHud_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t HudColor_cons_t[MAXSKINCOLORS+1]; @@ -7637,7 +7637,7 @@ static void K_initKartHUD(void) } } - if (timeinmap > 113) + if (timeinmap > 113 || forceshowhud) hudtrans = cv_translucenthud.value; else if (timeinmap > 105) hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105); @@ -9366,9 +9366,17 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (!stplyr->mo || !stplyr->kartstuff[k_drift] || (!splitscreen && !camera->chase)) + if (!stplyr->mo || (!splitscreen && !camera->chase)) return; + if (forceshowhud) + goto skipcrap; // i will skip the drift early return and you cant stop me! + + if (!stplyr->kartstuff[k_drift]) + return; + +skipcrap: + if (!K_GetScreenCoords(&pos, stplyr, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false)) return; @@ -9746,7 +9754,9 @@ static void K_drawKartMinimap(void) splitflags = info.flags; - if (timeinmap > 105) + if (forceshowhud) + minimaptrans = cv_kartminimap.value; + else if (timeinmap > 105) { minimaptrans = cv_kartminimap.value; if (timeinmap <= 113) diff --git a/src/m_menu.c b/src/m_menu.c index 4c2f9b9af..d4d2c6266 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -361,6 +361,7 @@ static void M_DeleteProtocol(void); // Saturn menu_t OP_SaturnDef; +menu_t OP_SaturnHudDef; menu_t OP_HudOffsetDef; menu_t OP_PlayerDistortDef; menu_t OP_SaturnCreditsDef; @@ -461,6 +462,9 @@ static void Newgametype_OnChange(void); static void Dummymenuplayer_OnChange(void); static void Dummystaff_OnChange(void); +// crap to force hud to show when in saturns hud options +boolean forceshowhud = false; + // ========================================================================== // CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE. // ========================================================================== @@ -2044,37 +2048,19 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 10}, {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 25}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 30}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 40}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 45}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 50}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 55}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 65}, - {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 70}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 85}, + {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 30}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 95}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 40}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 45}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 100}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 105}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 110}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 55}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 120}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 65}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 130}, - - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 140}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 145}, - - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 155}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 160}, - - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 170}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 75}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 80}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 85}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2082,28 +2068,13 @@ static const char* OP_SaturnTooltips[] = NULL, "How long can the game wait before it kicks you out from the server\nconnecting screen.", "How much speen do you want?", - "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", - "Change what style the speedometer is.", - "Enable the stat display.", - "Show Lap Time when doing a Lap on the Timer.", - "Enable the use of the higher resolution want icons instead of rank\nfor some places.", - "Enable colourized hud.", - "Enable the colourized itembox when colourized hud is enabled.", - "The color to use instead of the player color when\ncolourized hud is enabled.", - "Show the big 'LAP' text on a lap change.", - "Show player names on the minimap.", - "Minimize the player icons on the minimap.", "Makes the Camera Lagless in netgames.", - "Uncaps the HUD framerate, making it appear smoother.", - "Show the big Cecho Messages.", "Show Localskin Menus.", "Force menu to only use uppercase.", "Use your desired Keyboard Layout for Text Input\nthis is either the Default, Native or Azerty\nNative does not affect Gameplay only Text!", "Disables the flicker effect on Midnight Channel.", - "Nametag Options.", - "Driftgauge Options.", + "Options for Saturn specific HUD things.", "Options for sprite distortion effects.", - "Move position of HUD elements.", "See the people who helped make this project possible!", }; @@ -2112,28 +2083,13 @@ enum sm_header, sm_waittime, sm_skinselspeed, - sm_input, - sm_speedometer, - sm_statdisplay, - sm_laptime, - sm_highresport, - sm_colorhud, - sm_coloritem, - sm_colorhud_customcolor, - sm_lapemblem, - sm_mapnames, - sm_smallmap, sm_laglesscam, - sm_uncappedhud, - sm_cechotogle, sm_showlocalskin, op_uppercase_menu, sm_nativkey, sm_pisschannel, - sm_nametagmen, - sm_driftgaugemen, + sm_hud, sm_distortionmenu, - sm_hudoffsets, sm_credits, }; @@ -2183,6 +2139,80 @@ enum saltsquishy, }; +static menuitem_t OP_SaturnHudMenu[] = +{ + {IT_HEADER, NULL, "Saturn Hud Options", NULL, 0}, + + {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, + {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 15}, + + {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 20}, + + {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 25}, + + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 30}, + + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 35}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 40}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 45}, + + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 55}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 60}, + + {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 65}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, + + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 80}, + + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 90}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 95}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 105}, +}; + +static const char* OP_SaturnHudTooltips[] = +{ + NULL, + "Change what style the speedometer is.", + "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", + "Enable the stat display.", + "Show Lap Time when doing a Lap on the Timer.", + "Enable the use of the higher resolution want icons instead of rank\nfor some places.", + "Enable colourized hud.", + "Enable the colourized itembox when colourized hud is enabled.", + "The color to use instead of the player color when\ncolourized hud is enabled.", + "Show the big 'LAP' text on a lap change.", + "Show the big Cecho Messages.", + "Show player names on the minimap.", + "Minimize the player icons on the minimap.", + "Uncaps the HUD framerate, making it appear smoother.", + "Nametag Options.", + "Driftgauge Options.", + "Move position of HUD elements.", +}; + +enum +{ + sh_header, + sh_speedometer, + sh_input, + sh_laptime, + sh_statdisplay, + sh_highresport, + sh_colorhud, + sh_coloritem, + sh_colorhud_customcolor, + sh_lapemblem, + sh_cechotogle, + sh_mapname, + sh_smallmap, + sh_uncappedhud, + sh_nametagmen, + sh_driftgaugemen, + sh_hudoffsets, +}; + + static menuitem_t OP_HudOffsetMenu[] = { {IT_HEADER, NULL, "Kart Hud Offsets", NULL, 0}, @@ -2952,13 +2982,15 @@ menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOp menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30); menu_t OP_PlayerDistortDef = DEFAULTMENUSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30); -menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &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_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 10); menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); -menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnDef, 30, 40); -menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnDef, 30, 60); +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_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60); menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60); @@ -3283,7 +3315,7 @@ void Bird_menu_Onchange(void) } //menu code is nice -void Saturn_menu_Onchange(void) +void SaturnHud_menu_Onchange(void) { UINT16 status; @@ -3292,8 +3324,8 @@ void Saturn_menu_Onchange(void) else status = IT_GRAYEDOUT; - OP_SaturnMenu[sm_coloritem].status = status; - OP_SaturnMenu[sm_colorhud_customcolor].status = status; + OP_SaturnHudMenu[sh_coloritem].status = status; + OP_SaturnHudMenu[sh_colorhud_customcolor].status = status; } // ========================================================================== @@ -4101,7 +4133,6 @@ boolean M_DemoResponder(event_t *ev) return eatinput; } - // // M_Drawer // Called after the view has been rendered, @@ -4112,10 +4143,12 @@ void M_Drawer(void) if (currentMenu == &MessageDef) menuactive = true; + forceshowhud = gamestate == GS_LEVEL && menuactive && (currentMenu == &OP_SaturnHudDef || currentMenu == &OP_HudOffsetDef || currentMenu == &OP_NametagDef || currentMenu == &OP_DriftGaugeDef); // holy fuick + if (menuactive) { // now that's more readable with a faded background (yeah like Quake...) - if (!WipeInAction && currentMenu != &PlaybackMenuDef) // Replay playback has its own background + if (!WipeInAction && currentMenu != &PlaybackMenuDef && !forceshowhud) // Replay playback has its own background V_DrawFadeScreen(0xFF00, 16); if (currentMenu->drawroutine) @@ -4560,7 +4593,7 @@ void M_Init(void) #endif if (!xtra_speedo && !kartzspeedo && !achi_speedo) // why bother? - OP_SaturnMenu[sm_speedometer].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_speedometer].status = IT_GRAYEDOUT; //if (!xtra_speedo && kartzspeedo) //OP_SaturnMenu[sm_speedometer].text = "Speedometer (No Small)"; @@ -4571,9 +4604,9 @@ void M_Init(void) if (!clr_hud) // uhguauhauguuhee { - OP_SaturnMenu[sm_colorhud].status = IT_GRAYEDOUT; - OP_SaturnMenu[sm_coloritem].status = IT_GRAYEDOUT; - OP_SaturnMenu[sm_colorhud_customcolor].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_colorhud].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_coloritem].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_colorhud_customcolor].status = IT_GRAYEDOUT; } if (!nametaggfx) @@ -5361,6 +5394,16 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } + + if (currentMenu == &OP_SaturnHudDef) + { + if (!(OP_SaturnHudTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnHudTooltips[itemOn], coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } } static void M_DrawPauseMenu(void) diff --git a/src/m_menu.h b/src/m_menu.h index e74fd491f..570d8a94d 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -21,6 +21,8 @@ #include "mserv.h" #include "r_things.h" // for SKINNAMESIZE +extern boolean forceshowhud; + // // MENUS // @@ -290,8 +292,8 @@ void PDistort_menu_Onchange(void); // Bird menu updating void Bird_menu_Onchange(void); -// Saturn menu updating -void Saturn_menu_Onchange(void); +// Saturn Hud menu updating +void SaturnHud_menu_Onchange(void); void M_ReplayHut(INT32 choice); void M_SetPlaybackMenuPointer(void); diff --git a/src/st_stuff.c b/src/st_stuff.c index afbf74b8f..419b527c2 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -709,7 +709,7 @@ static void ST_overlayDrawer(void) } } - if (!(netgame || multiplayer) || !hu_showscores) + if ((!(netgame || multiplayer) || !hu_showscores) && !forceshowhud) { if (renderisnewtic) { @@ -718,7 +718,7 @@ static void ST_overlayDrawer(void) } // draw level title Tails - if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle)) + if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle) && !forceshowhud) ST_drawLevelTitle(); if (!hu_showscores && netgame && !mapreset) From c11d9255808774e607283c6fe42a2e4b356ab2dc Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Aug 2024 02:35:42 +0200 Subject: [PATCH 40/43] optimize z position checking for mobjs without collision and camera idk how much this does tbh only for stuff without collision since it may desynch otherwise based on https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2214 and https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2250 --- src/p_mobj.c | 8 ++++---- src/r_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/r_main.h | 1 + 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 390035c8a..8a0147194 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -616,7 +616,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t 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 (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(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 @@ -692,7 +692,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed 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 (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(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 @@ -770,7 +770,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_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) return P_GetZAt(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 @@ -847,7 +847,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_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) return P_GetZAt(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 diff --git a/src/r_main.c b/src/r_main.c index f4867d63e..e6247ceae 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1125,6 +1125,51 @@ void R_Init(void) framecount = 0; } +// +// R_IsPointInSector +// +boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y) +{ + size_t i; + size_t passes = 0; + + for (i = 0; i < sector->linecount; i++) + { + line_t *line = sector->lines[i]; + vertex_t *v1, *v2; + + if (line->frontsector == line->backsector) + continue; + + v1 = line->v1; + v2 = line->v2; + + // make sure v1 is below v2 + if (v1->y > v2->y) + { + vertex_t *tmp = v1; + v1 = v2; + v2 = tmp; + } + else if (v1->y == v2->y) + // horizontal line, we can't match this + continue; + + if (v1->y < y && y <= v2->y) + { + // if the y axis in inside the line, find the point where we intersect on the x axis... + fixed_t vx = v1->x + (INT64)(v2->x - v1->x) * (y - v1->y) / (v2->y - v1->y); + + // ...and if that point is to the left of the point, count it as inside. + if (vx < x) + passes++; + } + } + + // and odd number of passes means we're inside the polygon. + return passes % 2; +} + // // R_PointInSubsector // diff --git a/src/r_main.h b/src/r_main.h index 490f793f9..81bff3811 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -76,6 +76,7 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PlayerSliptideAngle(player_t *player); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); +boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y); subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); From 28d8e84d6bfefc23e6d3d7ac9e4cf920f9d3246d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Aug 2024 17:08:38 +0200 Subject: [PATCH 41/43] this can be static and inlined --- src/d_clisrv.c | 2 +- src/d_clisrv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 10d46689a..1efd88623 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -223,7 +223,7 @@ UINT16 software_MAXPACKETLENGTH; * \return The full tic value * */ -tic_t ExpandTics(INT32 low, tic_t basetic) +static inline tic_t ExpandTics(INT32 low, tic_t basetic) { INT32 delta; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 13c2bc353..6ddeb09bb 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -574,7 +574,7 @@ extern consvar_t cv_connectawaittime; extern consvar_t cv_discordinvites; // Used in d_net, the only dependence -tic_t ExpandTics(INT32 low, tic_t basetic); +//tic_t ExpandTics(INT32 low, tic_t basetic); void D_ClientServerInit(void); // Initialise the other field From 42fa29f78b785ba8329a751d08f5adb18b8f52c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 17:39:17 +0200 Subject: [PATCH 42/43] =?UTF-8?q?make=20timer=20flash=20at=2099=C2=B459?= =?UTF-8?q?=C2=B499=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/k_kart.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ad175397a..e344a6d63 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8227,39 +8227,36 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI { tic_t worktime = drawtime/(60*TICRATE); - if (worktime >= 100) - { - worktime = 99; - drawtime = (100*(60*TICRATE))-1; - } - - if ((cv_timelimit.value && G_BattleGametype()) && (!players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much + if ((G_BattleGametype() && cv_timelimit.value) && (!players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much { V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME")); - return; } + else if (worktime < 100) + { + // minutes time 00 __ __ + V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); - // minutes time 00 __ __ - V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); + // apostrophe location _'__ __ + V_DrawKartString(TX+24, TY+3, splitflags, va("'")); - // apostrophe location _'__ __ - V_DrawKartString(TX+24, TY+3, splitflags, va("'")); + worktime = (drawtime/TICRATE % 60); - worktime = (drawtime/TICRATE % 60); + // seconds time _ 00 __ + V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); - // seconds time _ 00 __ - V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); + // quotation mark location _ __"__ + V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); - // quotation mark location _ __"__ - V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); + worktime = G_TicsToCentiseconds(drawtime); - worktime = G_TicsToCentiseconds(drawtime); - - // tics _ __ 00 - V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); + // tics _ __ 00 + V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); + } + else if ((drawtime/TICRATE) & 1) + V_DrawKartString(TX, TY+3, splitflags, va("99'59\"99")); } if (emblemmap && (modeattacking || (mode == 1)) && !demo.playback) // emblem time! From 91fac0880d22382b25f92301271401a4c3405cbe Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:01:12 +0200 Subject: [PATCH 43/43] add battlespeedometer to saturn hud menu + apply offset to bumper gfx when enabled --- src/k_kart.c | 8 ++++++++ src/m_menu.c | 34 +++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e344a6d63..7ed4f5482 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8924,6 +8924,14 @@ static void K_drawKartBumpersOrKarma(void) fy = info.y; fflags = info.flags; + if (cv_battlespeedo.value) + { + if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) + fy -= -10; + else + fy -= -14; + } + if (splitscreen > 1) { if (stplyr->kartstuff[k_bumper] <= 0) diff --git a/src/m_menu.c b/src/m_menu.c index d4d2c6266..32ad2261f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2144,36 +2144,39 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_HEADER, NULL, "Saturn Hud Options", NULL, 0}, {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 15}, + {IT_STRING | IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 20}, + {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 20}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 25}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 25}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 30}, + {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 30}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 35}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 40}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 45}, + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 55}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 60}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 40}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 45}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 50}, - {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 65}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 60}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 65}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 80}, + {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 70}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 95}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 85}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 105}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 95}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 100}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 110}, }; static const char* OP_SaturnHudTooltips[] = { NULL, "Change what style the speedometer is.", + "Draw the Speedometer in Battle.", "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", "Enable the stat display.", "Show Lap Time when doing a Lap on the Timer.", @@ -2195,6 +2198,7 @@ enum { sh_header, sh_speedometer, + sh_battlespeedo, sh_input, sh_laptime, sh_statdisplay,