2026-02-02 12:24:50 -08:00
|
|
|
#include "core/application.hpp"
|
2026-02-04 17:37:28 -08:00
|
|
|
#include "core/coordinates.hpp"
|
2026-04-03 09:41:34 +03:00
|
|
|
#include "core/profiler.hpp"
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
#include "core/npc_interaction_callback_handler.hpp"
|
|
|
|
|
#include "core/audio_callback_handler.hpp"
|
|
|
|
|
#include "core/entity_spawn_callback_handler.hpp"
|
|
|
|
|
#include "core/animation_callback_handler.hpp"
|
|
|
|
|
#include "core/transport_callback_handler.hpp"
|
|
|
|
|
#include "core/world_entry_callback_handler.hpp"
|
|
|
|
|
#include "core/ui_screen_callback_handler.hpp"
|
2026-04-05 12:27:35 +03:00
|
|
|
#include "rendering/animation/animation_ids.hpp"
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
#include "rendering/animation_controller.hpp"
|
2026-02-06 17:15:46 -08:00
|
|
|
#include <unordered_set>
|
2026-02-07 23:34:28 -08:00
|
|
|
#include <cmath>
|
2026-03-02 14:45:49 -08:00
|
|
|
#include <chrono>
|
2026-02-04 18:27:52 -08:00
|
|
|
#include "core/spawn_presets.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "core/logger.hpp"
|
2026-02-08 23:15:26 -08:00
|
|
|
#include "core/memory_monitor.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "rendering/renderer.hpp"
|
2026-03-02 08:47:06 -08:00
|
|
|
#include "rendering/vk_context.hpp"
|
2026-02-09 01:29:44 -08:00
|
|
|
#include "audio/npc_voice_manager.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "rendering/camera.hpp"
|
|
|
|
|
#include "rendering/camera_controller.hpp"
|
|
|
|
|
#include "rendering/terrain_renderer.hpp"
|
|
|
|
|
#include "rendering/terrain_manager.hpp"
|
|
|
|
|
#include "rendering/performance_hud.hpp"
|
|
|
|
|
#include "rendering/water_renderer.hpp"
|
|
|
|
|
#include "rendering/skybox.hpp"
|
|
|
|
|
#include "rendering/celestial.hpp"
|
|
|
|
|
#include "rendering/starfield.hpp"
|
|
|
|
|
#include "rendering/clouds.hpp"
|
|
|
|
|
#include "rendering/lens_flare.hpp"
|
|
|
|
|
#include "rendering/weather.hpp"
|
|
|
|
|
#include "rendering/character_renderer.hpp"
|
|
|
|
|
#include "rendering/wmo_renderer.hpp"
|
2026-02-07 19:44:03 -08:00
|
|
|
#include "rendering/m2_renderer.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "rendering/minimap.hpp"
|
2026-02-09 23:41:38 -08:00
|
|
|
#include "rendering/quest_marker_renderer.hpp"
|
2026-02-03 13:33:31 -08:00
|
|
|
#include "rendering/loading_screen.hpp"
|
2026-02-05 15:59:06 -08:00
|
|
|
#include "audio/music_manager.hpp"
|
2026-02-05 17:55:30 -08:00
|
|
|
#include "audio/footstep_manager.hpp"
|
|
|
|
|
#include "audio/activity_sound_manager.hpp"
|
2026-02-19 21:13:13 -08:00
|
|
|
#include "audio/audio_engine.hpp"
|
2026-04-01 20:38:37 +03:00
|
|
|
#include "audio/audio_coordinator.hpp"
|
2026-03-20 11:12:07 -07:00
|
|
|
#include "addons/addon_manager.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <imgui.h>
|
|
|
|
|
#include "pipeline/m2_loader.hpp"
|
|
|
|
|
#include "pipeline/wmo_loader.hpp"
|
2026-02-26 17:56:11 -08:00
|
|
|
#include "pipeline/wdt_loader.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "pipeline/dbc_loader.hpp"
|
|
|
|
|
#include "ui/ui_manager.hpp"
|
`chore(application): extract appearance controller and unify UI flow`
- Refactor UI application architecture: extracted appearance controller into ui_services.hpp + implementation updates
- Update UI components and managers to use new service layer:
- `action_bar_panel`, `auth_screen`, `character_screen`, `chat_panel`, `combat_ui`, `dialog_manager`, `game_screen`, `settings_panel`, `social_panel`, `toast_manager`, `ui_manager`, `window_manager`
- Adjust core application entrypoints:
- application.cpp
- Update component implementations for new controller flow:
- action_bar_panel.cpp, `chat_panel.cpp`, `combat_ui.cpp`, `dialog_manager.cpp`, `game_screen.cpp`, `settings_panel.cpp`, `social_panel.cpp`, `toast_manager.cpp`, `window_manager.cpp`
These staged changes implement a major architectural refactor for UI/appearance controller separation
2026-04-01 20:59:17 +03:00
|
|
|
#include "ui/ui_services.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "auth/auth_handler.hpp"
|
|
|
|
|
#include "game/game_handler.hpp"
|
2026-02-10 21:29:10 -08:00
|
|
|
#include "game/transport_manager.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "game/world.hpp"
|
2026-02-12 22:56:36 -08:00
|
|
|
#include "game/expansion_profile.hpp"
|
|
|
|
|
#include "game/packet_parsers.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include "pipeline/asset_manager.hpp"
|
2026-02-12 22:56:36 -08:00
|
|
|
#include "pipeline/dbc_layout.hpp"
|
2026-02-15 04:18:34 -08:00
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
#include <cstdlib>
|
2026-03-07 18:40:24 -08:00
|
|
|
#include <climits>
|
2026-02-04 17:37:28 -08:00
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cctype>
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <sstream>
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <set>
|
2026-02-12 22:56:36 -08:00
|
|
|
#include <filesystem>
|
2026-03-07 13:44:09 -08:00
|
|
|
#include <fstream>
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-25 03:39:45 -08:00
|
|
|
#include <thread>
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
#include <sched.h>
|
|
|
|
|
#include <pthread.h>
|
2026-02-25 03:41:18 -08:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
#endif
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
#include <mach/mach.h>
|
|
|
|
|
#include <mach/thread_policy.h>
|
|
|
|
|
#include <pthread.h>
|
2026-02-25 03:39:45 -08:00
|
|
|
#endif
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
namespace wowee {
|
|
|
|
|
namespace core {
|
|
|
|
|
|
2026-02-22 07:45:49 -08:00
|
|
|
namespace {
|
|
|
|
|
bool envFlagEnabled(const char* key, bool defaultValue = false) {
|
|
|
|
|
const char* raw = std::getenv(key);
|
|
|
|
|
if (!raw || !*raw) return defaultValue;
|
|
|
|
|
return !(raw[0] == '0' || raw[0] == 'f' || raw[0] == 'F' ||
|
|
|
|
|
raw[0] == 'n' || raw[0] == 'N');
|
|
|
|
|
}
|
2026-03-27 18:42:48 -07:00
|
|
|
|
2026-02-22 07:45:49 -08:00
|
|
|
} // namespace
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
Application* Application::instance = nullptr;
|
|
|
|
|
|
|
|
|
|
Application::Application() {
|
|
|
|
|
instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Application::~Application() {
|
|
|
|
|
shutdown();
|
|
|
|
|
instance = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Application::initialize() {
|
2026-02-02 23:22:58 -08:00
|
|
|
LOG_INFO("Initializing Wowee Native Client");
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-08 23:15:26 -08:00
|
|
|
// Initialize memory monitoring for dynamic cache sizing
|
|
|
|
|
core::MemoryMonitor::getInstance().initialize();
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
// Create window
|
|
|
|
|
WindowConfig windowConfig;
|
2026-02-02 23:03:45 -08:00
|
|
|
windowConfig.title = "Wowee";
|
|
|
|
|
windowConfig.width = 1280;
|
|
|
|
|
windowConfig.height = 720;
|
|
|
|
|
windowConfig.vsync = false;
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
window = std::make_unique<Window>(windowConfig);
|
|
|
|
|
if (!window->initialize()) {
|
|
|
|
|
LOG_FATAL("Failed to initialize window");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create renderer
|
|
|
|
|
renderer = std::make_unique<rendering::Renderer>();
|
|
|
|
|
if (!renderer->initialize(window.get())) {
|
|
|
|
|
LOG_FATAL("Failed to initialize renderer");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 00:21:21 +03:00
|
|
|
// Create and initialize audio coordinator (owns all audio managers)
|
|
|
|
|
audioCoordinator_ = std::make_unique<audio::AudioCoordinator>();
|
2026-04-06 22:43:13 +03:00
|
|
|
if (!audioCoordinator_->initialize())
|
|
|
|
|
LOG_WARNING("Audio coordinator initialization failed — game will run without audio");
|
2026-04-02 00:21:21 +03:00
|
|
|
renderer->setAudioCoordinator(audioCoordinator_.get());
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
// Create UI manager
|
|
|
|
|
uiManager = std::make_unique<ui::UIManager>();
|
|
|
|
|
if (!uiManager->initialize(window.get())) {
|
|
|
|
|
LOG_FATAL("Failed to initialize UI manager");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create subsystems
|
|
|
|
|
authHandler = std::make_unique<auth::AuthHandler>();
|
|
|
|
|
world = std::make_unique<game::World>();
|
|
|
|
|
|
2026-02-12 22:56:36 -08:00
|
|
|
// Create and initialize expansion registry
|
|
|
|
|
expansionRegistry_ = std::make_unique<game::ExpansionRegistry>();
|
|
|
|
|
|
|
|
|
|
// Create DBC layout
|
|
|
|
|
dbcLayout_ = std::make_unique<pipeline::DBCLayout>();
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
// Create asset manager
|
|
|
|
|
assetManager = std::make_unique<pipeline::AssetManager>();
|
|
|
|
|
|
[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
|
|
|
// Populate game services — all subsystems now available
|
|
|
|
|
gameServices_.renderer = renderer.get();
|
chore(renderer): extract AnimationController and remove audio pass-throughs
Extract ~1,500 lines of character animation state from Renderer into a dedicated
AnimationController class, and complete the AudioCoordinator migration by removing
all 10 audio pass-through getters from Renderer.
AnimationController:
- New: include/rendering/animation_controller.hpp (182 lines)
- New: src/rendering/animation_controller.cpp (1,703 lines)
- Moves: locomotion state machine (50+ members), mount animation (40+ members),
emote system, footstep triggering, surface detection, melee combat animations
- Renderer holds std::unique_ptr<AnimationController> and delegates completely
- AnimationController accesses audio via renderer_->getAudioCoordinator()
Audio caller migration:
- Migrate ~60 external callers from renderer->getXManager() to AudioCoordinator
directly, grouped by access pattern:
- UIServices: settings_panel, game_screen, toast_manager, chat_panel,
combat_ui, window_manager
- GameServices: game_handler, spell_handler, inventory_handler, quest_handler,
social_handler, combat_handler
- Application singleton: application.cpp, auth_screen.cpp, lua_engine.cpp
- Remove 10 pass-through getter definitions from renderer.cpp
- Remove 10 pass-through getter declarations from renderer.hpp
- Remove individual audio manager forward declarations from renderer.hpp
- Redirect 69 internal renderer.cpp audio calls to audioCoordinator_ directly
- game_handler.cpp: withSoundManager template uses services_.audioCoordinator;
MFP changed from &Renderer::getUiSoundManager to &AudioCoordinator::getUiSoundManager
- GameServices struct: add AudioCoordinator* audioCoordinator member
- settings_panel: applyAudioVolumes(Renderer*) -> applyAudioVolumes(AudioCoordinator*)
2026-04-02 13:06:31 +03:00
|
|
|
gameServices_.audioCoordinator = audioCoordinator_.get();
|
[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
|
|
|
gameServices_.assetManager = assetManager.get();
|
|
|
|
|
gameServices_.expansionRegistry = expansionRegistry_.get();
|
|
|
|
|
|
|
|
|
|
// Create game handler with explicit service dependencies
|
|
|
|
|
gameHandler = std::make_unique<game::GameHandler>(gameServices_);
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
// Try to get WoW data path from environment variable
|
|
|
|
|
const char* dataPathEnv = std::getenv("WOW_DATA_PATH");
|
|
|
|
|
std::string dataPath = dataPathEnv ? dataPathEnv : "./Data";
|
|
|
|
|
|
2026-02-12 22:56:36 -08:00
|
|
|
// Scan for available expansion profiles
|
|
|
|
|
expansionRegistry_->initialize(dataPath);
|
|
|
|
|
|
|
|
|
|
// Load expansion-specific opcode table
|
|
|
|
|
if (gameHandler && expansionRegistry_) {
|
|
|
|
|
auto* profile = expansionRegistry_->getActive();
|
|
|
|
|
if (profile) {
|
|
|
|
|
std::string opcodesPath = profile->dataPath + "/opcodes.json";
|
|
|
|
|
if (!gameHandler->getOpcodeTable().loadFromJson(opcodesPath)) {
|
2026-02-20 00:39:20 -08:00
|
|
|
LOG_ERROR("Failed to load opcodes from ", opcodesPath);
|
2026-02-12 22:56:36 -08:00
|
|
|
}
|
|
|
|
|
game::setActiveOpcodeTable(&gameHandler->getOpcodeTable());
|
|
|
|
|
|
|
|
|
|
// Load expansion-specific update field table
|
|
|
|
|
std::string updateFieldsPath = profile->dataPath + "/update_fields.json";
|
|
|
|
|
if (!gameHandler->getUpdateFieldTable().loadFromJson(updateFieldsPath)) {
|
2026-02-20 00:39:20 -08:00
|
|
|
LOG_ERROR("Failed to load update fields from ", updateFieldsPath);
|
2026-02-12 22:56:36 -08:00
|
|
|
}
|
|
|
|
|
game::setActiveUpdateFieldTable(&gameHandler->getUpdateFieldTable());
|
|
|
|
|
|
|
|
|
|
// Create expansion-specific packet parsers
|
|
|
|
|
gameHandler->setPacketParsers(game::createPacketParsers(profile->id));
|
|
|
|
|
|
|
|
|
|
// Load expansion-specific DBC layouts
|
|
|
|
|
if (dbcLayout_) {
|
|
|
|
|
std::string dbcLayoutsPath = profile->dataPath + "/dbc_layouts.json";
|
|
|
|
|
if (!dbcLayout_->loadFromJson(dbcLayoutsPath)) {
|
2026-02-20 00:39:20 -08:00
|
|
|
LOG_ERROR("Failed to load DBC layouts from ", dbcLayoutsPath);
|
2026-02-12 22:56:36 -08:00
|
|
|
}
|
|
|
|
|
pipeline::setActiveDBCLayout(dbcLayout_.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Try expansion-specific asset path first, fall back to base Data/
|
|
|
|
|
std::string assetPath = dataPath;
|
|
|
|
|
if (expansionRegistry_) {
|
|
|
|
|
auto* profile = expansionRegistry_->getActive();
|
|
|
|
|
if (profile && !profile->dataPath.empty()) {
|
2026-02-13 00:10:01 -08:00
|
|
|
// Enable expansion-specific CSV DBC lookup (Data/expansions/<id>/db/*.csv).
|
|
|
|
|
assetManager->setExpansionDataPath(profile->dataPath);
|
|
|
|
|
|
2026-02-12 22:56:36 -08:00
|
|
|
std::string expansionManifest = profile->dataPath + "/manifest.json";
|
|
|
|
|
if (std::filesystem::exists(expansionManifest)) {
|
|
|
|
|
assetPath = profile->dataPath;
|
|
|
|
|
LOG_INFO("Using expansion-specific asset path: ", assetPath);
|
2026-03-10 07:25:04 -07:00
|
|
|
// Register base Data/ as fallback so world terrain files are found
|
|
|
|
|
// even when the expansion path only contains DBC overrides.
|
|
|
|
|
if (assetPath != dataPath) {
|
|
|
|
|
assetManager->setBaseFallbackPath(dataPath);
|
|
|
|
|
}
|
2026-02-12 22:56:36 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Attempting to load WoW assets from: ", assetPath);
|
|
|
|
|
if (assetManager->initialize(assetPath)) {
|
2026-02-02 12:24:50 -08:00
|
|
|
LOG_INFO("Asset manager initialized successfully");
|
2026-02-06 14:37:31 -08:00
|
|
|
// Eagerly load creature display DBC lookups so first spawn doesn't stall
|
2026-03-31 22:01:55 +03:00
|
|
|
entitySpawner_ = std::make_unique<EntitySpawner>(
|
|
|
|
|
renderer.get(), assetManager.get(), gameHandler.get(),
|
|
|
|
|
dbcLayout_.get(), &gameServices_);
|
|
|
|
|
entitySpawner_->initialize();
|
2026-02-11 00:54:38 -08:00
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
appearanceComposer_ = std::make_unique<AppearanceComposer>(
|
|
|
|
|
renderer.get(), assetManager.get(), gameHandler.get(),
|
|
|
|
|
dbcLayout_.get(), entitySpawner_.get());
|
|
|
|
|
|
2026-04-01 20:38:37 +03:00
|
|
|
// Wire AppearanceComposer to UI components (Phase A singleton breaking)
|
|
|
|
|
if (uiManager) {
|
|
|
|
|
uiManager->setAppearanceComposer(appearanceComposer_.get());
|
`chore(application): extract appearance controller and unify UI flow`
- Refactor UI application architecture: extracted appearance controller into ui_services.hpp + implementation updates
- Update UI components and managers to use new service layer:
- `action_bar_panel`, `auth_screen`, `character_screen`, `chat_panel`, `combat_ui`, `dialog_manager`, `game_screen`, `settings_panel`, `social_panel`, `toast_manager`, `ui_manager`, `window_manager`
- Adjust core application entrypoints:
- application.cpp
- Update component implementations for new controller flow:
- action_bar_panel.cpp, `chat_panel.cpp`, `combat_ui.cpp`, `dialog_manager.cpp`, `game_screen.cpp`, `settings_panel.cpp`, `social_panel.cpp`, `toast_manager.cpp`, `window_manager.cpp`
These staged changes implement a major architectural refactor for UI/appearance controller separation
2026-04-01 20:59:17 +03:00
|
|
|
|
|
|
|
|
// Wire all services to UI components (Phase B singleton breaking)
|
|
|
|
|
ui::UIServices uiServices;
|
|
|
|
|
uiServices.window = window.get();
|
|
|
|
|
uiServices.renderer = renderer.get();
|
|
|
|
|
uiServices.assetManager = assetManager.get();
|
|
|
|
|
uiServices.gameHandler = gameHandler.get();
|
|
|
|
|
uiServices.expansionRegistry = expansionRegistry_.get();
|
|
|
|
|
uiServices.addonManager = addonManager_.get(); // May be nullptr here, re-wire later
|
|
|
|
|
uiServices.audioCoordinator = audioCoordinator_.get();
|
|
|
|
|
uiServices.entitySpawner = entitySpawner_.get();
|
|
|
|
|
uiServices.appearanceComposer = appearanceComposer_.get();
|
|
|
|
|
uiServices.worldLoader = worldLoader_.get();
|
|
|
|
|
uiManager->setServices(uiServices);
|
2026-04-01 20:38:37 +03:00
|
|
|
}
|
|
|
|
|
|
2026-02-12 14:55:27 -08:00
|
|
|
// Ensure the main in-world CharacterRenderer can load textures immediately.
|
|
|
|
|
// Previously this was only wired during terrain initialization, which meant early spawns
|
|
|
|
|
// (before terrain load) would render with white fallback textures (notably hair).
|
|
|
|
|
if (renderer && renderer->getCharacterRenderer()) {
|
|
|
|
|
renderer->getCharacterRenderer()->setAssetManager(assetManager.get());
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-14 20:20:43 -08:00
|
|
|
// Load transport paths from TransportAnimation.dbc and TaxiPathNode.dbc
|
2026-02-11 00:54:38 -08:00
|
|
|
if (gameHandler && gameHandler->getTransportManager()) {
|
|
|
|
|
gameHandler->getTransportManager()->loadTransportAnimationDBC(assetManager.get());
|
2026-02-14 20:20:43 -08:00
|
|
|
gameHandler->getTransportManager()->loadTaxiPathNodeDBC(assetManager.get());
|
2026-02-11 00:54:38 -08:00
|
|
|
}
|
2026-02-12 22:56:36 -08:00
|
|
|
|
2026-03-20 11:12:07 -07:00
|
|
|
// Initialize addon system
|
|
|
|
|
addonManager_ = std::make_unique<addons::AddonManager>();
|
`chore(lua): refactor addon Lua engine API + progress docs`
- Refactor Lua addon integration:
- Update CMakeLists.txt for addon build paths
- Enhance addons API headers and Lua engine interface
- Add new Lua API addon modules (`lua_api_helpers`, `lua_api_registrations`, `lua_services`, `lua_action_api`, `lua_inventory_api`, `lua_quest_api`, `lua_social_api`, `lua_spell_api`, `lua_system_api`, `lua_unit_api`)
- Update implementation in addon_manager.cpp, lua_engine.cpp, application.cpp, game_handler.cpp
2026-04-03 07:31:06 +03:00
|
|
|
addons::LuaServices luaSvc;
|
|
|
|
|
luaSvc.window = window.get();
|
|
|
|
|
luaSvc.audioCoordinator = audioCoordinator_.get();
|
|
|
|
|
luaSvc.expansionRegistry = expansionRegistry_.get();
|
|
|
|
|
if (addonManager_->initialize(gameHandler.get(), luaSvc)) {
|
2026-03-20 11:12:07 -07:00
|
|
|
std::string addonsDir = assetPath + "/interface/AddOns";
|
|
|
|
|
addonManager_->scanAddons(addonsDir);
|
2026-03-21 06:00:06 -07:00
|
|
|
// Wire Lua errors to UI error display
|
|
|
|
|
addonManager_->getLuaEngine()->setLuaErrorCallback([gh = gameHandler.get()](const std::string& err) {
|
|
|
|
|
if (gh) gh->addUIError(err);
|
|
|
|
|
});
|
feat: fire CHAT_MSG_* events to Lua addons for all chat types
Wire chat messages to the addon event system via AddonChatCallback.
Every chat message now fires the corresponding WoW event:
- CHAT_MSG_SAY, CHAT_MSG_YELL, CHAT_MSG_WHISPER
- CHAT_MSG_PARTY, CHAT_MSG_GUILD, CHAT_MSG_OFFICER
- CHAT_MSG_RAID, CHAT_MSG_RAID_WARNING, CHAT_MSG_BATTLEGROUND
- CHAT_MSG_SYSTEM, CHAT_MSG_CHANNEL, CHAT_MSG_EMOTE
Event handlers receive (eventName, message, senderName) arguments.
Addons can now filter, react to, or log chat messages in real-time.
2026-03-20 11:29:53 -07:00
|
|
|
// Wire chat messages to addon event dispatch
|
|
|
|
|
gameHandler->setAddonChatCallback([this](const game::MessageChatData& msg) {
|
|
|
|
|
if (!addonManager_ || !addonsLoaded_) return;
|
|
|
|
|
// Map ChatType to WoW event name
|
|
|
|
|
const char* eventName = nullptr;
|
|
|
|
|
switch (msg.type) {
|
|
|
|
|
case game::ChatType::SAY: eventName = "CHAT_MSG_SAY"; break;
|
|
|
|
|
case game::ChatType::YELL: eventName = "CHAT_MSG_YELL"; break;
|
|
|
|
|
case game::ChatType::WHISPER: eventName = "CHAT_MSG_WHISPER"; break;
|
|
|
|
|
case game::ChatType::PARTY: eventName = "CHAT_MSG_PARTY"; break;
|
|
|
|
|
case game::ChatType::GUILD: eventName = "CHAT_MSG_GUILD"; break;
|
|
|
|
|
case game::ChatType::OFFICER: eventName = "CHAT_MSG_OFFICER"; break;
|
|
|
|
|
case game::ChatType::RAID: eventName = "CHAT_MSG_RAID"; break;
|
|
|
|
|
case game::ChatType::RAID_WARNING: eventName = "CHAT_MSG_RAID_WARNING"; break;
|
|
|
|
|
case game::ChatType::BATTLEGROUND: eventName = "CHAT_MSG_BATTLEGROUND"; break;
|
|
|
|
|
case game::ChatType::SYSTEM: eventName = "CHAT_MSG_SYSTEM"; break;
|
|
|
|
|
case game::ChatType::CHANNEL: eventName = "CHAT_MSG_CHANNEL"; break;
|
|
|
|
|
case game::ChatType::EMOTE:
|
|
|
|
|
case game::ChatType::TEXT_EMOTE: eventName = "CHAT_MSG_EMOTE"; break;
|
2026-03-21 04:28:15 -07:00
|
|
|
case game::ChatType::ACHIEVEMENT: eventName = "CHAT_MSG_ACHIEVEMENT"; break;
|
|
|
|
|
case game::ChatType::GUILD_ACHIEVEMENT: eventName = "CHAT_MSG_GUILD_ACHIEVEMENT"; break;
|
|
|
|
|
case game::ChatType::WHISPER_INFORM: eventName = "CHAT_MSG_WHISPER_INFORM"; break;
|
|
|
|
|
case game::ChatType::RAID_LEADER: eventName = "CHAT_MSG_RAID_LEADER"; break;
|
|
|
|
|
case game::ChatType::BATTLEGROUND_LEADER: eventName = "CHAT_MSG_BATTLEGROUND_LEADER"; break;
|
|
|
|
|
case game::ChatType::MONSTER_SAY: eventName = "CHAT_MSG_MONSTER_SAY"; break;
|
|
|
|
|
case game::ChatType::MONSTER_YELL: eventName = "CHAT_MSG_MONSTER_YELL"; break;
|
|
|
|
|
case game::ChatType::MONSTER_EMOTE: eventName = "CHAT_MSG_MONSTER_EMOTE"; break;
|
|
|
|
|
case game::ChatType::MONSTER_WHISPER: eventName = "CHAT_MSG_MONSTER_WHISPER"; break;
|
|
|
|
|
case game::ChatType::RAID_BOSS_EMOTE: eventName = "CHAT_MSG_RAID_BOSS_EMOTE"; break;
|
|
|
|
|
case game::ChatType::RAID_BOSS_WHISPER: eventName = "CHAT_MSG_RAID_BOSS_WHISPER"; break;
|
|
|
|
|
case game::ChatType::BG_SYSTEM_NEUTRAL: eventName = "CHAT_MSG_BG_SYSTEM_NEUTRAL"; break;
|
|
|
|
|
case game::ChatType::BG_SYSTEM_ALLIANCE: eventName = "CHAT_MSG_BG_SYSTEM_ALLIANCE"; break;
|
|
|
|
|
case game::ChatType::BG_SYSTEM_HORDE: eventName = "CHAT_MSG_BG_SYSTEM_HORDE"; break;
|
2026-03-21 04:57:19 -07:00
|
|
|
case game::ChatType::MONSTER_PARTY: eventName = "CHAT_MSG_MONSTER_PARTY"; break;
|
|
|
|
|
case game::ChatType::AFK: eventName = "CHAT_MSG_AFK"; break;
|
|
|
|
|
case game::ChatType::DND: eventName = "CHAT_MSG_DND"; break;
|
|
|
|
|
case game::ChatType::LOOT: eventName = "CHAT_MSG_LOOT"; break;
|
|
|
|
|
case game::ChatType::SKILL: eventName = "CHAT_MSG_SKILL"; break;
|
feat: fire CHAT_MSG_* events to Lua addons for all chat types
Wire chat messages to the addon event system via AddonChatCallback.
Every chat message now fires the corresponding WoW event:
- CHAT_MSG_SAY, CHAT_MSG_YELL, CHAT_MSG_WHISPER
- CHAT_MSG_PARTY, CHAT_MSG_GUILD, CHAT_MSG_OFFICER
- CHAT_MSG_RAID, CHAT_MSG_RAID_WARNING, CHAT_MSG_BATTLEGROUND
- CHAT_MSG_SYSTEM, CHAT_MSG_CHANNEL, CHAT_MSG_EMOTE
Event handlers receive (eventName, message, senderName) arguments.
Addons can now filter, react to, or log chat messages in real-time.
2026-03-20 11:29:53 -07:00
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
if (eventName) {
|
|
|
|
|
addonManager_->fireEvent(eventName, {msg.message, msg.senderName});
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-03-20 11:51:46 -07:00
|
|
|
// Wire generic game events to addon dispatch
|
|
|
|
|
gameHandler->setAddonEventCallback([this](const std::string& event, const std::vector<std::string>& args) {
|
|
|
|
|
if (addonManager_ && addonsLoaded_) {
|
|
|
|
|
addonManager_->fireEvent(event, args);
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-03-20 13:58:54 -07:00
|
|
|
// Wire spell icon path resolver for Lua API (GetSpellInfo, UnitBuff icon, etc.)
|
|
|
|
|
{
|
|
|
|
|
auto spellIconPaths = std::make_shared<std::unordered_map<uint32_t, std::string>>();
|
|
|
|
|
auto spellIconIds = std::make_shared<std::unordered_map<uint32_t, uint32_t>>();
|
|
|
|
|
auto loaded = std::make_shared<bool>(false);
|
|
|
|
|
auto* am = assetManager.get();
|
|
|
|
|
gameHandler->setSpellIconPathResolver([spellIconPaths, spellIconIds, loaded, am](uint32_t spellId) -> std::string {
|
|
|
|
|
if (!am) return {};
|
|
|
|
|
// Lazy-load SpellIcon.dbc + Spell.dbc icon IDs on first call
|
|
|
|
|
if (!*loaded) {
|
|
|
|
|
*loaded = true;
|
|
|
|
|
auto iconDbc = am->loadDBC("SpellIcon.dbc");
|
|
|
|
|
const auto* iconL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("SpellIcon") : nullptr;
|
|
|
|
|
if (iconDbc && iconDbc->isLoaded()) {
|
|
|
|
|
for (uint32_t i = 0; i < iconDbc->getRecordCount(); i++) {
|
|
|
|
|
uint32_t id = iconDbc->getUInt32(i, iconL ? (*iconL)["ID"] : 0);
|
|
|
|
|
std::string path = iconDbc->getString(i, iconL ? (*iconL)["Path"] : 1);
|
|
|
|
|
if (!path.empty() && id > 0) (*spellIconPaths)[id] = path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
auto spellDbc = am->loadDBC("Spell.dbc");
|
|
|
|
|
const auto* spellL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("Spell") : nullptr;
|
|
|
|
|
if (spellDbc && spellDbc->isLoaded()) {
|
|
|
|
|
uint32_t fieldCount = spellDbc->getFieldCount();
|
|
|
|
|
uint32_t iconField = 133; // WotLK default
|
|
|
|
|
uint32_t idField = 0;
|
|
|
|
|
if (spellL) {
|
|
|
|
|
uint32_t layoutIcon = (*spellL)["IconID"];
|
|
|
|
|
if (layoutIcon < fieldCount && fieldCount <= layoutIcon + 20) {
|
|
|
|
|
iconField = layoutIcon;
|
|
|
|
|
idField = (*spellL)["ID"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (uint32_t i = 0; i < spellDbc->getRecordCount(); i++) {
|
|
|
|
|
uint32_t id = spellDbc->getUInt32(i, idField);
|
|
|
|
|
uint32_t iconId = spellDbc->getUInt32(i, iconField);
|
|
|
|
|
if (id > 0 && iconId > 0) (*spellIconIds)[id] = iconId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
auto iit = spellIconIds->find(spellId);
|
|
|
|
|
if (iit == spellIconIds->end()) return {};
|
|
|
|
|
auto pit = spellIconPaths->find(iit->second);
|
|
|
|
|
if (pit == spellIconPaths->end()) return {};
|
|
|
|
|
return pit->second;
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-03-21 02:53:07 -07:00
|
|
|
// Wire item icon path resolver: displayInfoId -> "Interface\\Icons\\INV_..."
|
|
|
|
|
{
|
|
|
|
|
auto iconNames = std::make_shared<std::unordered_map<uint32_t, std::string>>();
|
|
|
|
|
auto loaded = std::make_shared<bool>(false);
|
|
|
|
|
auto* am = assetManager.get();
|
|
|
|
|
gameHandler->setItemIconPathResolver([iconNames, loaded, am](uint32_t displayInfoId) -> std::string {
|
|
|
|
|
if (!am || displayInfoId == 0) return {};
|
|
|
|
|
if (!*loaded) {
|
|
|
|
|
*loaded = true;
|
|
|
|
|
auto dbc = am->loadDBC("ItemDisplayInfo.dbc");
|
|
|
|
|
const auto* dispL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("ItemDisplayInfo") : nullptr;
|
|
|
|
|
if (dbc && dbc->isLoaded()) {
|
|
|
|
|
uint32_t iconField = dispL ? (*dispL)["InventoryIcon"] : 5;
|
|
|
|
|
for (uint32_t i = 0; i < dbc->getRecordCount(); i++) {
|
|
|
|
|
uint32_t id = dbc->getUInt32(i, 0); // field 0 = ID
|
|
|
|
|
std::string name = dbc->getString(i, iconField);
|
|
|
|
|
if (id > 0 && !name.empty()) (*iconNames)[id] = name;
|
|
|
|
|
}
|
|
|
|
|
LOG_INFO("Loaded ", iconNames->size(), " item icon names from ItemDisplayInfo.dbc");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
auto it = iconNames->find(displayInfoId);
|
|
|
|
|
if (it == iconNames->end()) return {};
|
|
|
|
|
return "Interface\\Icons\\" + it->second;
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-03-21 04:16:12 -07:00
|
|
|
// Wire spell data resolver: spellId -> {castTimeMs, minRange, maxRange}
|
|
|
|
|
{
|
|
|
|
|
auto castTimeMap = std::make_shared<std::unordered_map<uint32_t, uint32_t>>();
|
|
|
|
|
auto rangeMap = std::make_shared<std::unordered_map<uint32_t, std::pair<float,float>>>();
|
|
|
|
|
auto spellCastIdx = std::make_shared<std::unordered_map<uint32_t, uint32_t>>(); // spellId→castTimeIdx
|
|
|
|
|
auto spellRangeIdx = std::make_shared<std::unordered_map<uint32_t, uint32_t>>(); // spellId→rangeIdx
|
2026-03-21 04:20:58 -07:00
|
|
|
struct SpellCostEntry { uint32_t manaCost = 0; uint8_t powerType = 0; };
|
|
|
|
|
auto spellCostMap = std::make_shared<std::unordered_map<uint32_t, SpellCostEntry>>();
|
2026-03-21 04:16:12 -07:00
|
|
|
auto loaded = std::make_shared<bool>(false);
|
|
|
|
|
auto* am = assetManager.get();
|
2026-03-21 04:20:58 -07:00
|
|
|
gameHandler->setSpellDataResolver([castTimeMap, rangeMap, spellCastIdx, spellRangeIdx, spellCostMap, loaded, am](uint32_t spellId) -> game::GameHandler::SpellDataInfo {
|
2026-03-21 04:16:12 -07:00
|
|
|
if (!am) return {};
|
|
|
|
|
if (!*loaded) {
|
|
|
|
|
*loaded = true;
|
|
|
|
|
// Load SpellCastTimes.dbc
|
|
|
|
|
auto ctDbc = am->loadDBC("SpellCastTimes.dbc");
|
|
|
|
|
if (ctDbc && ctDbc->isLoaded()) {
|
|
|
|
|
for (uint32_t i = 0; i < ctDbc->getRecordCount(); ++i) {
|
|
|
|
|
uint32_t id = ctDbc->getUInt32(i, 0);
|
|
|
|
|
int32_t base = static_cast<int32_t>(ctDbc->getUInt32(i, 1));
|
|
|
|
|
if (id > 0 && base > 0) (*castTimeMap)[id] = static_cast<uint32_t>(base);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Load SpellRange.dbc
|
|
|
|
|
const auto* srL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("SpellRange") : nullptr;
|
|
|
|
|
uint32_t minRField = srL ? (*srL)["MinRange"] : 1;
|
|
|
|
|
uint32_t maxRField = srL ? (*srL)["MaxRange"] : 4;
|
|
|
|
|
auto rDbc = am->loadDBC("SpellRange.dbc");
|
|
|
|
|
if (rDbc && rDbc->isLoaded()) {
|
|
|
|
|
for (uint32_t i = 0; i < rDbc->getRecordCount(); ++i) {
|
|
|
|
|
uint32_t id = rDbc->getUInt32(i, 0);
|
|
|
|
|
float minR = rDbc->getFloat(i, minRField);
|
|
|
|
|
float maxR = rDbc->getFloat(i, maxRField);
|
|
|
|
|
if (id > 0) (*rangeMap)[id] = {minR, maxR};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Load Spell.dbc: extract castTimeIndex and rangeIndex per spell
|
|
|
|
|
auto sDbc = am->loadDBC("Spell.dbc");
|
|
|
|
|
const auto* spL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("Spell") : nullptr;
|
|
|
|
|
if (sDbc && sDbc->isLoaded()) {
|
|
|
|
|
uint32_t idF = spL ? (*spL)["ID"] : 0;
|
|
|
|
|
uint32_t ctF = spL ? (*spL)["CastingTimeIndex"] : 134; // WotLK default
|
|
|
|
|
uint32_t rF = spL ? (*spL)["RangeIndex"] : 132;
|
2026-03-21 04:20:58 -07:00
|
|
|
uint32_t ptF = UINT32_MAX, mcF = UINT32_MAX;
|
|
|
|
|
if (spL) {
|
|
|
|
|
try { ptF = (*spL)["PowerType"]; } catch (...) {}
|
|
|
|
|
try { mcF = (*spL)["ManaCost"]; } catch (...) {}
|
|
|
|
|
}
|
|
|
|
|
uint32_t fc = sDbc->getFieldCount();
|
2026-03-21 04:16:12 -07:00
|
|
|
for (uint32_t i = 0; i < sDbc->getRecordCount(); ++i) {
|
|
|
|
|
uint32_t id = sDbc->getUInt32(i, idF);
|
|
|
|
|
if (id == 0) continue;
|
|
|
|
|
uint32_t ct = sDbc->getUInt32(i, ctF);
|
|
|
|
|
uint32_t ri = sDbc->getUInt32(i, rF);
|
|
|
|
|
if (ct > 0) (*spellCastIdx)[id] = ct;
|
|
|
|
|
if (ri > 0) (*spellRangeIdx)[id] = ri;
|
2026-03-21 04:20:58 -07:00
|
|
|
// Extract power cost
|
|
|
|
|
uint32_t mc = (mcF < fc) ? sDbc->getUInt32(i, mcF) : 0;
|
|
|
|
|
uint8_t pt = (ptF < fc) ? static_cast<uint8_t>(sDbc->getUInt32(i, ptF)) : 0;
|
|
|
|
|
if (mc > 0) (*spellCostMap)[id] = {mc, pt};
|
2026-03-21 04:16:12 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LOG_INFO("SpellDataResolver: loaded ", spellCastIdx->size(), " cast indices, ",
|
|
|
|
|
spellRangeIdx->size(), " range indices");
|
|
|
|
|
}
|
|
|
|
|
game::GameHandler::SpellDataInfo info;
|
|
|
|
|
auto ciIt = spellCastIdx->find(spellId);
|
|
|
|
|
if (ciIt != spellCastIdx->end()) {
|
|
|
|
|
auto ctIt = castTimeMap->find(ciIt->second);
|
|
|
|
|
if (ctIt != castTimeMap->end()) info.castTimeMs = ctIt->second;
|
|
|
|
|
}
|
|
|
|
|
auto riIt = spellRangeIdx->find(spellId);
|
|
|
|
|
if (riIt != spellRangeIdx->end()) {
|
|
|
|
|
auto rIt = rangeMap->find(riIt->second);
|
|
|
|
|
if (rIt != rangeMap->end()) {
|
|
|
|
|
info.minRange = rIt->second.first;
|
|
|
|
|
info.maxRange = rIt->second.second;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-21 04:20:58 -07:00
|
|
|
auto mcIt = spellCostMap->find(spellId);
|
|
|
|
|
if (mcIt != spellCostMap->end()) {
|
|
|
|
|
info.manaCost = mcIt->second.manaCost;
|
|
|
|
|
info.powerType = mcIt->second.powerType;
|
|
|
|
|
}
|
2026-03-21 04:16:12 -07:00
|
|
|
return info;
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-03-20 19:18:30 -07:00
|
|
|
// Wire random property/suffix name resolver for item display
|
|
|
|
|
{
|
|
|
|
|
auto propNames = std::make_shared<std::unordered_map<int32_t, std::string>>();
|
|
|
|
|
auto propLoaded = std::make_shared<bool>(false);
|
|
|
|
|
auto* amPtr = assetManager.get();
|
|
|
|
|
gameHandler->setRandomPropertyNameResolver([propNames, propLoaded, amPtr](int32_t id) -> std::string {
|
|
|
|
|
if (!amPtr || id == 0) return {};
|
|
|
|
|
if (!*propLoaded) {
|
|
|
|
|
*propLoaded = true;
|
|
|
|
|
// ItemRandomProperties.dbc: ID=0, Name=4 (string)
|
|
|
|
|
if (auto dbc = amPtr->loadDBC("ItemRandomProperties.dbc"); dbc && dbc->isLoaded()) {
|
|
|
|
|
uint32_t nameField = (dbc->getFieldCount() > 4) ? 4 : 1;
|
|
|
|
|
for (uint32_t r = 0; r < dbc->getRecordCount(); ++r) {
|
|
|
|
|
int32_t rid = static_cast<int32_t>(dbc->getUInt32(r, 0));
|
|
|
|
|
std::string name = dbc->getString(r, nameField);
|
|
|
|
|
if (!name.empty() && rid > 0) (*propNames)[rid] = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ItemRandomSuffix.dbc: ID=0, Name=4 (string) — stored as negative IDs
|
|
|
|
|
if (auto dbc = amPtr->loadDBC("ItemRandomSuffix.dbc"); dbc && dbc->isLoaded()) {
|
|
|
|
|
uint32_t nameField = (dbc->getFieldCount() > 4) ? 4 : 1;
|
|
|
|
|
for (uint32_t r = 0; r < dbc->getRecordCount(); ++r) {
|
|
|
|
|
int32_t rid = static_cast<int32_t>(dbc->getUInt32(r, 0));
|
|
|
|
|
std::string name = dbc->getString(r, nameField);
|
|
|
|
|
if (!name.empty() && rid > 0) (*propNames)[-rid] = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
auto it = propNames->find(id);
|
|
|
|
|
return (it != propNames->end()) ? it->second : std::string{};
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-03-20 11:12:07 -07:00
|
|
|
LOG_INFO("Addon system initialized, found ", addonManager_->getAddons().size(), " addon(s)");
|
|
|
|
|
} else {
|
|
|
|
|
LOG_WARNING("Failed to initialize addon system");
|
|
|
|
|
addonManager_.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 20:06:26 +03:00
|
|
|
// Initialize world loader (handles terrain streaming, world preload, map transitions)
|
|
|
|
|
worldLoader_ = std::make_unique<WorldLoader>(
|
|
|
|
|
*this, renderer.get(), assetManager.get(), gameHandler.get(),
|
|
|
|
|
entitySpawner_.get(), appearanceComposer_.get(), window.get(),
|
|
|
|
|
world.get(), addonManager_.get());
|
|
|
|
|
|
`chore(application): extract appearance controller and unify UI flow`
- Refactor UI application architecture: extracted appearance controller into ui_services.hpp + implementation updates
- Update UI components and managers to use new service layer:
- `action_bar_panel`, `auth_screen`, `character_screen`, `chat_panel`, `combat_ui`, `dialog_manager`, `game_screen`, `settings_panel`, `social_panel`, `toast_manager`, `ui_manager`, `window_manager`
- Adjust core application entrypoints:
- application.cpp
- Update component implementations for new controller flow:
- action_bar_panel.cpp, `chat_panel.cpp`, `combat_ui.cpp`, `dialog_manager.cpp`, `game_screen.cpp`, `settings_panel.cpp`, `social_panel.cpp`, `toast_manager.cpp`, `window_manager.cpp`
These staged changes implement a major architectural refactor for UI/appearance controller separation
2026-04-01 20:59:17 +03:00
|
|
|
// Re-wire UIServices now that all services (addonManager_, worldLoader_) are available
|
|
|
|
|
if (uiManager) {
|
|
|
|
|
ui::UIServices uiServices;
|
|
|
|
|
uiServices.window = window.get();
|
|
|
|
|
uiServices.renderer = renderer.get();
|
|
|
|
|
uiServices.assetManager = assetManager.get();
|
|
|
|
|
uiServices.gameHandler = gameHandler.get();
|
|
|
|
|
uiServices.expansionRegistry = expansionRegistry_.get();
|
|
|
|
|
uiServices.addonManager = addonManager_.get();
|
|
|
|
|
uiServices.audioCoordinator = audioCoordinator_.get();
|
|
|
|
|
uiServices.entitySpawner = entitySpawner_.get();
|
|
|
|
|
uiServices.appearanceComposer = appearanceComposer_.get();
|
|
|
|
|
uiServices.worldLoader = worldLoader_.get();
|
|
|
|
|
uiManager->setServices(uiServices);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 20:06:26 +03:00
|
|
|
// Start background preload for last-played character's world.
|
|
|
|
|
// Warms the file cache so terrain tile loading is faster at Enter World.
|
|
|
|
|
{
|
|
|
|
|
auto lastWorld = worldLoader_->loadLastWorldInfo();
|
|
|
|
|
if (lastWorld.valid) {
|
|
|
|
|
worldLoader_->startWorldPreload(lastWorld.mapId, lastWorld.mapName, lastWorld.x, lastWorld.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
} else {
|
|
|
|
|
LOG_WARNING("Failed to initialize asset manager - asset loading will be unavailable");
|
|
|
|
|
LOG_WARNING("Set WOW_DATA_PATH environment variable to your WoW Data directory");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set up UI callbacks
|
|
|
|
|
setupUICallbacks();
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Application initialized successfully");
|
|
|
|
|
running = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::run() {
|
2026-04-03 09:41:34 +03:00
|
|
|
ZoneScopedN("Application::run");
|
2026-02-02 12:24:50 -08:00
|
|
|
LOG_INFO("Starting main loop");
|
2026-02-25 03:39:45 -08:00
|
|
|
|
|
|
|
|
// Pin main thread to a dedicated CPU core to reduce scheduling jitter
|
|
|
|
|
{
|
|
|
|
|
int numCores = static_cast<int>(std::thread::hardware_concurrency());
|
|
|
|
|
if (numCores >= 2) {
|
2026-02-25 03:41:18 -08:00
|
|
|
#ifdef __linux__
|
2026-02-25 03:39:45 -08:00
|
|
|
cpu_set_t cpuset;
|
|
|
|
|
CPU_ZERO(&cpuset);
|
|
|
|
|
CPU_SET(0, &cpuset);
|
|
|
|
|
int rc = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
|
|
|
|
if (rc == 0) {
|
|
|
|
|
LOG_INFO("Main thread pinned to CPU core 0 (", numCores, " cores available)");
|
|
|
|
|
} else {
|
|
|
|
|
LOG_WARNING("Failed to pin main thread to CPU core 0 (error ", rc, ")");
|
|
|
|
|
}
|
2026-02-25 03:41:18 -08:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
|
DWORD_PTR mask = 1; // Core 0
|
|
|
|
|
DWORD_PTR prev = SetThreadAffinityMask(GetCurrentThread(), mask);
|
|
|
|
|
if (prev != 0) {
|
|
|
|
|
LOG_INFO("Main thread pinned to CPU core 0 (", numCores, " cores available)");
|
|
|
|
|
} else {
|
|
|
|
|
LOG_WARNING("Failed to pin main thread to CPU core 0 (error ", GetLastError(), ")");
|
|
|
|
|
}
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
// macOS doesn't support hard pinning — use affinity tags to hint
|
|
|
|
|
// that the main thread should stay on its own core group
|
|
|
|
|
thread_affinity_policy_data_t policy = { 1 }; // tag 1 = main thread group
|
|
|
|
|
kern_return_t kr = thread_policy_set(
|
|
|
|
|
pthread_mach_thread_np(pthread_self()),
|
|
|
|
|
THREAD_AFFINITY_POLICY,
|
|
|
|
|
reinterpret_cast<thread_policy_t>(&policy),
|
|
|
|
|
THREAD_AFFINITY_POLICY_COUNT);
|
|
|
|
|
if (kr == KERN_SUCCESS) {
|
|
|
|
|
LOG_INFO("Main thread affinity tag set (", numCores, " cores available)");
|
|
|
|
|
} else {
|
|
|
|
|
LOG_WARNING("Failed to set main thread affinity tag (error ", kr, ")");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2026-02-25 03:39:45 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 07:45:49 -08:00
|
|
|
const bool frameProfileEnabled = envFlagEnabled("WOWEE_FRAME_PROFILE", false);
|
|
|
|
|
if (frameProfileEnabled) {
|
|
|
|
|
LOG_INFO("Frame timing profile enabled (WOWEE_FRAME_PROFILE=1)");
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
auto lastTime = std::chrono::high_resolution_clock::now();
|
2026-03-14 07:29:39 -07:00
|
|
|
std::atomic<bool> watchdogRunning{true};
|
|
|
|
|
std::atomic<int64_t> watchdogHeartbeatMs{
|
|
|
|
|
std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
|
|
|
std::chrono::steady_clock::now().time_since_epoch()).count()
|
|
|
|
|
};
|
2026-03-29 21:15:49 -07:00
|
|
|
// Signal flag: watchdog sets this when a stall is detected, main loop
|
|
|
|
|
// handles the actual SDL calls. SDL2 video functions must only be called
|
|
|
|
|
// from the main thread (the one that called SDL_Init); calling them from
|
|
|
|
|
// a background thread is UB on macOS (Cocoa) and unsafe on other platforms.
|
|
|
|
|
std::atomic<bool> watchdogRequestRelease{false};
|
|
|
|
|
std::thread watchdogThread([&watchdogRunning, &watchdogHeartbeatMs, &watchdogRequestRelease]() {
|
|
|
|
|
bool signalledForCurrentStall = false;
|
2026-03-14 07:29:39 -07:00
|
|
|
while (watchdogRunning.load(std::memory_order_acquire)) {
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
|
|
|
|
const int64_t nowMs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
|
|
|
std::chrono::steady_clock::now().time_since_epoch()).count();
|
|
|
|
|
const int64_t lastBeatMs = watchdogHeartbeatMs.load(std::memory_order_acquire);
|
|
|
|
|
const int64_t stallMs = nowMs - lastBeatMs;
|
|
|
|
|
|
|
|
|
|
if (stallMs > 1500) {
|
2026-03-29 21:15:49 -07:00
|
|
|
if (!signalledForCurrentStall) {
|
|
|
|
|
watchdogRequestRelease.store(true, std::memory_order_release);
|
2026-03-14 07:29:39 -07:00
|
|
|
LOG_WARNING("Main-loop stall detected (", stallMs,
|
2026-03-29 21:15:49 -07:00
|
|
|
"ms) — requesting mouse capture release");
|
|
|
|
|
signalledForCurrentStall = true;
|
2026-03-14 07:29:39 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
2026-03-29 21:15:49 -07:00
|
|
|
signalledForCurrentStall = false;
|
2026-03-14 07:29:39 -07:00
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
2026-03-14 07:29:39 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
while (running && !window->shouldClose()) {
|
|
|
|
|
watchdogHeartbeatMs.store(
|
|
|
|
|
std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
|
|
|
std::chrono::steady_clock::now().time_since_epoch()).count(),
|
|
|
|
|
std::memory_order_release);
|
|
|
|
|
|
2026-03-29 21:15:49 -07:00
|
|
|
// Handle watchdog mouse-release request on the main thread where
|
|
|
|
|
// SDL video calls are safe (required by SDL2 threading model).
|
|
|
|
|
if (watchdogRequestRelease.exchange(false, std::memory_order_acq_rel)) {
|
|
|
|
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
|
|
|
SDL_ShowCursor(SDL_ENABLE);
|
|
|
|
|
if (window && window->getSDLWindow()) {
|
|
|
|
|
SDL_SetWindowGrab(window->getSDLWindow(), SDL_FALSE);
|
|
|
|
|
}
|
|
|
|
|
LOG_WARNING("Watchdog: force-released mouse capture on main thread");
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-14 07:29:39 -07:00
|
|
|
// Calculate delta time
|
|
|
|
|
auto currentTime = std::chrono::high_resolution_clock::now();
|
|
|
|
|
std::chrono::duration<float> deltaTimeDuration = currentTime - lastTime;
|
|
|
|
|
float deltaTime = deltaTimeDuration.count();
|
|
|
|
|
lastTime = currentTime;
|
|
|
|
|
|
|
|
|
|
// Cap delta time to prevent large jumps
|
|
|
|
|
if (deltaTime > 0.1f) {
|
|
|
|
|
deltaTime = 0.1f;
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
2026-03-14 07:29:39 -07:00
|
|
|
// Poll events
|
|
|
|
|
SDL_Event event;
|
|
|
|
|
while (SDL_PollEvent(&event)) {
|
|
|
|
|
// Pass event to UI manager first
|
|
|
|
|
if (uiManager) {
|
|
|
|
|
uiManager->processEvent(event);
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
2026-03-14 07:29:39 -07:00
|
|
|
// Pass mouse events to camera controller (skip when UI has mouse focus)
|
|
|
|
|
if (renderer && renderer->getCameraController() && !ImGui::GetIO().WantCaptureMouse) {
|
|
|
|
|
if (event.type == SDL_MOUSEMOTION) {
|
|
|
|
|
renderer->getCameraController()->processMouseMotion(event.motion);
|
|
|
|
|
}
|
|
|
|
|
else if (event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) {
|
|
|
|
|
renderer->getCameraController()->processMouseButton(event.button);
|
|
|
|
|
}
|
|
|
|
|
else if (event.type == SDL_MOUSEWHEEL) {
|
|
|
|
|
renderer->getCameraController()->processMouseWheel(static_cast<float>(event.wheel.y));
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-14 07:29:39 -07:00
|
|
|
// Handle window events
|
|
|
|
|
if (event.type == SDL_QUIT) {
|
|
|
|
|
window->setShouldClose(true);
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
2026-03-14 07:29:39 -07:00
|
|
|
else if (event.type == SDL_WINDOWEVENT) {
|
|
|
|
|
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
|
|
|
|
int newWidth = event.window.data1;
|
|
|
|
|
int newHeight = event.window.data2;
|
|
|
|
|
window->setSize(newWidth, newHeight);
|
|
|
|
|
// Vulkan viewport set in command buffer, not globally
|
|
|
|
|
if (renderer && renderer->getCamera()) {
|
|
|
|
|
renderer->getCamera()->setAspectRatio(static_cast<float>(newWidth) / newHeight);
|
|
|
|
|
}
|
2026-03-22 19:29:06 -07:00
|
|
|
// Notify addons so UI layouts can adapt to the new size
|
|
|
|
|
if (addonManager_)
|
|
|
|
|
addonManager_->fireEvent("DISPLAY_SIZE_CHANGED");
|
2026-02-05 16:11:24 -08:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-14 07:29:39 -07:00
|
|
|
// Debug controls
|
|
|
|
|
else if (event.type == SDL_KEYDOWN) {
|
|
|
|
|
// Skip non-function-key input when UI (chat) has keyboard focus
|
|
|
|
|
bool uiHasKeyboard = ImGui::GetIO().WantCaptureKeyboard;
|
|
|
|
|
auto sc = event.key.keysym.scancode;
|
|
|
|
|
bool isFKey = (sc >= SDL_SCANCODE_F1 && sc <= SDL_SCANCODE_F12);
|
|
|
|
|
if (uiHasKeyboard && !isFKey) {
|
|
|
|
|
continue; // Let ImGui handle the keystroke
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// F1: Toggle performance HUD
|
|
|
|
|
if (event.key.keysym.scancode == SDL_SCANCODE_F1) {
|
|
|
|
|
if (renderer && renderer->getPerformanceHUD()) {
|
|
|
|
|
renderer->getPerformanceHUD()->toggle();
|
|
|
|
|
bool enabled = renderer->getPerformanceHUD()->isEnabled();
|
|
|
|
|
LOG_INFO("Performance HUD: ", enabled ? "ON" : "OFF");
|
|
|
|
|
}
|
2026-02-19 20:36:25 -08:00
|
|
|
}
|
2026-03-14 07:29:39 -07:00
|
|
|
// F4: Toggle shadows
|
|
|
|
|
else if (event.key.keysym.scancode == SDL_SCANCODE_F4) {
|
|
|
|
|
if (renderer) {
|
|
|
|
|
bool enabled = !renderer->areShadowsEnabled();
|
|
|
|
|
renderer->setShadowsEnabled(enabled);
|
|
|
|
|
LOG_INFO("Shadows: ", enabled ? "ON" : "OFF");
|
|
|
|
|
}
|
2026-02-19 20:36:25 -08:00
|
|
|
}
|
2026-03-14 07:29:39 -07:00
|
|
|
// F8: Debug WMO floor at current position
|
|
|
|
|
else if (event.key.keysym.scancode == SDL_SCANCODE_F8 && event.key.repeat == 0) {
|
|
|
|
|
if (renderer && renderer->getWMORenderer()) {
|
|
|
|
|
glm::vec3 pos = renderer->getCharacterPosition();
|
|
|
|
|
LOG_WARNING("F8: WMO floor debug at render pos (", pos.x, ", ", pos.y, ", ", pos.z, ")");
|
|
|
|
|
renderer->getWMORenderer()->debugDumpGroupsAtPosition(pos.x, pos.y, pos.z);
|
|
|
|
|
}
|
2026-03-04 19:47:01 -08:00
|
|
|
}
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
2026-03-14 07:29:39 -07:00
|
|
|
// Update input
|
|
|
|
|
Input::getInstance().update();
|
|
|
|
|
|
|
|
|
|
// Update application state
|
|
|
|
|
try {
|
2026-04-03 09:41:34 +03:00
|
|
|
FrameMark;
|
2026-03-14 07:29:39 -07:00
|
|
|
update(deltaTime);
|
|
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM during Application::update (state=", static_cast<int>(state),
|
|
|
|
|
", dt=", deltaTime, "): ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception during Application::update (state=", static_cast<int>(state),
|
|
|
|
|
", dt=", deltaTime, "): ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
// Render
|
|
|
|
|
try {
|
|
|
|
|
render();
|
|
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM during Application::render (state=", static_cast<int>(state), "): ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception during Application::render (state=", static_cast<int>(state), "): ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
// Swap buffers
|
|
|
|
|
try {
|
|
|
|
|
window->swapBuffers();
|
|
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM during swapBuffers: ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception during swapBuffers: ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Exit gracefully on GPU device lost (unrecoverable)
|
|
|
|
|
if (renderer && renderer->getVkContext() && renderer->getVkContext()->isDeviceLost()) {
|
|
|
|
|
LOG_ERROR("GPU device lost — exiting application");
|
|
|
|
|
window->setShouldClose(true);
|
|
|
|
|
}
|
2026-03-20 18:51:05 -07:00
|
|
|
|
|
|
|
|
// Soft frame rate cap when vsync is off to prevent 100% CPU usage.
|
|
|
|
|
// Target ~240 FPS max (~4.2ms per frame); vsync handles its own pacing.
|
|
|
|
|
if (!window->isVsyncEnabled() && deltaTime < 0.004f) {
|
|
|
|
|
float sleepMs = (0.004f - deltaTime) * 1000.0f;
|
|
|
|
|
if (sleepMs > 0.5f)
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds(
|
|
|
|
|
static_cast<int64_t>(sleepMs * 900.0f))); // 90% of target to account for sleep overshoot
|
|
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
2026-03-14 07:29:39 -07:00
|
|
|
} catch (...) {
|
|
|
|
|
watchdogRunning.store(false, std::memory_order_release);
|
|
|
|
|
if (watchdogThread.joinable()) {
|
|
|
|
|
watchdogThread.join();
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
2026-03-14 07:29:39 -07:00
|
|
|
throw;
|
|
|
|
|
}
|
2026-03-02 08:47:06 -08:00
|
|
|
|
2026-03-14 07:29:39 -07:00
|
|
|
watchdogRunning.store(false, std::memory_order_release);
|
|
|
|
|
if (watchdogThread.joinable()) {
|
|
|
|
|
watchdogThread.join();
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Main loop ended");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::shutdown() {
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Shutting down application...");
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-03-17 09:04:47 -07:00
|
|
|
// Hide the window immediately so the OS doesn't think the app is frozen
|
|
|
|
|
// during the (potentially slow) resource cleanup below.
|
|
|
|
|
if (window && window->getSDLWindow()) {
|
|
|
|
|
SDL_HideWindow(window->getSDLWindow());
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 13:44:09 -08:00
|
|
|
// Stop background world preloader before destroying AssetManager
|
2026-04-01 20:06:26 +03:00
|
|
|
if (worldLoader_) {
|
|
|
|
|
worldLoader_->cancelWorldPreload();
|
|
|
|
|
};
|
2026-03-07 13:44:09 -08:00
|
|
|
|
2026-02-05 17:20:30 -08:00
|
|
|
// Save floor cache before renderer is destroyed
|
|
|
|
|
if (renderer && renderer->getWMORenderer()) {
|
2026-02-05 17:26:18 -08:00
|
|
|
size_t cacheSize = renderer->getWMORenderer()->getFloorCacheSize();
|
|
|
|
|
if (cacheSize > 0) {
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Saving WMO floor cache (", cacheSize, " entries)...");
|
2026-02-05 17:35:17 -08:00
|
|
|
renderer->getWMORenderer()->saveFloorCache();
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Floor cache saved.");
|
2026-02-05 17:26:18 -08:00
|
|
|
}
|
2026-02-05 17:20:30 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-22 05:58:45 -08:00
|
|
|
// Explicitly shut down the renderer before destroying it — this ensures
|
|
|
|
|
// all sub-renderers free their VMA allocations in the correct order,
|
|
|
|
|
// before VkContext::shutdown() calls vmaDestroyAllocator().
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Shutting down renderer...");
|
2026-02-22 05:58:45 -08:00
|
|
|
if (renderer) {
|
|
|
|
|
renderer->shutdown();
|
|
|
|
|
}
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Renderer shutdown complete, resetting...");
|
2026-02-04 16:07:28 -08:00
|
|
|
renderer.reset();
|
|
|
|
|
|
2026-04-02 00:21:21 +03:00
|
|
|
// Shutdown audio coordinator after renderer (renderer may reference audio during shutdown)
|
|
|
|
|
if (audioCoordinator_) {
|
|
|
|
|
audioCoordinator_->shutdown();
|
|
|
|
|
}
|
|
|
|
|
audioCoordinator_.reset();
|
|
|
|
|
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Resetting world...");
|
2026-02-02 12:24:50 -08:00
|
|
|
world.reset();
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Resetting gameHandler...");
|
2026-02-02 12:24:50 -08:00
|
|
|
gameHandler.reset();
|
2026-03-30 13:40:40 -07:00
|
|
|
gameServices_ = {};
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Resetting authHandler...");
|
2026-02-02 12:24:50 -08:00
|
|
|
authHandler.reset();
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Resetting assetManager...");
|
2026-02-02 12:24:50 -08:00
|
|
|
assetManager.reset();
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Resetting uiManager...");
|
2026-02-02 12:24:50 -08:00
|
|
|
uiManager.reset();
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Resetting window...");
|
2026-02-02 12:24:50 -08:00
|
|
|
window.reset();
|
|
|
|
|
|
|
|
|
|
running = false;
|
2026-04-05 20:18:39 -07:00
|
|
|
LOG_DEBUG("Application shutdown complete");
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::setState(AppState newState) {
|
|
|
|
|
if (state == newState) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_INFO("State transition: ", static_cast<int>(state), " -> ", static_cast<int>(newState));
|
|
|
|
|
state = newState;
|
|
|
|
|
|
|
|
|
|
// Handle state transitions
|
|
|
|
|
switch (newState) {
|
|
|
|
|
case AppState::AUTHENTICATION:
|
|
|
|
|
// Show auth screen
|
|
|
|
|
break;
|
|
|
|
|
case AppState::REALM_SELECTION:
|
|
|
|
|
// Show realm screen
|
|
|
|
|
break;
|
2026-02-05 14:13:48 -08:00
|
|
|
case AppState::CHARACTER_CREATION:
|
|
|
|
|
// Show character create screen
|
|
|
|
|
break;
|
2026-02-02 12:24:50 -08:00
|
|
|
case AppState::CHARACTER_SELECTION:
|
|
|
|
|
// Show character screen
|
2026-02-12 14:55:27 -08:00
|
|
|
if (uiManager && assetManager) {
|
|
|
|
|
uiManager->getCharacterScreen().setAssetManager(assetManager.get());
|
|
|
|
|
}
|
|
|
|
|
// Ensure no stale in-world player model leaks into the next login attempt.
|
|
|
|
|
// If we reuse a previously spawned instance without forcing a respawn, appearance (notably hair) can desync.
|
2026-03-20 11:23:38 -07:00
|
|
|
if (addonManager_ && addonsLoaded_) {
|
|
|
|
|
addonManager_->fireEvent("PLAYER_LEAVING_WORLD");
|
2026-03-20 12:22:50 -07:00
|
|
|
addonManager_->saveAllSavedVariables();
|
2026-03-20 11:23:38 -07:00
|
|
|
}
|
2026-02-12 14:55:27 -08:00
|
|
|
npcsSpawned = false;
|
|
|
|
|
playerCharacterSpawned = false;
|
2026-03-20 11:12:07 -07:00
|
|
|
addonsLoaded_ = false;
|
2026-04-01 13:31:48 +03:00
|
|
|
if (appearanceComposer_) appearanceComposer_->setWeaponsSheathed(false);
|
2026-02-12 14:55:27 -08:00
|
|
|
wasAutoAttacking_ = false;
|
2026-04-01 20:06:26 +03:00
|
|
|
if (worldLoader_) worldLoader_->resetLoadedMap();
|
2026-02-12 14:55:27 -08:00
|
|
|
spawnedPlayerGuid_ = 0;
|
|
|
|
|
spawnedAppearanceBytes_ = 0;
|
|
|
|
|
spawnedFacialFeatures_ = 0;
|
|
|
|
|
if (renderer && renderer->getCharacterRenderer()) {
|
|
|
|
|
uint32_t oldInst = renderer->getCharacterInstanceId();
|
|
|
|
|
if (oldInst > 0) {
|
|
|
|
|
renderer->setCharacterFollow(0);
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->clearMount();
|
2026-02-12 14:55:27 -08:00
|
|
|
renderer->getCharacterRenderer()->removeInstance(oldInst);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
break;
|
2026-02-08 03:05:38 -08:00
|
|
|
case AppState::IN_GAME: {
|
2026-02-02 12:24:50 -08:00
|
|
|
// Wire up movement opcodes from camera controller
|
|
|
|
|
if (renderer && renderer->getCameraController()) {
|
|
|
|
|
auto* cc = renderer->getCameraController();
|
|
|
|
|
cc->setMovementCallback([this](uint32_t opcode) {
|
2026-02-06 23:52:16 -08:00
|
|
|
if (gameHandler) {
|
2026-02-02 12:24:50 -08:00
|
|
|
gameHandler->sendMovement(static_cast<game::Opcode>(opcode));
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-03-10 19:49:33 -07:00
|
|
|
cc->setStandUpCallback([this]() {
|
|
|
|
|
if (gameHandler) {
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
gameHandler->setStandState(rendering::AnimationController::STAND_STATE_STAND);
|
2026-03-10 19:49:33 -07:00
|
|
|
}
|
|
|
|
|
});
|
2026-04-05 12:27:35 +03:00
|
|
|
cc->setSitDownCallback([this]() {
|
|
|
|
|
if (gameHandler) {
|
|
|
|
|
gameHandler->setStandState(rendering::AnimationController::STAND_STATE_SIT);
|
|
|
|
|
}
|
|
|
|
|
if (renderer) {
|
|
|
|
|
if (auto* ac = renderer->getAnimationController()) {
|
|
|
|
|
ac->setStandState(rendering::AnimationController::STAND_STATE_SIT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-03-27 17:54:56 -07:00
|
|
|
cc->setAutoFollowCancelCallback([this]() {
|
|
|
|
|
if (gameHandler) {
|
|
|
|
|
gameHandler->cancelFollow();
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-02-03 20:40:59 -08:00
|
|
|
cc->setUseWoWSpeed(true);
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
2026-02-05 14:01:26 -08:00
|
|
|
if (gameHandler) {
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
gameHandler->setMeleeSwingCallback([this](uint32_t spellId) {
|
2026-02-05 14:01:26 -08:00
|
|
|
if (renderer) {
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
// Ranged auto-attack spells: Auto Shot (75), Shoot (5019), Throw (2764)
|
|
|
|
|
if (spellId == 75 || spellId == 5019 || spellId == 2764) {
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->triggerRangedShot();
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
} else if (spellId != 0) {
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->triggerSpecialAttack(spellId);
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
} else {
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->triggerMeleeSwing();
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
}
|
2026-02-05 14:01:26 -08:00
|
|
|
}
|
|
|
|
|
});
|
2026-03-10 12:28:11 -07:00
|
|
|
gameHandler->setKnockBackCallback([this](float vcos, float vsin, float hspeed, float vspeed) {
|
|
|
|
|
if (renderer && renderer->getCameraController()) {
|
|
|
|
|
renderer->getCameraController()->applyKnockBack(vcos, vsin, hspeed, vspeed);
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-03-12 19:37:53 -07:00
|
|
|
gameHandler->setCameraShakeCallback([this](float magnitude, float frequency, float duration) {
|
|
|
|
|
if (renderer && renderer->getCameraController()) {
|
|
|
|
|
renderer->getCameraController()->triggerShake(magnitude, frequency, duration);
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-03-27 17:54:56 -07:00
|
|
|
gameHandler->setAutoFollowCallback([this](const glm::vec3* renderPos) {
|
|
|
|
|
if (renderer && renderer->getCameraController()) {
|
|
|
|
|
if (renderPos) {
|
|
|
|
|
renderer->getCameraController()->setAutoFollow(renderPos);
|
|
|
|
|
} else {
|
|
|
|
|
renderer->getCameraController()->cancelAutoFollow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-02-05 14:01:26 -08:00
|
|
|
}
|
2026-02-09 23:05:23 -08:00
|
|
|
// Load quest marker models
|
|
|
|
|
loadQuestMarkerModels();
|
2026-02-02 12:24:50 -08:00
|
|
|
break;
|
2026-02-08 03:05:38 -08:00
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
case AppState::DISCONNECTED:
|
|
|
|
|
// Back to auth
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-13 16:53:28 -08:00
|
|
|
void Application::reloadExpansionData() {
|
|
|
|
|
if (!expansionRegistry_ || !gameHandler) return;
|
|
|
|
|
auto* profile = expansionRegistry_->getActive();
|
|
|
|
|
if (!profile) return;
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Reloading expansion data for: ", profile->name);
|
|
|
|
|
|
|
|
|
|
std::string opcodesPath = profile->dataPath + "/opcodes.json";
|
|
|
|
|
if (!gameHandler->getOpcodeTable().loadFromJson(opcodesPath)) {
|
2026-02-20 00:39:20 -08:00
|
|
|
LOG_ERROR("Failed to load opcodes from ", opcodesPath);
|
2026-02-13 16:53:28 -08:00
|
|
|
}
|
|
|
|
|
game::setActiveOpcodeTable(&gameHandler->getOpcodeTable());
|
|
|
|
|
|
|
|
|
|
std::string updateFieldsPath = profile->dataPath + "/update_fields.json";
|
|
|
|
|
if (!gameHandler->getUpdateFieldTable().loadFromJson(updateFieldsPath)) {
|
2026-02-20 00:39:20 -08:00
|
|
|
LOG_ERROR("Failed to load update fields from ", updateFieldsPath);
|
2026-02-13 16:53:28 -08:00
|
|
|
}
|
|
|
|
|
game::setActiveUpdateFieldTable(&gameHandler->getUpdateFieldTable());
|
|
|
|
|
|
|
|
|
|
gameHandler->setPacketParsers(game::createPacketParsers(profile->id));
|
|
|
|
|
|
|
|
|
|
if (dbcLayout_) {
|
|
|
|
|
std::string dbcLayoutsPath = profile->dataPath + "/dbc_layouts.json";
|
|
|
|
|
if (!dbcLayout_->loadFromJson(dbcLayoutsPath)) {
|
2026-02-20 00:39:20 -08:00
|
|
|
LOG_ERROR("Failed to load DBC layouts from ", dbcLayoutsPath);
|
2026-02-13 16:53:28 -08:00
|
|
|
}
|
|
|
|
|
pipeline::setActiveDBCLayout(dbcLayout_.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update expansion data path for CSV DBC lookups and clear DBC cache
|
|
|
|
|
if (assetManager && !profile->dataPath.empty()) {
|
|
|
|
|
assetManager->setExpansionDataPath(profile->dataPath);
|
|
|
|
|
assetManager->clearDBCCache();
|
|
|
|
|
}
|
2026-02-14 00:00:26 -08:00
|
|
|
|
|
|
|
|
// Reset map name cache so it reloads from new expansion's Map.dbc
|
2026-04-01 20:06:26 +03:00
|
|
|
if (worldLoader_) worldLoader_->resetMapNameCache();
|
2026-02-14 19:27:35 -08:00
|
|
|
|
|
|
|
|
// Reset game handler DBC caches so they reload from new expansion data
|
|
|
|
|
if (gameHandler) {
|
|
|
|
|
gameHandler->resetDbcCaches();
|
|
|
|
|
}
|
2026-02-17 01:00:04 -08:00
|
|
|
|
|
|
|
|
// Rebuild creature display lookups with the new expansion's DBC layout
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_) entitySpawner_->rebuildLookups();
|
2026-02-13 16:53:28 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-05 15:59:06 -08:00
|
|
|
void Application::logoutToLogin() {
|
|
|
|
|
LOG_INFO("Logout requested");
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
|
|
|
|
|
// Disconnect TransportManager from WMORenderer before tearing down
|
|
|
|
|
if (gameHandler && gameHandler->getTransportManager()) {
|
|
|
|
|
gameHandler->getTransportManager()->setWMORenderer(nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 15:59:06 -08:00
|
|
|
if (gameHandler) {
|
|
|
|
|
gameHandler->disconnect();
|
|
|
|
|
}
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
|
|
|
|
|
// --- Per-session flags ---
|
2026-02-05 15:59:06 -08:00
|
|
|
npcsSpawned = false;
|
2026-02-06 20:49:17 -08:00
|
|
|
playerCharacterSpawned = false;
|
2026-04-01 13:31:48 +03:00
|
|
|
if (appearanceComposer_) appearanceComposer_->setWeaponsSheathed(false);
|
2026-02-12 00:15:51 -08:00
|
|
|
wasAutoAttacking_ = false;
|
2026-04-01 20:06:26 +03:00
|
|
|
if (worldLoader_) worldLoader_->resetLoadedMap();
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
if (worldEntryCallbacks_) worldEntryCallbacks_->resetState();
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
facingSendCooldown_ = 0.0f;
|
|
|
|
|
lastSentCanonicalYaw_ = 1000.0f;
|
|
|
|
|
taxiStreamCooldown_ = 0.0f;
|
|
|
|
|
idleYawned_ = false;
|
|
|
|
|
|
|
|
|
|
// --- Charge state ---
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
if (animationCallbacks_) animationCallbacks_->resetChargeState();
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
|
|
|
|
|
// --- Player identity ---
|
|
|
|
|
spawnedPlayerGuid_ = 0;
|
|
|
|
|
spawnedAppearanceBytes_ = 0;
|
|
|
|
|
spawnedFacialFeatures_ = 0;
|
|
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
// --- Reset all EntitySpawner state (mount, creatures, players, GOs, queues, caches) ---
|
|
|
|
|
if (entitySpawner_) entitySpawner_->resetAllState();
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
|
2026-02-05 15:59:06 -08:00
|
|
|
world.reset();
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
|
2026-02-05 15:59:06 -08:00
|
|
|
if (renderer) {
|
2026-03-14 09:19:16 -07:00
|
|
|
renderer->resetCombatVisualState();
|
2026-02-06 20:49:17 -08:00
|
|
|
// Remove old player model so it doesn't persist into next session
|
|
|
|
|
if (auto* charRenderer = renderer->getCharacterRenderer()) {
|
|
|
|
|
charRenderer->removeInstance(1);
|
|
|
|
|
}
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
// Clear all world geometry renderers
|
|
|
|
|
if (auto* wmo = renderer->getWMORenderer()) {
|
|
|
|
|
wmo->clearInstances();
|
|
|
|
|
}
|
|
|
|
|
if (auto* m2 = renderer->getM2Renderer()) {
|
|
|
|
|
m2->clear();
|
|
|
|
|
}
|
2026-02-25 13:37:09 -08:00
|
|
|
// Clear terrain tile tracking + water surfaces so next world entry starts fresh.
|
|
|
|
|
// Use softReset() instead of unloadAll() to avoid blocking on worker thread joins.
|
2026-02-25 13:26:08 -08:00
|
|
|
if (auto* terrain = renderer->getTerrainManager()) {
|
2026-02-25 13:37:09 -08:00
|
|
|
terrain->softReset();
|
2026-02-25 13:26:08 -08:00
|
|
|
}
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
if (auto* questMarkers = renderer->getQuestMarkerRenderer()) {
|
|
|
|
|
questMarkers->clear();
|
|
|
|
|
}
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->clearMount();
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
renderer->setCharacterFollow(0);
|
chore(renderer): extract AnimationController and remove audio pass-throughs
Extract ~1,500 lines of character animation state from Renderer into a dedicated
AnimationController class, and complete the AudioCoordinator migration by removing
all 10 audio pass-through getters from Renderer.
AnimationController:
- New: include/rendering/animation_controller.hpp (182 lines)
- New: src/rendering/animation_controller.cpp (1,703 lines)
- Moves: locomotion state machine (50+ members), mount animation (40+ members),
emote system, footstep triggering, surface detection, melee combat animations
- Renderer holds std::unique_ptr<AnimationController> and delegates completely
- AnimationController accesses audio via renderer_->getAudioCoordinator()
Audio caller migration:
- Migrate ~60 external callers from renderer->getXManager() to AudioCoordinator
directly, grouped by access pattern:
- UIServices: settings_panel, game_screen, toast_manager, chat_panel,
combat_ui, window_manager
- GameServices: game_handler, spell_handler, inventory_handler, quest_handler,
social_handler, combat_handler
- Application singleton: application.cpp, auth_screen.cpp, lua_engine.cpp
- Remove 10 pass-through getter definitions from renderer.cpp
- Remove 10 pass-through getter declarations from renderer.hpp
- Remove individual audio manager forward declarations from renderer.hpp
- Redirect 69 internal renderer.cpp audio calls to audioCoordinator_ directly
- game_handler.cpp: withSoundManager template uses services_.audioCoordinator;
MFP changed from &Renderer::getUiSoundManager to &AudioCoordinator::getUiSoundManager
- GameServices struct: add AudioCoordinator* audioCoordinator member
- settings_panel: applyAudioVolumes(Renderer*) -> applyAudioVolumes(AudioCoordinator*)
2026-04-02 13:06:31 +03:00
|
|
|
if (auto* music = audioCoordinator_ ? audioCoordinator_->getMusicManager() : nullptr) {
|
2026-02-05 15:59:06 -08:00
|
|
|
music->stopMusic(0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
Fix crash on re-login by clearing all per-session state on logout
logoutToLogin() was only clearing a handful of flags, leaving stale
entity instance maps, pending spawn queues, transport state, mount
state, and charge state from the previous session. On second login,
these stale GUIDs and instance IDs caused invalid renderer operations
and crashes.
Now clears: creature/player/gameObject instance maps, all pending
spawn queues, transport doodad batches, mount/charge state, player
identity, and renderer world geometry (WMO instances, M2 models,
quest markers). Also disconnects TransportManager from WMORenderer
before teardown to prevent dangling pointer access.
2026-02-25 12:09:00 -08:00
|
|
|
|
2026-02-14 19:24:31 -08:00
|
|
|
// Clear stale realm/character selection so switching servers starts fresh
|
|
|
|
|
if (uiManager) {
|
|
|
|
|
uiManager->getRealmScreen().reset();
|
|
|
|
|
uiManager->getCharacterScreen().reset();
|
|
|
|
|
}
|
2026-02-05 15:59:06 -08:00
|
|
|
setState(AppState::AUTHENTICATION);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
void Application::update(float deltaTime) {
|
2026-04-03 09:41:34 +03:00
|
|
|
ZoneScopedN("Application::update");
|
2026-02-22 07:26:54 -08:00
|
|
|
const char* updateCheckpoint = "enter";
|
|
|
|
|
try {
|
2026-02-02 12:24:50 -08:00
|
|
|
// Update based on current state
|
2026-02-22 07:26:54 -08:00
|
|
|
updateCheckpoint = "state switch";
|
2026-02-02 12:24:50 -08:00
|
|
|
switch (state) {
|
|
|
|
|
case AppState::AUTHENTICATION:
|
2026-02-22 07:44:32 -08:00
|
|
|
updateCheckpoint = "auth: enter";
|
2026-02-02 12:24:50 -08:00
|
|
|
if (authHandler) {
|
|
|
|
|
authHandler->update(deltaTime);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AppState::REALM_SELECTION:
|
2026-02-22 07:44:32 -08:00
|
|
|
updateCheckpoint = "realm_selection: enter";
|
2026-02-05 13:59:33 -08:00
|
|
|
if (authHandler) {
|
|
|
|
|
authHandler->update(deltaTime);
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
break;
|
|
|
|
|
|
2026-02-05 14:13:48 -08:00
|
|
|
case AppState::CHARACTER_CREATION:
|
2026-02-22 07:44:32 -08:00
|
|
|
updateCheckpoint = "char_creation: enter";
|
2026-02-05 14:18:41 -08:00
|
|
|
if (gameHandler) {
|
|
|
|
|
gameHandler->update(deltaTime);
|
|
|
|
|
}
|
2026-02-05 14:55:42 -08:00
|
|
|
if (uiManager) {
|
|
|
|
|
uiManager->getCharacterCreateScreen().update(deltaTime);
|
|
|
|
|
}
|
2026-02-05 14:13:48 -08:00
|
|
|
break;
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
case AppState::CHARACTER_SELECTION:
|
2026-02-22 07:44:32 -08:00
|
|
|
updateCheckpoint = "char_selection: enter";
|
2026-02-05 14:18:41 -08:00
|
|
|
if (gameHandler) {
|
|
|
|
|
gameHandler->update(deltaTime);
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
break;
|
|
|
|
|
|
2026-02-08 03:05:38 -08:00
|
|
|
case AppState::IN_GAME: {
|
2026-02-22 07:44:32 -08:00
|
|
|
updateCheckpoint = "in_game: enter";
|
2026-02-22 07:26:54 -08:00
|
|
|
const char* inGameStep = "begin";
|
|
|
|
|
try {
|
|
|
|
|
auto runInGameStage = [&](const char* stageName, auto&& fn) {
|
2026-03-07 13:44:09 -08:00
|
|
|
auto stageStart = std::chrono::steady_clock::now();
|
2026-02-22 07:26:54 -08:00
|
|
|
try {
|
|
|
|
|
fn();
|
|
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM during IN_GAME update stage '", stageName, "': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception during IN_GAME update stage '", stageName, "': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2026-03-07 13:44:09 -08:00
|
|
|
auto stageEnd = std::chrono::steady_clock::now();
|
|
|
|
|
float stageMs = std::chrono::duration<float, std::milli>(stageEnd - stageStart).count();
|
2026-03-07 18:43:13 -08:00
|
|
|
if (stageMs > 50.0f) {
|
2026-03-07 13:44:09 -08:00
|
|
|
LOG_WARNING("SLOW update stage '", stageName, "': ", stageMs, "ms");
|
|
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
};
|
|
|
|
|
inGameStep = "gameHandler update";
|
|
|
|
|
updateCheckpoint = "in_game: gameHandler update";
|
|
|
|
|
runInGameStage("gameHandler->update", [&] {
|
|
|
|
|
if (gameHandler) {
|
|
|
|
|
gameHandler->update(deltaTime);
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-03-20 12:07:22 -07:00
|
|
|
if (addonManager_ && addonsLoaded_) {
|
|
|
|
|
addonManager_->update(deltaTime);
|
|
|
|
|
}
|
2026-02-12 00:15:51 -08:00
|
|
|
// Always unsheath on combat engage.
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "auto-unsheathe";
|
|
|
|
|
updateCheckpoint = "in_game: auto-unsheathe";
|
2026-02-12 00:15:51 -08:00
|
|
|
if (gameHandler) {
|
|
|
|
|
const bool autoAttacking = gameHandler->isAutoAttacking();
|
2026-04-01 13:31:48 +03:00
|
|
|
if (autoAttacking && !wasAutoAttacking_ && appearanceComposer_ && appearanceComposer_->isWeaponsSheathed()) {
|
|
|
|
|
appearanceComposer_->setWeaponsSheathed(false);
|
|
|
|
|
appearanceComposer_->loadEquippedWeapons();
|
2026-02-12 00:15:51 -08:00
|
|
|
}
|
|
|
|
|
wasAutoAttacking_ = autoAttacking;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 00:14:39 -08:00
|
|
|
// Toggle weapon sheathe state with Z (ignored while UI captures keyboard).
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "weapon-toggle input";
|
|
|
|
|
updateCheckpoint = "in_game: weapon-toggle input";
|
2026-02-12 00:14:39 -08:00
|
|
|
{
|
|
|
|
|
const bool uiWantsKeyboard = ImGui::GetIO().WantCaptureKeyboard;
|
|
|
|
|
auto& input = Input::getInstance();
|
2026-04-01 13:31:48 +03:00
|
|
|
if (!uiWantsKeyboard && input.isKeyJustPressed(SDL_SCANCODE_Z) && appearanceComposer_) {
|
|
|
|
|
appearanceComposer_->toggleWeaponsSheathed();
|
|
|
|
|
appearanceComposer_->loadEquippedWeapons();
|
2026-02-12 00:14:39 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "world update";
|
|
|
|
|
updateCheckpoint = "in_game: world update";
|
|
|
|
|
runInGameStage("world->update", [&] {
|
|
|
|
|
if (world) {
|
|
|
|
|
world->update(deltaTime);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
inGameStep = "spawn/equipment queues";
|
|
|
|
|
updateCheckpoint = "in_game: spawn/equipment queues";
|
|
|
|
|
runInGameStage("spawn/equipment queues", [&] {
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_) entitySpawner_->update();
|
2026-03-07 17:16:38 -08:00
|
|
|
if (auto* cr = renderer ? renderer->getCharacterRenderer() : nullptr) {
|
2026-03-07 18:40:24 -08:00
|
|
|
cr->processPendingNormalMaps(4);
|
2026-03-07 17:16:38 -08:00
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
});
|
2026-02-11 21:14:35 -08:00
|
|
|
// Self-heal missing creature visuals: if a nearby UNIT exists in
|
|
|
|
|
// entity state but has no render instance, queue a spawn retry.
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "creature resync scan";
|
|
|
|
|
updateCheckpoint = "in_game: creature resync scan";
|
2026-02-11 21:14:35 -08:00
|
|
|
if (gameHandler) {
|
|
|
|
|
static float creatureResyncTimer = 0.0f;
|
|
|
|
|
creatureResyncTimer += deltaTime;
|
2026-02-25 12:16:55 -08:00
|
|
|
if (creatureResyncTimer >= 3.0f) {
|
2026-02-11 21:14:35 -08:00
|
|
|
creatureResyncTimer = 0.0f;
|
|
|
|
|
|
|
|
|
|
glm::vec3 playerPos(0.0f);
|
|
|
|
|
bool havePlayerPos = false;
|
|
|
|
|
uint64_t playerGuid = gameHandler->getPlayerGuid();
|
|
|
|
|
if (auto playerEntity = gameHandler->getEntityManager().getEntity(playerGuid)) {
|
|
|
|
|
playerPos = glm::vec3(playerEntity->getX(), playerEntity->getY(), playerEntity->getZ());
|
|
|
|
|
havePlayerPos = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float kResyncRadiusSq = 260.0f * 260.0f;
|
|
|
|
|
for (const auto& pair : gameHandler->getEntityManager().getEntities()) {
|
|
|
|
|
uint64_t guid = pair.first;
|
|
|
|
|
const auto& entity = pair.second;
|
|
|
|
|
if (!entity || guid == playerGuid) continue;
|
|
|
|
|
if (entity->getType() != game::ObjectType::UNIT) continue;
|
|
|
|
|
auto unit = std::dynamic_pointer_cast<game::Unit>(entity);
|
|
|
|
|
if (!unit || unit->getDisplayId() == 0) continue;
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_->isCreatureSpawned(guid) || entitySpawner_->isCreaturePending(guid)) continue;
|
2026-02-11 21:14:35 -08:00
|
|
|
|
|
|
|
|
if (havePlayerPos) {
|
|
|
|
|
glm::vec3 pos(unit->getX(), unit->getY(), unit->getZ());
|
|
|
|
|
glm::vec3 delta = pos - playerPos;
|
|
|
|
|
float distSq = glm::dot(delta, delta);
|
|
|
|
|
if (distSq > kResyncRadiusSq) continue;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
float retryScale = 1.0f;
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
{
|
|
|
|
|
using game::fieldIndex; using game::UF;
|
|
|
|
|
uint16_t si = fieldIndex(UF::OBJECT_FIELD_SCALE_X);
|
|
|
|
|
if (si != 0xFFFF) {
|
|
|
|
|
uint32_t raw = unit->getField(si);
|
|
|
|
|
if (raw != 0) {
|
|
|
|
|
float s2 = 1.0f;
|
|
|
|
|
std::memcpy(&s2, &raw, sizeof(float));
|
2026-03-31 22:01:55 +03:00
|
|
|
if (s2 > 0.01f && s2 < 100.0f) retryScale = s2;
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-31 22:01:55 +03:00
|
|
|
entitySpawner_->queueCreatureSpawn(guid, unit->getDisplayId(),
|
|
|
|
|
unit->getX(), unit->getY(), unit->getZ(),
|
|
|
|
|
unit->getOrientation(), retryScale);
|
2026-02-11 21:14:35 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "gameobject/transport queues";
|
|
|
|
|
updateCheckpoint = "in_game: gameobject/transport queues";
|
|
|
|
|
runInGameStage("gameobject/transport queues", [&] {
|
2026-03-31 22:01:55 +03:00
|
|
|
// GO/transport queues handled by entitySpawner_->update() above
|
2026-02-22 07:26:54 -08:00
|
|
|
});
|
|
|
|
|
inGameStep = "pending mount";
|
|
|
|
|
updateCheckpoint = "in_game: pending mount";
|
|
|
|
|
runInGameStage("processPendingMount", [&] {
|
2026-03-31 22:01:55 +03:00
|
|
|
// Mount processing handled by entitySpawner_->update() above
|
2026-02-22 07:26:54 -08:00
|
|
|
});
|
2026-02-09 23:05:23 -08:00
|
|
|
// Update 3D quest markers above NPCs
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "quest markers";
|
|
|
|
|
updateCheckpoint = "in_game: quest markers";
|
|
|
|
|
runInGameStage("updateQuestMarkers", [&] {
|
|
|
|
|
updateQuestMarkers();
|
|
|
|
|
});
|
2026-02-07 17:59:40 -08:00
|
|
|
// Sync server run speed to camera controller
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "post-update sync";
|
|
|
|
|
updateCheckpoint = "in_game: post-update sync";
|
|
|
|
|
runInGameStage("post-update sync", [&] {
|
|
|
|
|
if (renderer && gameHandler && renderer->getCameraController()) {
|
|
|
|
|
renderer->getCameraController()->setRunSpeedOverride(gameHandler->getServerRunSpeed());
|
2026-03-10 13:11:50 -07:00
|
|
|
renderer->getCameraController()->setWalkSpeedOverride(gameHandler->getServerWalkSpeed());
|
|
|
|
|
renderer->getCameraController()->setSwimSpeedOverride(gameHandler->getServerSwimSpeed());
|
2026-03-10 13:51:47 -07:00
|
|
|
renderer->getCameraController()->setSwimBackSpeedOverride(gameHandler->getServerSwimBackSpeed());
|
2026-03-10 13:25:10 -07:00
|
|
|
renderer->getCameraController()->setFlightSpeedOverride(gameHandler->getServerFlightSpeed());
|
2026-03-10 14:05:50 -07:00
|
|
|
renderer->getCameraController()->setFlightBackSpeedOverride(gameHandler->getServerFlightBackSpeed());
|
2026-03-10 13:28:53 -07:00
|
|
|
renderer->getCameraController()->setRunBackSpeedOverride(gameHandler->getServerRunBackSpeed());
|
2026-03-10 14:18:25 -07:00
|
|
|
renderer->getCameraController()->setTurnRateOverride(gameHandler->getServerTurnRate());
|
2026-03-10 13:01:44 -07:00
|
|
|
renderer->getCameraController()->setMovementRooted(gameHandler->isPlayerRooted());
|
2026-03-10 13:07:34 -07:00
|
|
|
renderer->getCameraController()->setGravityDisabled(gameHandler->isGravityDisabled());
|
2026-03-10 13:14:52 -07:00
|
|
|
renderer->getCameraController()->setFeatherFallActive(gameHandler->isFeatherFalling());
|
2026-03-10 13:18:04 -07:00
|
|
|
renderer->getCameraController()->setWaterWalkActive(gameHandler->isWaterWalking());
|
physics: implement player-controlled flying mount physics
When CAN_FLY + FLYING movement flags are both set (flying mounts, Druid
Flight Form), the CameraController now uses 3D pitch-following movement
instead of ground physics:
- Forward/back follows the camera's 3D look direction (ascend when
looking up, descend when looking down)
- Space = ascend vertically, X (while mounted) = descend
- No gravity, no grounding, no jump coyote time
- Fall-damage checks suppressed (grounded=true)
Also wire up all remaining server movement state flags to CameraController:
- Feather Fall: cap terminal velocity at -2 m/s
- Water Walk: clamp to water surface, skip swim entry
- Flying: 3D movement with no gravity
All states synced each frame from GameHandler via isPlayerFlying(),
isFeatherFalling(), isWaterWalking(), isGravityDisabled().
2026-03-10 13:23:38 -07:00
|
|
|
renderer->getCameraController()->setFlyingActive(gameHandler->isPlayerFlying());
|
2026-03-10 13:39:23 -07:00
|
|
|
renderer->getCameraController()->setHoverActive(gameHandler->isHovering());
|
2026-03-10 14:46:17 -07:00
|
|
|
|
|
|
|
|
// Sync camera forward pitch to movement packets during flight / swimming.
|
|
|
|
|
// The server writes the pitch field when FLYING or SWIMMING flags are set;
|
|
|
|
|
// without this sync it would always be 0 (horizontal), causing other
|
|
|
|
|
// players to see the character flying flat even when pitching up/down.
|
|
|
|
|
if (gameHandler->isPlayerFlying() || gameHandler->isSwimming()) {
|
|
|
|
|
if (auto* cam = renderer->getCamera()) {
|
|
|
|
|
glm::vec3 fwd = cam->getForward();
|
|
|
|
|
float len = glm::length(fwd);
|
|
|
|
|
if (len > 1e-4f) {
|
|
|
|
|
float pitchRad = std::asin(std::clamp(fwd.z / len, -1.0f, 1.0f));
|
|
|
|
|
gameHandler->setMovementPitch(pitchRad);
|
|
|
|
|
// Tilt the mount/character model to match flight direction
|
|
|
|
|
// (taxi flight uses setTaxiOrientationCallback for this instead)
|
|
|
|
|
if (gameHandler->isPlayerFlying() && gameHandler->isMounted()) {
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->setMountPitchRoll(pitchRad, 0.0f);
|
2026-03-10 14:46:17 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (gameHandler->isMounted()) {
|
|
|
|
|
// Reset mount pitch when not flying
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->setMountPitchRoll(0.0f, 0.0f);
|
2026-03-10 14:46:17 -07:00
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
2026-02-07 17:59:40 -08:00
|
|
|
|
2026-02-22 07:26:54 -08:00
|
|
|
bool onTaxi = gameHandler &&
|
|
|
|
|
(gameHandler->isOnTaxiFlight() ||
|
|
|
|
|
gameHandler->isTaxiMountActive() ||
|
|
|
|
|
gameHandler->isTaxiActivationPending());
|
|
|
|
|
bool onTransportNow = gameHandler && gameHandler->isOnTransport();
|
2026-03-14 09:19:16 -07:00
|
|
|
// Clear stale client-side transport state when the tracked transport no longer exists.
|
|
|
|
|
if (onTransportNow && gameHandler->getTransportManager()) {
|
|
|
|
|
auto* currentTracked = gameHandler->getTransportManager()->getTransport(
|
|
|
|
|
gameHandler->getPlayerTransportGuid());
|
|
|
|
|
if (!currentTracked) {
|
|
|
|
|
gameHandler->clearPlayerTransport();
|
|
|
|
|
onTransportNow = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-06 23:01:11 -08:00
|
|
|
// M2 transports (trams) use position-delta approach: player keeps normal
|
|
|
|
|
// movement and the transport's frame-to-frame delta is applied on top.
|
|
|
|
|
// Only WMO transports (ships) use full external-driven mode.
|
|
|
|
|
bool isM2Transport = false;
|
|
|
|
|
if (onTransportNow && gameHandler->getTransportManager()) {
|
|
|
|
|
auto* tr = gameHandler->getTransportManager()->getTransport(gameHandler->getPlayerTransportGuid());
|
|
|
|
|
isM2Transport = (tr && tr->isM2);
|
|
|
|
|
}
|
|
|
|
|
bool onWMOTransport = onTransportNow && !isM2Transport;
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
if (worldEntryCallbacks_ && worldEntryCallbacks_->getWorldEntryMovementGraceTimer() > 0.0f) {
|
|
|
|
|
worldEntryCallbacks_->setWorldEntryMovementGraceTimer(
|
|
|
|
|
worldEntryCallbacks_->getWorldEntryMovementGraceTimer() - deltaTime);
|
2026-03-05 15:12:51 -08:00
|
|
|
// Clear stale movement from before teleport each frame
|
|
|
|
|
// until grace period expires (keys may still be held)
|
|
|
|
|
if (renderer && renderer->getCameraController())
|
|
|
|
|
renderer->getCameraController()->clearMovementInputs();
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
// Hearth teleport: delegated to WorldEntryCallbackHandler
|
|
|
|
|
if (worldEntryCallbacks_) {
|
|
|
|
|
worldEntryCallbacks_->update(deltaTime);
|
2026-03-07 22:03:28 -08:00
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
if (renderer && renderer->getCameraController()) {
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
const bool externallyDrivenMotion = onTaxi || onWMOTransport || (animationCallbacks_ && animationCallbacks_->isCharging());
|
Fix mount sounds, grey WMO meshes, taxi landing, tree animations, and classic dismount
- Per-family mount sounds (kodo, tallstrider, mechanostrider, etc.) detected from M2 model path
- Skip WMO groups with SHOW_SKYBOX flag or all-untextured batches (grey mesh in Orgrimmar)
- Freeze physics during taxi landing until terrain loads to prevent falling through void
- Disable bone animations on tropical vegetation (palm, bamboo, banana, etc.) to fix wiggling
- Snap player to final taxi waypoint on flight completion
- Extract mount aura spell ID from classic UNIT_FIELD_AURAS for CMSG_CANCEL_AURA dismount
- Increase /unstuck forward nudge to 5 units
2026-02-14 21:04:20 -08:00
|
|
|
// Keep physics frozen (externalFollow) during landing clamp when terrain
|
|
|
|
|
// hasn't loaded yet — prevents gravity from pulling player through void.
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
bool hearthFreeze = worldEntryCallbacks_ && worldEntryCallbacks_->isHearthTeleportPending();
|
|
|
|
|
bool landingClampActive = !onTaxi && worldEntryCallbacks_ && worldEntryCallbacks_->getTaxiLandingClampTimer() > 0.0f &&
|
|
|
|
|
worldEntryCallbacks_->getWorldEntryMovementGraceTimer() <= 0.0f &&
|
Fix mount sounds, grey WMO meshes, taxi landing, tree animations, and classic dismount
- Per-family mount sounds (kodo, tallstrider, mechanostrider, etc.) detected from M2 model path
- Skip WMO groups with SHOW_SKYBOX flag or all-untextured batches (grey mesh in Orgrimmar)
- Freeze physics during taxi landing until terrain loads to prevent falling through void
- Disable bone animations on tropical vegetation (palm, bamboo, banana, etc.) to fix wiggling
- Snap player to final taxi waypoint on flight completion
- Extract mount aura spell ID from classic UNIT_FIELD_AURAS for CMSG_CANCEL_AURA dismount
- Increase /unstuck forward nudge to 5 units
2026-02-14 21:04:20 -08:00
|
|
|
!gameHandler->isMounted();
|
2026-03-07 22:03:28 -08:00
|
|
|
renderer->getCameraController()->setExternalFollow(externallyDrivenMotion || landingClampActive || hearthFreeze);
|
2026-02-12 00:04:53 -08:00
|
|
|
renderer->getCameraController()->setExternalMoving(externallyDrivenMotion);
|
|
|
|
|
if (externallyDrivenMotion) {
|
2026-02-11 19:28:15 -08:00
|
|
|
// Drop any stale local movement toggles while server drives taxi motion.
|
|
|
|
|
renderer->getCameraController()->clearMovementInputs();
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
if (worldEntryCallbacks_) worldEntryCallbacks_->setTaxiLandingClampTimer(0.0f);
|
2026-02-11 19:28:15 -08:00
|
|
|
}
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
if (worldEntryCallbacks_ && worldEntryCallbacks_->getLastTaxiFlight() && !onTaxi) {
|
2026-02-08 03:05:38 -08:00
|
|
|
renderer->getCameraController()->clearMovementInputs();
|
Fix mount sounds, grey WMO meshes, taxi landing, tree animations, and classic dismount
- Per-family mount sounds (kodo, tallstrider, mechanostrider, etc.) detected from M2 model path
- Skip WMO groups with SHOW_SKYBOX flag or all-untextured batches (grey mesh in Orgrimmar)
- Freeze physics during taxi landing until terrain loads to prevent falling through void
- Disable bone animations on tropical vegetation (palm, bamboo, banana, etc.) to fix wiggling
- Snap player to final taxi waypoint on flight completion
- Extract mount aura spell ID from classic UNIT_FIELD_AURAS for CMSG_CANCEL_AURA dismount
- Increase /unstuck forward nudge to 5 units
2026-02-14 21:04:20 -08:00
|
|
|
// Keep clamping until terrain loads at landing position.
|
|
|
|
|
// Timer only counts down once a valid floor is found.
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
if (worldEntryCallbacks_) worldEntryCallbacks_->setTaxiLandingClampTimer(2.0f);
|
2026-02-11 21:14:35 -08:00
|
|
|
}
|
Fix mount sounds, grey WMO meshes, taxi landing, tree animations, and classic dismount
- Per-family mount sounds (kodo, tallstrider, mechanostrider, etc.) detected from M2 model path
- Skip WMO groups with SHOW_SKYBOX flag or all-untextured batches (grey mesh in Orgrimmar)
- Freeze physics during taxi landing until terrain loads to prevent falling through void
- Disable bone animations on tropical vegetation (palm, bamboo, banana, etc.) to fix wiggling
- Snap player to final taxi waypoint on flight completion
- Extract mount aura spell ID from classic UNIT_FIELD_AURAS for CMSG_CANCEL_AURA dismount
- Increase /unstuck forward nudge to 5 units
2026-02-14 21:04:20 -08:00
|
|
|
if (landingClampActive) {
|
2026-02-11 21:14:35 -08:00
|
|
|
if (renderer && gameHandler) {
|
|
|
|
|
glm::vec3 p = renderer->getCharacterPosition();
|
|
|
|
|
std::optional<float> terrainFloor;
|
|
|
|
|
std::optional<float> wmoFloor;
|
|
|
|
|
std::optional<float> m2Floor;
|
|
|
|
|
if (renderer->getTerrainManager()) {
|
|
|
|
|
terrainFloor = renderer->getTerrainManager()->getHeightAt(p.x, p.y);
|
|
|
|
|
}
|
|
|
|
|
if (renderer->getWMORenderer()) {
|
|
|
|
|
// Probe from above so we can recover when current Z is already below floor.
|
|
|
|
|
wmoFloor = renderer->getWMORenderer()->getFloorHeight(p.x, p.y, p.z + 40.0f);
|
|
|
|
|
}
|
|
|
|
|
if (renderer->getM2Renderer()) {
|
|
|
|
|
// Include M2 floors (bridges/platforms) in landing recovery.
|
|
|
|
|
m2Floor = renderer->getM2Renderer()->getFloorHeight(p.x, p.y, p.z + 40.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::optional<float> targetFloor;
|
|
|
|
|
if (terrainFloor) targetFloor = terrainFloor;
|
|
|
|
|
if (wmoFloor && (!targetFloor || *wmoFloor > *targetFloor)) targetFloor = wmoFloor;
|
|
|
|
|
if (m2Floor && (!targetFloor || *m2Floor > *targetFloor)) targetFloor = m2Floor;
|
|
|
|
|
|
|
|
|
|
if (targetFloor) {
|
Fix mount sounds, grey WMO meshes, taxi landing, tree animations, and classic dismount
- Per-family mount sounds (kodo, tallstrider, mechanostrider, etc.) detected from M2 model path
- Skip WMO groups with SHOW_SKYBOX flag or all-untextured batches (grey mesh in Orgrimmar)
- Freeze physics during taxi landing until terrain loads to prevent falling through void
- Disable bone animations on tropical vegetation (palm, bamboo, banana, etc.) to fix wiggling
- Snap player to final taxi waypoint on flight completion
- Extract mount aura spell ID from classic UNIT_FIELD_AURAS for CMSG_CANCEL_AURA dismount
- Increase /unstuck forward nudge to 5 units
2026-02-14 21:04:20 -08:00
|
|
|
// Floor found — snap player to it and start countdown to release
|
2026-02-11 21:14:35 -08:00
|
|
|
float targetZ = *targetFloor + 0.10f;
|
Fix mount sounds, grey WMO meshes, taxi landing, tree animations, and classic dismount
- Per-family mount sounds (kodo, tallstrider, mechanostrider, etc.) detected from M2 model path
- Skip WMO groups with SHOW_SKYBOX flag or all-untextured batches (grey mesh in Orgrimmar)
- Freeze physics during taxi landing until terrain loads to prevent falling through void
- Disable bone animations on tropical vegetation (palm, bamboo, banana, etc.) to fix wiggling
- Snap player to final taxi waypoint on flight completion
- Extract mount aura spell ID from classic UNIT_FIELD_AURAS for CMSG_CANCEL_AURA dismount
- Increase /unstuck forward nudge to 5 units
2026-02-14 21:04:20 -08:00
|
|
|
if (std::abs(p.z - targetZ) > 0.05f) {
|
2026-02-11 21:14:35 -08:00
|
|
|
p.z = targetZ;
|
|
|
|
|
renderer->getCharacterPosition() = p;
|
|
|
|
|
glm::vec3 canonical = core::coords::renderToCanonical(p);
|
|
|
|
|
gameHandler->setPosition(canonical.x, canonical.y, canonical.z);
|
2026-02-20 02:50:59 -08:00
|
|
|
gameHandler->sendMovement(game::Opcode::MSG_MOVE_HEARTBEAT);
|
2026-02-11 21:14:35 -08:00
|
|
|
}
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
float clampTimer = worldEntryCallbacks_ ? worldEntryCallbacks_->getTaxiLandingClampTimer() : 0.0f;
|
|
|
|
|
clampTimer -= deltaTime;
|
|
|
|
|
if (worldEntryCallbacks_) worldEntryCallbacks_->setTaxiLandingClampTimer(clampTimer);
|
2026-02-11 21:14:35 -08:00
|
|
|
}
|
Fix mount sounds, grey WMO meshes, taxi landing, tree animations, and classic dismount
- Per-family mount sounds (kodo, tallstrider, mechanostrider, etc.) detected from M2 model path
- Skip WMO groups with SHOW_SKYBOX flag or all-untextured batches (grey mesh in Orgrimmar)
- Freeze physics during taxi landing until terrain loads to prevent falling through void
- Disable bone animations on tropical vegetation (palm, bamboo, banana, etc.) to fix wiggling
- Snap player to final taxi waypoint on flight completion
- Extract mount aura spell ID from classic UNIT_FIELD_AURAS for CMSG_CANCEL_AURA dismount
- Increase /unstuck forward nudge to 5 units
2026-02-14 21:04:20 -08:00
|
|
|
// No floor found: don't decrement timer, keep player frozen until terrain loads
|
2026-02-11 21:14:35 -08:00
|
|
|
}
|
2026-02-08 03:05:38 -08:00
|
|
|
}
|
2026-02-08 03:39:02 -08:00
|
|
|
bool idleOrbit = renderer->getCameraController()->isIdleOrbit();
|
|
|
|
|
if (idleOrbit && !idleYawned_ && renderer) {
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->playEmote("yawn");
|
2026-02-08 03:39:02 -08:00
|
|
|
idleYawned_ = true;
|
|
|
|
|
} else if (!idleOrbit) {
|
|
|
|
|
idleYawned_ = false;
|
|
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
|
|
|
|
if (renderer) {
|
2026-04-05 19:30:44 +03:00
|
|
|
if (auto* ac = renderer->getAnimationController()) ac->setTaxiFlight(onTaxi);
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
|
|
|
|
if (renderer && renderer->getTerrainManager()) {
|
2026-02-08 03:05:38 -08:00
|
|
|
renderer->getTerrainManager()->setStreamingEnabled(true);
|
2026-02-26 03:06:17 -08:00
|
|
|
// Taxi flights move fast (32 u/s) — load further ahead so terrain is ready
|
|
|
|
|
// before the camera arrives. Keep updates frequent to spot new tiles early.
|
|
|
|
|
renderer->getTerrainManager()->setUpdateInterval(onTaxi ? 0.033f : 0.033f);
|
2026-03-09 20:58:49 -07:00
|
|
|
renderer->getTerrainManager()->setLoadRadius(onTaxi ? 8 : 4);
|
|
|
|
|
renderer->getTerrainManager()->setUnloadRadius(onTaxi ? 12 : 7);
|
2026-02-11 19:28:15 -08:00
|
|
|
renderer->getTerrainManager()->setTaxiStreamingMode(onTaxi);
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
if (worldEntryCallbacks_) worldEntryCallbacks_->setLastTaxiFlight(onTaxi);
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-22 07:26:54 -08:00
|
|
|
// Sync character render position ↔ canonical WoW coords each frame
|
|
|
|
|
if (renderer && gameHandler) {
|
2026-03-06 23:01:11 -08:00
|
|
|
// For position sync branching, only WMO transports use the dedicated
|
|
|
|
|
// onTransport branch. M2 transports use the normal movement else branch
|
|
|
|
|
// with a position-delta correction applied on top.
|
|
|
|
|
bool onTransport = onWMOTransport;
|
2026-02-10 21:29:10 -08:00
|
|
|
|
2026-02-11 00:54:38 -08:00
|
|
|
static bool wasOnTransport = false;
|
2026-03-06 23:01:11 -08:00
|
|
|
bool onTransportNowDbg = gameHandler->isOnTransport();
|
|
|
|
|
if (onTransportNowDbg != wasOnTransport) {
|
|
|
|
|
LOG_DEBUG("Transport state changed: onTransport=", onTransportNowDbg,
|
|
|
|
|
" isM2=", isM2Transport,
|
2026-02-11 00:54:38 -08:00
|
|
|
" guid=0x", std::hex, gameHandler->getPlayerTransportGuid(), std::dec);
|
2026-03-06 23:01:11 -08:00
|
|
|
wasOnTransport = onTransportNowDbg;
|
2026-02-11 00:54:38 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-08 03:05:38 -08:00
|
|
|
if (onTaxi) {
|
|
|
|
|
auto playerEntity = gameHandler->getEntityManager().getEntity(gameHandler->getPlayerGuid());
|
2026-02-11 21:14:35 -08:00
|
|
|
glm::vec3 canonical(0.0f);
|
|
|
|
|
bool haveCanonical = false;
|
2026-02-08 03:05:38 -08:00
|
|
|
if (playerEntity) {
|
2026-02-11 21:14:35 -08:00
|
|
|
canonical = glm::vec3(playerEntity->getX(), playerEntity->getY(), playerEntity->getZ());
|
|
|
|
|
haveCanonical = true;
|
|
|
|
|
} else {
|
|
|
|
|
// Fallback for brief entity gaps during taxi start/updates:
|
|
|
|
|
// movementInfo is still updated by client taxi simulation.
|
|
|
|
|
const auto& move = gameHandler->getMovementInfo();
|
|
|
|
|
canonical = glm::vec3(move.x, move.y, move.z);
|
|
|
|
|
haveCanonical = true;
|
|
|
|
|
}
|
|
|
|
|
if (haveCanonical) {
|
2026-02-08 03:05:38 -08:00
|
|
|
glm::vec3 renderPos = core::coords::canonicalToRender(canonical);
|
|
|
|
|
renderer->getCharacterPosition() = renderPos;
|
2026-02-11 21:14:35 -08:00
|
|
|
if (renderer->getCameraController()) {
|
|
|
|
|
glm::vec3* followTarget = renderer->getCameraController()->getFollowTargetMutable();
|
|
|
|
|
if (followTarget) {
|
|
|
|
|
*followTarget = renderPos;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-08 03:05:38 -08:00
|
|
|
}
|
2026-02-10 21:29:10 -08:00
|
|
|
} else if (onTransport) {
|
2026-03-06 23:01:11 -08:00
|
|
|
// WMO transport mode (ships): compose world position from transform + local offset
|
2026-02-10 21:29:10 -08:00
|
|
|
glm::vec3 canonical = gameHandler->getComposedWorldPosition();
|
|
|
|
|
glm::vec3 renderPos = core::coords::canonicalToRender(canonical);
|
|
|
|
|
renderer->getCharacterPosition() = renderPos;
|
2026-02-12 00:04:53 -08:00
|
|
|
gameHandler->setPosition(canonical.x, canonical.y, canonical.z);
|
2026-02-10 21:29:10 -08:00
|
|
|
if (renderer->getCameraController()) {
|
|
|
|
|
glm::vec3* followTarget = renderer->getCameraController()->getFollowTargetMutable();
|
|
|
|
|
if (followTarget) {
|
|
|
|
|
*followTarget = renderPos;
|
|
|
|
|
}
|
|
|
|
|
}
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
} else if (animationCallbacks_ && animationCallbacks_->isCharging()) {
|
|
|
|
|
// Warrior Charge: interpolation delegated to AnimationCallbackHandler
|
|
|
|
|
animationCallbacks_->updateCharge(deltaTime);
|
2026-02-08 03:05:38 -08:00
|
|
|
} else {
|
|
|
|
|
glm::vec3 renderPos = renderer->getCharacterPosition();
|
2026-03-06 23:01:11 -08:00
|
|
|
|
2026-03-14 09:19:16 -07:00
|
|
|
// M2 transport riding: resolve in canonical space and lock once per frame.
|
|
|
|
|
// This avoids visible jitter from mixed render/canonical delta application.
|
2026-03-06 23:01:11 -08:00
|
|
|
if (isM2Transport && gameHandler->getTransportManager()) {
|
|
|
|
|
auto* tr = gameHandler->getTransportManager()->getTransport(
|
|
|
|
|
gameHandler->getPlayerTransportGuid());
|
|
|
|
|
if (tr) {
|
2026-03-14 09:02:20 -07:00
|
|
|
// Keep passenger locked to elevator vertical motion while grounded.
|
|
|
|
|
// Without this, floor clamping can hold world-Z static unless the
|
|
|
|
|
// player is jumping, which makes lifts appear to not move vertically.
|
|
|
|
|
glm::vec3 tentativeCanonical = core::coords::renderToCanonical(renderPos);
|
|
|
|
|
glm::vec3 localOffset = gameHandler->getPlayerTransportOffset();
|
|
|
|
|
localOffset.x = tentativeCanonical.x - tr->position.x;
|
|
|
|
|
localOffset.y = tentativeCanonical.y - tr->position.y;
|
|
|
|
|
if (renderer->getCameraController() &&
|
|
|
|
|
!renderer->getCameraController()->isGrounded()) {
|
|
|
|
|
// While airborne (jump/fall), allow local Z offset to change.
|
|
|
|
|
localOffset.z = tentativeCanonical.z - tr->position.z;
|
|
|
|
|
}
|
|
|
|
|
gameHandler->setPlayerTransportOffset(localOffset);
|
|
|
|
|
|
|
|
|
|
glm::vec3 lockedCanonical = tr->position + localOffset;
|
|
|
|
|
renderPos = core::coords::canonicalToRender(lockedCanonical);
|
|
|
|
|
renderer->getCharacterPosition() = renderPos;
|
2026-03-06 23:01:11 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-08 03:05:38 -08:00
|
|
|
glm::vec3 canonical = core::coords::renderToCanonical(renderPos);
|
|
|
|
|
gameHandler->setPosition(canonical.x, canonical.y, canonical.z);
|
|
|
|
|
|
|
|
|
|
// Sync orientation: camera yaw (degrees) → WoW orientation (radians)
|
|
|
|
|
float yawDeg = renderer->getCharacterYaw();
|
2026-02-12 15:08:21 -08:00
|
|
|
// Keep all game-side orientation in canonical space.
|
|
|
|
|
// We historically sent serverYaw = radians(yawDeg - 90). With the new
|
|
|
|
|
// canonical<->server mapping (serverYaw = PI/2 - canonicalYaw), the
|
|
|
|
|
// equivalent canonical yaw is radians(180 - yawDeg).
|
|
|
|
|
float canonicalYaw = core::coords::normalizeAngleRad(glm::radians(180.0f - yawDeg));
|
|
|
|
|
gameHandler->setOrientation(canonicalYaw);
|
2026-02-19 16:40:17 -08:00
|
|
|
|
2026-02-20 02:50:59 -08:00
|
|
|
// Send MSG_MOVE_SET_FACING when the player changes facing direction
|
2026-02-19 16:40:17 -08:00
|
|
|
// (e.g. via mouse-look). Without this, the server predicts movement in
|
|
|
|
|
// the old facing and position-corrects on the next heartbeat — the
|
|
|
|
|
// micro-teleporting the GM observed.
|
|
|
|
|
// Skip while keyboard-turning: the server tracks that via TURN_LEFT/RIGHT flags.
|
|
|
|
|
facingSendCooldown_ -= deltaTime;
|
|
|
|
|
const auto& mi = gameHandler->getMovementInfo();
|
|
|
|
|
constexpr uint32_t kTurnFlags =
|
|
|
|
|
static_cast<uint32_t>(game::MovementFlags::TURN_LEFT) |
|
|
|
|
|
static_cast<uint32_t>(game::MovementFlags::TURN_RIGHT);
|
|
|
|
|
bool keyboardTurning = (mi.flags & kTurnFlags) != 0;
|
|
|
|
|
if (!keyboardTurning && facingSendCooldown_ <= 0.0f) {
|
|
|
|
|
float yawDiff = core::coords::normalizeAngleRad(canonicalYaw - lastSentCanonicalYaw_);
|
|
|
|
|
if (std::abs(yawDiff) > glm::radians(3.0f)) {
|
2026-02-20 02:50:59 -08:00
|
|
|
gameHandler->sendMovement(game::Opcode::MSG_MOVE_SET_FACING);
|
2026-02-19 16:40:17 -08:00
|
|
|
lastSentCanonicalYaw_ = canonicalYaw;
|
|
|
|
|
facingSendCooldown_ = 0.1f; // max 10 Hz
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-06 23:01:11 -08:00
|
|
|
|
|
|
|
|
// Client-side transport boarding detection (for M2 transports like trams
|
2026-03-14 08:09:23 -07:00
|
|
|
// and lifts where the server doesn't send transport attachment data).
|
|
|
|
|
// Thunder Bluff elevators use model origins that can be far from the deck
|
|
|
|
|
// the player stands on, so they need wider attachment bounds.
|
2026-03-06 23:01:11 -08:00
|
|
|
if (gameHandler->getTransportManager() && !gameHandler->isOnTransport()) {
|
|
|
|
|
auto* tm = gameHandler->getTransportManager();
|
|
|
|
|
glm::vec3 playerCanonical = core::coords::renderToCanonical(renderPos);
|
2026-03-14 08:09:23 -07:00
|
|
|
constexpr float kM2BoardHorizDistSq = 12.0f * 12.0f;
|
|
|
|
|
constexpr float kM2BoardVertDist = 15.0f;
|
2026-03-14 09:19:16 -07:00
|
|
|
constexpr float kTbLiftBoardHorizDistSq = 22.0f * 22.0f;
|
|
|
|
|
constexpr float kTbLiftBoardVertDist = 14.0f;
|
2026-03-06 23:01:11 -08:00
|
|
|
|
2026-03-14 09:02:20 -07:00
|
|
|
uint64_t bestGuid = 0;
|
|
|
|
|
float bestScore = 1e30f;
|
2026-03-06 23:01:11 -08:00
|
|
|
for (auto& [guid, transport] : tm->getTransports()) {
|
|
|
|
|
if (!transport.isM2) continue;
|
2026-03-14 08:09:23 -07:00
|
|
|
const bool isThunderBluffLift =
|
|
|
|
|
(transport.entry >= 20649u && transport.entry <= 20657u);
|
|
|
|
|
const float maxHorizDistSq = isThunderBluffLift
|
|
|
|
|
? kTbLiftBoardHorizDistSq
|
|
|
|
|
: kM2BoardHorizDistSq;
|
|
|
|
|
const float maxVertDist = isThunderBluffLift
|
|
|
|
|
? kTbLiftBoardVertDist
|
|
|
|
|
: kM2BoardVertDist;
|
2026-03-06 23:01:11 -08:00
|
|
|
glm::vec3 diff = playerCanonical - transport.position;
|
|
|
|
|
float horizDistSq = diff.x * diff.x + diff.y * diff.y;
|
|
|
|
|
float vertDist = std::abs(diff.z);
|
2026-03-14 08:09:23 -07:00
|
|
|
if (horizDistSq < maxHorizDistSq && vertDist < maxVertDist) {
|
2026-03-14 09:02:20 -07:00
|
|
|
float score = horizDistSq + vertDist * vertDist;
|
|
|
|
|
if (score < bestScore) {
|
|
|
|
|
bestScore = score;
|
|
|
|
|
bestGuid = guid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (bestGuid != 0) {
|
|
|
|
|
auto* tr = tm->getTransport(bestGuid);
|
|
|
|
|
if (tr) {
|
|
|
|
|
gameHandler->setPlayerOnTransport(bestGuid, playerCanonical - tr->position);
|
|
|
|
|
LOG_DEBUG("M2 transport boarding: guid=0x", std::hex, bestGuid, std::dec);
|
2026-03-06 23:01:11 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// M2 transport disembark: player walked far enough from transport center
|
|
|
|
|
if (isM2Transport && gameHandler->getTransportManager()) {
|
|
|
|
|
auto* tm = gameHandler->getTransportManager();
|
|
|
|
|
auto* tr = tm->getTransport(gameHandler->getPlayerTransportGuid());
|
|
|
|
|
if (tr) {
|
|
|
|
|
glm::vec3 playerCanonical = core::coords::renderToCanonical(renderPos);
|
|
|
|
|
glm::vec3 diff = playerCanonical - tr->position;
|
|
|
|
|
float horizDistSq = diff.x * diff.x + diff.y * diff.y;
|
2026-03-14 08:09:23 -07:00
|
|
|
const bool isThunderBluffLift =
|
|
|
|
|
(tr->entry >= 20649u && tr->entry <= 20657u);
|
|
|
|
|
constexpr float kM2DisembarkHorizDistSq = 15.0f * 15.0f;
|
2026-03-14 09:19:16 -07:00
|
|
|
constexpr float kTbLiftDisembarkHorizDistSq = 28.0f * 28.0f;
|
|
|
|
|
constexpr float kM2DisembarkVertDist = 18.0f;
|
|
|
|
|
constexpr float kTbLiftDisembarkVertDist = 16.0f;
|
2026-03-14 08:09:23 -07:00
|
|
|
const float disembarkHorizDistSq = isThunderBluffLift
|
|
|
|
|
? kTbLiftDisembarkHorizDistSq
|
|
|
|
|
: kM2DisembarkHorizDistSq;
|
2026-03-14 09:19:16 -07:00
|
|
|
const float disembarkVertDist = isThunderBluffLift
|
|
|
|
|
? kTbLiftDisembarkVertDist
|
|
|
|
|
: kM2DisembarkVertDist;
|
|
|
|
|
if (horizDistSq > disembarkHorizDistSq || std::abs(diff.z) > disembarkVertDist) {
|
2026-03-06 23:01:11 -08:00
|
|
|
gameHandler->clearPlayerTransport();
|
|
|
|
|
LOG_DEBUG("M2 transport disembark");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-08 03:05:38 -08:00
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
}
|
|
|
|
|
});
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-18 04:02:08 -08:00
|
|
|
// Keep creature render instances aligned with authoritative entity positions.
|
|
|
|
|
// This prevents desync where target circles move with server entities but
|
|
|
|
|
// creature models remain at stale spawn positions.
|
2026-02-22 07:26:54 -08:00
|
|
|
inGameStep = "creature render sync";
|
|
|
|
|
updateCheckpoint = "in_game: creature render sync";
|
2026-03-07 13:44:09 -08:00
|
|
|
auto creatureSyncStart = std::chrono::steady_clock::now();
|
2026-02-18 04:02:08 -08:00
|
|
|
if (renderer && gameHandler && renderer->getCharacterRenderer()) {
|
|
|
|
|
auto* charRenderer = renderer->getCharacterRenderer();
|
2026-02-20 23:04:57 -08:00
|
|
|
static float npcWeaponRetryTimer = 0.0f;
|
|
|
|
|
npcWeaponRetryTimer += deltaTime;
|
|
|
|
|
const bool npcWeaponRetryTick = (npcWeaponRetryTimer >= 1.0f);
|
|
|
|
|
if (npcWeaponRetryTick) npcWeaponRetryTimer = 0.0f;
|
2026-03-07 11:44:14 -08:00
|
|
|
int weaponAttachesThisTick = 0;
|
2026-02-18 04:02:08 -08:00
|
|
|
glm::vec3 playerPos(0.0f);
|
2026-02-20 16:27:21 -08:00
|
|
|
glm::vec3 playerRenderPos(0.0f);
|
2026-02-18 04:02:08 -08:00
|
|
|
bool havePlayerPos = false;
|
2026-02-20 16:27:21 -08:00
|
|
|
float playerCollisionRadius = 0.65f;
|
2026-02-18 04:02:08 -08:00
|
|
|
if (auto playerEntity = gameHandler->getEntityManager().getEntity(gameHandler->getPlayerGuid())) {
|
|
|
|
|
playerPos = glm::vec3(playerEntity->getX(), playerEntity->getY(), playerEntity->getZ());
|
2026-02-20 16:27:21 -08:00
|
|
|
playerRenderPos = core::coords::canonicalToRender(playerPos);
|
2026-02-18 04:02:08 -08:00
|
|
|
havePlayerPos = true;
|
2026-02-20 16:27:21 -08:00
|
|
|
glm::vec3 pc;
|
|
|
|
|
float pr = 0.0f;
|
|
|
|
|
if (getRenderBoundsForGuid(gameHandler->getPlayerGuid(), pc, pr)) {
|
|
|
|
|
playerCollisionRadius = std::clamp(pr * 0.35f, 0.45f, 1.1f);
|
|
|
|
|
}
|
2026-02-18 04:02:08 -08:00
|
|
|
}
|
|
|
|
|
const float syncRadiusSq = 320.0f * 320.0f;
|
2026-03-31 22:01:55 +03:00
|
|
|
auto& _creatureInstances = entitySpawner_->getCreatureInstances();
|
|
|
|
|
auto& _creatureWeaponsAttached = entitySpawner_->getCreatureWeaponsAttached();
|
|
|
|
|
auto& _creatureWeaponAttachAttempts = entitySpawner_->getCreatureWeaponAttachAttempts();
|
|
|
|
|
auto& _creatureModelIds = entitySpawner_->getCreatureModelIds();
|
|
|
|
|
auto& _modelIdIsWolfLike = entitySpawner_->getModelIdIsWolfLike();
|
|
|
|
|
auto& _creatureRenderPosCache = entitySpawner_->getCreatureRenderPosCache();
|
|
|
|
|
auto& _creatureSwimmingState = entitySpawner_->getCreatureSwimmingState();
|
|
|
|
|
auto& _creatureWalkingState = entitySpawner_->getCreatureWalkingState();
|
|
|
|
|
auto& _creatureFlyingState = entitySpawner_->getCreatureFlyingState();
|
|
|
|
|
auto& _creatureWasMoving = entitySpawner_->getCreatureWasMoving();
|
|
|
|
|
auto& _creatureWasSwimming = entitySpawner_->getCreatureWasSwimming();
|
|
|
|
|
auto& _creatureWasFlying = entitySpawner_->getCreatureWasFlying();
|
|
|
|
|
auto& _creatureWasWalking = entitySpawner_->getCreatureWasWalking();
|
|
|
|
|
for (const auto& [guid, instanceId] : _creatureInstances) {
|
2026-02-18 04:02:08 -08:00
|
|
|
auto entity = gameHandler->getEntityManager().getEntity(guid);
|
|
|
|
|
if (!entity || entity->getType() != game::ObjectType::UNIT) continue;
|
|
|
|
|
|
2026-03-07 11:44:14 -08:00
|
|
|
if (npcWeaponRetryTick &&
|
2026-03-31 22:01:55 +03:00
|
|
|
weaponAttachesThisTick < EntitySpawner::MAX_WEAPON_ATTACHES_PER_TICK &&
|
|
|
|
|
!_creatureWeaponsAttached.count(guid)) {
|
2026-02-20 23:04:57 -08:00
|
|
|
uint8_t attempts = 0;
|
2026-03-31 22:01:55 +03:00
|
|
|
auto itAttempts = _creatureWeaponAttachAttempts.find(guid);
|
|
|
|
|
if (itAttempts != _creatureWeaponAttachAttempts.end()) attempts = itAttempts->second;
|
2026-02-20 23:04:57 -08:00
|
|
|
if (attempts < 30) {
|
2026-03-07 11:44:14 -08:00
|
|
|
weaponAttachesThisTick++;
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_->tryAttachCreatureVirtualWeapons(guid, instanceId)) {
|
|
|
|
|
_creatureWeaponsAttached.insert(guid);
|
|
|
|
|
_creatureWeaponAttachAttempts.erase(guid);
|
2026-02-20 23:04:57 -08:00
|
|
|
} else {
|
2026-03-31 22:01:55 +03:00
|
|
|
_creatureWeaponAttachAttempts[guid] = static_cast<uint8_t>(attempts + 1);
|
2026-02-20 23:04:57 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-10 16:21:09 -07:00
|
|
|
// Distance check uses getLatestX/Y/Z (server-authoritative destination) to
|
|
|
|
|
// avoid false-culling entities that moved while getX/Y/Z was stale.
|
|
|
|
|
// Position sync still uses getX/Y/Z to preserve smooth interpolation for
|
|
|
|
|
// nearby entities; distant entities (> 150u) have planarDist≈0 anyway
|
|
|
|
|
// so the renderer remains driven correctly by creatureMoveCallback_.
|
|
|
|
|
glm::vec3 latestCanonical(entity->getLatestX(), entity->getLatestY(), entity->getLatestZ());
|
2026-03-07 13:44:09 -08:00
|
|
|
float canonDistSq = 0.0f;
|
2026-02-18 04:02:08 -08:00
|
|
|
if (havePlayerPos) {
|
2026-03-10 16:21:09 -07:00
|
|
|
glm::vec3 d = latestCanonical - playerPos;
|
2026-03-07 13:44:09 -08:00
|
|
|
canonDistSq = glm::dot(d, d);
|
|
|
|
|
if (canonDistSq > syncRadiusSq) continue;
|
2026-02-18 04:02:08 -08:00
|
|
|
}
|
|
|
|
|
|
2026-04-10 19:50:24 +03:00
|
|
|
// Use the destination position once the entity has reached its
|
|
|
|
|
// target. During the dead-reckoning overrun window getX/Y/Z
|
|
|
|
|
// drifts past the destination at the last known velocity;
|
|
|
|
|
// using getLatest (== moveEnd while isMoving_) avoids the
|
|
|
|
|
// visible forward-drift followed by a backward snap.
|
|
|
|
|
const bool inOverrun = entity->isEntityMoving() && !entity->isActivelyMoving();
|
|
|
|
|
glm::vec3 canonical(
|
|
|
|
|
inOverrun ? entity->getLatestX() : entity->getX(),
|
|
|
|
|
inOverrun ? entity->getLatestY() : entity->getY(),
|
|
|
|
|
inOverrun ? entity->getLatestZ() : entity->getZ());
|
2026-02-18 04:02:08 -08:00
|
|
|
glm::vec3 renderPos = core::coords::canonicalToRender(canonical);
|
2026-02-20 16:27:21 -08:00
|
|
|
|
|
|
|
|
// Visual collision guard: keep hostile melee units from rendering inside the
|
|
|
|
|
// player's model while attacking. This is client-side only (no server position change).
|
2026-03-07 13:44:09 -08:00
|
|
|
// Only check for creatures within 8 units (melee range) — saves expensive
|
|
|
|
|
// getRenderBoundsForGuid/getModelData calls for distant creatures.
|
|
|
|
|
bool clipGuardEligible = false;
|
|
|
|
|
bool isCombatTarget = false;
|
|
|
|
|
if (havePlayerPos && canonDistSq < 64.0f) { // 8² = melee range
|
|
|
|
|
auto unit = std::static_pointer_cast<game::Unit>(entity);
|
|
|
|
|
const uint64_t currentTargetGuid = gameHandler->hasTarget() ? gameHandler->getTargetGuid() : 0;
|
|
|
|
|
const uint64_t autoAttackGuid = gameHandler->getAutoAttackTargetGuid();
|
|
|
|
|
isCombatTarget = (guid == currentTargetGuid || guid == autoAttackGuid);
|
|
|
|
|
clipGuardEligible = unit->getHealth() > 0 &&
|
|
|
|
|
(unit->isHostile() ||
|
|
|
|
|
gameHandler->isAggressiveTowardPlayer(guid) ||
|
|
|
|
|
isCombatTarget);
|
|
|
|
|
}
|
2026-02-20 16:27:21 -08:00
|
|
|
if (clipGuardEligible) {
|
|
|
|
|
float creatureCollisionRadius = 0.8f;
|
|
|
|
|
glm::vec3 cc;
|
|
|
|
|
float cr = 0.0f;
|
|
|
|
|
if (getRenderBoundsForGuid(guid, cc, cr)) {
|
|
|
|
|
creatureCollisionRadius = std::clamp(cr * 0.45f, 0.65f, 1.9f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float minSep = std::max(playerCollisionRadius + creatureCollisionRadius, 1.9f);
|
|
|
|
|
if (isCombatTarget) {
|
|
|
|
|
// Stronger spacing for the actively engaged attacker to avoid bite-overlap.
|
|
|
|
|
minSep = std::max(minSep, 2.2f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Species/model-specific spacing for wolf-like creatures (their lunge anims
|
|
|
|
|
// often put head/torso inside the player capsule).
|
2026-03-31 22:01:55 +03:00
|
|
|
auto mit = _creatureModelIds.find(guid);
|
|
|
|
|
if (mit != _creatureModelIds.end()) {
|
2026-03-07 11:44:14 -08:00
|
|
|
uint32_t mid = mit->second;
|
2026-03-31 22:01:55 +03:00
|
|
|
auto wolfIt = _modelIdIsWolfLike.find(mid);
|
|
|
|
|
if (wolfIt == _modelIdIsWolfLike.end()) {
|
2026-03-07 11:44:14 -08:00
|
|
|
bool isWolf = false;
|
|
|
|
|
if (const auto* md = charRenderer->getModelData(mid)) {
|
|
|
|
|
std::string modelName = md->name;
|
|
|
|
|
std::transform(modelName.begin(), modelName.end(), modelName.begin(),
|
|
|
|
|
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
|
|
|
|
isWolf = (modelName.find("wolf") != std::string::npos ||
|
|
|
|
|
modelName.find("worg") != std::string::npos);
|
2026-02-20 16:27:21 -08:00
|
|
|
}
|
2026-03-31 22:01:55 +03:00
|
|
|
wolfIt = _modelIdIsWolfLike.emplace(mid, isWolf).first;
|
2026-03-07 11:44:14 -08:00
|
|
|
}
|
|
|
|
|
if (wolfIt->second) {
|
|
|
|
|
minSep = std::max(minSep, 2.45f);
|
2026-02-20 16:27:21 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glm::vec2 d2(renderPos.x - playerRenderPos.x, renderPos.y - playerRenderPos.y);
|
|
|
|
|
float distSq2 = glm::dot(d2, d2);
|
|
|
|
|
if (distSq2 < (minSep * minSep)) {
|
|
|
|
|
glm::vec2 dir2(1.0f, 0.0f);
|
|
|
|
|
if (distSq2 > 1e-6f) {
|
|
|
|
|
dir2 = d2 * (1.0f / std::sqrt(distSq2));
|
|
|
|
|
}
|
|
|
|
|
glm::vec2 clamped2 = glm::vec2(playerRenderPos.x, playerRenderPos.y) + dir2 * minSep;
|
|
|
|
|
renderPos.x = clamped2.x;
|
|
|
|
|
renderPos.y = clamped2.y;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
auto posIt = _creatureRenderPosCache.find(guid);
|
|
|
|
|
if (posIt == _creatureRenderPosCache.end()) {
|
2026-02-20 16:40:22 -08:00
|
|
|
charRenderer->setInstancePosition(instanceId, renderPos);
|
2026-03-31 22:01:55 +03:00
|
|
|
_creatureRenderPosCache[guid] = renderPos;
|
2026-02-20 16:40:22 -08:00
|
|
|
} else {
|
|
|
|
|
const glm::vec3 prevPos = posIt->second;
|
2026-03-27 16:33:16 -07:00
|
|
|
float ddx2 = renderPos.x - prevPos.x;
|
|
|
|
|
float ddy2 = renderPos.y - prevPos.y;
|
|
|
|
|
float planarDistSq = ddx2 * ddx2 + ddy2 * ddy2;
|
2026-02-20 16:40:22 -08:00
|
|
|
float dz = std::abs(renderPos.z - prevPos.z);
|
|
|
|
|
|
2026-03-07 13:44:09 -08:00
|
|
|
auto unitPtr = std::static_pointer_cast<game::Unit>(entity);
|
|
|
|
|
const bool deadOrCorpse = unitPtr->getHealth() == 0;
|
2026-03-27 16:33:16 -07:00
|
|
|
const bool largeCorrection = (planarDistSq > 36.0f) || (dz > 3.0f);
|
2026-04-10 19:50:24 +03:00
|
|
|
// Use isActivelyMoving() so Run/Walk animation stops when the
|
|
|
|
|
// creature reaches its destination. Don't use position-change
|
|
|
|
|
// (planarDistSq) as a movement indicator when the entity is in
|
|
|
|
|
// the dead-reckoning overrun window — the residual velocity
|
|
|
|
|
// drift would keep the walk/run animation playing long after
|
|
|
|
|
// the creature has actually arrived. Only fall back to position-
|
|
|
|
|
// change detection for entities with no active movement tracking
|
|
|
|
|
// (e.g. teleports or position-only updates from the server).
|
2026-03-18 08:22:50 -07:00
|
|
|
const bool entityIsMoving = entity->isActivelyMoving();
|
2026-03-27 16:33:16 -07:00
|
|
|
constexpr float kMoveThreshSq = 0.03f * 0.03f;
|
2026-04-10 19:50:24 +03:00
|
|
|
const bool posChanging = planarDistSq > kMoveThreshSq || dz > 0.08f;
|
|
|
|
|
const bool isMovingNow = !deadOrCorpse && (entityIsMoving || (posChanging && !entity->isEntityMoving()));
|
2026-02-20 16:40:22 -08:00
|
|
|
if (deadOrCorpse || largeCorrection) {
|
|
|
|
|
charRenderer->setInstancePosition(instanceId, renderPos);
|
2026-03-27 16:33:16 -07:00
|
|
|
} else if (planarDistSq > kMoveThreshSq || dz > 0.08f) {
|
2026-03-10 16:08:24 -07:00
|
|
|
// Position changed in entity coords → drive renderer toward it.
|
2026-03-27 16:33:16 -07:00
|
|
|
float planarDist = std::sqrt(planarDistSq);
|
2026-02-20 16:40:22 -08:00
|
|
|
float duration = std::clamp(planarDist / 5.5f, 0.05f, 0.22f);
|
|
|
|
|
charRenderer->moveInstanceTo(instanceId, renderPos, duration);
|
|
|
|
|
}
|
2026-03-10 16:08:24 -07:00
|
|
|
// When entity is moving but getX/Y/Z is stale (distance-culled),
|
|
|
|
|
// don't call moveInstanceTo — creatureMoveCallback_ already drove
|
|
|
|
|
// the renderer to the correct destination via the spline packet.
|
2026-02-20 16:40:22 -08:00
|
|
|
posIt->second = renderPos;
|
2026-03-10 10:06:56 -07:00
|
|
|
|
2026-03-10 10:55:23 -07:00
|
|
|
// Drive movement animation: Walk/Run/Swim (4/5/42) when moving,
|
|
|
|
|
// Stand/SwimIdle (0/41) when idle. Walk(4) selected when WALKING flag is set.
|
2026-03-10 10:36:45 -07:00
|
|
|
// WoW M2 animation IDs: 4=Walk, 5=Run, 41=SwimIdle, 42=Swim.
|
2026-03-10 10:06:56 -07:00
|
|
|
// Only switch on transitions to avoid resetting animation time.
|
|
|
|
|
// Don't override Death (1) animation.
|
2026-03-31 22:01:55 +03:00
|
|
|
const bool isSwimmingNow = _creatureSwimmingState.count(guid) > 0;
|
|
|
|
|
const bool isWalkingNow = _creatureWalkingState.count(guid) > 0;
|
|
|
|
|
const bool isFlyingNow = _creatureFlyingState.count(guid) > 0;
|
|
|
|
|
bool prevMoving = _creatureWasMoving[guid];
|
|
|
|
|
bool prevSwimming = _creatureWasSwimming[guid];
|
|
|
|
|
bool prevFlying = _creatureWasFlying[guid];
|
|
|
|
|
bool prevWalking = _creatureWasWalking[guid];
|
2026-03-10 12:03:33 -07:00
|
|
|
// Trigger animation update on any locomotion-state transition, not just
|
2026-03-10 12:04:59 -07:00
|
|
|
// moving/idle — e.g. creature lands while still moving → FlyForward→Run,
|
|
|
|
|
// or server changes WALKING flag while creature is already running → Walk.
|
|
|
|
|
const bool stateChanged = (isMovingNow != prevMoving) ||
|
2026-03-10 12:03:33 -07:00
|
|
|
(isSwimmingNow != prevSwimming) ||
|
2026-03-10 12:04:59 -07:00
|
|
|
(isFlyingNow != prevFlying) ||
|
|
|
|
|
(isWalkingNow != prevWalking && isMovingNow);
|
2026-03-10 12:03:33 -07:00
|
|
|
if (stateChanged) {
|
2026-03-31 22:01:55 +03:00
|
|
|
_creatureWasMoving[guid] = isMovingNow;
|
|
|
|
|
_creatureWasSwimming[guid] = isSwimmingNow;
|
|
|
|
|
_creatureWasFlying[guid] = isFlyingNow;
|
|
|
|
|
_creatureWasWalking[guid] = isWalkingNow;
|
2026-03-10 10:06:56 -07:00
|
|
|
uint32_t curAnimId = 0; float curT = 0.0f, curDur = 0.0f;
|
|
|
|
|
bool gotState = charRenderer->getAnimationState(instanceId, curAnimId, curT, curDur);
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
if (!gotState || curAnimId != rendering::anim::DEATH) {
|
2026-03-10 10:36:45 -07:00
|
|
|
uint32_t targetAnim;
|
2026-03-10 11:56:50 -07:00
|
|
|
if (isMovingNow) {
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
if (isFlyingNow) targetAnim = rendering::anim::FLY_FORWARD;
|
|
|
|
|
else if (isSwimmingNow) targetAnim = rendering::anim::SWIM;
|
|
|
|
|
else if (isWalkingNow) targetAnim = rendering::anim::WALK;
|
|
|
|
|
else targetAnim = rendering::anim::RUN;
|
2026-03-10 11:56:50 -07:00
|
|
|
} else {
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
if (isFlyingNow) targetAnim = rendering::anim::FLY_IDLE;
|
|
|
|
|
else if (isSwimmingNow) targetAnim = rendering::anim::SWIM_IDLE;
|
|
|
|
|
else targetAnim = rendering::anim::STAND;
|
2026-03-10 11:56:50 -07:00
|
|
|
}
|
2026-03-10 10:36:45 -07:00
|
|
|
charRenderer->playAnimation(instanceId, targetAnim, /*loop=*/true);
|
2026-03-10 10:06:56 -07:00
|
|
|
}
|
|
|
|
|
}
|
2026-02-20 16:40:22 -08:00
|
|
|
}
|
2026-02-18 04:02:08 -08:00
|
|
|
float renderYaw = entity->getOrientation() + glm::radians(90.0f);
|
|
|
|
|
charRenderer->setInstanceRotation(instanceId, glm::vec3(0.0f, 0.0f, renderYaw));
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-07 13:44:09 -08:00
|
|
|
{
|
|
|
|
|
float csMs = std::chrono::duration<float, std::milli>(
|
|
|
|
|
std::chrono::steady_clock::now() - creatureSyncStart).count();
|
|
|
|
|
if (csMs > 5.0f) {
|
|
|
|
|
LOG_WARNING("SLOW update stage 'creature render sync': ", csMs, "ms (",
|
2026-03-31 22:01:55 +03:00
|
|
|
entitySpawner_->getCreatureInstances().size(), " creatures)");
|
2026-03-07 13:44:09 -08:00
|
|
|
}
|
|
|
|
|
}
|
2026-02-18 04:02:08 -08:00
|
|
|
|
2026-03-18 08:33:45 -07:00
|
|
|
// --- Online player render sync (position, orientation, animation) ---
|
|
|
|
|
// Mirrors the creature sync loop above but without collision guard or
|
|
|
|
|
// weapon-attach logic. Without this, online players never transition
|
|
|
|
|
// back to Stand after movement stops ("run in place" bug).
|
|
|
|
|
auto playerSyncStart = std::chrono::steady_clock::now();
|
|
|
|
|
if (renderer && gameHandler && renderer->getCharacterRenderer()) {
|
|
|
|
|
auto* charRenderer = renderer->getCharacterRenderer();
|
|
|
|
|
glm::vec3 pPos(0.0f);
|
|
|
|
|
bool havePPos = false;
|
|
|
|
|
if (auto pe = gameHandler->getEntityManager().getEntity(gameHandler->getPlayerGuid())) {
|
|
|
|
|
pPos = glm::vec3(pe->getX(), pe->getY(), pe->getZ());
|
|
|
|
|
havePPos = true;
|
|
|
|
|
}
|
|
|
|
|
const float pSyncRadiusSq = 320.0f * 320.0f;
|
|
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
auto& _playerInstances = entitySpawner_->getPlayerInstances();
|
|
|
|
|
auto& _pCreatureWasMoving = entitySpawner_->getCreatureWasMoving();
|
|
|
|
|
auto& _pCreatureWasSwimming = entitySpawner_->getCreatureWasSwimming();
|
|
|
|
|
auto& _pCreatureWasFlying = entitySpawner_->getCreatureWasFlying();
|
|
|
|
|
auto& _pCreatureWasWalking = entitySpawner_->getCreatureWasWalking();
|
|
|
|
|
auto& _pCreatureSwimmingState = entitySpawner_->getCreatureSwimmingState();
|
|
|
|
|
auto& _pCreatureWalkingState = entitySpawner_->getCreatureWalkingState();
|
|
|
|
|
auto& _pCreatureFlyingState = entitySpawner_->getCreatureFlyingState();
|
|
|
|
|
auto& _pCreatureRenderPosCache = entitySpawner_->getCreatureRenderPosCache();
|
|
|
|
|
for (const auto& [guid, instanceId] : _playerInstances) {
|
2026-03-18 08:33:45 -07:00
|
|
|
auto entity = gameHandler->getEntityManager().getEntity(guid);
|
|
|
|
|
if (!entity || entity->getType() != game::ObjectType::PLAYER) continue;
|
|
|
|
|
|
|
|
|
|
// Distance cull
|
|
|
|
|
if (havePPos) {
|
|
|
|
|
glm::vec3 latestCanonical(entity->getLatestX(), entity->getLatestY(), entity->getLatestZ());
|
|
|
|
|
glm::vec3 d = latestCanonical - pPos;
|
|
|
|
|
if (glm::dot(d, d) > pSyncRadiusSq) continue;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 19:50:24 +03:00
|
|
|
// Position sync — clamp to destination during dead-reckoning
|
|
|
|
|
// overrun to avoid drift + backward snap (same as creature loop).
|
|
|
|
|
const bool inOverrun = entity->isEntityMoving() && !entity->isActivelyMoving();
|
|
|
|
|
glm::vec3 canonical(
|
|
|
|
|
inOverrun ? entity->getLatestX() : entity->getX(),
|
|
|
|
|
inOverrun ? entity->getLatestY() : entity->getY(),
|
|
|
|
|
inOverrun ? entity->getLatestZ() : entity->getZ());
|
2026-03-18 08:33:45 -07:00
|
|
|
glm::vec3 renderPos = core::coords::canonicalToRender(canonical);
|
|
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
auto posIt = _pCreatureRenderPosCache.find(guid);
|
|
|
|
|
if (posIt == _pCreatureRenderPosCache.end()) {
|
2026-03-18 08:33:45 -07:00
|
|
|
charRenderer->setInstancePosition(instanceId, renderPos);
|
2026-03-31 22:01:55 +03:00
|
|
|
_pCreatureRenderPosCache[guid] = renderPos;
|
2026-03-18 08:33:45 -07:00
|
|
|
} else {
|
|
|
|
|
const glm::vec3 prevPos = posIt->second;
|
2026-03-27 16:33:16 -07:00
|
|
|
float ddx2 = renderPos.x - prevPos.x;
|
|
|
|
|
float ddy2 = renderPos.y - prevPos.y;
|
|
|
|
|
float planarDistSq = ddx2 * ddx2 + ddy2 * ddy2;
|
2026-03-18 08:33:45 -07:00
|
|
|
float dz = std::abs(renderPos.z - prevPos.z);
|
|
|
|
|
|
|
|
|
|
auto unitPtr = std::static_pointer_cast<game::Unit>(entity);
|
|
|
|
|
const bool deadOrCorpse = unitPtr->getHealth() == 0;
|
2026-03-27 16:33:16 -07:00
|
|
|
const bool largeCorrection = (planarDistSq > 36.0f) || (dz > 3.0f);
|
2026-03-18 08:33:45 -07:00
|
|
|
const bool entityIsMoving = entity->isActivelyMoving();
|
2026-03-27 16:33:16 -07:00
|
|
|
constexpr float kMoveThreshSq2 = 0.03f * 0.03f;
|
2026-04-10 19:50:24 +03:00
|
|
|
const bool posChanging2 = planarDistSq > kMoveThreshSq2 || dz > 0.08f;
|
|
|
|
|
const bool isMovingNow = !deadOrCorpse && (entityIsMoving || (posChanging2 && !entity->isEntityMoving()));
|
2026-03-18 08:33:45 -07:00
|
|
|
|
|
|
|
|
if (deadOrCorpse || largeCorrection) {
|
|
|
|
|
charRenderer->setInstancePosition(instanceId, renderPos);
|
2026-03-27 16:33:16 -07:00
|
|
|
} else if (planarDistSq > kMoveThreshSq2 || dz > 0.08f) {
|
|
|
|
|
float planarDist = std::sqrt(planarDistSq);
|
2026-03-18 08:33:45 -07:00
|
|
|
float duration = std::clamp(planarDist / 5.5f, 0.05f, 0.22f);
|
|
|
|
|
charRenderer->moveInstanceTo(instanceId, renderPos, duration);
|
|
|
|
|
}
|
|
|
|
|
posIt->second = renderPos;
|
|
|
|
|
|
|
|
|
|
// Drive movement animation (same logic as creatures)
|
2026-03-31 22:01:55 +03:00
|
|
|
const bool isSwimmingNow = _pCreatureSwimmingState.count(guid) > 0;
|
|
|
|
|
const bool isWalkingNow = _pCreatureWalkingState.count(guid) > 0;
|
|
|
|
|
const bool isFlyingNow = _pCreatureFlyingState.count(guid) > 0;
|
|
|
|
|
bool prevMoving = _pCreatureWasMoving[guid];
|
|
|
|
|
bool prevSwimming = _pCreatureWasSwimming[guid];
|
|
|
|
|
bool prevFlying = _pCreatureWasFlying[guid];
|
|
|
|
|
bool prevWalking = _pCreatureWasWalking[guid];
|
2026-03-18 08:33:45 -07:00
|
|
|
const bool stateChanged = (isMovingNow != prevMoving) ||
|
|
|
|
|
(isSwimmingNow != prevSwimming) ||
|
|
|
|
|
(isFlyingNow != prevFlying) ||
|
|
|
|
|
(isWalkingNow != prevWalking && isMovingNow);
|
|
|
|
|
if (stateChanged) {
|
2026-03-31 22:01:55 +03:00
|
|
|
_pCreatureWasMoving[guid] = isMovingNow;
|
|
|
|
|
_pCreatureWasSwimming[guid] = isSwimmingNow;
|
|
|
|
|
_pCreatureWasFlying[guid] = isFlyingNow;
|
|
|
|
|
_pCreatureWasWalking[guid] = isWalkingNow;
|
2026-03-18 08:33:45 -07:00
|
|
|
uint32_t curAnimId = 0; float curT = 0.0f, curDur = 0.0f;
|
|
|
|
|
bool gotState = charRenderer->getAnimationState(instanceId, curAnimId, curT, curDur);
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
if (!gotState || curAnimId != rendering::anim::DEATH) {
|
2026-03-18 08:33:45 -07:00
|
|
|
uint32_t targetAnim;
|
|
|
|
|
if (isMovingNow) {
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
if (isFlyingNow) targetAnim = rendering::anim::FLY_FORWARD;
|
|
|
|
|
else if (isSwimmingNow) targetAnim = rendering::anim::SWIM;
|
|
|
|
|
else if (isWalkingNow) targetAnim = rendering::anim::WALK;
|
|
|
|
|
else targetAnim = rendering::anim::RUN;
|
2026-03-18 08:33:45 -07:00
|
|
|
} else {
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
if (isFlyingNow) targetAnim = rendering::anim::FLY_IDLE;
|
|
|
|
|
else if (isSwimmingNow) targetAnim = rendering::anim::SWIM_IDLE;
|
|
|
|
|
else targetAnim = rendering::anim::STAND;
|
2026-03-18 08:33:45 -07:00
|
|
|
}
|
|
|
|
|
charRenderer->playAnimation(instanceId, targetAnim, /*loop=*/true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Orientation sync
|
|
|
|
|
float renderYaw = entity->getOrientation() + glm::radians(90.0f);
|
|
|
|
|
charRenderer->setInstanceRotation(instanceId, glm::vec3(0.0f, 0.0f, renderYaw));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
float psMs = std::chrono::duration<float, std::milli>(
|
|
|
|
|
std::chrono::steady_clock::now() - playerSyncStart).count();
|
|
|
|
|
if (psMs > 5.0f) {
|
|
|
|
|
LOG_WARNING("SLOW update stage 'player render sync': ", psMs, "ms (",
|
2026-03-31 22:01:55 +03:00
|
|
|
entitySpawner_->getPlayerInstances().size(), " players)");
|
2026-03-18 08:33:45 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-11 22:27:02 -08:00
|
|
|
// Movement heartbeat is sent from GameHandler::update() to avoid
|
|
|
|
|
// duplicate packets from multiple update loops.
|
2026-02-10 19:30:45 -08:00
|
|
|
|
2026-02-22 07:26:54 -08:00
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM inside AppState::IN_GAME at step '", inGameStep, "': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception inside AppState::IN_GAME at step '", inGameStep, "': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
break;
|
2026-02-08 03:05:38 -08:00
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
case AppState::DISCONNECTED:
|
|
|
|
|
// Handle disconnection
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 20:06:26 +03:00
|
|
|
// Process any pending world entry request via WorldLoader
|
|
|
|
|
if (worldLoader_ && state != AppState::DISCONNECTED) {
|
|
|
|
|
worldLoader_->processPendingEntry();
|
2026-03-15 01:21:23 -07:00
|
|
|
}
|
|
|
|
|
|
Add gameplay systems: combat, spells, groups, loot, vendors, and UI
Implement ~70 new protocol opcodes across 5 phases while maintaining
full 3.3.5a private server compatibility:
- Phase 1: Server-aware targeting (CMSG_SET_SELECTION), player/creature
name queries, CMSG_SET_ACTIVE_MOVER after login
- Phase 2: Auto-attack, melee/spell damage parsing, health/mana/power
tracking from UPDATE_OBJECT fields, floating combat text
- Phase 3: Spell casting, action bar (12 slots, keys 1-=), cast bar,
cooldown tracking, aura/buff system with cancellation
- Phase 4: Group invite/accept/decline/leave, party frames UI,
/invite chat command
- Phase 5: Loot window, NPC gossip dialog, vendor buy/sell interface
Also: disable debug HUD/panels by default, gate 3D rendering to
IN_GAME state only, fix window resize not updating UI positions.
2026-02-04 10:30:52 -08:00
|
|
|
// Update renderer (camera, etc.) only when in-game
|
2026-02-22 07:26:54 -08:00
|
|
|
updateCheckpoint = "renderer update";
|
Add gameplay systems: combat, spells, groups, loot, vendors, and UI
Implement ~70 new protocol opcodes across 5 phases while maintaining
full 3.3.5a private server compatibility:
- Phase 1: Server-aware targeting (CMSG_SET_SELECTION), player/creature
name queries, CMSG_SET_ACTIVE_MOVER after login
- Phase 2: Auto-attack, melee/spell damage parsing, health/mana/power
tracking from UPDATE_OBJECT fields, floating combat text
- Phase 3: Spell casting, action bar (12 slots, keys 1-=), cast bar,
cooldown tracking, aura/buff system with cancellation
- Phase 4: Group invite/accept/decline/leave, party frames UI,
/invite chat command
- Phase 5: Loot window, NPC gossip dialog, vendor buy/sell interface
Also: disable debug HUD/panels by default, gate 3D rendering to
IN_GAME state only, fix window resize not updating UI positions.
2026-02-04 10:30:52 -08:00
|
|
|
if (renderer && state == AppState::IN_GAME) {
|
2026-03-07 13:44:09 -08:00
|
|
|
auto rendererUpdateStart = std::chrono::steady_clock::now();
|
2026-02-22 07:26:54 -08:00
|
|
|
try {
|
|
|
|
|
renderer->update(deltaTime);
|
|
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM during Application::update stage 'renderer->update': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception during Application::update stage 'renderer->update': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2026-03-07 13:44:09 -08:00
|
|
|
float ruMs = std::chrono::duration<float, std::milli>(
|
|
|
|
|
std::chrono::steady_clock::now() - rendererUpdateStart).count();
|
2026-03-07 18:43:13 -08:00
|
|
|
if (ruMs > 50.0f) {
|
2026-03-07 13:44:09 -08:00
|
|
|
LOG_WARNING("SLOW update stage 'renderer->update': ", ruMs, "ms");
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
// Update UI
|
2026-02-22 07:26:54 -08:00
|
|
|
updateCheckpoint = "ui update";
|
2026-02-02 12:24:50 -08:00
|
|
|
if (uiManager) {
|
2026-02-22 07:26:54 -08:00
|
|
|
try {
|
|
|
|
|
uiManager->update(deltaTime);
|
|
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM during Application::update stage 'uiManager->update': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception during Application::update stage 'uiManager->update': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
2026-02-22 07:26:54 -08:00
|
|
|
} catch (const std::bad_alloc& e) {
|
|
|
|
|
LOG_ERROR("OOM in Application::update checkpoint '", updateCheckpoint, "': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
LOG_ERROR("Exception in Application::update checkpoint '", updateCheckpoint, "': ", e.what());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::render() {
|
|
|
|
|
if (!renderer) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderer->beginFrame();
|
|
|
|
|
|
2026-02-17 15:37:02 -08:00
|
|
|
// Only render 3D world when in-game
|
Add gameplay systems: combat, spells, groups, loot, vendors, and UI
Implement ~70 new protocol opcodes across 5 phases while maintaining
full 3.3.5a private server compatibility:
- Phase 1: Server-aware targeting (CMSG_SET_SELECTION), player/creature
name queries, CMSG_SET_ACTIVE_MOVER after login
- Phase 2: Auto-attack, melee/spell damage parsing, health/mana/power
tracking from UPDATE_OBJECT fields, floating combat text
- Phase 3: Spell casting, action bar (12 slots, keys 1-=), cast bar,
cooldown tracking, aura/buff system with cancellation
- Phase 4: Group invite/accept/decline/leave, party frames UI,
/invite chat command
- Phase 5: Loot window, NPC gossip dialog, vendor buy/sell interface
Also: disable debug HUD/panels by default, gate 3D rendering to
IN_GAME state only, fix window resize not updating UI positions.
2026-02-04 10:30:52 -08:00
|
|
|
if (state == AppState::IN_GAME) {
|
|
|
|
|
if (world) {
|
2026-02-10 19:30:45 -08:00
|
|
|
renderer->renderWorld(world.get(), gameHandler.get());
|
Add gameplay systems: combat, spells, groups, loot, vendors, and UI
Implement ~70 new protocol opcodes across 5 phases while maintaining
full 3.3.5a private server compatibility:
- Phase 1: Server-aware targeting (CMSG_SET_SELECTION), player/creature
name queries, CMSG_SET_ACTIVE_MOVER after login
- Phase 2: Auto-attack, melee/spell damage parsing, health/mana/power
tracking from UPDATE_OBJECT fields, floating combat text
- Phase 3: Spell casting, action bar (12 slots, keys 1-=), cast bar,
cooldown tracking, aura/buff system with cancellation
- Phase 4: Group invite/accept/decline/leave, party frames UI,
/invite chat command
- Phase 5: Loot window, NPC gossip dialog, vendor buy/sell interface
Also: disable debug HUD/panels by default, gate 3D rendering to
IN_GAME state only, fix window resize not updating UI positions.
2026-02-04 10:30:52 -08:00
|
|
|
} else {
|
2026-02-10 19:30:45 -08:00
|
|
|
renderer->renderWorld(nullptr, gameHandler.get());
|
Add gameplay systems: combat, spells, groups, loot, vendors, and UI
Implement ~70 new protocol opcodes across 5 phases while maintaining
full 3.3.5a private server compatibility:
- Phase 1: Server-aware targeting (CMSG_SET_SELECTION), player/creature
name queries, CMSG_SET_ACTIVE_MOVER after login
- Phase 2: Auto-attack, melee/spell damage parsing, health/mana/power
tracking from UPDATE_OBJECT fields, floating combat text
- Phase 3: Spell casting, action bar (12 slots, keys 1-=), cast bar,
cooldown tracking, aura/buff system with cancellation
- Phase 4: Group invite/accept/decline/leave, party frames UI,
/invite chat command
- Phase 5: Loot window, NPC gossip dialog, vendor buy/sell interface
Also: disable debug HUD/panels by default, gate 3D rendering to
IN_GAME state only, fix window resize not updating UI positions.
2026-02-04 10:30:52 -08:00
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Render performance HUD (within ImGui frame, before UI ends the frame)
|
|
|
|
|
if (renderer) {
|
|
|
|
|
renderer->renderHUD();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Render UI on top (ends ImGui frame with ImGui::Render())
|
|
|
|
|
if (uiManager) {
|
|
|
|
|
uiManager->render(state, authHandler.get(), gameHandler.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderer->endFrame();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::setupUICallbacks() {
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
// ── UI screen callbacks (auth, realm, character selection/creation) ──
|
|
|
|
|
uiScreenCallbacks_ = std::make_unique<UIScreenCallbackHandler>(
|
|
|
|
|
*uiManager, *gameHandler, *authHandler, expansionRegistry_.get(),
|
|
|
|
|
assetManager.get(),
|
|
|
|
|
[this](AppState s) { setState(s); });
|
|
|
|
|
uiScreenCallbacks_->setupCallbacks();
|
|
|
|
|
|
|
|
|
|
// ── World entry, unstuck, hearthstone, bind point ──
|
|
|
|
|
worldEntryCallbacks_ = std::make_unique<WorldEntryCallbackHandler>(
|
|
|
|
|
*renderer, *gameHandler, worldLoader_.get(), entitySpawner_.get(),
|
|
|
|
|
audioCoordinator_.get(), assetManager.get());
|
|
|
|
|
worldEntryCallbacks_->setupCallbacks();
|
|
|
|
|
|
|
|
|
|
// ── Entity spawn/despawn (creatures, players, game objects) ──
|
|
|
|
|
entitySpawnCallbacks_ = std::make_unique<EntitySpawnCallbackHandler>(
|
|
|
|
|
*entitySpawner_, *renderer, *gameHandler,
|
|
|
|
|
[this](uint64_t guid) {
|
|
|
|
|
uint64_t localGuid = gameHandler ? gameHandler->getPlayerGuid() : 0;
|
|
|
|
|
uint64_t activeGuid = gameHandler ? gameHandler->getActiveCharacterGuid() : 0;
|
|
|
|
|
return (localGuid != 0 && guid == localGuid) ||
|
|
|
|
|
(activeGuid != 0 && guid == activeGuid) ||
|
|
|
|
|
(spawnedPlayerGuid_ != 0 && guid == spawnedPlayerGuid_);
|
2026-02-08 15:32:04 -08:00
|
|
|
});
|
refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.
New handlers (include/core/ + src/core/):
- NPCInteractionCallbackHandler NPC greeting/farewell/vendor/aggro voice
- AudioCallbackHandler Music, positional sound, level-up, achievement, LFG
- EntitySpawnCallbackHandler Creature/player/GO spawn, despawn, move, state
- AnimationCallbackHandler Death, respawn, combat, emotes, charge, sprint, vehicle
- TransportCallbackHandler Mount, taxi, transport spawn/move
- WorldEntryCallbackHandler World entry, unstuck, hearthstone, bind point
- UIScreenCallbackHandler Auth, realm selection, char selection/creation/deletion
application.cpp: 4,462 → 2,791 lines (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)
Deduplication:
resolveSoundEntryPath() — was 3× copy-paste of SoundEntries.dbc lookup
resolveNpcVoiceType() — was 4× copy-paste of display-ID→voice detection
precacheNearbyTiles() — was 3× copy-paste of 17×17 tile loop
4 helper lambdas — promoted to private methods on WorldEntryCallbackHandler
State migration out of Application:
charge* (6 vars) → AnimationCallbackHandler
hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
pendingCreatedCharacterName_ → UIScreenCallbackHandler
Bug fixes:
- Duplicate `namespace core {` in application.hpp caused wowee::std pollution
- AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
- world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00
|
|
|
entitySpawnCallbacks_->setupCallbacks();
|
|
|
|
|
|
|
|
|
|
// ── Animation: death, respawn, swing, hit, spell, emote, charge, etc. ──
|
|
|
|
|
animationCallbacks_ = std::make_unique<AnimationCallbackHandler>(
|
|
|
|
|
*entitySpawner_, *renderer, *gameHandler);
|
|
|
|
|
animationCallbacks_->setupCallbacks();
|
|
|
|
|
|
|
|
|
|
// ── NPC interaction: greeting, farewell, vendor, aggro voice ──
|
|
|
|
|
npcInteractionCallbacks_ = std::make_unique<NPCInteractionCallbackHandler>(
|
|
|
|
|
*entitySpawner_, renderer.get(), *gameHandler, audioCoordinator_.get());
|
|
|
|
|
npcInteractionCallbacks_->setupCallbacks();
|
|
|
|
|
|
|
|
|
|
// ── Audio: music, sound effects, level-up, achievement, LFG ──
|
|
|
|
|
audioCallbacks_ = std::make_unique<AudioCallbackHandler>(
|
|
|
|
|
*assetManager, audioCoordinator_.get(), renderer.get(),
|
|
|
|
|
uiManager.get(), *gameHandler);
|
|
|
|
|
audioCallbacks_->setupCallbacks();
|
|
|
|
|
|
|
|
|
|
// ── Transport: mount, taxi, transport spawn/move ──
|
|
|
|
|
transportCallbacks_ = std::make_unique<TransportCallbackHandler>(
|
|
|
|
|
*entitySpawner_, *renderer, *gameHandler, worldLoader_.get());
|
|
|
|
|
transportCallbacks_->setupCallbacks();
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::spawnPlayerCharacter() {
|
|
|
|
|
if (playerCharacterSpawned) return;
|
|
|
|
|
if (!renderer || !renderer->getCharacterRenderer() || !renderer->getCamera()) return;
|
|
|
|
|
|
|
|
|
|
auto* charRenderer = renderer->getCharacterRenderer();
|
|
|
|
|
auto* camera = renderer->getCamera();
|
|
|
|
|
bool loaded = false;
|
2026-04-01 13:31:48 +03:00
|
|
|
std::string m2Path = appearanceComposer_->getPlayerModelPath(playerRace_, playerGender_);
|
2026-02-05 14:35:12 -08:00
|
|
|
std::string modelDir;
|
|
|
|
|
std::string baseName;
|
|
|
|
|
{
|
|
|
|
|
size_t slash = m2Path.rfind('\\');
|
|
|
|
|
if (slash != std::string::npos) {
|
|
|
|
|
modelDir = m2Path.substr(0, slash + 1);
|
|
|
|
|
baseName = m2Path.substr(slash + 1);
|
|
|
|
|
} else {
|
|
|
|
|
baseName = m2Path;
|
|
|
|
|
}
|
|
|
|
|
size_t dot = baseName.rfind('.');
|
|
|
|
|
if (dot != std::string::npos) {
|
|
|
|
|
baseName = baseName.substr(0, dot);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-05 14:35:12 -08:00
|
|
|
// Try loading selected character model from MPQ
|
2026-02-02 12:24:50 -08:00
|
|
|
if (assetManager && assetManager->isInitialized()) {
|
|
|
|
|
auto m2Data = assetManager->readFile(m2Path);
|
|
|
|
|
if (!m2Data.empty()) {
|
|
|
|
|
auto model = pipeline::M2Loader::load(m2Data);
|
|
|
|
|
|
|
|
|
|
// Load skin file for submesh/batch data
|
2026-02-05 14:35:12 -08:00
|
|
|
std::string skinPath = modelDir + baseName + "00.skin";
|
2026-02-02 12:24:50 -08:00
|
|
|
auto skinData = assetManager->readFile(skinPath);
|
2026-02-14 13:57:54 -08:00
|
|
|
if (!skinData.empty() && model.version >= 264) {
|
2026-02-02 12:24:50 -08:00
|
|
|
pipeline::M2Loader::loadSkin(skinData, model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (model.isValid()) {
|
|
|
|
|
// Log texture slots
|
|
|
|
|
for (size_t ti = 0; ti < model.textures.size(); ti++) {
|
|
|
|
|
auto& tex = model.textures[ti];
|
|
|
|
|
LOG_INFO(" Texture ", ti, ": type=", tex.type, " name='", tex.filename, "'");
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
// Resolve textures from CharSections.dbc via AppearanceComposer
|
|
|
|
|
PlayerTextureInfo texInfo;
|
2026-02-06 17:27:20 -08:00
|
|
|
bool useCharSections = true;
|
2026-04-01 13:31:48 +03:00
|
|
|
if (appearanceComposer_) {
|
|
|
|
|
uint32_t appearanceBytes = 0;
|
|
|
|
|
if (gameHandler) {
|
|
|
|
|
const game::Character* activeChar = gameHandler->getActiveCharacter();
|
|
|
|
|
if (activeChar) {
|
|
|
|
|
appearanceBytes = activeChar->appearanceBytes;
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-01 13:31:48 +03:00
|
|
|
texInfo = appearanceComposer_->resolvePlayerTextures(model, playerRace_, playerGender_, appearanceBytes);
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load external .anim files for sequences with external data.
|
|
|
|
|
// Sequences WITH flag 0x20 have their animation data inline in the M2 file.
|
|
|
|
|
// Sequences WITHOUT flag 0x20 store data in external .anim files.
|
|
|
|
|
for (uint32_t si = 0; si < model.sequences.size(); si++) {
|
|
|
|
|
if (!(model.sequences[si].flags & 0x20)) {
|
|
|
|
|
// File naming: <ModelPath><AnimId>-<VariationIndex>.anim
|
|
|
|
|
// e.g. Character\Human\Male\HumanMale0097-00.anim
|
|
|
|
|
char animFileName[256];
|
|
|
|
|
snprintf(animFileName, sizeof(animFileName),
|
2026-02-05 14:35:12 -08:00
|
|
|
"%s%s%04u-%02u.anim",
|
|
|
|
|
modelDir.c_str(),
|
|
|
|
|
baseName.c_str(),
|
|
|
|
|
model.sequences[si].id,
|
|
|
|
|
model.sequences[si].variationIndex);
|
2026-02-12 02:27:59 -08:00
|
|
|
auto animFileData = assetManager->readFileOptional(animFileName);
|
2026-02-02 12:24:50 -08:00
|
|
|
if (!animFileData.empty()) {
|
|
|
|
|
pipeline::M2Loader::loadAnimFile(m2Data, animFileData, si, model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
charRenderer->loadModel(model, 1);
|
|
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
// Apply composited textures via AppearanceComposer (saves skin state for re-compositing)
|
|
|
|
|
if (useCharSections && appearanceComposer_) {
|
|
|
|
|
appearanceComposer_->compositePlayerSkin(1, texInfo);
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loaded = true;
|
2026-02-05 14:35:12 -08:00
|
|
|
LOG_INFO("Loaded character model: ", m2Path, " (", model.vertices.size(), " verts, ",
|
2026-02-02 12:24:50 -08:00
|
|
|
model.bones.size(), " bones, ", model.sequences.size(), " anims, ",
|
|
|
|
|
model.indices.size(), " indices, ", model.batches.size(), " batches");
|
|
|
|
|
// Log all animation sequence IDs
|
|
|
|
|
for (size_t i = 0; i < model.sequences.size(); i++) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fallback: create a simple cube if MPQ not available
|
|
|
|
|
if (!loaded) {
|
|
|
|
|
pipeline::M2Model testModel;
|
|
|
|
|
float size = 2.0f;
|
|
|
|
|
glm::vec3 cubePos[] = {
|
|
|
|
|
{-size, -size, -size}, { size, -size, -size},
|
|
|
|
|
{ size, size, -size}, {-size, size, -size},
|
|
|
|
|
{-size, -size, size}, { size, -size, size},
|
|
|
|
|
{ size, size, size}, {-size, size, size}
|
|
|
|
|
};
|
|
|
|
|
for (const auto& pos : cubePos) {
|
|
|
|
|
pipeline::M2Vertex v;
|
|
|
|
|
v.position = pos;
|
|
|
|
|
v.normal = glm::normalize(pos);
|
|
|
|
|
v.texCoords[0] = glm::vec2(0.0f);
|
|
|
|
|
v.boneWeights[0] = 255;
|
|
|
|
|
v.boneWeights[1] = v.boneWeights[2] = v.boneWeights[3] = 0;
|
|
|
|
|
v.boneIndices[0] = 0;
|
|
|
|
|
v.boneIndices[1] = v.boneIndices[2] = v.boneIndices[3] = 0;
|
|
|
|
|
testModel.vertices.push_back(v);
|
|
|
|
|
}
|
|
|
|
|
uint16_t cubeIndices[] = {
|
|
|
|
|
0,1,2, 0,2,3, 4,6,5, 4,7,6,
|
|
|
|
|
0,4,5, 0,5,1, 2,6,7, 2,7,3,
|
|
|
|
|
0,3,7, 0,7,4, 1,5,6, 1,6,2
|
|
|
|
|
};
|
|
|
|
|
for (uint16_t idx : cubeIndices)
|
|
|
|
|
testModel.indices.push_back(idx);
|
|
|
|
|
|
|
|
|
|
pipeline::M2Bone bone;
|
|
|
|
|
bone.keyBoneId = -1;
|
|
|
|
|
bone.flags = 0;
|
|
|
|
|
bone.parentBone = -1;
|
|
|
|
|
bone.submeshId = 0;
|
|
|
|
|
bone.pivot = glm::vec3(0.0f);
|
|
|
|
|
testModel.bones.push_back(bone);
|
|
|
|
|
|
|
|
|
|
pipeline::M2Sequence seq{};
|
|
|
|
|
seq.id = 0;
|
|
|
|
|
seq.duration = 1000;
|
|
|
|
|
testModel.sequences.push_back(seq);
|
|
|
|
|
|
|
|
|
|
testModel.name = "TestCube";
|
|
|
|
|
testModel.globalFlags = 0;
|
|
|
|
|
charRenderer->loadModel(testModel, 1);
|
|
|
|
|
LOG_INFO("Loaded fallback cube model (no MPQ data)");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-04 23:30:03 -08:00
|
|
|
// Spawn character at the camera controller's default position (matches hearthstone).
|
|
|
|
|
// Most presets snap to floor; explicit WMO-floor presets keep their authored Z.
|
2026-02-04 13:29:27 -08:00
|
|
|
auto* camCtrl = renderer->getCameraController();
|
|
|
|
|
glm::vec3 spawnPos = camCtrl ? camCtrl->getDefaultPosition()
|
|
|
|
|
: (camera->getPosition() - glm::vec3(0.0f, 0.0f, 5.0f));
|
2026-02-04 23:30:03 -08:00
|
|
|
if (spawnSnapToGround && renderer->getTerrainManager()) {
|
2026-02-04 13:29:27 -08:00
|
|
|
auto terrainH = renderer->getTerrainManager()->getHeightAt(spawnPos.x, spawnPos.y);
|
|
|
|
|
if (terrainH) {
|
|
|
|
|
spawnPos.z = *terrainH + 0.1f;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
uint32_t instanceId = charRenderer->createInstance(1, spawnPos,
|
2026-02-03 14:26:08 -08:00
|
|
|
glm::vec3(0.0f), 1.0f); // Scale 1.0 = normal WoW character size
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
if (instanceId > 0) {
|
2026-02-12 14:55:27 -08:00
|
|
|
// Set up third-person follow
|
|
|
|
|
renderer->getCharacterPosition() = spawnPos;
|
|
|
|
|
renderer->setCharacterFollow(instanceId);
|
|
|
|
|
|
2026-04-01 13:31:48 +03:00
|
|
|
// Build default geosets for the active character via AppearanceComposer
|
2026-02-12 14:55:27 -08:00
|
|
|
uint8_t hairStyleId = 0;
|
|
|
|
|
uint8_t facialId = 0;
|
2026-04-03 22:43:37 -07:00
|
|
|
uint8_t raceId = 0;
|
|
|
|
|
uint8_t sexId = 0;
|
2026-02-12 14:55:27 -08:00
|
|
|
if (gameHandler) {
|
|
|
|
|
if (const game::Character* ch = gameHandler->getActiveCharacter()) {
|
|
|
|
|
hairStyleId = static_cast<uint8_t>((ch->appearanceBytes >> 16) & 0xFF);
|
|
|
|
|
facialId = ch->facialFeatures;
|
2026-04-03 22:43:37 -07:00
|
|
|
raceId = static_cast<uint8_t>(ch->race);
|
|
|
|
|
sexId = static_cast<uint8_t>(ch->gender);
|
2026-02-12 14:55:27 -08:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-01 13:31:48 +03:00
|
|
|
auto activeGeosets = appearanceComposer_
|
2026-04-03 22:43:37 -07:00
|
|
|
? appearanceComposer_->buildDefaultPlayerGeosets(raceId, sexId, hairStyleId, facialId)
|
2026-04-01 13:31:48 +03:00
|
|
|
: std::unordered_set<uint16_t>{};
|
2026-02-12 14:55:27 -08:00
|
|
|
charRenderer->setActiveGeosets(instanceId, activeGeosets);
|
2026-02-02 12:24:50 -08:00
|
|
|
|
feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.
Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.
Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.
Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.
Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.
Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
|
|
|
// Play idle animation
|
|
|
|
|
charRenderer->playAnimation(instanceId, rendering::anim::STAND, true);
|
2026-02-02 12:24:50 -08:00
|
|
|
LOG_INFO("Spawned player character at (",
|
|
|
|
|
static_cast<int>(spawnPos.x), ", ",
|
|
|
|
|
static_cast<int>(spawnPos.y), ", ",
|
|
|
|
|
static_cast<int>(spawnPos.z), ")");
|
|
|
|
|
playerCharacterSpawned = true;
|
|
|
|
|
|
2026-02-23 06:22:30 -08:00
|
|
|
// Set voice profile to match character race/gender
|
chore(renderer): extract AnimationController and remove audio pass-throughs
Extract ~1,500 lines of character animation state from Renderer into a dedicated
AnimationController class, and complete the AudioCoordinator migration by removing
all 10 audio pass-through getters from Renderer.
AnimationController:
- New: include/rendering/animation_controller.hpp (182 lines)
- New: src/rendering/animation_controller.cpp (1,703 lines)
- Moves: locomotion state machine (50+ members), mount animation (40+ members),
emote system, footstep triggering, surface detection, melee combat animations
- Renderer holds std::unique_ptr<AnimationController> and delegates completely
- AnimationController accesses audio via renderer_->getAudioCoordinator()
Audio caller migration:
- Migrate ~60 external callers from renderer->getXManager() to AudioCoordinator
directly, grouped by access pattern:
- UIServices: settings_panel, game_screen, toast_manager, chat_panel,
combat_ui, window_manager
- GameServices: game_handler, spell_handler, inventory_handler, quest_handler,
social_handler, combat_handler
- Application singleton: application.cpp, auth_screen.cpp, lua_engine.cpp
- Remove 10 pass-through getter definitions from renderer.cpp
- Remove 10 pass-through getter declarations from renderer.hpp
- Remove individual audio manager forward declarations from renderer.hpp
- Redirect 69 internal renderer.cpp audio calls to audioCoordinator_ directly
- game_handler.cpp: withSoundManager template uses services_.audioCoordinator;
MFP changed from &Renderer::getUiSoundManager to &AudioCoordinator::getUiSoundManager
- GameServices struct: add AudioCoordinator* audioCoordinator member
- settings_panel: applyAudioVolumes(Renderer*) -> applyAudioVolumes(AudioCoordinator*)
2026-04-02 13:06:31 +03:00
|
|
|
if (auto* asm_ = audioCoordinator_ ? audioCoordinator_->getActivitySoundManager() : nullptr) {
|
2026-02-23 06:22:30 -08:00
|
|
|
const char* raceFolder = "Human";
|
|
|
|
|
const char* raceBase = "Human";
|
|
|
|
|
switch (playerRace_) {
|
|
|
|
|
case game::Race::HUMAN: raceFolder = "Human"; raceBase = "Human"; break;
|
|
|
|
|
case game::Race::ORC: raceFolder = "Orc"; raceBase = "Orc"; break;
|
|
|
|
|
case game::Race::DWARF: raceFolder = "Dwarf"; raceBase = "Dwarf"; break;
|
|
|
|
|
case game::Race::NIGHT_ELF: raceFolder = "NightElf"; raceBase = "NightElf"; break;
|
|
|
|
|
case game::Race::UNDEAD: raceFolder = "Scourge"; raceBase = "Scourge"; break;
|
|
|
|
|
case game::Race::TAUREN: raceFolder = "Tauren"; raceBase = "Tauren"; break;
|
|
|
|
|
case game::Race::GNOME: raceFolder = "Gnome"; raceBase = "Gnome"; break;
|
|
|
|
|
case game::Race::TROLL: raceFolder = "Troll"; raceBase = "Troll"; break;
|
|
|
|
|
case game::Race::BLOOD_ELF: raceFolder = "BloodElf"; raceBase = "BloodElf"; break;
|
|
|
|
|
case game::Race::DRAENEI: raceFolder = "Draenei"; raceBase = "Draenei"; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
bool useFemaleVoice = (playerGender_ == game::Gender::FEMALE);
|
|
|
|
|
if (playerGender_ == game::Gender::NONBINARY && gameHandler) {
|
|
|
|
|
if (const game::Character* ch = gameHandler->getActiveCharacter()) {
|
|
|
|
|
useFemaleVoice = ch->useFemaleModel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
asm_->setCharacterVoiceProfile(std::string(raceFolder), std::string(raceBase), !useFemaleVoice);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 14:55:27 -08:00
|
|
|
// Track which character's appearance this instance represents so we can
|
|
|
|
|
// respawn if the user logs into a different character without restarting.
|
|
|
|
|
spawnedPlayerGuid_ = gameHandler ? gameHandler->getActiveCharacterGuid() : 0;
|
|
|
|
|
spawnedAppearanceBytes_ = 0;
|
|
|
|
|
spawnedFacialFeatures_ = 0;
|
|
|
|
|
if (gameHandler) {
|
|
|
|
|
if (const game::Character* ch = gameHandler->getActiveCharacter()) {
|
|
|
|
|
spawnedAppearanceBytes_ = ch->appearanceBytes;
|
|
|
|
|
spawnedFacialFeatures_ = ch->facialFeatures;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 14:26:08 -08:00
|
|
|
// Set up camera controller for first-person player hiding
|
|
|
|
|
if (renderer->getCameraController()) {
|
|
|
|
|
renderer->getCameraController()->setCharacterRenderer(charRenderer, instanceId);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
// Load equipped weapons (sword + shield)
|
2026-04-01 13:31:48 +03:00
|
|
|
if (appearanceComposer_) appearanceComposer_->loadEquippedWeapons();
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-06 17:27:20 -08:00
|
|
|
void Application::buildFactionHostilityMap(uint8_t playerRace) {
|
|
|
|
|
if (!assetManager || !assetManager->isInitialized() || !gameHandler) return;
|
|
|
|
|
|
|
|
|
|
auto ftDbc = assetManager->loadDBC("FactionTemplate.dbc");
|
|
|
|
|
auto fDbc = assetManager->loadDBC("Faction.dbc");
|
|
|
|
|
if (!ftDbc || !ftDbc->isLoaded()) return;
|
|
|
|
|
|
|
|
|
|
// Race enum → race mask bit: race 1=0x1, 2=0x2, 3=0x4, 4=0x8, 5=0x10, 6=0x20, 7=0x40, 8=0x80, 10=0x200, 11=0x400
|
|
|
|
|
uint32_t playerRaceMask = 0;
|
|
|
|
|
if (playerRace >= 1 && playerRace <= 8) {
|
|
|
|
|
playerRaceMask = 1u << (playerRace - 1);
|
|
|
|
|
} else if (playerRace == 10) {
|
|
|
|
|
playerRaceMask = 0x200; // Blood Elf
|
|
|
|
|
} else if (playerRace == 11) {
|
|
|
|
|
playerRaceMask = 0x400; // Draenei
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Race → player faction template ID
|
|
|
|
|
// Human=1, Orc=2, Dwarf=3, NightElf=4, Undead=5, Tauren=6, Gnome=115, Troll=116, BloodElf=1610, Draenei=1629
|
|
|
|
|
uint32_t playerFtId = 0;
|
|
|
|
|
switch (playerRace) {
|
|
|
|
|
case 1: playerFtId = 1; break; // Human
|
|
|
|
|
case 2: playerFtId = 2; break; // Orc
|
|
|
|
|
case 3: playerFtId = 3; break; // Dwarf
|
|
|
|
|
case 4: playerFtId = 4; break; // Night Elf
|
|
|
|
|
case 5: playerFtId = 5; break; // Undead
|
|
|
|
|
case 6: playerFtId = 6; break; // Tauren
|
|
|
|
|
case 7: playerFtId = 115; break; // Gnome
|
|
|
|
|
case 8: playerFtId = 116; break; // Troll
|
|
|
|
|
case 10: playerFtId = 1610; break; // Blood Elf
|
|
|
|
|
case 11: playerFtId = 1629; break; // Draenei
|
|
|
|
|
default: playerFtId = 1; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build set of hostile parent faction IDs from Faction.dbc base reputation
|
2026-02-12 22:56:36 -08:00
|
|
|
const auto* facL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("Faction") : nullptr;
|
|
|
|
|
const auto* ftL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("FactionTemplate") : nullptr;
|
2026-02-06 17:27:20 -08:00
|
|
|
std::unordered_set<uint32_t> hostileParentFactions;
|
|
|
|
|
if (fDbc && fDbc->isLoaded()) {
|
2026-02-12 22:56:36 -08:00
|
|
|
const uint32_t facID = facL ? (*facL)["ID"] : 0;
|
|
|
|
|
const uint32_t facRaceMask0 = facL ? (*facL)["ReputationRaceMask0"] : 2;
|
|
|
|
|
const uint32_t facBase0 = facL ? (*facL)["ReputationBase0"] : 10;
|
2026-02-06 17:27:20 -08:00
|
|
|
for (uint32_t i = 0; i < fDbc->getRecordCount(); i++) {
|
2026-02-12 22:56:36 -08:00
|
|
|
uint32_t factionId = fDbc->getUInt32(i, facID);
|
2026-02-06 17:27:20 -08:00
|
|
|
for (int slot = 0; slot < 4; slot++) {
|
2026-02-12 22:56:36 -08:00
|
|
|
uint32_t raceMask = fDbc->getUInt32(i, facRaceMask0 + slot);
|
2026-02-06 17:27:20 -08:00
|
|
|
if (raceMask & playerRaceMask) {
|
2026-02-12 22:56:36 -08:00
|
|
|
int32_t baseRep = fDbc->getInt32(i, facBase0 + slot);
|
2026-02-06 17:27:20 -08:00
|
|
|
if (baseRep < 0) {
|
|
|
|
|
hostileParentFactions.insert(factionId);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-25 11:40:49 -07:00
|
|
|
LOG_INFO("Faction.dbc: ", hostileParentFactions.size(), " factions hostile to race ", static_cast<int>(playerRace));
|
2026-02-06 17:27:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get player faction template data
|
2026-02-12 22:56:36 -08:00
|
|
|
const uint32_t ftID = ftL ? (*ftL)["ID"] : 0;
|
|
|
|
|
const uint32_t ftFaction = ftL ? (*ftL)["Faction"] : 1;
|
|
|
|
|
const uint32_t ftFG = ftL ? (*ftL)["FactionGroup"] : 3;
|
|
|
|
|
const uint32_t ftFriend = ftL ? (*ftL)["FriendGroup"] : 4;
|
|
|
|
|
const uint32_t ftEnemy = ftL ? (*ftL)["EnemyGroup"] : 5;
|
|
|
|
|
const uint32_t ftEnemy0 = ftL ? (*ftL)["Enemy0"] : 6;
|
2026-02-06 17:27:20 -08:00
|
|
|
uint32_t playerFriendGroup = 0;
|
|
|
|
|
uint32_t playerEnemyGroup = 0;
|
|
|
|
|
uint32_t playerFactionId = 0;
|
|
|
|
|
for (uint32_t i = 0; i < ftDbc->getRecordCount(); i++) {
|
2026-02-12 22:56:36 -08:00
|
|
|
if (ftDbc->getUInt32(i, ftID) == playerFtId) {
|
|
|
|
|
playerFriendGroup = ftDbc->getUInt32(i, ftFriend) | ftDbc->getUInt32(i, ftFG);
|
|
|
|
|
playerEnemyGroup = ftDbc->getUInt32(i, ftEnemy);
|
|
|
|
|
playerFactionId = ftDbc->getUInt32(i, ftFaction);
|
2026-02-06 17:27:20 -08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build hostility map for each faction template
|
|
|
|
|
std::unordered_map<uint32_t, bool> factionMap;
|
|
|
|
|
for (uint32_t i = 0; i < ftDbc->getRecordCount(); i++) {
|
2026-02-12 22:56:36 -08:00
|
|
|
uint32_t id = ftDbc->getUInt32(i, ftID);
|
|
|
|
|
uint32_t parentFaction = ftDbc->getUInt32(i, ftFaction);
|
|
|
|
|
uint32_t factionGroup = ftDbc->getUInt32(i, ftFG);
|
|
|
|
|
uint32_t friendGroup = ftDbc->getUInt32(i, ftFriend);
|
|
|
|
|
uint32_t enemyGroup = ftDbc->getUInt32(i, ftEnemy);
|
2026-02-06 17:27:20 -08:00
|
|
|
|
|
|
|
|
// 1. Symmetric group check
|
|
|
|
|
bool hostile = (enemyGroup & playerFriendGroup) != 0
|
|
|
|
|
|| (factionGroup & playerEnemyGroup) != 0;
|
|
|
|
|
|
|
|
|
|
// 2. Monster factionGroup bit (8)
|
|
|
|
|
if (!hostile && (factionGroup & 8) != 0) {
|
|
|
|
|
hostile = true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 22:56:36 -08:00
|
|
|
// 3. Individual enemy faction IDs
|
2026-02-06 17:27:20 -08:00
|
|
|
if (!hostile && playerFactionId > 0) {
|
2026-02-12 22:56:36 -08:00
|
|
|
for (uint32_t e = ftEnemy0; e <= ftEnemy0 + 3; e++) {
|
2026-02-06 17:27:20 -08:00
|
|
|
if (ftDbc->getUInt32(i, e) == playerFactionId) {
|
|
|
|
|
hostile = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. Parent faction base reputation check (Faction.dbc)
|
|
|
|
|
if (!hostile && parentFaction > 0) {
|
|
|
|
|
if (hostileParentFactions.count(parentFaction)) {
|
|
|
|
|
hostile = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 5. If explicitly friendly (friendGroup includes player), override to non-hostile
|
|
|
|
|
if (hostile && (friendGroup & playerFriendGroup) != 0) {
|
|
|
|
|
hostile = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
factionMap[id] = hostile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t hostileCount = 0;
|
|
|
|
|
for (const auto& [fid, h] : factionMap) { if (h) hostileCount++; }
|
|
|
|
|
gameHandler->setFactionHostileMap(std::move(factionMap));
|
2026-03-25 11:40:49 -07:00
|
|
|
LOG_INFO("Faction hostility for race ", static_cast<int>(playerRace), " (FT ", playerFtId, "): ",
|
2026-02-06 17:27:20 -08:00
|
|
|
hostileCount, "/", ftDbc->getRecordCount(),
|
|
|
|
|
" hostile (friendGroup=0x", std::hex, playerFriendGroup, ", enemyGroup=0x", playerEnemyGroup, std::dec, ")");
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
// Render bounds/position queries — delegates to EntitySpawner
|
2026-02-06 18:34:45 -08:00
|
|
|
bool Application::getRenderBoundsForGuid(uint64_t guid, glm::vec3& outCenter, float& outRadius) const {
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_) return entitySpawner_->getRenderBoundsForGuid(guid, outCenter, outRadius);
|
|
|
|
|
return false;
|
2026-02-06 18:34:45 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-20 16:02:34 -08:00
|
|
|
bool Application::getRenderFootZForGuid(uint64_t guid, float& outFootZ) const {
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_) return entitySpawner_->getRenderFootZForGuid(guid, outFootZ);
|
|
|
|
|
return false;
|
2026-02-20 16:02:34 -08:00
|
|
|
}
|
|
|
|
|
|
2026-03-10 06:33:44 -07:00
|
|
|
bool Application::getRenderPositionForGuid(uint64_t guid, glm::vec3& outPos) const {
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_) return entitySpawner_->getRenderPositionForGuid(guid, outPos);
|
|
|
|
|
return false;
|
2026-02-07 19:44:03 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-09 23:05:23 -08:00
|
|
|
void Application::loadQuestMarkerModels() {
|
|
|
|
|
if (!assetManager || !renderer) return;
|
|
|
|
|
|
2026-03-09 15:39:16 -07:00
|
|
|
// Quest markers are billboard sprites; the renderer's QuestMarkerRenderer handles
|
|
|
|
|
// texture loading and pipeline setup during world initialization.
|
|
|
|
|
// Calling initialize() here is a no-op if already done; harmless if called early.
|
|
|
|
|
if (auto* qmr = renderer->getQuestMarkerRenderer()) {
|
|
|
|
|
if (auto* vkCtx = renderer->getVkContext()) {
|
|
|
|
|
VkDescriptorSetLayout pfl = renderer->getPerFrameSetLayout();
|
|
|
|
|
if (pfl != VK_NULL_HANDLE) {
|
2026-04-06 22:43:13 +03:00
|
|
|
if (!qmr->initialize(vkCtx, pfl, assetManager.get()))
|
|
|
|
|
LOG_WARNING("Quest marker renderer re-init failed (non-fatal)");
|
2026-03-09 15:39:16 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-09 23:05:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::updateQuestMarkers() {
|
2026-02-09 23:41:38 -08:00
|
|
|
if (!gameHandler || !renderer) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto* questMarkerRenderer = renderer->getQuestMarkerRenderer();
|
|
|
|
|
if (!questMarkerRenderer) {
|
2026-02-09 23:08:30 -08:00
|
|
|
static bool logged = false;
|
|
|
|
|
if (!logged) {
|
2026-02-09 23:41:38 -08:00
|
|
|
LOG_WARNING("QuestMarkerRenderer not available!");
|
2026-02-09 23:08:30 -08:00
|
|
|
logged = true;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-02-09 23:05:23 -08:00
|
|
|
|
|
|
|
|
const auto& questStatuses = gameHandler->getNpcQuestStatuses();
|
|
|
|
|
|
2026-02-09 23:41:38 -08:00
|
|
|
// Clear all markers (we'll re-add active ones)
|
|
|
|
|
questMarkerRenderer->clear();
|
|
|
|
|
|
|
|
|
|
static bool firstRun = true;
|
|
|
|
|
int markersAdded = 0;
|
2026-02-09 23:05:23 -08:00
|
|
|
|
2026-02-09 23:41:38 -08:00
|
|
|
// Add markers for NPCs with quest status
|
2026-02-09 23:05:23 -08:00
|
|
|
for (const auto& [guid, status] : questStatuses) {
|
2026-02-09 23:41:38 -08:00
|
|
|
// Determine marker type
|
|
|
|
|
int markerType = -1; // -1 = no marker
|
2026-02-09 23:05:23 -08:00
|
|
|
|
|
|
|
|
using game::QuestGiverStatus;
|
2026-03-10 22:26:50 -07:00
|
|
|
float markerGrayscale = 0.0f; // 0 = colour, 1 = grey (trivial quests)
|
2026-02-09 23:05:23 -08:00
|
|
|
switch (status) {
|
|
|
|
|
case QuestGiverStatus::AVAILABLE:
|
2026-03-10 22:26:50 -07:00
|
|
|
markerType = 0; // Yellow !
|
|
|
|
|
break;
|
2026-02-09 23:05:23 -08:00
|
|
|
case QuestGiverStatus::AVAILABLE_LOW:
|
2026-03-10 22:26:50 -07:00
|
|
|
markerType = 0; // Grey ! (same texture, desaturated in shader)
|
|
|
|
|
markerGrayscale = 1.0f;
|
2026-02-09 23:05:23 -08:00
|
|
|
break;
|
|
|
|
|
case QuestGiverStatus::REWARD:
|
2026-02-19 02:04:56 -08:00
|
|
|
case QuestGiverStatus::REWARD_REP:
|
2026-03-10 22:26:50 -07:00
|
|
|
markerType = 1; // Yellow ?
|
2026-02-09 23:05:23 -08:00
|
|
|
break;
|
|
|
|
|
case QuestGiverStatus::INCOMPLETE:
|
2026-03-10 22:26:50 -07:00
|
|
|
markerType = 2; // Grey ?
|
2026-02-09 23:05:23 -08:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 23:41:38 -08:00
|
|
|
if (markerType < 0) continue;
|
|
|
|
|
|
2026-02-09 23:05:23 -08:00
|
|
|
// Get NPC entity position
|
|
|
|
|
auto entity = gameHandler->getEntityManager().getEntity(guid);
|
|
|
|
|
if (!entity) continue;
|
2026-02-19 03:31:49 -08:00
|
|
|
if (entity->getType() == game::ObjectType::UNIT) {
|
|
|
|
|
auto unit = std::static_pointer_cast<game::Unit>(entity);
|
|
|
|
|
std::string name = unit->getName();
|
|
|
|
|
std::transform(name.begin(), name.end(), name.begin(),
|
|
|
|
|
[](unsigned char c){ return static_cast<char>(std::tolower(c)); });
|
|
|
|
|
if (name.find("spirit healer") != std::string::npos ||
|
|
|
|
|
name.find("spirit guide") != std::string::npos) {
|
|
|
|
|
continue; // Spirit healers/guides use their own white visual cue.
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-09 23:05:23 -08:00
|
|
|
|
|
|
|
|
glm::vec3 canonical(entity->getX(), entity->getY(), entity->getZ());
|
|
|
|
|
glm::vec3 renderPos = coords::canonicalToRender(canonical);
|
|
|
|
|
|
2026-02-09 23:41:38 -08:00
|
|
|
// Get NPC bounding height for proper marker positioning
|
2026-02-09 23:05:23 -08:00
|
|
|
glm::vec3 boundsCenter;
|
|
|
|
|
float boundsRadius = 0.0f;
|
2026-02-09 23:41:38 -08:00
|
|
|
float boundingHeight = 2.0f; // Default
|
2026-02-09 23:05:23 -08:00
|
|
|
if (getRenderBoundsForGuid(guid, boundsCenter, boundsRadius)) {
|
2026-02-09 23:41:38 -08:00
|
|
|
boundingHeight = boundsRadius * 2.0f;
|
2026-02-09 23:05:23 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-09 23:41:38 -08:00
|
|
|
// Set the marker (renderer will handle positioning, bob, glow, etc.)
|
2026-03-10 22:26:50 -07:00
|
|
|
questMarkerRenderer->setMarker(guid, renderPos, markerType, boundingHeight, markerGrayscale);
|
2026-02-09 23:41:38 -08:00
|
|
|
markersAdded++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (firstRun && markersAdded > 0) {
|
2026-02-11 21:14:35 -08:00
|
|
|
LOG_DEBUG("Quest markers: Added ", markersAdded, " markers on first run");
|
2026-02-09 23:41:38 -08:00
|
|
|
firstRun = false;
|
2026-02-09 23:05:23 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-10 21:29:10 -08:00
|
|
|
void Application::setupTestTransport() {
|
2026-03-31 22:10:20 -07:00
|
|
|
if (!entitySpawner_) return;
|
2026-03-31 22:01:55 +03:00
|
|
|
if (entitySpawner_->isTestTransportSetup()) return;
|
2026-02-10 21:29:10 -08:00
|
|
|
if (!gameHandler || !renderer || !assetManager) return;
|
|
|
|
|
|
|
|
|
|
auto* transportManager = gameHandler->getTransportManager();
|
|
|
|
|
auto* wmoRenderer = renderer->getWMORenderer();
|
|
|
|
|
if (!transportManager || !wmoRenderer) return;
|
|
|
|
|
|
|
|
|
|
LOG_INFO("========================================");
|
|
|
|
|
LOG_INFO(" SETTING UP TEST TRANSPORT");
|
|
|
|
|
LOG_INFO("========================================");
|
|
|
|
|
|
|
|
|
|
// Connect transport manager to WMO renderer
|
|
|
|
|
transportManager->setWMORenderer(wmoRenderer);
|
|
|
|
|
|
2026-02-11 02:23:37 -08:00
|
|
|
// Connect WMORenderer to M2Renderer (for hierarchical transforms: doodads following WMO parents)
|
|
|
|
|
if (renderer->getM2Renderer()) {
|
|
|
|
|
wmoRenderer->setM2Renderer(renderer->getM2Renderer());
|
|
|
|
|
LOG_INFO("WMORenderer connected to M2Renderer for test transport doodad transforms");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-10 21:29:10 -08:00
|
|
|
// Define a simple circular path around Stormwind harbor (canonical coordinates)
|
|
|
|
|
// These coordinates are approximate - adjust based on actual harbor layout
|
|
|
|
|
std::vector<glm::vec3> harborPath = {
|
|
|
|
|
{-8833.0f, 628.0f, 94.0f}, // Start point (Stormwind harbor)
|
|
|
|
|
{-8900.0f, 650.0f, 94.0f}, // Move west
|
|
|
|
|
{-8950.0f, 700.0f, 94.0f}, // Northwest
|
|
|
|
|
{-8950.0f, 780.0f, 94.0f}, // North
|
|
|
|
|
{-8900.0f, 830.0f, 94.0f}, // Northeast
|
|
|
|
|
{-8833.0f, 850.0f, 94.0f}, // East
|
|
|
|
|
{-8766.0f, 830.0f, 94.0f}, // Southeast
|
|
|
|
|
{-8716.0f, 780.0f, 94.0f}, // South
|
|
|
|
|
{-8716.0f, 700.0f, 94.0f}, // Southwest
|
|
|
|
|
{-8766.0f, 650.0f, 94.0f}, // Back to start direction
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Register the path with transport manager
|
|
|
|
|
uint32_t pathId = 1;
|
|
|
|
|
float speed = 12.0f; // 12 units/sec (slower than taxi for a leisurely boat ride)
|
|
|
|
|
transportManager->loadPathFromNodes(pathId, harborPath, true, speed);
|
|
|
|
|
LOG_INFO("Registered transport path ", pathId, " with ", harborPath.size(), " waypoints, speed=", speed);
|
|
|
|
|
|
2026-02-18 22:36:34 -08:00
|
|
|
// Try transport WMOs in manifest-backed paths first.
|
|
|
|
|
std::vector<std::string> transportCandidates = {
|
|
|
|
|
"World\\wmo\\transports\\transport_ship\\transportship.wmo",
|
|
|
|
|
"World\\wmo\\transports\\transport_zeppelin\\transport_zeppelin.wmo",
|
|
|
|
|
"World\\wmo\\transports\\transport_horde_zeppelin\\Transport_Horde_Zeppelin.wmo",
|
|
|
|
|
"World\\wmo\\transports\\icebreaker\\Transport_Icebreaker_ship.wmo",
|
|
|
|
|
// Legacy fallbacks
|
|
|
|
|
"Transports\\Transportship\\Transportship.wmo",
|
|
|
|
|
"Transports\\Boat\\Boat.wmo",
|
|
|
|
|
};
|
2026-02-10 21:29:10 -08:00
|
|
|
|
2026-02-18 22:36:34 -08:00
|
|
|
std::string transportWmoPath;
|
|
|
|
|
std::vector<uint8_t> wmoData;
|
|
|
|
|
for (const auto& candidate : transportCandidates) {
|
|
|
|
|
wmoData = assetManager->readFile(candidate);
|
|
|
|
|
if (!wmoData.empty()) {
|
|
|
|
|
transportWmoPath = candidate;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2026-02-10 21:29:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wmoData.empty()) {
|
|
|
|
|
LOG_WARNING("No transport WMO found - test transport disabled");
|
2026-02-18 22:36:34 -08:00
|
|
|
LOG_INFO("Expected under World\\wmo\\transports\\...");
|
2026-02-10 21:29:10 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-18 22:36:34 -08:00
|
|
|
LOG_INFO("Using transport WMO: ", transportWmoPath);
|
|
|
|
|
|
2026-02-10 21:29:10 -08:00
|
|
|
// Load WMO model
|
|
|
|
|
pipeline::WMOModel wmoModel = pipeline::WMOLoader::load(wmoData);
|
|
|
|
|
LOG_INFO("Transport WMO root loaded: ", transportWmoPath, " nGroups=", wmoModel.nGroups);
|
|
|
|
|
|
|
|
|
|
// Load WMO groups
|
|
|
|
|
int loadedGroups = 0;
|
|
|
|
|
if (wmoModel.nGroups > 0) {
|
|
|
|
|
std::string basePath = transportWmoPath.substr(0, transportWmoPath.size() - 4);
|
|
|
|
|
|
|
|
|
|
for (uint32_t gi = 0; gi < wmoModel.nGroups; gi++) {
|
|
|
|
|
char groupSuffix[16];
|
|
|
|
|
snprintf(groupSuffix, sizeof(groupSuffix), "_%03u.wmo", gi);
|
|
|
|
|
std::string groupPath = basePath + groupSuffix;
|
|
|
|
|
std::vector<uint8_t> groupData = assetManager->readFile(groupPath);
|
|
|
|
|
|
|
|
|
|
if (!groupData.empty()) {
|
|
|
|
|
pipeline::WMOLoader::loadGroup(groupData, wmoModel, gi);
|
|
|
|
|
loadedGroups++;
|
|
|
|
|
} else {
|
|
|
|
|
LOG_WARNING(" Failed to load WMO group ", gi, " for: ", basePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loadedGroups == 0 && wmoModel.nGroups > 0) {
|
|
|
|
|
LOG_WARNING("Failed to load any WMO groups for transport");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load WMO into renderer
|
|
|
|
|
uint32_t wmoModelId = 99999; // Use high ID to avoid conflicts
|
|
|
|
|
if (!wmoRenderer->loadModel(wmoModel, wmoModelId)) {
|
|
|
|
|
LOG_WARNING("Failed to load transport WMO model into renderer");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create WMO instance at first waypoint (convert canonical to render coords)
|
|
|
|
|
glm::vec3 startCanonical = harborPath[0];
|
|
|
|
|
glm::vec3 startRender = core::coords::canonicalToRender(startCanonical);
|
|
|
|
|
|
|
|
|
|
uint32_t wmoInstanceId = wmoRenderer->createInstance(wmoModelId, startRender,
|
|
|
|
|
glm::vec3(0.0f, 0.0f, 0.0f), 1.0f);
|
|
|
|
|
|
|
|
|
|
if (wmoInstanceId == 0) {
|
|
|
|
|
LOG_WARNING("Failed to create transport WMO instance");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register transport with transport manager
|
|
|
|
|
uint64_t transportGuid = 0x1000000000000001ULL; // Fake GUID for test
|
2026-02-11 00:54:38 -08:00
|
|
|
transportManager->registerTransport(transportGuid, wmoInstanceId, pathId, startCanonical);
|
2026-02-10 21:29:10 -08:00
|
|
|
|
|
|
|
|
// Optional: Set deck bounds (rough estimate for a ship deck)
|
|
|
|
|
transportManager->setDeckBounds(transportGuid,
|
|
|
|
|
glm::vec3(-15.0f, -30.0f, 0.0f),
|
|
|
|
|
glm::vec3(15.0f, 30.0f, 10.0f));
|
|
|
|
|
|
2026-03-31 22:01:55 +03:00
|
|
|
entitySpawner_->setTestTransportSetup(true);
|
2026-02-10 21:29:10 -08:00
|
|
|
LOG_INFO("========================================");
|
|
|
|
|
LOG_INFO("Test transport registered:");
|
|
|
|
|
LOG_INFO(" GUID: 0x", std::hex, transportGuid, std::dec);
|
|
|
|
|
LOG_INFO(" WMO Instance: ", wmoInstanceId);
|
|
|
|
|
LOG_INFO(" Path: ", pathId, " (", harborPath.size(), " waypoints)");
|
|
|
|
|
LOG_INFO(" Speed: ", speed, " units/sec");
|
|
|
|
|
LOG_INFO("========================================");
|
|
|
|
|
LOG_INFO("");
|
|
|
|
|
LOG_INFO("To board the transport, use console command:");
|
|
|
|
|
LOG_INFO(" /transport board");
|
|
|
|
|
LOG_INFO("To disembark:");
|
|
|
|
|
LOG_INFO(" /transport leave");
|
|
|
|
|
LOG_INFO("========================================");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
} // namespace core
|
|
|
|
|
} // namespace wowee
|