@@ -619,20 +619,71 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg)
619619 name = m_connections[playerID]->getUser ()->GetName ();
620620 // DEBUG_LOG(("connection is non-NULL, using %ls", name.str()));
621621 }
622- unitext.format (L" [%ls] %ls" , name.str (), msg->getText ().str ());
623- // DEBUG_LOG(("ConnectionManager::processChat - got message from player %d (mask %8.8X), message is %ls", playerID, msg->getPlayerMask(), unitext.str()));
624622
625623 AsciiString playerName;
626624 playerName.format (" player%d" , msg->getPlayerID ());
627625 const Player *player = ThePlayerList->findPlayerWithNameKey ( TheNameKeyGenerator->nameToKey ( playerName ) );
628626 if (!player)
629627 {
628+ unitext.format (L" [%ls] %ls" , name.str (), msg->getText ().str ());
630629 TheInGameUI->message (UnicodeString (L" %ls" ), unitext.str ());
631630 return ;
632631 }
633632
633+ // TheSuperHackers @feature TheSuperHackers 31/10/2025 Add chat prefix to distinguish between All/Observers
634+ // Allies chat has no prefix, only All and Observers are marked
635+ UnicodeString chatPrefix;
634636 Bool fromObserver = !player->isPlayerActive ();
635- Bool amIObserver = !ThePlayerList->getLocalPlayer ()->isPlayerActive ();
637+ const Player *localPlayer = ThePlayerList->getLocalPlayer ();
638+
639+ if (fromObserver)
640+ {
641+ // Message from an observer
642+ chatPrefix = L" [Observers] " ;
643+ }
644+ else
645+ {
646+ // Count how many active (non-observer) players receive this message
647+ Int activePlayers = 0 ;
648+ Int alliesCount = 0 ;
649+
650+ for (Int i = 0 ; i < MAX_SLOTS; ++i)
651+ {
652+ if ((1 << i) & msg->getPlayerMask ())
653+ {
654+ AsciiString checkPlayerName;
655+ checkPlayerName.format (" player%d" , i);
656+ const Player *checkPlayer = ThePlayerList->findPlayerWithNameKey (TheNameKeyGenerator->nameToKey (checkPlayerName));
657+
658+ if (checkPlayer && checkPlayer->isPlayerActive ())
659+ {
660+ activePlayers++;
661+
662+ // Check if this recipient is an ally of the sender
663+ if (player->getRelationship (checkPlayer->getDefaultTeam ()) == ALLIES &&
664+ checkPlayer->getRelationship (player->getDefaultTeam ()) == ALLIES)
665+ {
666+ alliesCount++;
667+ }
668+ }
669+ }
670+ }
671+
672+ // Only mark "All" chat, allies chat has no prefix
673+ if (activePlayers > alliesCount)
674+ {
675+ chatPrefix = L" [All] " ;
676+ }
677+ else
678+ {
679+ chatPrefix = L" " ;
680+ }
681+ }
682+
683+ unitext.format (L" %ls[%ls] %ls" , chatPrefix.str (), name.str (), msg->getText ().str ());
684+ // DEBUG_LOG(("ConnectionManager::processChat - got message from player %d (mask %8.8X), message is %ls", playerID, msg->getPlayerMask(), unitext.str()));
685+
686+ Bool amIObserver = !localPlayer->isPlayerActive ();
636687 Bool canSeeChat = (amIObserver || !fromObserver) && !TheGameInfo->getConstSlot (playerID)->isMuted ();
637688
638689 if ( ((1 <<m_localSlot) & msg->getPlayerMask () ) && canSeeChat )
0 commit comments