-
Notifications
You must be signed in to change notification settings - Fork 119
feat: Add chat prefixes to distinguish All and Observer messages #1764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
4f792db
61a85a7
5626ae0
a8a5138
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -619,20 +619,69 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg) | |
| name = m_connections[playerID]->getUser()->GetName(); | ||
| //DEBUG_LOG(("connection is non-NULL, using %ls", name.str())); | ||
| } | ||
| unitext.format(L"[%ls] %ls", name.str(), msg->getText().str()); | ||
| // DEBUG_LOG(("ConnectionManager::processChat - got message from player %d (mask %8.8X), message is %ls", playerID, msg->getPlayerMask(), unitext.str())); | ||
|
|
||
| AsciiString playerName; | ||
| playerName.format("player%d", msg->getPlayerID()); | ||
| const Player *player = ThePlayerList->findPlayerWithNameKey( TheNameKeyGenerator->nameToKey( playerName ) ); | ||
| if (!player) | ||
| { | ||
| unitext.format(L"[%ls] %ls", name.str(), msg->getText().str()); | ||
| TheInGameUI->message(UnicodeString(L"%ls"), unitext.str()); | ||
| return; | ||
| } | ||
|
|
||
| // TheSuperHackers @feature TheSuperHackers 31/10/2025 Add team chat prefix to distinguish from global messages | ||
| // Global chat has no prefix (default), team messages are prefixed with (TEAM) | ||
| Bool isTeamMessage = FALSE; | ||
| Bool fromObserver = !player->isPlayerActive(); | ||
| Bool amIObserver = !ThePlayerList->getLocalPlayer()->isPlayerActive(); | ||
| const Player *localPlayer = ThePlayerList->getLocalPlayer(); | ||
|
|
||
| if (player->isPlayerActive()) | ||
| { | ||
| // Count how many active (non-observer) players receive this message | ||
| Int activePlayers = 0; | ||
| Int alliesCount = 0; | ||
|
|
||
| for (Int i = 0; i < MAX_SLOTS; ++i) | ||
| { | ||
| if ((1 << i) & msg->getPlayerMask()) | ||
| { | ||
| AsciiString checkPlayerName; | ||
| checkPlayerName.format("player%d", i); | ||
| const Player *checkPlayer = ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey(checkPlayerName)); | ||
|
|
||
| if (checkPlayer && checkPlayer->isPlayerActive()) | ||
| { | ||
| activePlayers++; | ||
|
|
||
| // Check if this recipient is an ally of the sender | ||
| if (player->getRelationship(checkPlayer->getDefaultTeam()) == ALLIES && | ||
| checkPlayer->getRelationship(player->getDefaultTeam()) == ALLIES) | ||
| { | ||
| alliesCount++; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Team message: sent to allies only (not to all active players) | ||
| isTeamMessage = (activePlayers == alliesCount && alliesCount > 0); | ||
|
||
| } | ||
|
|
||
| if (isTeamMessage) | ||
| { | ||
| // Format: (TEAM) [Player Name] Message | ||
| UnicodeString teamPrefix = TheGameText->FETCH_OR_SUBSTITUTE("GUI:Team", L"TEAM"); | ||
| unitext.format(L"(%ls) [%ls] %ls", teamPrefix.str(), name.str(), msg->getText().str()); | ||
| } | ||
| else | ||
| { | ||
| // Format: [Player Name] Message (no prefix for global/observer chat) | ||
| unitext.format(L"[%ls] %ls", name.str(), msg->getText().str()); | ||
| } | ||
| // DEBUG_LOG(("ConnectionManager::processChat - got message from player %d (mask %8.8X), message is %ls", playerID, msg->getPlayerMask(), unitext.str())); | ||
|
|
||
| Bool amIObserver = !localPlayer->isPlayerActive(); | ||
| Bool canSeeChat = (amIObserver || !fromObserver) && !TheGameInfo->getConstSlot(playerID)->isMuted(); | ||
|
|
||
| if ( ((1<<m_localSlot) & msg->getPlayerMask() ) && canSeeChat ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this is correct. You only need to verify the relationship between receiver and sender. Don't need to loop through all players for this.