MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / play

Method play

pcsx2/Recording/InputRecording.cpp:83–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83bool InputRecording::play(const std::string& filename)
84{
85 if (!m_file.openExisting(filename))
86 {
87 return false;
88 }
89
90 // Either load the savestate, or restart the game
91 if (m_file.fromSaveState())
92 {
93 std::string savestatePath = fmt::format("{}_SaveState.p2s", m_file.getFilename());
94 if (!FileSystem::FileExists(savestatePath.c_str()))
95 {
96 InputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}", savestatePath));
97 InputRec::log(TRANSLATE_STR("InputRecording", "Failed to load state for input recording"), Host::OSD_ERROR_DURATION);
98 m_file.close();
99 return false;
100 }
101 m_type = Type::FROM_SAVESTATE;
102 m_initial_load_complete = false;
103 m_is_active = true;
104 const auto loaded = VMManager::LoadState(savestatePath.c_str());
105 if (!loaded)
106 {
107 InputRec::log(TRANSLATE_STR("InputRecording", "Failed to load state for input recording, unsupported version?"), Host::OSD_ERROR_DURATION);
108 m_file.close();
109 m_is_active = false;
110 return false;
111 }
112 }
113 else
114 {
115 m_starting_frame = 0;
116 m_type = Type::POWER_ON;
117 m_initial_load_complete = false;
118 m_is_active = true;
119 // TODO - should this be an explicit [full] boot instead of a reset?
120 VMManager::Reset();
121 }
122 m_controls.setReplayMode();
123 initializeState();
124 InputRec::log(TRANSLATE_STR("InputRecording", "Replaying input recording"), Host::OSD_INFO_DURATION);
125 m_file.logRecordingMetadata();
126 if (VMManager::GetTitle(false) != m_file.getGameName())
127 {
128 InputRec::consoleLog(fmt::format("Input recording was possibly constructed for a different game. Expected: {}, Actual: {}", m_file.getGameName(), VMManager::GetTitle(false)));
129 }
130 return true;
131}
132
133void InputRecording::closeActiveFile()
134{

Callers 1

Calls 11

consoleLogFunction · 0.85
logFunction · 0.85
ResetFunction · 0.85
openExistingMethod · 0.80
fromSaveStateMethod · 0.80
setReplayModeMethod · 0.80
logRecordingMetadataMethod · 0.80
getGameNameMethod · 0.80
formatFunction · 0.50
c_strMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected