2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 23:47:42 +00:00

CGameOptions: Make use of std::string_view where applicable

Enforces the use of valid strings in the interface. Also reduces c_str()
noise a little bit.
This commit is contained in:
Lioncash
2020-03-14 19:59:58 -04:00
parent df4487bae8
commit 659b8a43d3
5 changed files with 37 additions and 27 deletions

View File

@@ -578,43 +578,51 @@ const CHintOptions::SHintState* CHintOptions::GetCurrentDisplayedHint() const {
return nullptr;
}
void CHintOptions::DelayHint(const char* name) {
int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1)
void CHintOptions::DelayHint(std::string_view name) {
const int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1) {
return;
}
if (x10_nextHintIdx == idx)
for (SHintState& state : x0_hintStates)
if (x10_nextHintIdx == idx) {
for (SHintState& state : x0_hintStates) {
state.x4_time += 60.f;
}
}
x0_hintStates[idx].x0_state = EHintState::Delayed;
}
void CHintOptions::ActivateImmediateHintTimer(const char* name) {
int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1)
void CHintOptions::ActivateImmediateHintTimer(std::string_view name) {
const int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1) {
return;
}
SHintState& hintState = x0_hintStates[idx];
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[idx];
if (hintState.x0_state != EHintState::Zero)
if (hintState.x0_state != EHintState::Zero) {
return;
}
hintState.x0_state = EHintState::Waiting;
hintState.x4_time = hint.GetImmediateTime();
}
void CHintOptions::ActivateContinueDelayHintTimer(const char* name) {
void CHintOptions::ActivateContinueDelayHintTimer(std::string_view name) {
int idx = x10_nextHintIdx;
if (idx != 0)
if (idx != 0) {
idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1)
}
if (idx == -1) {
return;
}
SHintState& hintState = x0_hintStates[idx];
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[idx];
if (hintState.x0_state != EHintState::Displaying)
if (hintState.x0_state != EHintState::Displaying) {
return;
}
hintState.x4_time = hint.GetTextTime();
}