From 689ae61b2446d8311b0bc528aa96af3696e8cd67 Mon Sep 17 00:00:00 2001
From: past-due <30942300+past-due@users.noreply.github.com>
Date: Fri, 27 Oct 2023 17:06:29 -0400
Subject: [PATCH] quickchat: Tweaks

---
 src/hci/quickchat.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/hci/quickchat.cpp b/src/hci/quickchat.cpp
index bbf63009fc7..57ff13c097f 100644
--- a/src/hci/quickchat.cpp
+++ b/src/hci/quickchat.cpp
@@ -2819,6 +2819,7 @@ void sendQuickChat(WzQuickChatMessage message, uint32_t fromPlayer, WzQuickChatT
 	bool isInGame = (GetGameMode() == GS_NORMAL);
 	auto senderTeam = checkedGetPlayerTeam(fromPlayer);
 	bool senderIsSpectator = NetPlay.players[fromPlayer].isSpectator;
+	bool senderCanUseSecuredMessages = realSelectedPlayer == NetPlay.hostPlayer || realSelectedPlayer < MAX_PLAYERS; // non-host spectator slots don't currently support / send secured messages
 
 	auto isPotentiallyValidTarget = [&](uint32_t playerIdx) -> bool {
 		if (playerIdx == fromPlayer)
@@ -2921,7 +2922,7 @@ void sendQuickChat(WzQuickChatMessage message, uint32_t fromPlayer, WzQuickChatT
 		}
 
 		NETQUEUE queue = NETnetQueue((recipient < MAX_PLAYERS) ? whosResponsible(recipient) : recipient);
-		bool sendSecured = isInGame && (queue.index == NetPlay.hostPlayer || queue.index < MAX_PLAYERS);
+		bool sendSecured = isInGame && (queue.index == NetPlay.hostPlayer || queue.index < MAX_PLAYERS) && senderCanUseSecuredMessages;
 		if (sendSecured)
 		{
 			if (!NETbeginEncodeSecured(queue, NET_QUICK_CHAT_MSG))
@@ -2972,7 +2973,8 @@ void sendQuickChat(WzQuickChatMessage message, uint32_t fromPlayer, WzQuickChatT
 bool recvQuickChat(NETQUEUE queue)
 {
 	bool isInGame = (GetGameMode() == GS_NORMAL);
-	bool expectingSecuredMessage = isInGame && (realSelectedPlayer == NetPlay.hostPlayer || realSelectedPlayer < MAX_PLAYERS); // spectators do not expect secured messages
+	bool senderCanUseSecuredMessages = queue.index == NetPlay.hostPlayer || queue.index < MAX_PLAYERS;
+	bool expectingSecuredMessage = isInGame && (realSelectedPlayer == NetPlay.hostPlayer || realSelectedPlayer < MAX_PLAYERS) && senderCanUseSecuredMessages; // spectator slots do not expect secured messages
 
 	uint32_t sender = MAX_CONNECTED_PLAYERS;
 	uint32_t recipient = MAX_CONNECTED_PLAYERS;