From 1141c2c1f2cd8b6789e7d3f197d45a2cd5c97f48 Mon Sep 17 00:00:00 2001 From: ThatAwesomeGuy173 Date: Fri, 25 Jan 2019 21:50:58 -0700 Subject: [PATCH 1/3] Allow letters to be used in the "Specify IPv4 Address:" field --- src/m_menu.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 034c32425..9d230a135 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7708,7 +7708,7 @@ static void M_StartServerMenu(INT32 choice) // CONNECT VIA IP // ============== -static char setupm_ip[16]; +static char setupm_ip[28]; #endif static UINT8 setupm_pselect = 1; @@ -7741,12 +7741,12 @@ Update the maxplayers label... V_DrawFill(x+5, y+4+5, /*16*8 + 6,*/ BASEVIDWIDTH - 2*(x+5), 8+6, 239); // draw name string - V_DrawString(x+8,y+12, V_MONOSPACE, setupm_ip); + V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip); // draw text cursor for name if (itemOn == 8 && skullAnimCounter < 4) //blink cursor - V_DrawCharacter(x+8+V_StringWidth(setupm_ip, V_MONOSPACE),y+12,'_',false); + V_DrawCharacter(x+8+V_StringWidth(setupm_ip, V_ALLOWLOWERCASE),y+12,'_',false); #endif // character bar, ripped off the color bar :V @@ -7959,25 +7959,16 @@ static void M_HandleConnectIP(INT32 choice) break; default: - l = strlen(setupm_ip); - if (l >= 16-1) + if (choice < 32 || choice > 127) // also allows letters to be typed in so hostnames can be used instead of an IP break; - if (choice == 46 || (choice >= 48 && choice <= 57)) // Rudimentary number and period enforcing + l = strlen(setupm_ip); + if (l < 28-1) { S_StartSound(NULL,sfx_menu1); // Tails setupm_ip[l] = (char)choice; setupm_ip[l+1] = 0; } - else if (choice >= 199 && choice <= 211 && choice != 202 && choice != 206) //numpad too! - { - char keypad_translation[] = {'7','8','9','-','4','5','6','+','1','2','3','0','.'}; - choice = keypad_translation[choice - 199]; - S_StartSound(NULL,sfx_menu1); // Tails - setupm_ip[l] = (char)choice; - setupm_ip[l+1] = 0; - } - break; } From ea13f606ca76a1dfa09e1c7ac394ded35dd1e7e2 Mon Sep 17 00:00:00 2001 From: ThatAwesomeGuy173 Date: Sat, 26 Jan 2019 02:41:05 -0700 Subject: [PATCH 2/3] I accidentally the numpad also reduced the range of usable characters --- src/m_menu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 9d230a135..1e7f07b2e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7959,16 +7959,25 @@ static void M_HandleConnectIP(INT32 choice) break; default: - if (choice < 32 || choice > 127) // also allows letters to be typed in so hostnames can be used instead of an IP + l = strlen(setupm_ip); + if (l >= 28-1) break; - l = strlen(setupm_ip); - if (l < 28-1) + // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead + if ((choice >= 45 && choice <= 58) || (choice >= 65 && choice <= 90) || (choice >= 97 && choice <= 122)) { S_StartSound(NULL,sfx_menu1); // Tails setupm_ip[l] = (char)choice; setupm_ip[l+1] = 0; } + else if (choice >= 199 && choice <= 211 && choice != 202 && choice != 206) //numpad too! + { + char keypad_translation[] = {'7','8','9','-','4','5','6','+','1','2','3','0','.'}; + choice = keypad_translation[choice - 199]; + S_StartSound(NULL,sfx_menu1); // Tails + setupm_ip[l] = (char)choice; + setupm_ip[l+1] = 0; + } break; } From f12f154f87d1e72c49ddf1a3825c6b54f11a8357 Mon Sep 17 00:00:00 2001 From: ThatAwesomeGuy173 Date: Sat, 26 Jan 2019 14:15:37 -0700 Subject: [PATCH 3/3] Use actual characters instead of ASCII codes as per Sryder's suggestion --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 1e7f07b2e..f0831a172 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7964,7 +7964,7 @@ static void M_HandleConnectIP(INT32 choice) break; // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead - if ((choice >= 45 && choice <= 58) || (choice >= 65 && choice <= 90) || (choice >= 97 && choice <= 122)) + if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z')) { S_StartSound(NULL,sfx_menu1); // Tails setupm_ip[l] = (char)choice;