2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-16 04:17:03 +00:00

string_view refactor

This commit is contained in:
Jack Andersen
2017-11-12 20:19:18 -10:00
parent 742ab2514f
commit f7ec7bdc0c
345 changed files with 907 additions and 921 deletions

View File

@@ -21,7 +21,7 @@ class CAudioGroupSet
public:
CAudioGroupSet(std::unique_ptr<u8[]>&& in);
const amuse::AudioGroupData& GetAudioGroupData() const {return m_data;}
const std::string& GetName() const { return x20_name; }
std::string_view GetName() const { return x20_name; }
};
CFactoryFnReturn FAudioGroupSetDataFactory(const urde::SObjectTag& tag,

View File

@@ -10,15 +10,15 @@ static std::unordered_map<std::string, TLockedToken<CAudioGroupSet>> mpGroupSetD
static std::unordered_map<CAssetId, std::string> mpGroupSetResNameDB;
static const std::string mpDefaultInvalidString = "NULL";
TLockedToken<CAudioGroupSet> CAudioSys::FindGroupSet(const std::string& name)
TLockedToken<CAudioGroupSet> CAudioSys::FindGroupSet(std::string_view name)
{
auto search = mpGroupSetDB.find(name);
auto search = mpGroupSetDB.find(name.data());
if (search == mpGroupSetDB.cend())
return {};
return search->second;
}
const std::string& CAudioSys::SysGetGroupSetName(CAssetId id)
std::string_view CAudioSys::SysGetGroupSetName(CAssetId id)
{
auto search = mpGroupSetResNameDB.find(id);
if (search == mpGroupSetResNameDB.cend())
@@ -41,7 +41,7 @@ bool CAudioSys::SysLoadGroupSet(CSimplePool* pool, CAssetId id)
}
}
bool CAudioSys::SysLoadGroupSet(const TLockedToken<CAudioGroupSet>& set, const std::string& name, CAssetId id)
bool CAudioSys::SysLoadGroupSet(const TLockedToken<CAudioGroupSet>& set, std::string_view name, CAssetId id)
{
if (!FindGroupSet(name))
{
@@ -55,28 +55,28 @@ bool CAudioSys::SysLoadGroupSet(const TLockedToken<CAudioGroupSet>& set, const s
}
}
void CAudioSys::SysUnloadAudioGroupSet(const std::string& name)
void CAudioSys::SysUnloadAudioGroupSet(std::string_view name)
{
auto set = FindGroupSet(name);
if (!set)
return;
mpGroupSetDB.erase(name);
mpGroupSetDB.erase(name.data());
mpGroupSetResNameDB.erase(set.GetObjectTag()->id);
}
bool CAudioSys::SysIsGroupSetLoaded(const std::string& name)
bool CAudioSys::SysIsGroupSetLoaded(std::string_view name)
{
return FindGroupSet(name).operator bool();
}
void CAudioSys::SysAddGroupIntoAmuse(const std::string& name)
void CAudioSys::SysAddGroupIntoAmuse(std::string_view name)
{
if (auto set = FindGroupSet(name))
AddAudioGroup(set->GetAudioGroupData());
}
void CAudioSys::SysRemoveGroupFromAmuse(const std::string& name)
void CAudioSys::SysRemoveGroupFromAmuse(std::string_view name)
{
if (auto set = FindGroupSet(name))
RemoveAudioGroup(set->GetAudioGroupData());

View File

@@ -78,14 +78,14 @@ public:
{
}
static TLockedToken<CAudioGroupSet> FindGroupSet(const std::string& name);
static const std::string& SysGetGroupSetName(CAssetId id);
static TLockedToken<CAudioGroupSet> FindGroupSet(std::string_view name);
static std::string_view SysGetGroupSetName(CAssetId id);
static bool SysLoadGroupSet(CSimplePool* pool, CAssetId id);
static bool SysLoadGroupSet(const TLockedToken<CAudioGroupSet>& set, const std::string& name, CAssetId id);
static void SysUnloadAudioGroupSet(const std::string& name);
static bool SysIsGroupSetLoaded(const std::string& name);
static void SysAddGroupIntoAmuse(const std::string& name);
static void SysRemoveGroupFromAmuse(const std::string& name);
static bool SysLoadGroupSet(const TLockedToken<CAudioGroupSet>& set, std::string_view name, CAssetId id);
static void SysUnloadAudioGroupSet(std::string_view name);
static bool SysIsGroupSetLoaded(std::string_view name);
static void SysAddGroupIntoAmuse(std::string_view name);
static void SysRemoveGroupFromAmuse(std::string_view name);
static void SysSetVolume(u8 volume);
static void SysSetSfxVolume(u8 volume, u16 time, bool music, bool fx);

View File

@@ -7,7 +7,7 @@ namespace urde
#define RSF_BUFFER_SIZE 0x20000
CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, const std::string& path,
CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path,
int loopStart, int loopEnd)
: x0_path(path), x1c_loopStartSamp(loopStart & 0xfffffffe), x20_loopEndSamp(loopEnd & 0xfffffffe),
m_voiceCallback(*this), m_voice(engine.allocateNewStereoVoice(32000, &m_voiceCallback))
@@ -16,7 +16,7 @@ CStaticAudioPlayer::CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, const std
//x28_dmaLeft.reset(new u8[640]);
//x30_dmaRight.reset(new u8[640]);
CDvdFile file(path.c_str());
CDvdFile file(path);
x10_rsfRem = file.Length();
x14_rsfLength = x10_rsfRem;

View File

@@ -57,9 +57,9 @@ class CStaticAudioPlayer
std::unique_ptr<boo::IAudioVoice> m_voice;
public:
CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, const std::string& path,
CStaticAudioPlayer(boo::IAudioVoiceEngine& engine, std::string_view path,
int loopStart, int loopEnd);
CStaticAudioPlayer(const std::string& path,
CStaticAudioPlayer(std::string_view path,
int loopStart, int loopEnd)
: CStaticAudioPlayer(*CAudioSys::GetVoiceEngine(), path, loopStart, loopEnd) {}

View File

@@ -503,10 +503,10 @@ public:
x70_24_unclaimed = true;
}
CDSPStreamManager(const std::string& fileName, u32 handle, float volume, bool oneshot)
CDSPStreamManager(std::string_view fileName, u32 handle, float volume, bool oneshot)
: x60_fileName(fileName), x73_volume(volume), x74_oneshot(oneshot), x78_handleId(handle)
{
if (!CDvdFile::FileExists(fileName.c_str()))
if (!CDvdFile::FileExists(fileName))
x70_24_unclaimed = true;
}
@@ -771,7 +771,7 @@ public:
m_dvdReq.reset();
}
static u32 StartStreaming(const std::string& fileName, float volume, bool oneshot)
static u32 StartStreaming(std::string_view fileName, float volume, bool oneshot)
{
auto pipePos = fileName.find('|');
if (pipePos == std::string::npos)
@@ -951,7 +951,7 @@ struct SDSPPlayer
bool x28_music = true;
SDSPPlayer() = default;
SDSPPlayer(EPlayerState playing, const std::string& fileName, float volume,
SDSPPlayer(EPlayerState playing, std::string_view fileName, float volume,
float fadeIn, float fadeOut, u32 handle, bool music)
: x0_fileName(fileName), x10_playState(playing), x14_volume(volume),
x18_fadeIn(fadeIn), x1c_fadeOut(fadeOut), x20_internalHandle(handle), x28_music(music) {}
@@ -967,7 +967,7 @@ float CStreamAudioManager::GetTargetDSPVolume(float fileVol, bool music)
return g_SfxUnmute ? (g_SfxVolume * fileVol / 127.f) : 0.f;
}
void CStreamAudioManager::Start(bool oneshot, const std::string& fileName,
void CStreamAudioManager::Start(bool oneshot, std::string_view fileName,
u8 volume, bool music, float fadeIn, float fadeOut)
{
float fvol = volume / 127.f;
@@ -1022,7 +1022,7 @@ void CStreamAudioManager::Start(bool oneshot, const std::string& fileName,
}
}
void CStreamAudioManager::Stop(bool oneshot, const std::string& fileName)
void CStreamAudioManager::Stop(bool oneshot, std::string_view fileName)
{
SDSPPlayer& p = s_Players[oneshot];
SDSPPlayer& qp = s_QueuedPlayers[oneshot];

View File

@@ -20,9 +20,9 @@ class CStreamAudioManager
static void StopAllStreams();
public:
static void Start(bool oneshot, const std::string& fileName, u8 volume,
static void Start(bool oneshot, std::string_view fileName, u8 volume,
bool music, float fadeIn, float fadeOut);
static void Stop(bool oneshot, const std::string& fileName);
static void Stop(bool oneshot, std::string_view fileName);
static void FadeBackIn(bool oneshot, float fadeTime);
static void TemporaryFadeOut(bool oneshot, float fadeTime);
static void Update(float dt);