mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
[refactor] Break Application::getInstance() from GameHandler
Introduce `GameServices` struct — an explicit dependency bundle that `Application` populates and passes to `GameHandler` at construction time. Eliminates all 47 hidden `Application::getInstance()` calls in `src/game/*.cpp`, completing SOLID-D (dependency-inversion) cleanup. Changes: - New `include/game/game_services.hpp` — `struct GameServices` carrying pointers to `Renderer`, `AssetManager`, `ExpansionRegistry`, and two taxi-mount display IDs - `GameHandler(GameServices&)` replaces default constructor; exposes `services() const` accessor for domain handlers - `Application` holds `game::GameServices gameServices_`; populates it after all subsystems are created, then constructs `GameHandler` (fixes latent init-order bug: `GameHandler` was previously created before `AssetManager` / `ExpansionRegistry`) - `game_handler.cpp`: duplicate `isActiveExpansion` / `isClassicLikeExpansion` / `isPreWotlk` anonymous-namespace helpers removed; `game_utils.hpp` included instead - All domain handlers (`InventoryHandler`, `SpellHandler`, `MovementHandler`, `CombatHandler`, `QuestHandler`, `SocialHandler`, `WardenHandler`) replace `Application::getInstance().getXxx()` with `owner_.services().xxx`
This commit is contained in:
parent
c1c28d4216
commit
a86efaaa18
12 changed files with 92 additions and 68 deletions
|
|
@ -781,7 +781,7 @@ void WardenHandler::handleWardenData(network::Packet& packet) {
|
|||
std::replace(np.begin(), np.end(), '/', '\\');
|
||||
auto knownIt = knownDoorHashes().find(np);
|
||||
if (knownIt != knownDoorHashes().end()) { found = true; hash.assign(knownIt->second.begin(), knownIt->second.end()); }
|
||||
auto* am = core::Application::getInstance().getAssetManager();
|
||||
auto* am = owner_.services().assetManager;
|
||||
if (am && am->isInitialized() && !found) {
|
||||
std::vector<uint8_t> fd;
|
||||
std::string rp = resolveCaseInsensitiveDataPath(am->getDataPath(), filePath);
|
||||
|
|
@ -1194,7 +1194,7 @@ void WardenHandler::handleWardenData(network::Packet& packet) {
|
|||
hash.assign(knownIt->second.begin(), knownIt->second.end());
|
||||
}
|
||||
|
||||
auto* am = core::Application::getInstance().getAssetManager();
|
||||
auto* am = owner_.services().assetManager;
|
||||
if (am && am->isInitialized() && !found) {
|
||||
std::vector<uint8_t> fileData;
|
||||
std::string resolvedFsPath =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue