mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-09 22:33:51 +00:00
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.
126 lines
4.8 KiB
C++
126 lines
4.8 KiB
C++
#pragma once
|
|
|
|
// Domain interfaces for GameHandler decomposition (Phase 1.2A).
|
|
// Each interface defines a narrow contract for a specific domain concern,
|
|
// enabling domain handlers to depend only on the state they need.
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <array>
|
|
#include <unordered_map>
|
|
|
|
namespace wowee::network { class WorldSocket; }
|
|
|
|
namespace wowee::game {
|
|
|
|
// Forward declarations
|
|
class Entity;
|
|
class EntityManager;
|
|
enum class WorldState;
|
|
struct ContactEntry;
|
|
struct BgQueueSlot;
|
|
struct AvailableBgInfo;
|
|
struct BgScoreboardData;
|
|
struct BgPlayerPosition;
|
|
struct ArenaTeamStats;
|
|
struct ArenaTeamRoster;
|
|
struct GuildRosterData;
|
|
struct GuildInfoData;
|
|
struct GuildQueryResponseData;
|
|
struct CreatureQueryResponseData;
|
|
struct GameObjectQueryResponseData;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// IConnectionState — server connection and authentication state
|
|
// ---------------------------------------------------------------------------
|
|
class IConnectionState {
|
|
public:
|
|
virtual ~IConnectionState() = default;
|
|
|
|
virtual bool isConnected() const = 0;
|
|
virtual bool isInWorld() const = 0;
|
|
virtual WorldState getState() const = 0;
|
|
virtual network::WorldSocket* getSocket() = 0;
|
|
virtual const std::vector<uint8_t>& getSessionKey() const = 0;
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ITargetingState — target, focus, and mouseover management
|
|
// ---------------------------------------------------------------------------
|
|
class ITargetingState {
|
|
public:
|
|
virtual ~ITargetingState() = default;
|
|
|
|
virtual void setTarget(uint64_t guid) = 0;
|
|
virtual void clearTarget() = 0;
|
|
virtual uint64_t getTargetGuid() const = 0;
|
|
virtual std::shared_ptr<Entity> getTarget() const = 0;
|
|
virtual bool hasTarget() const = 0;
|
|
|
|
virtual void setFocus(uint64_t guid) = 0;
|
|
virtual void clearFocus() = 0;
|
|
virtual uint64_t getFocusGuid() const = 0;
|
|
virtual bool hasFocus() const = 0;
|
|
|
|
virtual void setMouseoverGuid(uint64_t guid) = 0;
|
|
virtual uint64_t getMouseoverGuid() const = 0;
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// IEntityAccess — entity queries and name/info caching
|
|
// ---------------------------------------------------------------------------
|
|
class IEntityAccess {
|
|
public:
|
|
virtual ~IEntityAccess() = default;
|
|
|
|
virtual EntityManager& getEntityManager() = 0;
|
|
virtual const EntityManager& getEntityManager() const = 0;
|
|
|
|
virtual void queryPlayerName(uint64_t guid) = 0;
|
|
virtual void queryCreatureInfo(uint32_t entry, uint64_t guid) = 0;
|
|
virtual std::string getCachedPlayerName(uint64_t guid) const = 0;
|
|
virtual std::string getCachedCreatureName(uint32_t entry) const = 0;
|
|
virtual const std::unordered_map<uint64_t, std::string>& getPlayerNameCache() const = 0;
|
|
virtual const std::unordered_map<uint32_t, CreatureQueryResponseData>& getCreatureInfoCache() const = 0;
|
|
virtual const GameObjectQueryResponseData* getCachedGameObjectInfo(uint32_t entry) const = 0;
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ISocialState — friends, ignore list, contacts, guild info
|
|
// ---------------------------------------------------------------------------
|
|
class ISocialState {
|
|
public:
|
|
virtual ~ISocialState() = default;
|
|
|
|
virtual void addFriend(const std::string& playerName, const std::string& note = "") = 0;
|
|
virtual void removeFriend(const std::string& playerName) = 0;
|
|
virtual void addIgnore(const std::string& playerName) = 0;
|
|
virtual void removeIgnore(const std::string& playerName) = 0;
|
|
virtual const std::unordered_map<std::string, uint64_t>& getIgnoreCache() const = 0;
|
|
virtual const std::vector<ContactEntry>& getContacts() const = 0;
|
|
|
|
virtual bool isInGuild() const = 0;
|
|
virtual const std::string& getGuildName() const = 0;
|
|
virtual const GuildRosterData& getGuildRoster() const = 0;
|
|
virtual bool hasGuildRoster() const = 0;
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// IPvpState — battleground queues, arena teams, scoreboard
|
|
// ---------------------------------------------------------------------------
|
|
class IPvpState {
|
|
public:
|
|
virtual ~IPvpState() = default;
|
|
|
|
virtual bool hasPendingBgInvite() const = 0;
|
|
virtual void acceptBattlefield(uint32_t queueSlot = 0xFFFFFFFF) = 0;
|
|
virtual void declineBattlefield(uint32_t queueSlot = 0xFFFFFFFF) = 0;
|
|
virtual const std::array<BgQueueSlot, 3>& getBgQueues() const = 0;
|
|
virtual const std::vector<AvailableBgInfo>& getAvailableBgs() const = 0;
|
|
virtual const BgScoreboardData* getBgScoreboard() const = 0;
|
|
virtual const std::vector<ArenaTeamStats>& getArenaTeamStats() const = 0;
|
|
};
|
|
|
|
} // namespace wowee::game
|