d_snd_distant_sound_actor_pool OK

This commit is contained in:
robojumper
2025-06-14 21:45:38 +02:00
parent b9ed6c26bd
commit d3d5b57363
9 changed files with 111 additions and 27 deletions
+19 -19
View File
@@ -21442,22 +21442,22 @@ fn_803932D0 = .text:0x803932D0; // type:function size:0x64
fn_80393340 = .text:0x80393340; // type:function size:0xC8
fn_80393410 = .text:0x80393410; // type:function size:0x64
fn_80393480 = .text:0x80393480; // type:function size:0x28
__dt__45SndMgrDisposer<27dSndDistantSoundActorPool_c>Fv = .text:0x803934B0; // type:function size:0x78
create__45SndMgrDisposer<27dSndDistantSoundActorPool_c>Fv = .text:0x80393530; // type:function size:0x48
remove__45SndMgrDisposer<27dSndDistantSoundActorPool_c>Fv = .text:0x80393580; // type:function size:0x10
__dt__45SndMgrDisposer<27dSndDistantSoundActorPool_c>Fv = .text:0x803934B0; // type:function size:0x78 scope:weak
create__45SndMgrDisposer<27dSndDistantSoundActorPool_c>Fv = .text:0x80393530; // type:function size:0x48 scope:weak
remove__45SndMgrDisposer<27dSndDistantSoundActorPool_c>Fv = .text:0x80393580; // type:function size:0x10 scope:weak
__ct__27dSndDistantSoundActorPool_cFv = .text:0x80393590; // type:function size:0xA0
__dt__23dSndDistantSoundActor_cFv = .text:0x80393630; // type:function size:0x70
fn_803936A0 = .text:0x803936A0; // type:function size:0x7C
fn_80393720 = .text:0x80393720; // type:function size:0xBC
__dt__23dSndDistantSoundActor_cFv = .text:0x80393630; // type:function size:0x70 scope:weak
initialize__27dSndDistantSoundActorPool_cFv = .text:0x803936A0; // type:function size:0x7C
calc__27dSndDistantSoundActorPool_cFv = .text:0x80393720; // type:function size:0xBC
acquireActor__27dSndDistantSoundActorPool_cFUlPCQ34nw4r4math4VEC3P14dSoundSource_c = .text:0x803937E0; // type:function size:0x158
addToActiveList__27dSndDistantSoundActorPool_cFP23dSndDistantSoundActor_cUl = .text:0x80393940; // type:function size:0x4C
fn_80393990 = .text:0x80393990; // type:function size:0x4C
fn_803939E0 = .text:0x803939E0; // type:function size:0x5C
removeFromActiveList__27dSndDistantSoundActorPool_cFP23dSndDistantSoundActor_c = .text:0x80393990; // type:function size:0x4C
startSound__27dSndDistantSoundActorPool_cFUlPCQ34nw4r4math4VEC3 = .text:0x803939E0; // type:function size:0x5C
findActiveActor__27dSndDistantSoundActorPool_cFUlP14dSoundSource_c = .text:0x80393A40; // type:function size:0xA0
holdSound__27dSndDistantSoundActorPool_cFUlPCQ34nw4r4math4VEC3 = .text:0x80393AE0; // type:function size:0xA4
fn_80393B90 = .text:0x80393B90; // type:function size:0x90
fn_80393C20 = .text:0x80393C20; // type:function size:0x98
fn_80393CC0 = .text:0x80393CC0; // type:function size:0x98
setAllPause__27dSndDistantSoundActorPool_cFbl = .text:0x80393B90; // type:function size:0x90
disableAll__27dSndDistantSoundActorPool_cFv = .text:0x80393C20; // type:function size:0x98
enableAll__27dSndDistantSoundActorPool_cFv = .text:0x80393CC0; // type:function size:0x98
onChangeStage__27dSndDistantSoundActorPool_cFv = .text:0x80393D60; // type:function size:0x60
__sinit_\d_snd_distant_sound_actor_pool_cpp = .text:0x80393DC0; // type:function size:0x34 scope:local
__ct__23dSndDistantSoundActor_cFv = .text:0x80393E00; // type:function size:0x74
@@ -38092,7 +38092,7 @@ lbl_8054CFC4 = .data:0x8054CFC4; // type:object size:0x1FC
lbl_8054D1C0 = .data:0x8054D1C0; // type:object size:0x1F0
lbl_8054D3B0 = .data:0x8054D3B0; // type:object size:0xC
lbl_8054D3BC = .data:0x8054D3BC; // type:object size:0x44
__vt__45SndMgrDisposer<27dSndDistantSoundActorPool_c> = .data:0x8054D400; // type:object size:0x10
__vt__45SndMgrDisposer<27dSndDistantSoundActorPool_c> = .data:0x8054D400; // type:object size:0xC scope:weak
__vt__23dSndDistantSoundActor_c = .data:0x8054D410; // type:object size:0x60
__vt__13dSndSeSound_c = .data:0x8054D470; // type:object size:0x14
__vt__14dSndSeSound1_c = .data:0x8054D488; // type:object size:0x14
@@ -49432,12 +49432,12 @@ lbl_8057E380 = .sdata2:0x8057E380; // type:object size:0x8 data:string
lbl_8057E388 = .sdata2:0x8057E388; // type:object size:0x8 data:string
lbl_8057E390 = .sdata2:0x8057E390; // type:object size:0x4 data:string
lbl_8057E394 = .sdata2:0x8057E394; // type:object size:0x4 data:4byte
lbl_8057E398 = .sdata2:0x8057E398; // type:object size:0x4 align:4 data:float
lbl_8057E39C = .sdata2:0x8057E39C; // type:object size:0x4 align:4 data:float
lbl_8057E3A0 = .sdata2:0x8057E3A0; // type:object size:0x4 align:4 data:float
lbl_8057E3A4 = .sdata2:0x8057E3A4; // type:object size:0x4 align:4 data:float
lbl_8057E3A8 = .sdata2:0x8057E3A8; // type:object size:0x4 align:4 data:float
lbl_8057E3AC = .sdata2:0x8057E3AC; // type:object size:0x4 align:4 data:float
@4479 = .sdata2:0x8057E398; // type:object size:0x4 scope:local align:4 data:float
@4480 = .sdata2:0x8057E39C; // type:object size:0x4 scope:local align:4 data:float
@4481 = .sdata2:0x8057E3A0; // type:object size:0x4 scope:local align:4 data:float
@4482 = .sdata2:0x8057E3A4; // type:object size:0x4 scope:local align:4 data:float
@4483 = .sdata2:0x8057E3A8; // type:object size:0x4 scope:local align:4 data:float
@4616 = .sdata2:0x8057E3AC; // type:object size:0x4 scope:local align:4 data:float
@3193 = .sdata2:0x8057E3B0; // type:object size:0x4 scope:local align:4 data:float
lbl_8057E3B8 = .sdata2:0x8057E3B8; // type:object size:0x4 align:4 data:float
lbl_8057E3BC = .sdata2:0x8057E3BC; // type:object size:0x4 align:4 data:float
@@ -52194,7 +52194,7 @@ lbl_805D0FB8 = .bss:0x805D0FB8; // type:object size:0x30 align:4 data:float
lbl_805D0FE8 = .bss:0x805D0FE8; // type:object size:0x10
lbl_805D0FF8 = .bss:0x805D0FF8; // type:object size:0x10 align:4 data:float
lbl_805D1008 = .bss:0x805D1008; // type:object size:0x10 align:4 data:float
sParam__27dSndDistantSoundActorPool_c = .bss:0x805D1018; // type:object size:0x18 align:4 data:float
sParam__27dSndDistantSoundActorPool_c = .bss:0x805D1018; // type:object size:0x14 align:4 data:float
lbl_805D1030 = .bss:0x805D1030; // type:object size:0xC data:4byte
lbl_805D103C = .bss:0x805D103C; // type:object size:0x14 data:4byte
lbl_805D1050 = .bss:0x805D1050; // type:object size:0x80 data:4byte
+1 -1
View File
@@ -769,7 +769,7 @@ config.libs = [
# sound source subclasses end
Object(NonMatching, "d/snd/d_snd_source_tg_sound.cpp"),
Object(NonMatching, "d/snd/d_snd_mgr_unk_16.cpp"),
Object(NonMatching, "d/snd/d_snd_distant_sound_actor_pool.cpp"),
Object(Matching, "d/snd/d_snd_distant_sound_actor_pool.cpp"),
Object(Matching, "d/snd/d_snd_distant_sound_actor.cpp"),
Object(Matching, "d/snd/d_snd_se_sound.cpp"),
Object(Matching, "d/snd/d_snd_se_sound_1.cpp"),
+5 -1
View File
@@ -74,6 +74,10 @@ public:
mFlags |= flag;
}
void setDisabled(bool value) {
mIsDisabled = value;
}
f32 getDistanceToListener() {
updateDistanceToListener();
return mDistanceToListener;
@@ -98,7 +102,7 @@ public:
protected:
// a_ prefix to prevent multiple inheritance clashes
/* 0x7D */ u8 a_field_0x7D;
/* 0x7E */ u8 a_field_0x7E;
/* 0x7E */ bool mIsDisabled;
/* 0x7F */ u8 a_field_0x7F;
/* 0x80 */ u8 mIsPaused;
/* 0x84 */ f32 a_field_0x84;
+10
View File
@@ -38,6 +38,10 @@ public:
return mpSoundSource == source;
}
bool hasAttachedSource() const {
return mpSoundSource;
}
nw4r::snd::SoundHandle *getHandle() {
return mpSoundHandle;
}
@@ -46,6 +50,12 @@ public:
mpSoundSource = source;
}
// not sure if this combination makes sense
void resetHandle() {
field_0x0F4 = 0;
mpSoundHandle = &mSoundHandle;
}
bool isActive() const {
return mIsActive;
}
@@ -30,15 +30,23 @@ public:
return sParam;
}
void initialize();
void calc();
void onChangeStage();
dSndDistantSoundActor_c *acquireActor(u32 soundId, const nw4r::math::VEC3 *position, dSoundSource_c *source);
dSndDistantSoundActor_c *findActiveActor(u32 soundId, dSoundSource_c *source);
bool startSound(u32 soundId, const nw4r::math::VEC3 *position);
bool holdSound(u32 soundId, const nw4r::math::VEC3 *position);
void setAllPause(bool flag, s32 fadeFrames);
void disableAll();
void enableAll();
private:
void addToActiveList(dSndDistantSoundActor_c *actor, u32 id);
void removeFromActiveList(dSndDistantSoundActor_c *actor);
/* 0x0010 */ dSndDistantSoundActor_c mSounds[POOL_SIZE];
/* 0x4210 */ UNKWORD field_0x4210;
+1 -1
View File
@@ -15,7 +15,7 @@ dSnd3DActor_c::dSnd3DActor_c(dSndSourceParam *pSourceParam, u8 sourceType)
dSndPlayerMgr_c::GetInstance()->getSoundArchivePlayerForType(sourceType), dSnd3DManager_c::GetInstance()->getManager()
),
a_field_0x7D(0),
a_field_0x7E(0),
mIsDisabled(false),
a_field_0x7F(0),
mIsPaused(0),
a_field_0x84(0.0f),
+2 -2
View File
@@ -54,7 +54,7 @@ void dSndDistantSoundActor_c::d_vt_0x5C(nw4r::snd::SoundHandle &handle, dSndSeSo
bool dSndDistantSoundActor_c::startSound(
u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle
) {
if (a_field_0x7E) {
if (mIsDisabled) {
return false;
}
@@ -72,7 +72,7 @@ bool dSndDistantSoundActor_c::startSound(
bool dSndDistantSoundActor_c::holdSound(
u32 soundId, const nw4r::math::VEC3 &position, nw4r::snd::SoundHandle *pHandle
) {
if (a_field_0x7E) {
if (mIsDisabled) {
return false;
}
+64 -2
View File
@@ -3,7 +3,7 @@
#include "common.h"
#include "d/snd/d_snd_distant_sound_actor.h"
#include "d/snd/d_snd_source.h"
#include "m/m_vec.h"
#include "nw4r/math/math_types.h"
#include "nw4r/ut/ut_list.h"
#include <cmath>
@@ -19,6 +19,31 @@ dSndDistantSoundActorPool_c::dSndDistantSoundActorPool_c() {
sParam.reset(INFINITY);
}
void dSndDistantSoundActorPool_c::initialize() {
field_0x4210 = 0;
for (int i = 0; i < POOL_SIZE; i++) {
mSounds[i].loadDefaultParam();
mSounds[i].setSource(nullptr);
mSounds[i].initSource(nullptr);
}
}
void dSndDistantSoundActorPool_c::calc() {
dSndDistantSoundActor_c *it, *next;
for (dSndDistantSoundActor_c *it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetFirst(&mActiveActors)); it != nullptr; it = next) {
next = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetNext(&mActiveActors, it));
if (it->hasPlayingSounds()) {
it->updatePosition();
} else {
if (it->hasAttachedSource()) {
it->detachFromSource();
}
it->resetHandle();
removeFromActiveList(it);
}
}
}
dSndDistantSoundActor_c *
dSndDistantSoundActorPool_c::acquireActor(u32 soundId, const nw4r::math::VEC3 *position, dSoundSource_c *source) {
if (soundId == -1) {
@@ -72,6 +97,25 @@ void dSndDistantSoundActorPool_c::addToActiveList(dSndDistantSoundActor_c *actor
actor->setActive(true);
}
void dSndDistantSoundActorPool_c::removeFromActiveList(dSndDistantSoundActor_c *actor) {
if (actor == nullptr) {
return;
}
if (!actor->isActive()) {
return;
}
nw4r::ut::List_Remove(&mActiveActors, actor);
actor->setActive(false);
}
bool dSndDistantSoundActorPool_c::startSound(u32 soundId, const nw4r::math::VEC3 *position) {
dSndDistantSoundActor_c *ac = acquireActor(soundId, position, nullptr);
if (ac != nullptr) {
return ac->startSound(soundId, *position, nullptr);
}
return false;
}
dSndDistantSoundActor_c *dSndDistantSoundActorPool_c::findActiveActor(u32 soundId, dSoundSource_c *source) {
for (dSndDistantSoundActor_c *it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetFirst(&mActiveActors)); it != nullptr; it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetNext(&mActiveActors, it))) {
if (it->isAttachedSource(source) && it->isPlayingSound(soundId)) {
@@ -97,8 +141,26 @@ bool dSndDistantSoundActorPool_c::holdSound(u32 soundId, const nw4r::math::VEC3
}
void dSndDistantSoundActorPool_c::setAllPause(bool flag, s32 fadeFrames) {
for (dSndDistantSoundActor_c *it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetFirst(&mActiveActors)); it != nullptr; it = static_cast<dSndDistantSoundActor_c*>(nw4r::ut::List_GetNext(&mActiveActors, it))) {
it->setPause(flag, fadeFrames);
}
}
void dSndDistantSoundActorPool_c::disableAll() {
for (int i = 0; i < POOL_SIZE; i++) {
mSounds[i].setDisabled(true);
}
}
void dSndDistantSoundActorPool_c::enableAll() {
for (int i = 0; i < POOL_SIZE; i++) {
mSounds[i].setDisabled(false);
}
}
void dSndDistantSoundActorPool_c::onChangeStage() {
mVec3_c v(INFINITY, INFINITY, INFINITY);
nw4r::math::VEC3 v(INFINITY, INFINITY, INFINITY);
for (int i = 0; i < POOL_SIZE; i++) {
mSounds[i].SetPosition(v);
}
+1 -1
View File
@@ -147,7 +147,7 @@ void dSoundSource_c::setPause(bool flag, int fadeFrames) {
PauseAllSound(flag, fadeFrames);
pauseAllDistantSounds(flag, fadeFrames);
mIsPaused = 0;
} else if (a_field_0x7E == 0) {
} else if (!mIsDisabled) {
PauseAllSound(flag, fadeFrames);
pauseAllDistantSounds(flag, fadeFrames);
mIsPaused = 1;