Skip to content

Commit 61a85a7

Browse files
committed
refactor: Use localization for team chat prefix and reverse logic
- Changed from prefixing global/observer messages to prefixing team messages - Global messages now have no prefix (default behavior) - Team messages are prefixed with (TEAM) using GUI:Team localization key - Removed observer message prefix as it's unnecessary - Used TheGameText->FETCH_OR_SUBSTITUTE() for proper localization support - Format: Global chat: '[Player Name] Message' - Format: Team chat: '(TEAM) [Player Name] Message' - Applied changes to both GeneralsMD and Generals codebases
1 parent 4f792db commit 61a85a7

File tree

2 files changed

+34
-38
lines changed

2 files changed

+34
-38
lines changed

Generals/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -630,18 +630,13 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg)
630630
return;
631631
}
632632

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;
633+
// TheSuperHackers @feature TheSuperHackers 31/10/2025 Add team chat prefix to distinguish from global messages
634+
// Global chat has no prefix (default), team messages are prefixed with (TEAM)
635+
Bool isTeamMessage = FALSE;
636636
Bool fromObserver = !player->isPlayerActive();
637637
const Player *localPlayer = ThePlayerList->getLocalPlayer();
638638

639-
if (fromObserver)
640-
{
641-
// Message from an observer
642-
chatPrefix = L"[Observers] ";
643-
}
644-
else
639+
if (player->isPlayerActive())
645640
{
646641
// Count how many active (non-observer) players receive this message
647642
Int activePlayers = 0;
@@ -669,18 +664,21 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg)
669664
}
670665
}
671666

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-
}
667+
// Team message: sent to allies only (not to all active players)
668+
isTeamMessage = (activePlayers == alliesCount && alliesCount > 0);
681669
}
682670

683-
unitext.format(L"%ls[%ls] %ls", chatPrefix.str(), name.str(), msg->getText().str());
671+
if (isTeamMessage)
672+
{
673+
// Format: (TEAM) [Player Name] Message
674+
UnicodeString teamPrefix = TheGameText->FETCH_OR_SUBSTITUTE("GUI:Team", L"TEAM");
675+
unitext.format(L"(%ls) [%ls] %ls", teamPrefix.str(), name.str(), msg->getText().str());
676+
}
677+
else
678+
{
679+
// Format: [Player Name] Message (no prefix for global/observer chat)
680+
unitext.format(L"[%ls] %ls", name.str(), msg->getText().str());
681+
}
684682
// DEBUG_LOG(("ConnectionManager::processChat - got message from player %d (mask %8.8X), message is %ls", playerID, msg->getPlayerMask(), unitext.str()));
685683

686684
Bool amIObserver = !localPlayer->isPlayerActive();

GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -630,18 +630,13 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg)
630630
return;
631631
}
632632

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;
633+
// TheSuperHackers @feature TheSuperHackers 31/10/2025 Add team chat prefix to distinguish from global messages
634+
// Global chat has no prefix (default), team messages are prefixed with (TEAM)
635+
Bool isTeamMessage = FALSE;
636636
Bool fromObserver = !player->isPlayerActive();
637637
const Player *localPlayer = ThePlayerList->getLocalPlayer();
638638

639-
if (fromObserver)
640-
{
641-
// Message from an observer
642-
chatPrefix = L"[Observers] ";
643-
}
644-
else
639+
if (player->isPlayerActive())
645640
{
646641
// Count how many active (non-observer) players receive this message
647642
Int activePlayers = 0;
@@ -669,18 +664,21 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg)
669664
}
670665
}
671666

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-
}
667+
// Team message: sent to allies only (not to all active players)
668+
isTeamMessage = (activePlayers == alliesCount && alliesCount > 0);
681669
}
682670

683-
unitext.format(L"%ls[%ls] %ls", chatPrefix.str(), name.str(), msg->getText().str());
671+
if (isTeamMessage)
672+
{
673+
// Format: (TEAM) [Player Name] Message
674+
UnicodeString teamPrefix = TheGameText->FETCH_OR_SUBSTITUTE("GUI:Team", L"TEAM");
675+
unitext.format(L"(%ls) [%ls] %ls", teamPrefix.str(), name.str(), msg->getText().str());
676+
}
677+
else
678+
{
679+
// Format: [Player Name] Message (no prefix for global/observer chat)
680+
unitext.format(L"[%ls] %ls", name.str(), msg->getText().str());
681+
}
684682
// DEBUG_LOG(("ConnectionManager::processChat - got message from player %d (mask %8.8X), message is %ls", playerID, msg->getPlayerMask(), unitext.str()));
685683

686684
Bool amIObserver = !localPlayer->isPlayerActive();

0 commit comments

Comments
 (0)