mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-13 03:29:11 +00:00
AchievementManager: Make GetInstance() return a reference
The internal static member will always have a valid lifetime. Makes this consistent with other instance based objects in our code.
This commit is contained in:
parent
d84ed054ee
commit
e55f9ed102
21 changed files with 81 additions and 74 deletions
|
@ -28,10 +28,10 @@ static constexpr bool hardcore_mode_enabled = false;
|
|||
|
||||
static std::unique_ptr<OSD::Icon> DecodeBadgeToOSDIcon(const AchievementManager::Badge& badge);
|
||||
|
||||
AchievementManager* AchievementManager::GetInstance()
|
||||
AchievementManager& AchievementManager::GetInstance()
|
||||
{
|
||||
static AchievementManager s_instance;
|
||||
return &s_instance;
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void AchievementManager::Init()
|
||||
|
@ -650,7 +650,7 @@ void AchievementManager::DoFrame()
|
|||
rc_runtime_do_frame(
|
||||
&m_runtime,
|
||||
[](const rc_runtime_event_t* runtime_event) {
|
||||
AchievementManager::GetInstance()->AchievementEventHandler(runtime_event);
|
||||
GetInstance().AchievementEventHandler(runtime_event);
|
||||
},
|
||||
[](unsigned address, unsigned num_bytes, void* ud) {
|
||||
return static_cast<AchievementManager*>(ud)->MemoryPeeker(address, num_bytes, ud);
|
||||
|
@ -933,8 +933,9 @@ void* AchievementManager::FilereaderOpenByVolume(const char* path_utf8)
|
|||
{
|
||||
auto state = std::make_unique<FilereaderState>();
|
||||
{
|
||||
std::lock_guard lg{*AchievementManager::GetInstance()->GetLock()};
|
||||
state->volume = std::move(AchievementManager::GetInstance()->GetLoadingVolume());
|
||||
auto& instance = GetInstance();
|
||||
std::lock_guard lg{*instance.GetLock()};
|
||||
state->volume = std::move(instance.GetLoadingVolume());
|
||||
}
|
||||
if (!state->volume)
|
||||
return nullptr;
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
std::unordered_map<u32, LeaderboardEntry> entries;
|
||||
};
|
||||
|
||||
static AchievementManager* GetInstance();
|
||||
static AchievementManager& GetInstance();
|
||||
void Init();
|
||||
void SetUpdateCallback(UpdateCallback callback);
|
||||
ResponseType Login(const std::string& password);
|
||||
|
|
|
@ -580,8 +580,8 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
|||
}
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance()->HashGame(executable.path,
|
||||
[](AchievementManager::ResponseType r_type) {});
|
||||
AchievementManager::GetInstance().HashGame(executable.path,
|
||||
[](AchievementManager::ResponseType r_type) {});
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
if (!executable.reader->LoadIntoMemory(system))
|
||||
|
|
|
@ -165,7 +165,7 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
|
|||
}
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance()->SetDisabled(false);
|
||||
AchievementManager::GetInstance().SetDisabled(false);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
const bool load_ipl = !StartUp.bWii && !Config::Get(Config::MAIN_SKIP_IPL) &&
|
||||
|
|
|
@ -170,7 +170,7 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
|
|||
return;
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance()->SetDisabled(true);
|
||||
AchievementManager::GetInstance().SetDisabled(true);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
if (game_id == "00000000")
|
||||
|
|
|
@ -293,7 +293,7 @@ void Stop() // - Hammertime!
|
|||
return;
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance()->CloseGame();
|
||||
AchievementManager::GetInstance().CloseGame();
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
s_is_stopping = true;
|
||||
|
@ -940,7 +940,7 @@ void Callback_NewField(Core::System& system)
|
|||
}
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance()->DoFrame();
|
||||
AchievementManager::GetInstance().DoFrame();
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
}
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ void HostDispatchJobs()
|
|||
void DoFrameStep()
|
||||
{
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
if (AchievementManager::GetInstance()->IsHardcoreModeActive())
|
||||
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
||||
{
|
||||
OSD::AddMessage("Frame stepping is disabled in RetroAchievements hardcore mode");
|
||||
return;
|
||||
|
|
|
@ -139,7 +139,7 @@ void CoreTimingManager::RefreshConfig()
|
|||
m_max_variance = std::chrono::duration_cast<DT>(DT_ms(Config::Get(Config::MAIN_TIMING_VARIANCE)));
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
if (AchievementManager::GetInstance()->IsHardcoreModeActive() &&
|
||||
if (AchievementManager::GetInstance().IsHardcoreModeActive() &&
|
||||
Config::Get(Config::MAIN_EMULATION_SPEED) < 1.0f &&
|
||||
Config::Get(Config::MAIN_EMULATION_SPEED) > 0.0f)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ void Config::Refresh()
|
|||
camera_config.control_type = ::Config::Get(::Config::FL1_CONTROL_TYPE);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED) &&
|
||||
!AchievementManager::GetInstance()->IsHardcoreModeActive();
|
||||
!AchievementManager::GetInstance().IsHardcoreModeActive();
|
||||
#else // USE_RETRO_ACHIEVEMENTS
|
||||
enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
|
|
@ -398,8 +398,8 @@ void DVDInterface::SetDisc(std::unique_ptr<DiscIO::VolumeDisc> disc,
|
|||
}
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance()->HashGame(disc.get(),
|
||||
[](AchievementManager::ResponseType r_type) {});
|
||||
AchievementManager::GetInstance().HashGame(disc.get(),
|
||||
[](AchievementManager::ResponseType r_type) {});
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
// Assume that inserting a disc requires having an empty disc before
|
||||
|
|
|
@ -480,7 +480,7 @@ bool ESDevice::LaunchPPCTitle(u64 title_id)
|
|||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
INFO_LOG_FMT(ACHIEVEMENTS,
|
||||
"WAD and NAND formats not currently supported by Achievement Manager.");
|
||||
AchievementManager::GetInstance()->SetDisabled(true);
|
||||
AchievementManager::GetInstance().SetDisabled(true);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
core_timing.RemoveEvent(s_bootstrap_ppc_for_launch_event);
|
||||
|
|
|
@ -207,7 +207,7 @@ void LoadFromBuffer(std::vector<u8>& buffer)
|
|||
}
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
if (AchievementManager::GetInstance()->IsHardcoreModeActive())
|
||||
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
||||
{
|
||||
OSD::AddMessage("Loading savestates is disabled in RetroAchievements hardcore mode");
|
||||
return;
|
||||
|
@ -853,7 +853,7 @@ void LoadAs(const std::string& filename)
|
|||
}
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
if (AchievementManager::GetInstance()->IsHardcoreModeActive())
|
||||
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
||||
{
|
||||
OSD::AddMessage("Loading savestates is disabled in RetroAchievements hardcore mode");
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue