From a2faa975cb67c6110ec7ef4a281271758ae09588 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Fri, 20 Dec 2019 16:39:19 -0600 Subject: [PATCH 01/12] Allow Clipboard actions. --- src/m_menu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index e367041e0..eb9bbaffe 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10436,6 +10436,28 @@ static void M_HandleConnectIP(INT32 choice) if (l >= 28-1) break; + const char *paste = I_ClipboardPaste(); // Paste clipboard into char + + if ( ctrldown ) { + switch (choice) { + case 118: // ctrl+v, pasting + if (paste != NULL) + strcat(setupm_ip, paste); // Concat the ip field with clipboard + setupm_ip[127] = 0; // Truncate to maximum length + break; + case 99: // ctrl+c, copying + I_ClipboardCopy(setupm_ip, l); + break; + case 120: // ctrl+x, cutting + I_ClipboardCopy(setupm_ip, l); + setupm_ip[0] = 0; + break; + default: // otherwise do nothing + break; + } + break; // break + } + // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z')) { From ed847e831b562ee86f4d1eba49013ba844d76d2b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Fri, 20 Dec 2019 20:28:30 -0600 Subject: [PATCH 02/12] Fix pasting going out of bounds and dash the possibility of memory leaks while pasting. --- src/m_menu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index eb9bbaffe..ad0f70eb2 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10436,14 +10436,16 @@ static void M_HandleConnectIP(INT32 choice) if (l >= 28-1) break; - const char *paste = I_ClipboardPaste(); // Paste clipboard into char + char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char if ( ctrldown ) { switch (choice) { case 118: // ctrl+v, pasting - if (paste != NULL) + if (paste != NULL) { + if (strlen(paste) + strlen(setupm_ip) >= 28-1) + paste[28-1 - strlen(setupm_ip)] = 0; strcat(setupm_ip, paste); // Concat the ip field with clipboard - setupm_ip[127] = 0; // Truncate to maximum length + } break; case 99: // ctrl+c, copying I_ClipboardCopy(setupm_ip, l); From 1f93ab0e0ffe5c19dee2fa1c47f1dbe0c161d207 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 23 Dec 2019 18:53:41 -0600 Subject: [PATCH 03/12] Optimise further, play beep on cut/copy, play beep when paste is successful. --- src/m_menu.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ad0f70eb2..fed0d65b1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10433,33 +10433,42 @@ static void M_HandleConnectIP(INT32 choice) default: l = strlen(setupm_ip); - if (l >= 28-1) - break; - - char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char if ( ctrldown ) { switch (choice) { case 118: // ctrl+v, pasting + ; + char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char + if (paste != NULL) { - if (strlen(paste) + strlen(setupm_ip) >= 28-1) - paste[28-1 - strlen(setupm_ip)] = 0; + if (strlen(paste) + l >= 28-1) + paste[28-1 - l] = 0; strcat(setupm_ip, paste); // Concat the ip field with clipboard + if (strlen(paste) != 0) // Don't play sound if nothing was pasted + S_StartSound(NULL,sfx_menu1); // Tails } break; + case 99: // ctrl+c, copying I_ClipboardCopy(setupm_ip, l); + S_StartSound(NULL,sfx_menu1); // Tails break; + case 120: // ctrl+x, cutting I_ClipboardCopy(setupm_ip, l); + S_StartSound(NULL,sfx_menu1); // Tails setupm_ip[0] = 0; break; + default: // otherwise do nothing break; } - break; // break + break; // don't check for typed keys } + if (l >= 28-1) + break; + // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z')) { From ae9adce873cbb4938a34657d783286fa14469c8a Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 29 Dec 2019 18:26:56 -0600 Subject: [PATCH 04/12] Replace magic numbers with less magic and more readable chars. --- src/m_menu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index fed0d65b1..e1e28b671 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10436,7 +10436,8 @@ static void M_HandleConnectIP(INT32 choice) if ( ctrldown ) { switch (choice) { - case 118: // ctrl+v, pasting + case 'v': + case 'V': // ctrl+v, pasting ; char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char @@ -10448,13 +10449,15 @@ static void M_HandleConnectIP(INT32 choice) S_StartSound(NULL,sfx_menu1); // Tails } break; - - case 99: // ctrl+c, copying + + case 'c': + case 'C': // ctrl+c, copying I_ClipboardCopy(setupm_ip, l); S_StartSound(NULL,sfx_menu1); // Tails break; - case 120: // ctrl+x, cutting + case 'x': + case 'X': // ctrl+x, cutting I_ClipboardCopy(setupm_ip, l); S_StartSound(NULL,sfx_menu1); // Tails setupm_ip[0] = 0; From 9d701d722ebd08d4939ea43e195a5f0325338e0a Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 29 Dec 2019 20:15:18 -0600 Subject: [PATCH 05/12] Reverted to better, less complex system, and added support for Shift+Insert and Shift+Delete. Major thanks to James for helping me. Turns out that strncpy thwarts the memory leaks for me. Silly, me! --- src/m_menu.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e1e28b671..ef9335907 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10424,13 +10424,15 @@ static void M_HandleConnectIP(INT32 choice) break; case KEY_DEL: - if (setupm_ip[0]) + if (setupm_ip[0] && !shiftdown) // Shift+Delete is used for something else. { S_StartSound(NULL,sfx_menu1); // Tails setupm_ip[0] = 0; } - break; - + if (!shiftdown) // Shift+Delete is used for something else. + break; + + /* FALLTHRU */ default: l = strlen(setupm_ip); @@ -10438,18 +10440,17 @@ static void M_HandleConnectIP(INT32 choice) switch (choice) { case 'v': case 'V': // ctrl+v, pasting - ; - char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char - + { + const char *paste = I_ClipboardPaste(); + if (paste != NULL) { - if (strlen(paste) + l >= 28-1) - paste[28-1 - l] = 0; - strcat(setupm_ip, paste); // Concat the ip field with clipboard + strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard if (strlen(paste) != 0) // Don't play sound if nothing was pasted S_StartSound(NULL,sfx_menu1); // Tails } + break; - + } case 'c': case 'C': // ctrl+c, copying I_ClipboardCopy(setupm_ip, l); @@ -10469,6 +10470,31 @@ static void M_HandleConnectIP(INT32 choice) break; // don't check for typed keys } + if ( shiftdown ) { + switch (choice) { + case KEY_INS: + { + const char *paste = I_ClipboardPaste(); + + if (paste != NULL) { + strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard + if (strlen(paste) != 0) // Don't play sound if nothing was pasted + S_StartSound(NULL,sfx_menu1); // Tails + } + + break; + } + case KEY_DEL: // shift+delete, cutting + I_ClipboardCopy(setupm_ip, l); + S_StartSound(NULL,sfx_menu1); // Tails + setupm_ip[0] = 0; + break; + default: // otherwise do nothing. + break; + } + break; // don't check for typed keys + } + if (l >= 28-1) break; From bc88def2254afd6d24f6503fddf49f008b811bc9 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 29 Dec 2019 20:22:58 -0600 Subject: [PATCH 06/12] Slap in some Ctrl+Insert (copy) support too while I'm at it. Also added a comment but you didn't see that. --- src/m_menu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ef9335907..e9cbe9980 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10431,7 +10431,7 @@ static void M_HandleConnectIP(INT32 choice) } if (!shiftdown) // Shift+Delete is used for something else. break; - + /* FALLTHRU */ default: l = strlen(setupm_ip); @@ -10451,8 +10451,9 @@ static void M_HandleConnectIP(INT32 choice) break; } + case KEY_INS: case 'c': - case 'C': // ctrl+c, copying + case 'C': // ctrl+c, ctrl+insert, copying I_ClipboardCopy(setupm_ip, l); S_StartSound(NULL,sfx_menu1); // Tails break; @@ -10472,7 +10473,7 @@ static void M_HandleConnectIP(INT32 choice) if ( shiftdown ) { switch (choice) { - case KEY_INS: + case KEY_INS: // shift+insert, pasting { const char *paste = I_ClipboardPaste(); From 658b8dcfa95935bbaef92c15476ad57ecc96950f Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 2 Jan 2020 15:45:13 -0800 Subject: [PATCH 07/12] Use GCC 8.1 for x86_64 --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0edc7ce28..c8a5832c2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ environment: # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead MINGW_SDK: c:\msys64\mingw32 # c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead - MINGW_SDK_64: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64 + MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64 CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn NASM_ZIP: nasm-2.12.01 NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip @@ -92,8 +92,8 @@ before_build: - ccache -V - ccache -s - if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" ) -- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 GCC73=1 NOOBJDUMP=1 %NOUPX%" -- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" ) +- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX%" +- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" ) - set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1" build_script: From deee2a0d6fae77ed8cd1a17669fb6384ecde2119 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 4 Jan 2020 22:19:30 -0300 Subject: [PATCH 08/12] I was using V_GetColor in a lot of places I shouldn't have, making the game look wrong with a non-default colour profile. Though, I left R_RainbowColormap alone. --- src/r_data.c | 6 +++--- src/v_video.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index bfd83a62d..986b65dea 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -324,8 +324,8 @@ UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 al else if (style != AST_TRANSLUCENT) { RGBA_t texel; - RGBA_t bg = V_GetColor(background); - RGBA_t fg = V_GetColor(foreground); + RGBA_t bg = V_GetMasterColor(background); + RGBA_t fg = V_GetMasterColor(foreground); texel.rgba = ASTBlendPixel(bg, fg, style, alpha); return NearestColor(texel.s.red, texel.s.green, texel.s.blue); } @@ -1664,7 +1664,7 @@ static void R_CreateFadeColormaps(void) #define GETCOLOR \ px = colormaps[i%256]; \ fade = (i/256) * (256 / FADECOLORMAPROWS); \ - rgba = V_GetColor(px); + rgba = V_GetMasterColor(px); // to black makeblack: diff --git a/src/v_video.h b/src/v_video.h index 36d1914af..eb75a414f 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -64,6 +64,7 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); // Retrieve the ARGB value from a palette color index #define V_GetColor(color) (pLocalPalette[color&0xFF]) +#define V_GetMasterColor(color) (pMasterPalette[color&0xFF]) // Bottom 8 bits are used for parameter (screen or character) #define V_PARAMMASK 0x000000FF From 6c85c4e1d39f6d686d19595539f6b349d01df887 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 5 Jan 2020 18:39:16 +0100 Subject: [PATCH 09/12] Fix mouse being grabbed even when not used --- src/sdl/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index e6a40327b..785d8c4dc 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -110,7 +110,7 @@ static SDL_bool disable_fullscreen = SDL_FALSE; #define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?0:cv_fullscreen.value static SDL_bool disable_mouse = SDL_FALSE; #define USE_MOUSEINPUT (!disable_mouse && cv_usemouse.value && havefocus) -#define IGNORE_MOUSE (!cv_alwaysgrabmouse.value && (menuactive || paused || con_destlines || chat_on || gamestate != GS_LEVEL)) +#define IGNORE_MOUSE (!USE_MOUSEINPUT || (!cv_alwaysgrabmouse.value && (menuactive || paused || con_destlines || chat_on || gamestate != GS_LEVEL))) #define MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menuactive && !USE_FULLSCREEN) #define MOUSEBUTTONS_MAX MOUSEBUTTONS From 88c8049c77f3c38768de19c02394f5b888028f96 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 5 Jan 2020 18:39:16 +0100 Subject: [PATCH 10/12] Revert "Fix mouse being grabbed even when not used" This reverts commit 6c85c4e1d39f6d686d19595539f6b349d01df887. --- src/sdl/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 785d8c4dc..e6a40327b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -110,7 +110,7 @@ static SDL_bool disable_fullscreen = SDL_FALSE; #define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?0:cv_fullscreen.value static SDL_bool disable_mouse = SDL_FALSE; #define USE_MOUSEINPUT (!disable_mouse && cv_usemouse.value && havefocus) -#define IGNORE_MOUSE (!USE_MOUSEINPUT || (!cv_alwaysgrabmouse.value && (menuactive || paused || con_destlines || chat_on || gamestate != GS_LEVEL))) +#define IGNORE_MOUSE (!cv_alwaysgrabmouse.value && (menuactive || paused || con_destlines || chat_on || gamestate != GS_LEVEL)) #define MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menuactive && !USE_FULLSCREEN) #define MOUSEBUTTONS_MAX MOUSEBUTTONS From e847777a35eab5a5c3e05bd189b6f308457ca5db Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sun, 5 Jan 2020 18:39:16 +0100 Subject: [PATCH 11/12] Fix mouse being grabbed even when not used The other way around this time. --- src/sdl/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index e6a40327b..2b8633e5b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -388,7 +388,7 @@ void I_UpdateMouseGrab(void) { if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO && window != NULL && SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window - && !IGNORE_MOUSE) + && USE_MOUSEINPUT && !IGNORE_MOUSE) SDLdoGrabMouse(); } From 0fbc459243323a4de96faaffb1c9ff7e2e7a4ee9 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 5 Jan 2020 21:49:07 -0500 Subject: [PATCH 12/12] cleanup whitespace --- 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 e9d794bd1..ea2c5c6d8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10524,7 +10524,7 @@ static void M_HandleConnectIP(INT32 choice) case 'V': // ctrl+v, pasting { const char *paste = I_ClipboardPaste(); - + if (paste != NULL) { strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard if (strlen(paste) != 0) // Don't play sound if nothing was pasted @@ -10558,7 +10558,7 @@ static void M_HandleConnectIP(INT32 choice) case KEY_INS: // shift+insert, pasting { const char *paste = I_ClipboardPaste(); - + if (paste != NULL) { strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard if (strlen(paste) != 0) // Don't play sound if nothing was pasted