From 87ba3411a43125a26502f96287691052dfa35122 Mon Sep 17 00:00:00 2001
From: toasterbabe <rollerorbital@gmail.com>
Date: Sat, 18 Mar 2017 00:41:40 +0000
Subject: [PATCH] * Fixes forceskin causing desynchronisations, baby! Checks
 only when attempting to send.

* Makes the forceskin print more consistent with the skin print.

* Disabled the printing of availabilities.
---
 src/command.c  | 16 +++++++++++-----
 src/d_netcmd.c |  2 +-
 src/r_things.c |  1 -
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/command.c b/src/command.c
index ad576b54c..412b75e32 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1361,6 +1361,16 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
 			return;
 		}
 
+		if (var == &cv_forceskin)
+		{
+			INT32 skin = R_SkinAvailable(value);
+			if ((stricmp(value, "None")) && ((skin == -1) || !R_SkinUnlock(-1, skin)))
+			{
+				CONS_Printf("Please provide a valid skin name (\"None\" disables).\n");
+				return;
+			}
+		}
+
 		// Only add to netcmd buffer if in a netgame, otherwise, just change it.
 		if (netgame || multiplayer)
 		{
@@ -1407,12 +1417,8 @@ static void CV_SetValueMaybeStealth(consvar_t *var, INT32 value, boolean stealth
 
 	if (var == &cv_forceskin) // Special handling.
 	{
-		if ((server || adminplayer == consoleplayer) && ((value < 0) || (value >= numskins) || !(R_SkinUnlock(-1, cv_forceskin.value))))
-		{
-			CONS_Printf("Please provide a valid skin name (\"None\" disables).\n");
+		if ((value < 0) || (value >= numskins))
 			sprintf(val, "None");
-			value = -1;
-		}
 		else
 			sprintf(val, "%s", skins[value].name);
 	}
diff --git a/src/d_netcmd.c b/src/d_netcmd.c
index 1220b77af..51b9e28ca 100644
--- a/src/d_netcmd.c
+++ b/src/d_netcmd.c
@@ -4056,7 +4056,7 @@ static void ForceSkin_OnChange(void)
 		CONS_Printf("The server has lifted the forced skin restrictions.\n");
 	else
 	{
-		CONS_Printf("The server is restricting all players to skin \"%s\".\n",skins[cv_forceskin.value].realname);
+		CONS_Printf("The server is restricting all players to skin \"%s\".\n",skins[cv_forceskin.value].name);
 		ForceAllSkins(cv_forceskin.value);
 	}
 }
diff --git a/src/r_things.c b/src/r_things.c
index 520dae30e..5280db73a 100644
--- a/src/r_things.c
+++ b/src/r_things.c
@@ -2622,7 +2622,6 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
 	player_t *player = &players[playernum];
 	skin_t *skin = &skins[skinnum];
 	UINT8 newcolor = 0;
-	CONS_Printf("%d - %d\n", playernum, player->availabilities);
 
 	if (skinnum >= 0 && skinnum < numskins && R_SkinUnlock(playernum, skinnum)) // Make sure it exists!
 	{