feat(game): introduce GameHandler domain interfaces and eliminate friend declarations

Add game_interfaces.hpp with five narrow domain contracts that GameHandler now
publishes to its domain handlers, replacing the previous friend-class anti-pattern.

Changes:
- include/game/game_interfaces.hpp (new): IConnectionState, ITargetingState,
  IEntityAccess, ISocialState, IPvpState — each interface exposes only the state
  its consumer legitimately needs
- include/game/game_handler.hpp: GameHandler inherits all five interfaces;
  include of game_interfaces.hpp added
- include/game/movement_handler.hpp: remove `friend class GameHandler`; add
  public named accessors for previously-private fields (monsterMovePacketsThisTickRef,
  timeSinceLastMoveHeartbeatRef, resetMovementClock, setFalling, setFallStartMs)
- include/game/spell_handler.hpp: remove `friend class GameHandler/InventoryHandler/
  CombatHandler/EntityController`; promote private packet handlers (handlePetSpells,
  handleListStabledPets, pet stable commands, DBC loaders) to public; add accessor
  methods for aura cache, known spells, and player aura slot mutation
- src/game/game_handler.cpp, game_handler_callbacks.cpp, game_handler_packets.cpp:
  replace direct private field access with the new accessor API
  (e.g. casting_ → isCasting(), monsterMovePacketsThisTick_ → ...ThisTickRef())
- src/game/inventory_handler.cpp, combat_handler.cpp, entity_controller.cpp:
  replace friend-class private access with public accessor calls

No behaviour change. All 13 test suites pass. Zero build warnings.
This commit is contained in:
Paul 2026-04-05 20:25:02 +03:00
parent 34c0e3ca28
commit 65839287b4
10 changed files with 196 additions and 47 deletions

View file

@ -1019,10 +1019,11 @@ void GameHandler::registerOpcodeHandlers() {
// SMSG_SPELL_COOLDOWN often arrives before SMSG_ACTION_BUTTONS during login,
// so the per-slot cooldownRemaining would be 0 without this sync.
if (spellHandler_) {
const auto& cooldowns = spellHandler_->getSpellCooldowns();
for (auto& slot : actionBar) {
if (slot.type == ActionBarSlot::SPELL && slot.id != 0) {
auto cdIt = spellHandler_->spellCooldowns_.find(slot.id);
if (cdIt != spellHandler_->spellCooldowns_.end() && cdIt->second > 0.0f) {
auto cdIt = cooldowns.find(slot.id);
if (cdIt != cooldowns.end() && cdIt->second > 0.0f) {
slot.cooldownRemaining = cdIt->second;
slot.cooldownTotal = cdIt->second;
}
@ -1033,8 +1034,8 @@ void GameHandler::registerOpcodeHandlers() {
if (qi && qi->valid) {
for (const auto& sp : qi->spells) {
if (sp.spellId == 0) continue;
auto cdIt = spellHandler_->spellCooldowns_.find(sp.spellId);
if (cdIt != spellHandler_->spellCooldowns_.end() && cdIt->second > 0.0f) {
auto cdIt = cooldowns.find(sp.spellId);
if (cdIt != cooldowns.end() && cdIt->second > 0.0f) {
slot.cooldownRemaining = cdIt->second;
slot.cooldownTotal = cdIt->second;
break;