refactor(game): split GameHandler into domain handlers
Extract domain-specific logic from the monolithic GameHandler into
dedicated handler classes, each owning its own opcode registration,
state, and packet parsing:
- CombatHandler: combat, XP, kill, PvP, loot roll (~26 methods)
- SpellHandler: spells, auras, pet stable, talent (~3+ methods)
- SocialHandler: friends, guild, groups, BG, RAF, PvP AFK (~14+ methods)
- ChatHandler: chat messages, channels, GM tickets, server messages,
defense/area-trigger messages (~7+ methods)
- InventoryHandler: items, trade, loot, mail, vendor, equipment sets,
read item (~3+ methods)
- QuestHandler: gossip, quests, completed quest response (~5+ methods)
- MovementHandler: movement, follow, transport (~2 methods)
- WardenHandler: Warden anti-cheat module
Each handler registers its own dispatch table entries via
registerOpcodes(DispatchTable&), called from
GameHandler::registerOpcodeHandlers(). GameHandler retains core
orchestration: auth/session handshake, update-object parsing,
opcode routing, and cross-handler coordination.
game_handler.cpp reduced from ~10,188 to ~9,432 lines.
Also add a POST_BUILD CMake step to symlink Data/ next to the
executable so expansion profiles and opcode tables are found at
runtime when running from build/bin/.
2026-03-28 09:42:37 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "game/expansion_profile.hpp"
|
|
|
|
|
#include "core/application.hpp"
|
|
|
|
|
|
|
|
|
|
namespace wowee {
|
|
|
|
|
namespace game {
|
|
|
|
|
|
|
|
|
|
inline bool isActiveExpansion(const char* expansionId) {
|
|
|
|
|
auto& app = core::Application::getInstance();
|
|
|
|
|
auto* registry = app.getExpansionRegistry();
|
|
|
|
|
if (!registry) return false;
|
|
|
|
|
auto* profile = registry->getActive();
|
|
|
|
|
if (!profile) return false;
|
|
|
|
|
return profile->id == expansionId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool isClassicLikeExpansion() {
|
|
|
|
|
return isActiveExpansion("classic") || isActiveExpansion("turtle");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool isPreWotlk() {
|
|
|
|
|
return isClassicLikeExpansion() || isActiveExpansion("tbc");
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 17:57:05 -07:00
|
|
|
// Shared item link formatter used by inventory, quest, spell, and social handlers.
|
|
|
|
|
// Centralised here so quality color table changes propagate everywhere.
|
|
|
|
|
inline std::string buildItemLink(uint32_t itemId, uint32_t quality, const std::string& name) {
|
|
|
|
|
static const char* kQualHex[] = {
|
|
|
|
|
"9d9d9d", // 0 Poor
|
|
|
|
|
"ffffff", // 1 Common
|
|
|
|
|
"1eff00", // 2 Uncommon
|
|
|
|
|
"0070dd", // 3 Rare
|
|
|
|
|
"a335ee", // 4 Epic
|
|
|
|
|
"ff8000", // 5 Legendary
|
|
|
|
|
"e6cc80", // 6 Artifact
|
|
|
|
|
"e6cc80", // 7 Heirloom
|
|
|
|
|
};
|
|
|
|
|
uint32_t qi = quality < 8 ? quality : 1u;
|
|
|
|
|
char buf[512];
|
|
|
|
|
snprintf(buf, sizeof(buf), "|cff%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r",
|
|
|
|
|
kQualHex[qi], itemId, name.c_str());
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
refactor(game): split GameHandler into domain handlers
Extract domain-specific logic from the monolithic GameHandler into
dedicated handler classes, each owning its own opcode registration,
state, and packet parsing:
- CombatHandler: combat, XP, kill, PvP, loot roll (~26 methods)
- SpellHandler: spells, auras, pet stable, talent (~3+ methods)
- SocialHandler: friends, guild, groups, BG, RAF, PvP AFK (~14+ methods)
- ChatHandler: chat messages, channels, GM tickets, server messages,
defense/area-trigger messages (~7+ methods)
- InventoryHandler: items, trade, loot, mail, vendor, equipment sets,
read item (~3+ methods)
- QuestHandler: gossip, quests, completed quest response (~5+ methods)
- MovementHandler: movement, follow, transport (~2 methods)
- WardenHandler: Warden anti-cheat module
Each handler registers its own dispatch table entries via
registerOpcodes(DispatchTable&), called from
GameHandler::registerOpcodeHandlers(). GameHandler retains core
orchestration: auth/session handshake, update-object parsing,
opcode routing, and cross-handler coordination.
game_handler.cpp reduced from ~10,188 to ~9,432 lines.
Also add a POST_BUILD CMake step to symlink Data/ next to the
executable so expansion profiles and opcode tables are found at
runtime when running from build/bin/.
2026-03-28 09:42:37 +03:00
|
|
|
} // namespace game
|
|
|
|
|
} // namespace wowee
|