From 4d8ca41e653d78a329d3f112d08f55019f237963 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Tue, 3 Jan 2017 22:43:46 +0000
Subject: [PATCH] Fix player colors mysteriously turning red if a resynch
 occurs outside of CTF/Team Match. Not technically a $$$.sav fix, but still
 netplay related of course

At least, I assume this is how it's happening for some, I haven't been able to get the full info since WHERE IS EVERYBODY?
---
 src/d_clisrv.c | 21 +++++----------------
 src/d_clisrv.h |  2 +-
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/d_clisrv.c b/src/d_clisrv.c
index 7e9dcf8efa..2a2d5fead8 100644
--- a/src/d_clisrv.c
+++ b/src/d_clisrv.c
@@ -868,12 +868,13 @@ static inline void resynch_write_others(resynchend_pak *rst)
 {
 	UINT8 i;
 
-	rst->ingame = rst->ctfteam = 0;
+	rst->ingame = 0;
 
 	for (i = 0; i < MAXPLAYERS; ++i)
 	{
 		if (!playeringame[i])
 		{
+			rst->ctfteam[i] = 0;
 			rst->score[i] = 0;
 			rst->numboxes[i] = 0;
 			rst->totalring[i] = 0;
@@ -883,11 +884,8 @@ static inline void resynch_write_others(resynchend_pak *rst)
 		}
 
 		if (!players[i].spectator)
-		{
 			rst->ingame |= (1<<i);
-			if (players[i].ctfteam > 1)
-				rst->ctfteam |= (1<<i);
-		}
+		rst->ctfteam[i] = (INT32)LONG(players[i].ctfteam);
 		rst->score[i] = (UINT32)LONG(players[i].score);
 		rst->numboxes[i] = SHORT(players[i].numboxes);
 		rst->totalring[i] = SHORT(players[i].totalring);
@@ -904,21 +902,12 @@ static inline void resynch_read_others(resynchend_pak *p)
 {
 	UINT8 i;
 	UINT32 loc_ingame = (UINT32)LONG(p->ingame);
-	UINT32 loc_ctfteam = (UINT32)LONG(p->ctfteam);
 
 	for (i = 0; i < MAXPLAYERS; ++i)
 	{
 		// We don't care if they're in the game or not, just write all the data.
-		if (loc_ingame & (1<<i))
-		{
-			players[i].spectator = false;
-			players[i].ctfteam = (loc_ctfteam & (1<<i)) ? 2 : 1;
-		}
-		else
-		{
-			players[i].spectator = true;
-			players[i].ctfteam = 0;
-		}
+		players[i].spectator = !(loc_ingame & i<<i);
+		players[i].ctfteam = (INT32)LONG(p->ctfteam[i]); // no, 0 does not mean spectator, at least not in Match
 		players[i].score = (UINT32)LONG(p->score[i]);
 		players[i].numboxes = SHORT(p->numboxes[i]);
 		players[i].totalring = SHORT(p->totalring[i]);
diff --git a/src/d_clisrv.h b/src/d_clisrv.h
index fe80be1be5..02a0373875 100644
--- a/src/d_clisrv.h
+++ b/src/d_clisrv.h
@@ -133,7 +133,7 @@ typedef struct
 	fixed_t flagz[2];
 
 	UINT32 ingame;  // Spectator bit for each player
-	UINT32 ctfteam; // If not spectator, then which team?
+	INT32 ctfteam[MAXPLAYERS]; // Which team? (can't be 1 bit, since in regular Match there are no teams)
 
 	// Resynch game scores and the like all at once
 	UINT32 score[MAXPLAYERS]; // Everyone's score
-- 
GitLab