From d34d90b78b9c72fd5414462f25e8f6c517d31aee Mon Sep 17 00:00:00 2001
From: LJ Sonic <lamr@free.fr>
Date: Wed, 16 Nov 2022 10:21:39 +0100
Subject: [PATCH] Enable reverse-iterating through viewpoints with shift+F12

---
 src/g_game.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/g_game.c b/src/g_game.c
index c6d749feef..5b39857500 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1978,9 +1978,9 @@ static boolean ViewpointSwitchResponder(event_t *ev)
 	// spy mode
 	do
 	{
-		displayplayer++;
-		if (displayplayer == MAXPLAYERS)
-			displayplayer = 0;
+		// Wrap in both directions
+		displayplayer += shiftdown ? -1 : 1;
+		displayplayer = (displayplayer + MAXPLAYERS) % MAXPLAYERS;
 
 		if (!playeringame[displayplayer])
 			continue;
-- 
GitLab