Wire SMSG_PLAY_SOUND to AudioEngine via SoundEntries.dbc lookup

Add PlaySoundCallback to GameHandler (same pattern as PlayMusicCallback).
When SMSG_PLAY_SOUND arrives, resolve the soundId through SoundEntries.dbc
(fields 3-12 = files, field 23 = DirectoryBase) and play the first found
file as a 2-D sound effect via AudioEngine::playSound2D(). Previously the
opcode was parsed and dropped.
This commit is contained in:
Kelsi 2026-03-09 16:11:19 -07:00
parent 55082a0925
commit a2c2675039
3 changed files with 29 additions and 1 deletions

View file

@ -943,6 +943,11 @@ public:
using PlayMusicCallback = std::function<void(uint32_t soundId)>;
void setPlayMusicCallback(PlayMusicCallback cb) { playMusicCallback_ = std::move(cb); }
// Server-triggered 2-D sound effect callback — fires when SMSG_PLAY_SOUND is received.
// The soundId corresponds to a SoundEntries.dbc record.
using PlaySoundCallback = std::function<void(uint32_t soundId)>;
void setPlaySoundCallback(PlaySoundCallback cb) { playSoundCallback_ = std::move(cb); }
// Mount state
using MountCallback = std::function<void(uint32_t mountDisplayId)>; // 0 = dismount
void setMountCallback(MountCallback cb) { mountCallback_ = std::move(cb); }
@ -2095,8 +2100,9 @@ private:
// ---- Forced faction reactions (SMSG_SET_FORCED_REACTIONS) ----
std::unordered_map<uint32_t, uint8_t> forcedReactions_; // factionId -> reaction tier
// ---- Server-triggered music ----
// ---- Server-triggered audio ----
PlayMusicCallback playMusicCallback_;
PlaySoundCallback playSoundCallback_;
};
} // namespace game