Headless: Don't save states while running from a state without its game

The game runs without its disc there, so a state saved from it would keep that broken
environment. Saves are refused, and so is --save-state together with a state to boot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-11-01 15:41:23 +01:00
1 parent 5c37b0d798
commit bf2c81e37d
4 files changed
+14 -4

No files matched your search

+1 -1
View File
@@ -67,7 +67,7 @@ public:
}
// Opens of files that aren't on the disc, and reads and seeks on handles whose file was dropped
// when a savestate loaded. On a real disc these don't happen, so they tell when a game booted
// when a savestate loaded. With the real disc these are rare, so they tell when a game booted
// from a state alone has missed data it needed.
int FailedDiscReads() const { return failedDiscReads_; }
void ResetFailedDiscReads() { failedDiscReads_ = 0; }
+9
View File
@@ -498,6 +498,15 @@ int g_screenshotFailures;
CallbackRefused(op.callback);
return false;
}
// A game booted from a state alone (headless) runs without its disc. A state saved from that
// would hold the broken environment, and be no use with the game or without it.
if (op.type == OperationType::Save && PSP_CoreParameter().fileType == IdentifiedFileType::PPSSPP_SAVESTATE) {
ERROR_LOG(Log::SaveState, "Can't save a state while running from a state without its game");
if (op.callback) {
op.callback(Status::FAILURE, "Can't save a state while running from a state without its game", "");
}
return false;
}
// Verify saves and loads back in place, with the mounts as they are.
if (op.type != OperationType::Verify && WarnUserIfVSHSession()) {
CallbackRefused(op.callback);
+2 -1
View File
@@ -231,7 +231,8 @@ but a state taken while the game streams music or video, or just before it loads
so save perf states in the middle of gameplay. Headless prints `Failed disc reads: N` at the end, counted from
the load: opens of files on the disc and reads and seeks on dropped handles. A state that keeps it at 0, or close,
measures the game as it really runs. Only states saved since the disc ID was added to them (`SaveStart` version 6)
boot this way. The app doesn't: it refuses a `.ppst` as before.
boot this way. The app doesn't: it refuses a `.ppst` as before. States can't be saved while running from one this
way (`--save-state` is refused): without the disc the game isn't in a state worth keeping.
`Tools/headless_bench.py` takes such states as games (`--game some.ppst`, or `--state-dir DIR` for every `.ppst`
in a directory), and reports the failed disc reads with the timings.
+2 -2
View File
@@ -1051,8 +1051,8 @@ int main(int argc, const char* argv[]) {
std::string stateBootPath;
if (testFilenames.size() == 1 && endsWithNoCase(testFilenames[0], ".ppst")) {
stateBootPath = testFilenames[0];
if (stateToLoad) {
fprintf(stderr, "--state can't be used when booting a state\n");
if (stateToLoad || cmdLineOptions.stateToSave.has_value()) {
fprintf(stderr, "--state and --save-state can't be used when booting a state\n");
return 1;
}
stateToLoad = stateBootPath.c_str();