forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Open
Hamood-bot
wants to merge
4
commits into
TheSuperHackers:main
Choose a base branch
from
Hamood-bot:feature/chat-message-prefixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4f792db
feat: Add chat prefixes to distinguish All and Observer messages
Hamood-bot 61a85a7
refactor: Use localization for team chat prefix and reverse logic
Hamood-bot 5626ae0
refactor: Mirror GeneralsMD team-chat refactor into Generals Connecti…
Hamood-bot a8a5138
refactor(chat): use FETCH_OR_SUBSTITUTE_FORMAT localized chat formats…
Hamood-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -619,20 +619,71 @@ 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 chat prefix to distinguish between All/Observers | ||
| // Allies chat has no prefix, only All and Observers are marked | ||
| UnicodeString chatPrefix; | ||
| Bool fromObserver = !player->isPlayerActive(); | ||
| Bool amIObserver = !ThePlayerList->getLocalPlayer()->isPlayerActive(); | ||
| const Player *localPlayer = ThePlayerList->getLocalPlayer(); | ||
|
|
||
| if (fromObserver) | ||
| { | ||
| // Message from an observer | ||
| chatPrefix = L"[Observers] "; | ||
| } | ||
| else | ||
| { | ||
| // Count how many active (non-observer) players receive this message | ||
| Int activePlayers = 0; | ||
| Int alliesCount = 0; | ||
|
|
||
| for (Int i = 0; i < MAX_SLOTS; ++i) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| { | ||
| 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++; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Only mark "All" chat, allies chat has no prefix | ||
| if (activePlayers > alliesCount) | ||
| { | ||
| chatPrefix = L"[All] "; | ||
| } | ||
| else | ||
| { | ||
| chatPrefix = L""; | ||
| } | ||
| } | ||
|
|
||
| unitext.format(L"%ls[%ls] %ls", chatPrefix.str(), 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 ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Are we using European date format d/m/yyyy or freedom date format m/d/yyyy?
Edit: Oh no, I've been using American, but I see a lot of European in the codebase.