mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-06-06 23:13:27 +00:00
MP1: Make use of std::array where applicable
Same behavior, stronger typing, and allows eliminating hardcoded sizes in some places.
This commit is contained in:
parent
a77b9cb609
commit
e46a37e893
@ -1,5 +1,7 @@
|
|||||||
#include "Runtime/MP1/MP1.hpp"
|
#include "Runtime/MP1/MP1.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "NESEmulator/CNESShader.hpp"
|
#include "NESEmulator/CNESShader.hpp"
|
||||||
|
|
||||||
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
|
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
|
||||||
@ -75,6 +77,20 @@ extern CVar* com_cubemaps;
|
|||||||
}; // namespace hecl
|
}; // namespace hecl
|
||||||
|
|
||||||
namespace urde::MP1 {
|
namespace urde::MP1 {
|
||||||
|
namespace {
|
||||||
|
struct AudioGroupInfo {
|
||||||
|
const char* name;
|
||||||
|
u32 id;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<AudioGroupInfo, 5> StaticAudioGroups{{
|
||||||
|
{"Misc_AGSC", GRPmisc},
|
||||||
|
{"MiscSamus_AGSC", GRPmiscSamus},
|
||||||
|
{"UI_AGSC", GRPui},
|
||||||
|
{"Weapons_AGSC", GRPweapons},
|
||||||
|
{"ZZZ_AGSC", GRPzzz},
|
||||||
|
}};
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine,
|
CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine,
|
||||||
amuse::IBackendVoiceAllocator& backend)
|
amuse::IBackendVoiceAllocator& backend)
|
||||||
@ -127,17 +143,6 @@ void CGameArchitectureSupport::Update(float dt) {
|
|||||||
x58_ioWinManager.PumpMessages(x4_archQueue);
|
x58_ioWinManager.PumpMessages(x4_archQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AudioGroupInfo {
|
|
||||||
const char* name;
|
|
||||||
u32 id;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const AudioGroupInfo StaticAudioGroups[] = {{"Misc_AGSC", GRPmisc},
|
|
||||||
{"MiscSamus_AGSC", GRPmiscSamus},
|
|
||||||
{"UI_AGSC", GRPui},
|
|
||||||
{"Weapons_AGSC", GRPweapons},
|
|
||||||
{"ZZZ_AGSC", GRPzzz}};
|
|
||||||
|
|
||||||
bool CGameArchitectureSupport::LoadAudio() {
|
bool CGameArchitectureSupport::LoadAudio() {
|
||||||
if (x88_audioLoadStatus == EAudioLoadStatus::Loaded)
|
if (x88_audioLoadStatus == EAudioLoadStatus::Loaded)
|
||||||
return true;
|
return true;
|
||||||
@ -169,26 +174,30 @@ bool CGameArchitectureSupport::LoadAudio() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGameArchitectureSupport::PreloadAudio() {
|
void CGameArchitectureSupport::PreloadAudio() {
|
||||||
if (x88_audioLoadStatus != EAudioLoadStatus::Uninitialized)
|
if (x88_audioLoadStatus != EAudioLoadStatus::Uninitialized) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x8c_pendingAudioGroups.clear();
|
x8c_pendingAudioGroups.clear();
|
||||||
x8c_pendingAudioGroups.reserve(5);
|
x8c_pendingAudioGroups.reserve(5);
|
||||||
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (size_t i = 0; i < StaticAudioGroups.size(); ++i) {
|
||||||
const AudioGroupInfo& info = StaticAudioGroups[i];
|
const AudioGroupInfo& info = StaticAudioGroups[i];
|
||||||
CToken grp = g_SimplePool->GetObj(info.name);
|
CToken grp = g_SimplePool->GetObj(info.name);
|
||||||
if (i == 0) /* Lock first group in sequence */
|
|
||||||
|
// Lock first group in sequence
|
||||||
|
if (i == 0) {
|
||||||
grp.Lock();
|
grp.Lock();
|
||||||
x8c_pendingAudioGroups.push_back(std::move(grp));
|
}
|
||||||
|
|
||||||
|
x8c_pendingAudioGroups.emplace_back(std::move(grp));
|
||||||
}
|
}
|
||||||
|
|
||||||
x88_audioLoadStatus = EAudioLoadStatus::Loading;
|
x88_audioLoadStatus = EAudioLoadStatus::Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameArchitectureSupport::UnloadAudio() {
|
void CGameArchitectureSupport::UnloadAudio() {
|
||||||
|
for (const AudioGroupInfo& info : StaticAudioGroups) {
|
||||||
for (int i = 0; i < 5; ++i) {
|
|
||||||
const AudioGroupInfo& info = StaticAudioGroups[i];
|
|
||||||
const SObjectTag* tag = g_ResFactory->GetResourceIdByName(info.name);
|
const SObjectTag* tag = g_ResFactory->GetResourceIdByName(info.name);
|
||||||
auto name = CAudioSys::SysGetGroupSetName(tag->id);
|
auto name = CAudioSys::SysGetGroupSetName(tag->id);
|
||||||
CAudioSys::SysRemoveGroupFromAmuse(name);
|
CAudioSys::SysRemoveGroupFromAmuse(name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user