refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
// MacroEvaluator — WoW macro conditional parser and evaluator.
|
|
|
|
|
// Extracted from evaluateMacroConditionals() in chat_panel_commands.cpp.
|
|
|
|
|
// Phase 4.4 of chat_panel_ref.md.
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace wowee {
|
2026-04-12 15:46:03 +03:00
|
|
|
namespace game { class GameHandler; }
|
refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
|
|
class IGameState;
|
|
|
|
|
class IModifierState;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Evaluates WoW-style macro conditional expressions.
|
|
|
|
|
*
|
|
|
|
|
* Syntax: [cond1,cond2] Spell1; [cond3] Spell2; DefaultSpell
|
|
|
|
|
*
|
|
|
|
|
* The first alternative whose conditions all evaluate true is returned.
|
|
|
|
|
* If no conditions match, returns "".
|
|
|
|
|
*
|
|
|
|
|
* @p targetOverride is set to a specific GUID if [target=X] or [@X]
|
|
|
|
|
* was in the matching conditions, or left as UINT64_MAX for "use normal target".
|
|
|
|
|
*/
|
|
|
|
|
class MacroEvaluator {
|
|
|
|
|
public:
|
|
|
|
|
MacroEvaluator(IGameState& gameState, IModifierState& modState);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Evaluate a macro conditional string.
|
|
|
|
|
* @param rawArg The conditional text (e.g. "[combat] Spell1; Spell2")
|
|
|
|
|
* @param targetOverride Output: set to target GUID if specified, or -1
|
|
|
|
|
* @return The matched argument text, or "" if nothing matched
|
|
|
|
|
*/
|
|
|
|
|
std::string evaluate(const std::string& rawArg, uint64_t& targetOverride) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/** Evaluate a single condition token (e.g. "combat", "mod:shift", "@focus"). */
|
|
|
|
|
bool evalCondition(const std::string& cond, uint64_t& tgt) const;
|
|
|
|
|
|
|
|
|
|
/** Resolve effective target GUID (follows @/target= overrides). */
|
|
|
|
|
uint64_t resolveEffectiveTarget(uint64_t tgt) const;
|
|
|
|
|
|
|
|
|
|
IGameState& gameState_;
|
|
|
|
|
IModifierState& modState_;
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-12 15:46:03 +03:00
|
|
|
// Convenience free function — thin wrapper over MacroEvaluator.
|
|
|
|
|
// Used by command modules (combat_commands, system_commands, target_commands).
|
|
|
|
|
std::string evaluateMacroConditionals(const std::string& rawArg,
|
|
|
|
|
game::GameHandler& gameHandler,
|
|
|
|
|
uint64_t& targetOverride);
|
|
|
|
|
|
refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
} // namespace ui
|
|
|
|
|
} // namespace wowee
|