2026-02-02 12:24:50 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "core/window.hpp"
|
|
|
|
|
#include "core/input.hpp"
|
2026-03-31 22:01:55 +03:00
|
|
|
#include "core/entity_spawner.hpp"
|
2026-04-01 13:31:48 +03:00
|
|
|
#include "core/appearance_composer.hpp"
|
2026-04-01 20:06:26 +03:00
|
|
|
#include "core/world_loader.hpp"
|
2026-02-05 14:35:12 -08:00
|
|
|
#include "game/character.hpp"
|
[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`
2026-03-30 09:17:42 +03:00
|
|
|
#include "game/game_services.hpp"
|
2026-03-07 15:46:56 -08:00
|
|
|
#include "pipeline/blp_loader.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2026-03-07 13:44:09 -08:00
|
|
|
#include <deque>
|
2026-02-05 21:55:52 -08:00
|
|
|
#include <unordered_map>
|
2026-02-11 18:25:04 -08:00
|
|
|
#include <unordered_set>
|
2026-02-13 20:10:19 -08:00
|
|
|
#include <array>
|
2026-03-02 08:06:35 -08:00
|
|
|
#include <optional>
|
2026-03-07 11:44:14 -08:00
|
|
|
#include <future>
|
|
|
|
|
#include <mutex>
|
2026-03-07 13:44:09 -08:00
|
|
|
#include <thread>
|
|
|
|
|
#include <atomic>
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
namespace wowee {
|
|
|
|
|
|
|
|
|
|
// Forward declarations
|
|
|
|
|
namespace rendering { class Renderer; }
|
|
|
|
|
namespace ui { class UIManager; }
|
|
|
|
|
namespace auth { class AuthHandler; }
|
2026-02-12 22:56:36 -08:00
|
|
|
namespace game { class GameHandler; class World; class ExpansionRegistry; }
|
2026-03-07 15:46:56 -08:00
|
|
|
namespace pipeline { class AssetManager; class DBCLayout; struct M2Model; struct WMOModel; }
|
2026-02-09 02:22:20 -08:00
|
|
|
namespace audio { enum class VoiceType; }
|
2026-03-20 11:12:07 -07:00
|
|
|
namespace addons { class AddonManager; }
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
namespace core {
|
|
|
|
|
|
|
|
|
|
enum class AppState {
|
|
|
|
|
AUTHENTICATION,
|
|
|
|
|
REALM_SELECTION,
|
2026-02-05 14:13:48 -08:00
|
|
|
CHARACTER_CREATION,
|
2026-02-02 12:24:50 -08:00
|
|
|
CHARACTER_SELECTION,
|
|
|
|
|
IN_GAME,
|
|
|
|
|
DISCONNECTED
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Application {
|
2026-04-01 20:06:26 +03:00
|
|
|
friend class WorldLoader;
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
public:
|
|
|
|
|
Application();
|
|
|
|
|
~Application();
|
|
|
|
|
|
|
|
|
|
Application(const Application&) = delete;
|
|
|
|
|
Application& operator=(const Application&) = delete;
|
|
|
|
|
|
|
|
|
|
bool initialize();
|
|
|
|
|
void run();
|
|
|
|
|
void shutdown();
|
|
|
|
|
|
|
|
|
|
// State management
|
|
|
|
|
AppState getState() const { return state; }
|
|
|
|
|
void setState(AppState newState);
|
|
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
|
Window* getWindow() { return window.get(); }
|
|
|
|
|
rendering::Renderer* getRenderer() { return renderer.get(); }
|
|
|
|
|
ui::UIManager* getUIManager() { return uiManager.get(); }
|
|
|
|
|
auth::AuthHandler* getAuthHandler() { return authHandler.get(); }
|
|
|
|
|
game::GameHandler* getGameHandler() { return gameHandler.get(); }
|
|
|
|
|
game::World* getWorld() { return world.get(); }
|
|
|
|
|
pipeline::AssetManager* getAssetManager() { return assetManager.get(); }
|
2026-03-20 11:12:07 -07:00
|
|
|
addons::AddonManager* getAddonManager() { return addonManager_.get(); }
|
2026-02-12 22:56:36 -08:00
|
|
|
game::ExpansionRegistry* getExpansionRegistry() { return expansionRegistry_.get(); }
|
|
|
|
|
pipeline::DBCLayout* getDBCLayout() { return dbcLayout_.get(); }
|
2026-02-13 16:53:28 -08:00
|
|
|
void reloadExpansionData(); // Reload DBC layouts, opcodes, etc. after expansion change
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
// Singleton access
|
|
|
|
|
static Application& getInstance() { return *instance; }
|
|
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-06 23:52:16 -08:00
|
|
|
// Logout to login screen
|
|
|
|
|
void logoutToLogin();
|
2026-02-04 18:27:52 -08:00
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
// Render bounds lookup (for click targeting / selection) — delegates to EntitySpawner
|
2026-02-06 18:34:45 -08:00
|
|
|
bool getRenderBoundsForGuid(uint64_t guid, glm::vec3& outCenter, float& outRadius) const;
|
2026-02-20 16:02:34 -08:00
|
|
|
bool getRenderFootZForGuid(uint64_t guid, float& outFootZ) const;
|
2026-03-10 06:33:44 -07:00
|
|
|
bool getRenderPositionForGuid(uint64_t guid, glm::vec3& outPos) const;
|
2026-02-06 18:34:45 -08:00
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
// Character skin composite state — delegated to AppearanceComposer
|
|
|
|
|
const std::string& getBodySkinPath() const { return appearanceComposer_ ? appearanceComposer_->getBodySkinPath() : emptyString_; }
|
|
|
|
|
const std::vector<std::string>& getUnderwearPaths() const { return appearanceComposer_ ? appearanceComposer_->getUnderwearPaths() : emptyStringVec_; }
|
|
|
|
|
uint32_t getSkinTextureSlotIndex() const { return appearanceComposer_ ? appearanceComposer_->getSkinTextureSlotIndex() : 0; }
|
|
|
|
|
uint32_t getCloakTextureSlotIndex() const { return appearanceComposer_ ? appearanceComposer_->getCloakTextureSlotIndex() : 0; }
|
2026-03-31 22:01:55 +03:00
|
|
|
uint32_t getGryphonDisplayId() const { return entitySpawner_ ? entitySpawner_->getGryphonDisplayId() : 0; }
|
|
|
|
|
uint32_t getWyvernDisplayId() const { return entitySpawner_ ? entitySpawner_->getWyvernDisplayId() : 0; }
|
|
|
|
|
|
|
|
|
|
// Entity spawner access
|
|
|
|
|
EntitySpawner* getEntitySpawner() { return entitySpawner_.get(); }
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
// Appearance composer access
|
|
|
|
|
AppearanceComposer* getAppearanceComposer() { return appearanceComposer_.get(); }
|
|
|
|
|
|
2026-04-01 20:06:26 +03:00
|
|
|
// World loader access
|
|
|
|
|
WorldLoader* getWorldLoader() { return worldLoader_.get(); }
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
private:
|
|
|
|
|
void update(float deltaTime);
|
|
|
|
|
void render();
|
|
|
|
|
void setupUICallbacks();
|
|
|
|
|
void spawnPlayerCharacter();
|
2026-02-06 17:27:20 -08:00
|
|
|
void buildFactionHostilityMap(uint8_t playerRace);
|
2026-02-10 21:29:10 -08:00
|
|
|
void setupTestTransport(); // Test transport boat for development
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
static Application* instance;
|
|
|
|
|
|
[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`
2026-03-30 09:17:42 +03:00
|
|
|
game::GameServices gameServices_;
|
2026-02-02 12:24:50 -08:00
|
|
|
std::unique_ptr<Window> window;
|
|
|
|
|
std::unique_ptr<rendering::Renderer> renderer;
|
|
|
|
|
std::unique_ptr<ui::UIManager> uiManager;
|
|
|
|
|
std::unique_ptr<auth::AuthHandler> authHandler;
|
|
|
|
|
std::unique_ptr<game::GameHandler> gameHandler;
|
|
|
|
|
std::unique_ptr<game::World> world;
|
|
|
|
|
std::unique_ptr<pipeline::AssetManager> assetManager;
|
2026-03-20 11:12:07 -07:00
|
|
|
std::unique_ptr<addons::AddonManager> addonManager_;
|
|
|
|
|
bool addonsLoaded_ = false;
|
2026-02-12 22:56:36 -08:00
|
|
|
std::unique_ptr<game::ExpansionRegistry> expansionRegistry_;
|
|
|
|
|
std::unique_ptr<pipeline::DBCLayout> dbcLayout_;
|
2026-03-31 22:01:55 +03:00
|
|
|
std::unique_ptr<EntitySpawner> entitySpawner_;
|
2026-04-01 13:31:48 +03:00
|
|
|
std::unique_ptr<AppearanceComposer> appearanceComposer_;
|
2026-04-01 20:06:26 +03:00
|
|
|
std::unique_ptr<WorldLoader> worldLoader_;
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
AppState state = AppState::AUTHENTICATION;
|
|
|
|
|
bool running = false;
|
2026-02-09 22:51:13 -08:00
|
|
|
std::string pendingCreatedCharacterName_; // Auto-select after character creation
|
2026-02-02 12:24:50 -08:00
|
|
|
bool playerCharacterSpawned = false;
|
|
|
|
|
bool npcsSpawned = false;
|
2026-02-04 23:30:03 -08:00
|
|
|
bool spawnSnapToGround = true;
|
2026-02-02 12:24:50 -08:00
|
|
|
float lastFrameTime = 0.0f;
|
|
|
|
|
|
2026-02-07 11:26:49 -08:00
|
|
|
// Player character info (for model spawning)
|
|
|
|
|
game::Race playerRace_ = game::Race::HUMAN;
|
|
|
|
|
game::Gender playerGender_ = game::Gender::MALE;
|
|
|
|
|
game::Class playerClass_ = game::Class::WARRIOR;
|
2026-02-12 14:55:27 -08:00
|
|
|
uint64_t spawnedPlayerGuid_ = 0;
|
|
|
|
|
uint32_t spawnedAppearanceBytes_ = 0;
|
|
|
|
|
uint8_t spawnedFacialFeatures_ = 0;
|
2026-02-07 11:26:49 -08:00
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
// Static empty values for null-safe delegation
|
|
|
|
|
static inline const std::string emptyString_;
|
|
|
|
|
static inline const std::vector<std::string> emptyStringVec_;
|
2026-02-05 21:55:52 -08:00
|
|
|
|
2026-02-08 03:05:38 -08:00
|
|
|
bool lastTaxiFlight_ = false;
|
2026-02-11 21:14:35 -08:00
|
|
|
float taxiLandingClampTimer_ = 0.0f;
|
|
|
|
|
float worldEntryMovementGraceTimer_ = 0.0f;
|
2026-03-07 22:03:28 -08:00
|
|
|
|
|
|
|
|
// Hearth teleport: freeze player until terrain loads at destination
|
|
|
|
|
bool hearthTeleportPending_ = false;
|
|
|
|
|
glm::vec3 hearthTeleportPos_{0.0f}; // render coords
|
|
|
|
|
float hearthTeleportTimer_ = 0.0f; // timeout safety
|
2026-02-20 02:50:59 -08:00
|
|
|
float facingSendCooldown_ = 0.0f; // Rate-limits MSG_MOVE_SET_FACING
|
2026-02-19 16:40:17 -08:00
|
|
|
float lastSentCanonicalYaw_ = 1000.0f; // Sentinel — triggers first send
|
2026-02-08 03:05:38 -08:00
|
|
|
float taxiStreamCooldown_ = 0.0f;
|
2026-02-08 03:39:02 -08:00
|
|
|
bool idleYawned_ = false;
|
2026-02-07 17:59:40 -08:00
|
|
|
|
2026-02-19 21:13:13 -08:00
|
|
|
// Charge rush state
|
|
|
|
|
bool chargeActive_ = false;
|
|
|
|
|
float chargeTimer_ = 0.0f;
|
|
|
|
|
float chargeDuration_ = 0.0f;
|
|
|
|
|
glm::vec3 chargeStartPos_{0.0f}; // Render coordinates
|
|
|
|
|
glm::vec3 chargeEndPos_{0.0f}; // Render coordinates
|
|
|
|
|
uint64_t chargeTargetGuid_ = 0;
|
|
|
|
|
|
2026-02-12 00:15:51 -08:00
|
|
|
bool wasAutoAttacking_ = false;
|
2026-02-06 13:47:03 -08:00
|
|
|
|
2026-02-09 23:41:38 -08:00
|
|
|
// Quest marker billboard sprites (above NPCs)
|
|
|
|
|
void loadQuestMarkerModels(); // Now loads BLP textures
|
|
|
|
|
void updateQuestMarkers(); // Updates billboard positions
|
2026-02-02 12:24:50 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace core
|
|
|
|
|
} // namespace wowee
|