mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-12 15:53:50 +00:00
Magic number elimination: - Create protocol_constants.hpp, warden_constants.hpp, render_constants.hpp, ui_constants.hpp - Replace ~55 magic numbers across game_handler, warden_handler, m2_renderer_render Reduce nesting depth: - Extract 5 parseEffect* methods from handleSpellLogExecute (max indent 52 → 16 cols) - Extract resolveSpellSchool/playSpellCastSound/playSpellImpactSound from 3× duplicate audio blocks in handleSpellGo - Flatten SMSG_INVENTORY_CHANGE_FAILURE with early-return guards - Extract drawScreenEdgeVignette() for 3 duplicate vignette blocks DRY extract patterns: - Replace 12 compound expansion checks with isPreWotlk() across movement_handler (9), chat_handler (1), social_handler (1) const to constexpr: - Promote 23+ static const arrays/scalars to static constexpr across 12 source files Error handling: - Convert PIN auth from exceptions to std::optional<PinProof> - Add [[nodiscard]] to 15+ initialize/parse methods - Wrap ~20 unchecked initialize() calls with LOG_WARNING/LOG_ERROR Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
106 lines
4 KiB
C++
106 lines
4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <glm/vec3.hpp>
|
|
|
|
namespace wowee {
|
|
namespace pipeline { class AssetManager; }
|
|
namespace game { class ZoneManager; }
|
|
namespace audio {
|
|
|
|
class MusicManager;
|
|
class FootstepManager;
|
|
class ActivitySoundManager;
|
|
class MountSoundManager;
|
|
class NpcVoiceManager;
|
|
class AmbientSoundManager;
|
|
class UiSoundManager;
|
|
class CombatSoundManager;
|
|
class SpellSoundManager;
|
|
class MovementSoundManager;
|
|
|
|
/// Flat context passed from Renderer into updateZoneAudio() each frame.
|
|
/// All values are pre-queried so AudioCoordinator needs no rendering pointers.
|
|
struct ZoneAudioContext {
|
|
float deltaTime = 0.0f;
|
|
glm::vec3 cameraPosition{0.0f};
|
|
bool isSwimming = false;
|
|
bool insideWmo = false;
|
|
uint32_t insideWmoId = 0;
|
|
// Visual weather state for ambient audio sync
|
|
int weatherType = 0; // 0=none, 1=rain, 2=snow, 3=storm
|
|
float weatherIntensity = 0.0f;
|
|
// Terrain tile for offline zone lookup
|
|
int tileX = 0, tileY = 0;
|
|
bool hasTile = false;
|
|
// Server-authoritative zone (from SMSG_INIT_WORLD_STATES); 0 = offline
|
|
uint32_t serverZoneId = 0;
|
|
// Zone manager pointer (for zone info and music queries)
|
|
game::ZoneManager* zoneManager = nullptr;
|
|
};
|
|
|
|
/// Coordinates all audio subsystems.
|
|
/// Extracted from Renderer to separate audio lifecycle from rendering.
|
|
/// Owned by Application; Renderer and UI components access through Application.
|
|
class AudioCoordinator {
|
|
public:
|
|
AudioCoordinator();
|
|
~AudioCoordinator();
|
|
|
|
/// Initialize the audio engine and all managers.
|
|
/// @return true if audio is available (engine initialized successfully)
|
|
[[nodiscard]] bool initialize();
|
|
|
|
/// Initialize managers that need AssetManager (music lookups, sound banks).
|
|
void initializeWithAssets(pipeline::AssetManager* assetManager);
|
|
|
|
/// Shutdown all audio managers and engine.
|
|
void shutdown();
|
|
|
|
/// Per-frame zone detection, music transitions, and ambient weather sync.
|
|
/// Called from Renderer::update() with a pre-filled context.
|
|
void updateZoneAudio(const ZoneAudioContext& ctx);
|
|
|
|
const std::string& getCurrentZoneName() const { return currentZoneName_; }
|
|
uint32_t getCurrentZoneId() const { return currentZoneId_; }
|
|
|
|
// Accessors for all audio managers (same interface as Renderer had)
|
|
MusicManager* getMusicManager() { return musicManager_.get(); }
|
|
FootstepManager* getFootstepManager() { return footstepManager_.get(); }
|
|
ActivitySoundManager* getActivitySoundManager() { return activitySoundManager_.get(); }
|
|
MountSoundManager* getMountSoundManager() { return mountSoundManager_.get(); }
|
|
NpcVoiceManager* getNpcVoiceManager() { return npcVoiceManager_.get(); }
|
|
AmbientSoundManager* getAmbientSoundManager() { return ambientSoundManager_.get(); }
|
|
UiSoundManager* getUiSoundManager() { return uiSoundManager_.get(); }
|
|
CombatSoundManager* getCombatSoundManager() { return combatSoundManager_.get(); }
|
|
SpellSoundManager* getSpellSoundManager() { return spellSoundManager_.get(); }
|
|
MovementSoundManager* getMovementSoundManager() { return movementSoundManager_.get(); }
|
|
|
|
private:
|
|
void playZoneMusic(const std::string& music);
|
|
|
|
std::unique_ptr<MusicManager> musicManager_;
|
|
std::unique_ptr<FootstepManager> footstepManager_;
|
|
std::unique_ptr<ActivitySoundManager> activitySoundManager_;
|
|
std::unique_ptr<MountSoundManager> mountSoundManager_;
|
|
std::unique_ptr<NpcVoiceManager> npcVoiceManager_;
|
|
std::unique_ptr<AmbientSoundManager> ambientSoundManager_;
|
|
std::unique_ptr<UiSoundManager> uiSoundManager_;
|
|
std::unique_ptr<CombatSoundManager> combatSoundManager_;
|
|
std::unique_ptr<SpellSoundManager> spellSoundManager_;
|
|
std::unique_ptr<MovementSoundManager> movementSoundManager_;
|
|
|
|
bool audioAvailable_ = false;
|
|
|
|
// Zone/music state — moved from Renderer
|
|
uint32_t currentZoneId_ = 0;
|
|
std::string currentZoneName_;
|
|
bool inTavern_ = false;
|
|
bool inBlacksmith_ = false;
|
|
float musicSwitchCooldown_ = 0.0f;
|
|
};
|
|
|
|
} // namespace audio
|
|
} // namespace wowee
|