From 512435c59f2d31c8b892a5838a83df3db620c56d Mon Sep 17 00:00:00 2001
From: Louis-Antoine <lamr@free.fr>
Date: Sat, 18 Jan 2020 20:18:20 +0100
Subject: [PATCH 01/17] Fix mouse in controls setup menu

---
 src/m_menu.c      |  6 ++++++
 src/m_menu.h      |  3 +++
 src/sdl/i_video.c | 22 ++++++++++++++++------
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/m_menu.c b/src/m_menu.c
index 0d19a6a43..f8c14dd69 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -3645,6 +3645,12 @@ void M_SetupNextMenu(menu_t *menudef)
 	hidetitlemap = false;
 }
 
+// Guess I'll put this here, idk
+boolean M_MouseNeeded(void)
+{
+	return (currentMenu == &MessageDef && currentMenu->prevMenu == &OP_ChangeControlsDef);
+}
+
 //
 // M_Ticker
 //
diff --git a/src/m_menu.h b/src/m_menu.h
index 3504868c9..3d7fb3b1c 100644
--- a/src/m_menu.h
+++ b/src/m_menu.h
@@ -320,6 +320,9 @@ typedef struct menu_s
 void M_SetupNextMenu(menu_t *menudef);
 void M_ClearMenus(boolean callexitmenufunc);
 
+// Maybe this goes here????? Who knows.
+boolean M_MouseNeeded(void);
+
 extern menu_t *currentMenu;
 
 extern menu_t MainDef;
diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c
index 2b8633e5b..13e2423c4 100644
--- a/src/sdl/i_video.c
+++ b/src/sdl/i_video.c
@@ -110,7 +110,6 @@ 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 MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menuactive && !USE_FULLSCREEN)
 #define MOUSEBUTTONS_MAX MOUSEBUTTONS
 
@@ -362,6 +361,17 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
 	return 0;
 }
 
+static boolean IgnoreMouse(void)
+{
+	if (cv_alwaysgrabmouse.value)
+		return false;
+	if (menuactive)
+		return !M_MouseNeeded();
+	if (paused || con_destlines || chat_on || gamestate != GS_LEVEL)
+		return true;
+	return false;
+}
+
 static void SDLdoGrabMouse(void)
 {
 	SDL_ShowCursor(SDL_DISABLE);
@@ -388,7 +398,7 @@ void I_UpdateMouseGrab(void)
 {
 	if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO && window != NULL
 	&& SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window
-	&& USE_MOUSEINPUT && !IGNORE_MOUSE)
+	&& USE_MOUSEINPUT && !IgnoreMouse())
 		SDLdoGrabMouse();
 }
 
@@ -596,7 +606,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
 		}
 		//else firsttimeonmouse = SDL_FALSE;
 
-		if (USE_MOUSEINPUT && !IGNORE_MOUSE)
+		if (USE_MOUSEINPUT && !IgnoreMouse())
 			SDLdoGrabMouse();
 	}
 	else if (!mousefocus && !kbfocus)
@@ -647,7 +657,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
 
 	if (USE_MOUSEINPUT)
 	{
-		if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window) || (IGNORE_MOUSE && !firstmove))
+		if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window) || (IgnoreMouse() && !firstmove))
 		{
 			SDLdoUngrabMouse();
 			firstmove = false;
@@ -700,7 +710,7 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
 	// this apparently makes a mouse button down event but not a mouse button up event,
 	// resulting in whatever key was pressed down getting "stuck" if we don't ignore it.
 	// -- Monster Iestyn (28/05/18)
-	if (SDL_GetMouseFocus() != window || IGNORE_MOUSE)
+	if (SDL_GetMouseFocus() != window || IgnoreMouse())
 		return;
 
 	/// \todo inputEvent.button.which
@@ -1082,7 +1092,7 @@ void I_StartupMouse(void)
 	}
 	else
 		firsttimeonmouse = SDL_FALSE;
-	if (cv_usemouse.value && !IGNORE_MOUSE)
+	if (cv_usemouse.value && !IgnoreMouse())
 		SDLdoGrabMouse();
 	else
 		SDLdoUngrabMouse();

From c1097813f47f717a63b687a670f5e090308b6b52 Mon Sep 17 00:00:00 2001
From: Zwip-Zwap Zapony <ZwipZwapZapony@gmail.com>
Date: Mon, 20 Jan 2020 16:14:20 +0100
Subject: [PATCH 02/17] Fix "cam2_turnmultiplier"

In splitscreen stuff, player 2's "cam2_turnmultiplier" implementation
was wrong compared to player 1's "cam_turnmultiplier"
This commit makes player 2's multiplier work just like player 1's does
---
 src/g_game.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/g_game.c b/src/g_game.c
index a80d0f40a..0bec68d6e 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1497,9 +1497,9 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
 	else
 	{
 		if (turnright)
-			cmd->angleturn = (INT16)(cmd->angleturn - (((angleturn[tspeed]<<FRACBITS) * cv_cam2_turnmultiplier.value)>>FRACBITS));
+			cmd->angleturn = (INT16)(cmd->angleturn - ((angleturn[tspeed] * cv_cam2_turnmultiplier.value)>>FRACBITS));
 		else if (turnleft)
-			cmd->angleturn = (INT16)(cmd->angleturn + (((angleturn[tspeed]<<FRACBITS) * cv_cam2_turnmultiplier.value)>>FRACBITS));
+			cmd->angleturn = (INT16)(cmd->angleturn + ((angleturn[tspeed] * cv_cam2_turnmultiplier.value)>>FRACBITS));
 
 		if (analogjoystickmove && lookjoystickvector.xaxis != 0)
 		{

From c347254e8005b7d9aba5bea4290dded68b5a8a93 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Tue, 21 Jan 2020 03:20:50 -0800
Subject: [PATCH 03/17] Reorder Sonic's ass so the OpenGL wipe doesn't see
 garbage

---
 src/d_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/d_main.c b/src/d_main.c
index 2432c5e9e..74547f9f7 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -651,8 +651,12 @@ void D_SRB2Loop(void)
 	// hack to start on a nice clear console screen.
 	COM_ImmedExecute("cls;version");
 
-	V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(W_GetNumForName("CONSBACK"), PU_CACHE));
 	I_FinishUpdate(); // page flip or blit buffer
+	/*
+	LMFAO this was showing garbage under OpenGL
+	because I_FinishUpdate was called afterward
+	*/
+	V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(W_GetNumForName("CONSBACK"), PU_CACHE));
 
 	for (;;)
 	{

From f297f4ff5636cbf081b7991875b563dc06eef3d1 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Tue, 21 Jan 2020 03:28:33 -0800
Subject: [PATCH 04/17] Sonic is dead again

---
 src/d_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/d_main.c b/src/d_main.c
index 74547f9f7..32972c151 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -656,7 +656,9 @@ void D_SRB2Loop(void)
 	LMFAO this was showing garbage under OpenGL
 	because I_FinishUpdate was called afterward
 	*/
-	V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(W_GetNumForName("CONSBACK"), PU_CACHE));
+	/* Smells like a hack... Don't fade Sonic's ass into the title screen. */
+	if (gamestate != GS_TITLESCREEN)
+		V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(W_GetNumForName("CONSBACK"), PU_CACHE));
 
 	for (;;)
 	{

From 9cd101c68ddb9618e215e2f4c6dff90c7d1b6a9d Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Tue, 21 Jan 2020 14:55:50 -0800
Subject: [PATCH 05/17] Revert "Fix Ploadflat closing the game with "Too many
 flats in level" error message"

This reverts commit ea129f701c86f87daa7355e6f031d0633951cdfa.
---
 src/p_setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/p_setup.c b/src/p_setup.c
index 42a6438a0..9a270d2f3 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -672,7 +672,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat)
 //
 INT32 P_AddLevelFlatRuntime(const char *flatname)
 {
-	return Ploadflat(levelflats, flatname);
+	return Ploadflat(0, flatname);
 }
 
 // help function for $$$.sav checking

From d90c0b8fbd0e122073b5a8adba09db832a39daf7 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Tue, 21 Jan 2020 15:11:16 -0800
Subject: [PATCH 06/17] Don't check "Too many flats in level" with
 P_AddLevelFlatRuntime

Also moved the debug down in case anyone uses that.
---
 src/p_setup.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/p_setup.c b/src/p_setup.c
index 9a270d2f3..9b5b7e5c2 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -585,15 +585,11 @@ Ploadflat (levelflat_t *levelflat, const char *flatname)
 			if (strnicmp(levelflat[i].name, flatname, 8) == 0)
 				return i;
 		}
+
+		if (numlevelflats >= MAXLEVELFLATS)
+			I_Error("Too many flats in level\n");
 	}
 
-#ifndef ZDEBUG
-	CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
-#endif
-
-	if (numlevelflats >= MAXLEVELFLATS)
-		I_Error("Too many flats in level\n");
-
 	if (levelflat)
 		levelflat += numlevelflats;
 	else
@@ -656,6 +652,10 @@ flatfound:
 		levelflat->u.flat.baselumpnum = LUMPERROR;
 	}
 
+#ifndef ZDEBUG
+	CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
+#endif
+
 	return ( numlevelflats++ );
 }
 

From 2373a0aa8308816e2e6037fea736bf58a116b4dc Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Tue, 21 Jan 2020 16:47:47 -0800
Subject: [PATCH 07/17] Actually actually match the old behavior and check
 existing levelflats in P_AddLevelFlatRuntime BRUH

---
 src/p_setup.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/p_setup.c b/src/p_setup.c
index 9b5b7e5c2..132684163 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -566,7 +566,7 @@ levelflat refers to an array of level flats,
 or NULL if we want to allocate it now.
 */
 static INT32
-Ploadflat (levelflat_t *levelflat, const char *flatname)
+Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize)
 {
 #ifndef NO_PNG_LUMPS
 	UINT8         buffer[8];
@@ -577,27 +577,26 @@ Ploadflat (levelflat_t *levelflat, const char *flatname)
 
 	size_t i;
 
-	if (levelflat)
+	// Scan through the already found flats, return if it matches.
+	for (i = 0; i < numlevelflats; i++)
 	{
-		// Scan through the already found flats, return if it matches.
-		for (i = 0; i < numlevelflats; i++)
-		{
-			if (strnicmp(levelflat[i].name, flatname, 8) == 0)
-				return i;
-		}
-
-		if (numlevelflats >= MAXLEVELFLATS)
-			I_Error("Too many flats in level\n");
+		if (strnicmp(levelflat[i].name, flatname, 8) == 0)
+			return i;
 	}
 
-	if (levelflat)
-		levelflat += numlevelflats;
-	else
+	if (resize)
 	{
 		// allocate new flat memory
 		levelflats = Z_Realloc(levelflats, (numlevelflats + 1) * sizeof(*levelflats), PU_LEVEL, NULL);
 		levelflat  = levelflats + numlevelflats;
 	}
+	else
+	{
+		if (numlevelflats >= MAXLEVELFLATS)
+			I_Error("Too many flats in level\n");
+
+		levelflat += numlevelflats;
+	}
 
 	// Store the name.
 	strlcpy(levelflat->name, flatname, sizeof (levelflat->name));
@@ -663,7 +662,7 @@ flatfound:
 // allocate an id for it, and set the levelflat (to speedup search)
 INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat)
 {
-	return Ploadflat(levelflat, flatname);
+	return Ploadflat(levelflat, flatname, false);
 }
 
 // help function for Lua and $$$.sav reading
@@ -672,7 +671,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat)
 //
 INT32 P_AddLevelFlatRuntime(const char *flatname)
 {
-	return Ploadflat(0, flatname);
+	return Ploadflat(levelflats, flatname, true);
 }
 
 // help function for $$$.sav checking

From f0daea39d43d1a3cd54385474dd6c27e65da2e4c Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Wed, 22 Jan 2020 22:19:00 -0800
Subject: [PATCH 08/17] Don't set controls to keys out of array bounds

Shout-out to TAG's config that somehow had
`setcontrol2 "custom3" "KEY931926528"`, cuasing the game to crash only in
Splitscreen.
---
 src/g_input.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/g_input.c b/src/g_input.c
index ac901703f..2efae9cf3 100644
--- a/src/g_input.c
+++ b/src/g_input.c
@@ -662,7 +662,14 @@ INT32 G_KeyStringtoNum(const char *keystr)
 		return keystr[0];
 
 	if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9')
-		return atoi(&keystr[3]);
+	{
+		/* what if we out of range bruh? */
+		j = atoi(&keystr[3]);
+		if (j < NUMINPUTS)
+			return j;
+		else
+			return 0;
+	}
 
 	for (j = 0; j < NUMKEYNAMES; j++)
 		if (!stricmp(keynames[j].name, keystr))

From 3d9466e5f550a8d11da4989f62e32eb0ea888c11 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 13:57:39 -0800
Subject: [PATCH 09/17] Semantics

---
 src/g_input.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/g_input.c b/src/g_input.c
index 2efae9cf3..ed7bc5cb6 100644
--- a/src/g_input.c
+++ b/src/g_input.c
@@ -667,8 +667,7 @@ INT32 G_KeyStringtoNum(const char *keystr)
 		j = atoi(&keystr[3]);
 		if (j < NUMINPUTS)
 			return j;
-		else
-			return 0;
+		return 0;
 	}
 
 	for (j = 0; j < NUMKEYNAMES; j++)

From c3f42859882e6a1a789668d9b78d1310dd5e7312 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 18:01:59 -0800
Subject: [PATCH 10/17] Put branch name and commit hash in EXENAME for AppVeyor
 builds

srb2win-master-a6d49eaaa70be5f88c26623c7b4a2fa5a770341e.exe
---
 appveyor.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/appveyor.yml b/appveyor.yml
index 6b80b4ec3..cc77f102e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -83,7 +83,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 NOOBJDUMP=1 %NOUPX%"
+- set "EXENAME=EXENAME=srb2win-%APPVEYOR_REPO_BRANCH%-%APPVEYOR_REPO_COMMIT%.exe"
+- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
 - 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"
 

From d3315ae03c57296bfb5a7f9f5959492bdb7de24c Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 18:09:34 -0800
Subject: [PATCH 11/17] Put the abbreviated commit hash in the EXENAME for
 AppVeyor

srb2win-master-a6d49eaaa.exe
---
 appveyor.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/appveyor.yml b/appveyor.yml
index cc77f102e..c4b5263e9 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -83,7 +83,9 @@ before_build:
 - ccache -V
 - ccache -s
 - if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
-- set "EXENAME=EXENAME=srb2win-%APPVEYOR_REPO_BRANCH%-%APPVEYOR_REPO_COMMIT%.exe"
+# get abbreviated (7 char) commit hash
+- set "COMMIT=%APPVEYOR_REPO_COMMIT:~0,7%"
+- set "EXENAME=EXENAME=srb2win-%APPVEYOR_REPO_BRANCH%-%COMMIT%.exe"
 - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
 - 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"

From b1d931d471bcf2ec9a40f6e7e52518807c5fd14b Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 18:55:25 -0800
Subject: [PATCH 12/17] Well I'm an idiot

---
 appveyor.yml | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index c4b5263e9..96bd6ce84 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -83,9 +83,9 @@ before_build:
 - ccache -V
 - ccache -s
 - if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
-# get abbreviated (7 char) commit hash
-- set "COMMIT=%APPVEYOR_REPO_COMMIT:~0,7%"
-- set "EXENAME=EXENAME=srb2win-%APPVEYOR_REPO_BRANCH%-%COMMIT%.exe"
+- cmd: git rev-parse --short %APPVEYOR_REPO_COMMIT%>%TMP%/gitshort.txt
+- cmd: set /P GITSHORT=<%TMP%/gitshort.txt
+- set "EXENAME=EXENAME=srb2win-%APPVEYOR_REPO_BRANCH%-%GITSHORT%.exe"
 - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
 - 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"
@@ -102,8 +102,6 @@ after_build:
   )
 - if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" )
 - ccache -s
-- cmd: git rev-parse --short %APPVEYOR_REPO_COMMIT%>%TMP%/gitshort.txt
-- cmd: set /P GITSHORT=<%TMP%/gitshort.txt
 - set BUILD_ARCHIVE=%APPVEYOR_REPO_BRANCH%-%GITSHORT%-%CONFIGURATION%.7z
 - set BUILDSARCHIVE=%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%.7z
 - cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore

From ef2febe1e01bc7c93f30d2063bfd754b1a79dd3a Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 19:58:26 -0800
Subject: [PATCH 13/17] Use the pull request repo, branch and commit

srb2win-jameds:appveyor-exename-b1d931d47.exe
---
 appveyor.yml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 96bd6ce84..543308306 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -83,9 +83,12 @@ before_build:
 - ccache -V
 - ccache -s
 - if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
-- cmd: git rev-parse --short %APPVEYOR_REPO_COMMIT%>%TMP%/gitshort.txt
+- if defined [%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%] ( set "COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%" ) else ( set "COMMIT=%APPVEYOR_REPO_COMMIT%" )
+- cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt
 - cmd: set /P GITSHORT=<%TMP%/gitshort.txt
-- set "EXENAME=EXENAME=srb2win-%APPVEYOR_REPO_BRANCH%-%GITSHORT%.exe"
+# for pull requests, take the owner's name only, if this isn't the same repo of course
+- if [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( set "REPO=%APPVEYOR_REPO_BRANCH" ) else ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a:%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH" )
+- set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
 - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
 - 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"

From 6337932190d68d6f825f4f5dd47a6f3655c88f16 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 20:13:57 -0800
Subject: [PATCH 14/17] I promise I know what I'm doing

---
 appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/appveyor.yml b/appveyor.yml
index 543308306..fac974c17 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -87,7 +87,7 @@ before_build:
 - cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt
 - cmd: set /P GITSHORT=<%TMP%/gitshort.txt
 # for pull requests, take the owner's name only, if this isn't the same repo of course
-- if [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( set "REPO=%APPVEYOR_REPO_BRANCH" ) else ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a:%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH" )
+- if [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( set "REPO=%APPVEYOR_REPO_BRANCH%" ) else ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a:%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" )
 - set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
 - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
 - if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" )

From e082553f6d3a90baf97e056ab6790ce136f502d0 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 20:34:26 -0800
Subject: [PATCH 15/17] Check if this actually is a PR before using those
 variables

---
 appveyor.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/appveyor.yml b/appveyor.yml
index fac974c17..51052ff6e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -87,7 +87,8 @@ before_build:
 - cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt
 - cmd: set /P GITSHORT=<%TMP%/gitshort.txt
 # for pull requests, take the owner's name only, if this isn't the same repo of course
-- if [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( set "REPO=%APPVEYOR_REPO_BRANCH%" ) else ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a:%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" )
+- set "REPO=%APPVEYOR_REPO_BRANCH%"
+- if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] (  for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a:%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) )
 - set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
 - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
 - if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" )

From 70cf119a8402607116b2f8fbb79028a2de0e8d96 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 20:35:53 -0800
Subject: [PATCH 16/17] Windows is dumb so no colon

srb2win-jameds-appveyor-exename-b1d931d47.exe
---
 appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/appveyor.yml b/appveyor.yml
index 51052ff6e..b111c8f28 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -88,7 +88,7 @@ before_build:
 - cmd: set /P GITSHORT=<%TMP%/gitshort.txt
 # for pull requests, take the owner's name only, if this isn't the same repo of course
 - set "REPO=%APPVEYOR_REPO_BRANCH%"
-- if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] (  for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a:%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) )
+- if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] (  for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) )
 - set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
 - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
 - if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" )

From 4304fe91e65845e3887935de046876b6313af9c9 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Thu, 23 Jan 2020 21:06:48 -0800
Subject: [PATCH 17/17] Name the archive like the EXE

---
 appveyor.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index b111c8f28..d33d3d3a3 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -106,8 +106,8 @@ after_build:
   )
 - if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" )
 - ccache -s
-- set BUILD_ARCHIVE=%APPVEYOR_REPO_BRANCH%-%GITSHORT%-%CONFIGURATION%.7z
-- set BUILDSARCHIVE=%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%.7z
+- set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z
+- set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z
 - cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore
 - appveyor PushArtifact %BUILD_ARCHIVE%
 - cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE%