From 1af832d875b1d6ba9364e0990c68cebb610a4683 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 8 Jun 2025 09:08:18 +0200 Subject: [PATCH] Review --- include/d/snd/d_snd_3d_actor.h | 2 +- include/d/snd/d_snd_3d_manager.h | 10 +++++----- include/d/snd/d_snd_player_mgr.h | 4 ++-- include/d/snd/d_snd_source_group.h | 2 +- include/d/snd/d_snd_source_mgr.h | 13 ------------- src/d/snd/d_snd_3d_actor.cpp | 18 +++++++++--------- src/d/snd/d_snd_control_player_mgr.cpp | 4 ++-- src/d/snd/d_snd_control_sound.cpp | 3 +-- src/d/snd/d_snd_player_mgr.cpp | 19 +++++++++++-------- src/d/snd/d_snd_small_effect_mgr.cpp | 12 ++++++------ src/d/snd/d_snd_source_group.cpp | 2 +- 11 files changed, 39 insertions(+), 50 deletions(-) diff --git a/include/d/snd/d_snd_3d_actor.h b/include/d/snd/d_snd_3d_actor.h index dc93574d..6f3ad6d4 100644 --- a/include/d/snd/d_snd_3d_actor.h +++ b/include/d/snd/d_snd_3d_actor.h @@ -8,7 +8,7 @@ class dSnd3DActor_c : public nw4r::snd::Sound3DActor { public: - dSnd3DActor_c(dSndSourceParam *pSourceParam, u8); + dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 sourceType); virtual ~dSnd3DActor_c() {} diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index 679e7963..2ac0b062 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -46,11 +46,11 @@ public: private: void updateListenerPos(f32); - /* 0x10 */ bool mIsSetup; - /* 0x11 */ bool mCalculationsFresh; - /* 0x14 */ dSnd3DEngine_c *mpEngine; - /* 0x18 */ nw4r::snd::Sound3DManager mManager; - /* 0x44 */ nw4r::snd::Sound3DListener mListener; + /* 0x010 */ bool mIsSetup; + /* 0x011 */ bool mCalculationsFresh; + /* 0x014 */ dSnd3DEngine_c *mpEngine; + /* 0x018 */ nw4r::snd::Sound3DManager mManager; + /* 0x044 */ nw4r::snd::Sound3DListener mListener; /* 0xB0 */ EGG::LookAtCamera mCamera; /* 0x138 */ mVec3_c mCameraDirectionNormalized; /* 0x144 */ mVec3_c mCameraTargetPosition; diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index d803ab70..7808092d 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -41,8 +41,8 @@ public: const char *getSoundArchivePath(); u32 convertLabelStringToSoundId(const char *label) const; - nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 type); - bool canUseThisPlayer(u8 type) const; + nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 sourceType); + bool canUseThisPlayer(u8 sourceType) const; enum PlayerMgrFlag_e { MGR_HBM = 0x1, diff --git a/include/d/snd/d_snd_source_group.h b/include/d/snd/d_snd_source_group.h index 2e1e8c1f..187b41a5 100644 --- a/include/d/snd/d_snd_source_group.h +++ b/include/d/snd/d_snd_source_group.h @@ -57,7 +57,7 @@ private: /* 0x64 */ dSoundSource_c *mpCachedClosestSourceToListener; /* 0x68 */ dSoundSource_c *mpCachedClosestSourceToPlayer; /* 0x6C */ bool mCalculatedClosestToListener; - /* 0x6C */ bool mCalculatedClosestToPlayer; + /* 0x6D */ bool mCalculatedClosestToPlayer; }; #endif diff --git a/include/d/snd/d_snd_source_mgr.h b/include/d/snd/d_snd_source_mgr.h index b1f9db06..5582b2d3 100644 --- a/include/d/snd/d_snd_source_mgr.h +++ b/include/d/snd/d_snd_source_mgr.h @@ -8,19 +8,6 @@ SND_DISPOSER_FORWARD_DECL(dSndSourceMgr_c); -// 0 - "" - Link -// ActorLink::initModels -// 0x2C - NpcKenT -// 0x20 - Door, TBox, CharE (Chair), Tubo -// 0x35 - TgSound -// 0x2D - PyBird -// 0x22 - Bamboo -// 0x23 - Item - -// 0x19 - Nusi*, BKr, BBs -// 0x1A - MgRArm, MgLArm -// 0x1B - Mgtail - class dSndSourceMgr_c { SND_DISPOSER_MEMBERS(dSndSourceMgr_c); diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index f617fb35..e304d296 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -9,9 +9,9 @@ #include -dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 a2) +dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 sourceType) : nw4r::snd::Sound3DActor( - dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(a2), dSnd3DManager_c::GetInstance()->getManager() + dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(sourceType), dSnd3DManager_c::GetInstance()->getManager() ), a_field_0x7D(0), a_field_0x7E(0), @@ -31,7 +31,7 @@ dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 a2) resetCachedRelativePositions(); // Portability hazard SetUserParam(reinterpret_cast(this)); - if (dSndPlayerMgr_c::GetInstance()->canUseThisPlayer(a2)) { + if (dSndPlayerMgr_c::GetInstance()->canUseThisPlayer(sourceType)) { a_field_0x7F = 1; } } @@ -43,9 +43,9 @@ void dSnd3DActor_c::d_vt_0x34(const nw4r::math::VEC3 &rPosition) { } void dSnd3DActor_c::updatePositionRelativeToListener() { - if (!checkFlag(1)) { + if (!checkFlag(0x1)) { calculatePositionRelativeToListener(); - setFlag(1); + setFlag(0x1); } } @@ -70,10 +70,10 @@ void dSnd3DActor_c::calculatePositionRelativeToListener() { } void dSnd3DActor_c::updateDistanceToListener() { - if (!checkFlag(2)) { + if (!checkFlag(0x2)) { updatePositionRelativeToListener(); mDistanceToListener = VEC3Len(&mPositionRelativeToListener); - setFlag(2); + setFlag(0x2); } } @@ -110,10 +110,10 @@ void dSnd3DActor_c::calculatePositionRelativeToCameraTarget() { } void dSnd3DActor_c::updateDistanceToCameraTarget() { - if (!checkFlag(8)) { + if (!checkFlag(0x8)) { updatePositionRelativeToCameraTarget(); mDistanceToCameraTarget = VEC3Len(&mPositionRelativeToCameraTarget); - setFlag(8); + setFlag(0x8); } } diff --git a/src/d/snd/d_snd_control_player_mgr.cpp b/src/d/snd/d_snd_control_player_mgr.cpp index 5bb01d0a..22223c98 100644 --- a/src/d/snd/d_snd_control_player_mgr.cpp +++ b/src/d/snd/d_snd_control_player_mgr.cpp @@ -177,7 +177,7 @@ void dSndControlPlayerMgr_c::calcVolumes() { targetVolume = currentVolume + maxVolumeIncrease; } // @bug not actually clamped - nw4r::ut::Clamp(targetVolume, 0.0f, 2.0f); + (void)nw4r::ut::Clamp(targetVolume, 0.0f, 2.0f); setVolume(i, targetVolume, 0); } mpTargetVolumes[i] = 1.0f; @@ -356,7 +356,7 @@ void dSndControlPlayerMgr_c::setPlayerVolumeInternal(u32 playerIdx, f32 volume) return; } // @bug not actually clamped - nw4r::ut::Clamp(volume, 0.0f, 2.0f); + (void)nw4r::ut::Clamp(volume, 0.0f, 2.0f); if (mpTargetVolumes[playerIdx] > volume) { mpTargetVolumes[playerIdx] = volume; diff --git a/src/d/snd/d_snd_control_sound.cpp b/src/d/snd/d_snd_control_sound.cpp index aaef106f..d6ab1bac 100644 --- a/src/d/snd/d_snd_control_sound.cpp +++ b/src/d/snd/d_snd_control_sound.cpp @@ -7,7 +7,7 @@ // I'm not super happy with these base class function in a separate file, // but either we add another intermediate class or this is ok. It's weird -// that d_snd_sound has dSndControl_c::stop though +// that d_snd_sound has dSndControl_c::configure though void dSndControl_c::reset() { mCurrValue = mResetValue; @@ -18,7 +18,6 @@ void dSndControl_c::reset() { } void dSndControl_c::stop() { - // field_0x10 = field_0x04; mStartValue = mCurrValue; mTargetValue = mCurrValue; mDuration = 0; diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 6a25a564..4851d179 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -5,6 +5,7 @@ #include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_source_enums.h" #include "d/snd/d_snd_wzsound.h" #include "egg/core/eggDvdRipper.h" #include "nw4r/snd/snd_SoundHandle.h" @@ -102,24 +103,26 @@ u32 dSndPlayerMgr_c::convertLabelStringToSoundId(const char *label) const { return dSndMgr_c::GetInstance()->changeNameToId(label); } -nw4r::snd::SoundArchivePlayer &dSndPlayerMgr_c::getSoundArchivePlayerForType(u8 type) { - if (canUseThisPlayer(type)) { +nw4r::snd::SoundArchivePlayer &dSndPlayerMgr_c::getSoundArchivePlayerForType(u8 sourceType) { + if (canUseThisPlayer(sourceType)) { return mSoundArchivePlayer; } return *dSndMgr_c::getPlayer(); } -bool dSndPlayerMgr_c::canUseThisPlayer(u8 type) const { +bool dSndPlayerMgr_c::canUseThisPlayer(u8 sourceType) const { if (!mSoundArchivePlayer.IsAvailable()) { return false; } - int ty = type; - - if ((ty >= 0 && ty <= 1) || ty == 58) { - return true; + switch (sourceType) { + case SND_SOURCE_PLAYER: + case SND_SOURCE_PLAYER_HEAD: + case SND_SOURCE_58: + return true; + default: + return false; } - return false; } bool dSndPlayerMgr_c::loadDemoArchive(const char *demoArchiveName) { diff --git a/src/d/snd/d_snd_small_effect_mgr.cpp b/src/d/snd/d_snd_small_effect_mgr.cpp index 24cc3216..1dca1655 100644 --- a/src/d/snd/d_snd_small_effect_mgr.cpp +++ b/src/d/snd/d_snd_small_effect_mgr.cpp @@ -63,13 +63,13 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } case SE_S_MENU_SELECT_TURN_PAGE_LEFT: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_LEFT)) { - return 0; + return false; } break; } case SE_S_MENU_SELECT_TURN_PAGE_RIGHT: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_RIGHT)) { - return 0; + return false; } break; } @@ -87,7 +87,7 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } case SE_S_WINDOW_PRESS_A: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT, SE_S_POINTER_OK)) { - return 0; + return false; } break; } @@ -97,7 +97,7 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } case SE_S_MENU_P1_POINT_ITEM: { if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_MENU_P1_HOLD_POINTER)) { - return 0; + return false; } break; } @@ -108,9 +108,9 @@ bool dSndSmallEffectMgr_c::playSound(u32 soundId) { } break; } - case 0x13EF: + case SE_S_DOWSING_WAIT: if (isPlayingSound(dSndPlayerMgr_c::PLAYER_SMALL_NORMAL, SE_S_FIRST_PERSON_ON)) { - return 0; + return false; } break; } diff --git a/src/d/snd/d_snd_source_group.cpp b/src/d/snd/d_snd_source_group.cpp index 951a7514..d973deaa 100644 --- a/src/d/snd/d_snd_source_group.cpp +++ b/src/d/snd/d_snd_source_group.cpp @@ -127,7 +127,7 @@ dSoundSource_c *dSndSourceGroup_c::getSourceClosestToListener() { f32 closest = INFINITY; for (dSoundSource_c *source = static_cast(nw4r::ut::List_GetFirst(&mSourceList)); source != nullptr; source = static_cast(nw4r::ut::List_GetNext(&mSourceList, source))) { - if (source->getActorType() != 1 && source->getActorType() != 48) { + if (source->getActorType() != SND_SOURCE_PLAYER_HEAD && source->getActorType() != SND_SOURCE_NPC_48) { f32 dist = source->getDistanceToListener(); if (dist < closest) { closest = dist;