mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 16:49:58 -06:00
Core::GetState: Avoid Global System Accessor
This commit is contained in:
@ -202,7 +202,8 @@ void DisplayMessage(std::string message, int time_in_ms)
|
||||
|
||||
bool IsRunning()
|
||||
{
|
||||
return (GetState() != State::Uninitialized || s_hardware_initialized) && !s_is_stopping;
|
||||
auto& system = Core::System::GetInstance();
|
||||
return (GetState(system) != State::Uninitialized || s_hardware_initialized) && !s_is_stopping;
|
||||
}
|
||||
|
||||
bool IsRunningAndStarted()
|
||||
@ -281,8 +282,11 @@ static void ResetRumble()
|
||||
// Called from GUI thread
|
||||
void Stop(Core::System& system) // - Hammertime!
|
||||
{
|
||||
if (GetState() == State::Stopping || GetState() == State::Uninitialized)
|
||||
if (const State state = GetState(system);
|
||||
state == State::Stopping || state == State::Uninitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
AchievementManager::GetInstance().CloseGame();
|
||||
@ -728,17 +732,16 @@ void SetState(State state, bool report_state_change)
|
||||
// Certain callers only change the state momentarily. Sending a callback for them causes
|
||||
// unwanted updates, such as the Pause/Play button flickering between states on frame advance.
|
||||
if (report_state_change)
|
||||
CallOnStateChangedCallbacks(GetState());
|
||||
CallOnStateChangedCallbacks(GetState(system));
|
||||
}
|
||||
|
||||
State GetState()
|
||||
State GetState(Core::System& system)
|
||||
{
|
||||
if (s_is_stopping)
|
||||
return State::Stopping;
|
||||
|
||||
if (s_hardware_initialized)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (system.GetCPU().IsStepping())
|
||||
return State::Paused;
|
||||
|
||||
@ -904,7 +907,7 @@ void Callback_NewField(Core::System& system)
|
||||
{
|
||||
s_frame_step = false;
|
||||
system.GetCPU().Break();
|
||||
CallOnStateChangedCallbacks(Core::GetState());
|
||||
CallOnStateChangedCallbacks(Core::GetState(system));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1046,7 +1049,7 @@ void HostDispatchJobs(Core::System& system)
|
||||
}
|
||||
|
||||
// NOTE: Host Thread
|
||||
void DoFrameStep()
|
||||
void DoFrameStep(Core::System& system)
|
||||
{
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
if (AchievementManager::GetInstance().IsHardcoreModeActive())
|
||||
@ -1055,7 +1058,7 @@ void DoFrameStep()
|
||||
return;
|
||||
}
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
if (GetState() == State::Paused)
|
||||
if (GetState(system) == State::Paused)
|
||||
{
|
||||
// if already paused, frame advance for 1 frame
|
||||
s_stop_frame_step = false;
|
||||
|
Reference in New Issue
Block a user