Skip to content

Conversation

@Hamood-bot
Copy link

Description

Adds chat message prefixes to improve in-game communication clarity:

  • [All] prefix for messages sent to all players
  • [Observers] prefix for observer chat
  • No prefix for allies-only messages (cleaner display)

Changes

  • Modified ConnectionManager::processChat() in both Generals and GeneralsMD
  • Analyzes the player mask to determine message scope
  • Checks player relationships to distinguish between All and Allies chat

Behavior

  • Allies chat: [PlayerName] message (no prefix)
  • All chat: [All] [PlayerName] messagen- **Observer chat**: [Observers] [PlayerName] messagen
    This follows the convention used in games like League of Legends and makes it immediately obvious whether a message was sent to everyone or just to your team.

Testing

  • Code compiles without errors
  • Logic properly distinguishes between chat types based on recipient mask
  • Maintains compatibility with existing chat system

Adds [All] prefix for messages sent to all players and [Observers] prefix for observer chat. Allies-only messages show no prefix for cleaner display.

This improves chat clarity by making it immediately obvious when a message was sent to everyone versus just to allies, following the convention used in games like League of Legends.
return;
}

// TheSuperHackers @feature TheSuperHackers 31/10/2025 Add chat prefix to distinguish between All/Observers
Copy link

@bobtista bobtista Oct 31, 2025

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.

Copy link

@Stubbjax Stubbjax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use localisation keys and the appropriate TheGameText->fetch() calls.

@Stubbjax
Copy link

I think as global chat is typically considered the default, it makes more sense to prefix team messages rather than global messages.

Example:

[Player A] This is a global message
(TEAM) [Player B] This is a team message

There is an existing GUI:Team localisation key which would avoid data changes, though it would be a more hardcoded format. But seeing as the existing chat message format is hardcoded to [%ls] %ls, it might not be an issue to prepend (%ls) for team messages. Ideally we eventually have localisation keys that specify the formats for each type of chat message.

// Team message format
unitext.format(L"(ls) [%ls] %ls", TheGameText->fetch("GUI:Team"), name.str(), msg->getText().str());

It also seems unnecessary to prefix observer messages as fellow observers can easily deduce who is observing vs playing.

- 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
@Skyaero42
Copy link

Use TheGameText->FETCH_OR_SUBSTITUTE_FORMAT() if key may not be defined

}

// Team message: sent to allies only (not to all active players)
isTeamMessage = (activePlayers == alliesCount && alliesCount > 0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a complicated way to determine this is a team message. Can this be simplified?

Also this would be better as a standalone isTeamChat function, not embedded in ConnectionManager::processChat like this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay its no big deal will work on it later still in the process of understanding the code

…onManager::processChat() - Add isTeamChat helper and localized GUI:Team prefix
@Hamood-bot
Copy link
Author

WhatsApp Image 2025-10-31 at 17 22 41_5c9d103e

… for team/global messages in ConnectionManager::processChat - Use CHAT:TeamFormat and CHAT:GlobalFormat via FETCH_OR_SUBSTITUTE_FORMAT - Keep team detection with isTeamChat helper - Applied to both GeneralsMD and Generals versions
@Hamood-bot Hamood-bot force-pushed the feature/chat-message-prefixes branch from 5a10ff3 to a8a5138 Compare October 31, 2025 15:34
@Hamood-bot
Copy link
Author

Force-pushed to apply requested formatting / localization changes. Ready for re-review 👍

@Skyaero42 Skyaero42 added Enhancement Is new feature or request GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker labels Nov 1, 2025
Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a bit like this was coded with AI without after check. It needs another pass.

Also the post description doesnt match the code.

Up for discussion, i think all message should be marked, so All, Team and Observer

// Simplified team chat detection + localizable format via FETCH_OR_SUBSTITUTE_FORMAT()
// =============================================================

static Bool isTeamChat(const Player* sender, UInt32 mask)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions should not exist within other functions. Usr private functions in the class instead

Bool amIObserver = !ThePlayerList->getLocalPlayer()->isPlayerActive();
Bool canSeeChat = (amIObserver || !fromObserver) && !TheGameInfo->getConstSlot(playerID)->isMuted();
// =============================================================
// ConnectionManager::processChat()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit too much written by AI without a human checking the result.

Comment is incorrect, because it is not a refactor but a feature or enhancment.

Int allies = 0;
Int recipients = 0;

for (Int i = 0; i < MAX_SLOTS; ++i)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants