chore(refactor): god-object decomposition and mega-file splits

Split all mega-files by single-responsibility concern and
partially extracting AudioCoordinator and
OverlaySystem from the Renderer facade. No behavioral changes.

Splits:
- game_handler.cpp (5,247 LOC) → core + callbacks + packets (3 files)
- world_packets.cpp (4,453 LOC) → economy/entity/social/world (4 files)
- game_screen.cpp  (5,786 LOC) → core + frames + hud + minimap (4 files)
- m2_renderer.cpp  (3,343 LOC) → core + instance + particles + render (4 files)
- chat_panel.cpp   (3,140 LOC) → core + commands + utils (3 files)
- entity_spawner.cpp (2,750 LOC) → core + player + processing (3 files)

Extractions:
- AudioCoordinator: include/audio/ + src/audio/ (owned by Renderer)
- OverlaySystem: include/rendering/ + src/rendering/overlay_system.*

CMakeLists.txt: registered all 17 new translation units.
Related handler/callback files: minor include fixups post-split.
This commit is contained in:
Paul 2026-04-05 19:30:44 +03:00
parent 6dcc06697b
commit 34c0e3ca28
49 changed files with 29113 additions and 28109 deletions

View file

@ -51,7 +51,7 @@ bool AnimationCallbackHandler::updateCharge(float deltaTime) {
dir *= glm::inversesqrt(dirLenSq);
float yawDeg = glm::degrees(std::atan2(dir.x, dir.y));
renderer_.setCharacterYaw(yawDeg);
renderer_.emitChargeEffect(renderPos, dir);
if (auto* ac = renderer_.getAnimationController()) ac->emitChargeEffect(renderPos, dir);
}
// Sync to game handler
@ -69,8 +69,8 @@ bool AnimationCallbackHandler::updateCharge(float deltaTime) {
// Charge complete
if (t >= 1.0f) {
chargeActive_ = false;
renderer_.setCharging(false);
renderer_.stopChargeEffect();
if (auto* ac = renderer_.getAnimationController()) ac->setCharging(false);
if (auto* ac = renderer_.getAnimationController()) ac->stopChargeEffect();
renderer_.getCameraController()->setExternalFollow(false);
renderer_.getCameraController()->setExternalMoving(false);
@ -95,7 +95,7 @@ bool AnimationCallbackHandler::updateCharge(float deltaTime) {
}
}
gameHandler_.startAutoAttack(chargeTargetGuid_);
renderer_.triggerMeleeSwing();
if (auto* ac = renderer_.getAnimationController()) ac->triggerMeleeSwing();
}
// Send movement heartbeat so server knows our new position
@ -157,11 +157,11 @@ void AnimationCallbackHandler::setupCallbacks() {
// Disable player input, play charge animation
renderer_.getCameraController()->setExternalFollow(true);
renderer_.getCameraController()->clearMovementInputs();
renderer_.setCharging(true);
if (auto* ac = renderer_.getAnimationController()) ac->setCharging(true);
// Start charge visual effect (red haze + dust)
glm::vec3 chargeDir = glm::normalize(endRender - startRender);
renderer_.startChargeEffect(startRender, chargeDir);
if (auto* ac = renderer_.getAnimationController()) ac->startChargeEffect(startRender, chargeDir);
// Play charge whoosh sound (try multiple paths)
auto& audio = audio::AudioEngine::instance();

View file

@ -934,7 +934,7 @@ void Application::setState(AppState newState) {
uint32_t oldInst = renderer->getCharacterInstanceId();
if (oldInst > 0) {
renderer->setCharacterFollow(0);
renderer->clearMount();
if (auto* ac = renderer->getAnimationController()) ac->clearMount();
renderer->getCharacterRenderer()->removeInstance(oldInst);
}
}
@ -975,11 +975,11 @@ void Application::setState(AppState newState) {
if (renderer) {
// Ranged auto-attack spells: Auto Shot (75), Shoot (5019), Throw (2764)
if (spellId == 75 || spellId == 5019 || spellId == 2764) {
renderer->triggerRangedShot();
if (auto* ac = renderer->getAnimationController()) ac->triggerRangedShot();
} else if (spellId != 0) {
renderer->triggerSpecialAttack(spellId);
if (auto* ac = renderer->getAnimationController()) ac->triggerSpecialAttack(spellId);
} else {
renderer->triggerMeleeSwing();
if (auto* ac = renderer->getAnimationController()) ac->triggerMeleeSwing();
}
}
});
@ -1118,7 +1118,7 @@ void Application::logoutToLogin() {
if (auto* questMarkers = renderer->getQuestMarkerRenderer()) {
questMarkers->clear();
}
renderer->clearMount();
if (auto* ac = renderer->getAnimationController()) ac->clearMount();
renderer->setCharacterFollow(0);
if (auto* music = audioCoordinator_ ? audioCoordinator_->getMusicManager() : nullptr) {
music->stopMusic(0.0f);
@ -1346,13 +1346,13 @@ void Application::update(float deltaTime) {
// Tilt the mount/character model to match flight direction
// (taxi flight uses setTaxiOrientationCallback for this instead)
if (gameHandler->isPlayerFlying() && gameHandler->isMounted()) {
renderer->setMountPitchRoll(pitchRad, 0.0f);
if (auto* ac = renderer->getAnimationController()) ac->setMountPitchRoll(pitchRad, 0.0f);
}
}
}
} else if (gameHandler->isMounted()) {
// Reset mount pitch when not flying
renderer->setMountPitchRoll(0.0f, 0.0f);
if (auto* ac = renderer->getAnimationController()) ac->setMountPitchRoll(0.0f, 0.0f);
}
}
@ -1454,14 +1454,14 @@ void Application::update(float deltaTime) {
}
bool idleOrbit = renderer->getCameraController()->isIdleOrbit();
if (idleOrbit && !idleYawned_ && renderer) {
renderer->playEmote("yawn");
if (auto* ac = renderer->getAnimationController()) ac->playEmote("yawn");
idleYawned_ = true;
} else if (!idleOrbit) {
idleYawned_ = false;
}
}
if (renderer) {
renderer->setTaxiFlight(onTaxi);
if (auto* ac = renderer->getAnimationController()) ac->setTaxiFlight(onTaxi);
}
if (renderer && renderer->getTerrainManager()) {
renderer->getTerrainManager()->setStreamingEnabled(true);

View file

@ -2,6 +2,8 @@
#include "core/coordinates.hpp"
#include "core/logger.hpp"
#include "rendering/renderer.hpp"
#include "rendering/animation_controller.hpp"
#include "pipeline/asset_manager.hpp"
#include "pipeline/dbc_loader.hpp"
#include "game/game_handler.hpp"
#include "audio/audio_coordinator.hpp"
@ -50,7 +52,7 @@ void AudioCallbackHandler::setupCallbacks() {
uiManager_->getGameScreen().toastManager().triggerDing(newLevel);
}
if (renderer_) {
renderer_->triggerLevelUpEffect(renderer_->getCharacterPosition());
if (auto* ac = renderer_->getAnimationController()) ac->triggerLevelUpEffect(renderer_->getCharacterPosition());
}
});
@ -108,7 +110,7 @@ void AudioCallbackHandler::setupCallbacks() {
if (entity) {
glm::vec3 canonical(entity->getX(), entity->getY(), entity->getZ());
glm::vec3 renderPos = core::coords::canonicalToRender(canonical);
renderer_->triggerLevelUpEffect(renderPos);
if (auto* ac = renderer_->getAnimationController()) ac->triggerLevelUpEffect(renderPos);
}
// Show chat message if in group

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@
#include "core/coordinates.hpp"
#include "core/logger.hpp"
#include "rendering/renderer.hpp"
#include "rendering/animation_controller.hpp"
#include "rendering/character_renderer.hpp"
#include "rendering/camera_controller.hpp"
#include "rendering/terrain_manager.hpp"
@ -37,7 +38,7 @@ void TransportCallbackHandler::setupCallbacks() {
entitySpawner_.clearMountState();
}
entitySpawner_.setMountDisplayId(0);
renderer_.clearMount();
if (auto* ac = renderer_.getAnimationController()) ac->clearMount();
LOG_INFO("Dismounted");
return;
}
@ -106,7 +107,7 @@ void TransportCallbackHandler::setupCallbacks() {
renderer_.getCameraController()->setFacingYaw(yawDegrees);
renderer_.setCharacterYaw(yawDegrees);
// Set mount pitch and roll for realistic flight animation
renderer_.setMountPitchRoll(pitch, roll);
if (auto* ac = renderer_.getAnimationController()) ac->setMountPitchRoll(pitch, roll);
}
});

View file

@ -4,6 +4,7 @@
#include "core/world_loader.hpp"
#include "core/logger.hpp"
#include "rendering/renderer.hpp"
#include "rendering/animation_controller.hpp"
#include "rendering/camera_controller.hpp"
#include "rendering/terrain_manager.hpp"
#include "rendering/wmo_renderer.hpp"

View file

@ -11,6 +11,7 @@
#include "core/coordinates.hpp"
#include "core/logger.hpp"
#include "rendering/renderer.hpp"
#include "rendering/animation_controller.hpp"
#include "rendering/vk_context.hpp"
#include "rendering/camera.hpp"
#include "rendering/camera_controller.hpp"
@ -290,7 +291,7 @@ void WorldLoader::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
if (auto* questMarkers = renderer_->getQuestMarkerRenderer()) {
questMarkers->clear();
}
renderer_->clearMount();
if (auto* ac = renderer_->getAnimationController()) ac->clearMount();
}
// Clear application-level instance tracking (after renderer cleanup)
@ -416,7 +417,7 @@ void WorldLoader::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
uint32_t oldInst = renderer_->getCharacterInstanceId();
if (oldInst > 0) {
renderer_->setCharacterFollow(0);
renderer_->clearMount();
if (auto* ac = renderer_->getAnimationController()) ac->clearMount();
renderer_->getCharacterRenderer()->removeInstance(oldInst);
}
}