mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-21 18:29:05 +02:00
Debugger: Fail game.state.load/save when the savestate is refused
SaveState::Load and Save silently drop the operation when the network or achievements hardcore mode forbids it, but the debugger still answered as if it had been queued. Return whether it was, and check the boot state in the same CPU-thread call. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b000d557e2
commit
681a60b3ca
3 files changed
+40
-27
No files matched your search
@@ -136,24 +136,30 @@ void WebSocketGameStatus(DebuggerRequest &req) {
|
||||
// Parameters:
|
||||
// - path: string, path to the .ppst file.
|
||||
//
|
||||
// Response (same event name) with no extra data, once queued.
|
||||
// Response (same event name) with no extra data, once queued, or an error if the network or
|
||||
// achievements hardcore mode refuses it.
|
||||
void WebSocketGameStateLoad(DebuggerRequest &req) {
|
||||
std::string path;
|
||||
if (!req.ParamString("path", &path))
|
||||
return;
|
||||
|
||||
bool running = false;
|
||||
bool queued = false;
|
||||
Core_RunOnCPUThread([&] {
|
||||
running = PSP_GetBootState() == BootState::Complete;
|
||||
if (running) {
|
||||
queued = SaveState::Load(Path(path), -1, [](SaveState::Status status, std::string_view message, std::string_view) {
|
||||
if (status == SaveState::Status::FAILURE) {
|
||||
ERROR_LOG(Log::System, "game.state.load: %.*s", STR_VIEW(message));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!running)
|
||||
return req.Fail("Game not running");
|
||||
|
||||
SaveState::Load(Path(path), -1, [](SaveState::Status status, std::string_view message, std::string_view) {
|
||||
if (status == SaveState::Status::FAILURE) {
|
||||
ERROR_LOG(Log::System, "game.state.load: %.*s", STR_VIEW(message));
|
||||
}
|
||||
});
|
||||
if (!queued) {
|
||||
return req.Fail("Could not queue savestate load");
|
||||
}
|
||||
req.Respond();
|
||||
}
|
||||
|
||||
@@ -164,24 +170,30 @@ void WebSocketGameStateLoad(DebuggerRequest &req) {
|
||||
// Parameters:
|
||||
// - path: string, path to write the .ppst file to.
|
||||
//
|
||||
// Response (same event name) with no extra data, once queued.
|
||||
// Response (same event name) with no extra data, once queued, or an error if the network or
|
||||
// achievements hardcore mode refuses it.
|
||||
void WebSocketGameStateSave(DebuggerRequest &req) {
|
||||
std::string path;
|
||||
if (!req.ParamString("path", &path))
|
||||
return;
|
||||
|
||||
bool running = false;
|
||||
bool queued = false;
|
||||
Core_RunOnCPUThread([&] {
|
||||
running = PSP_GetBootState() == BootState::Complete;
|
||||
if (running) {
|
||||
queued = SaveState::Save(Path(path), -1, [](SaveState::Status status, std::string_view message, std::string_view) {
|
||||
if (status == SaveState::Status::FAILURE) {
|
||||
ERROR_LOG(Log::System, "game.state.save: %.*s", STR_VIEW(message));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!running)
|
||||
return req.Fail("Game not running");
|
||||
|
||||
SaveState::Save(Path(path), -1, [](SaveState::Status status, std::string_view message, std::string_view) {
|
||||
if (status == SaveState::Status::FAILURE) {
|
||||
ERROR_LOG(Log::System, "game.state.save: %.*s", STR_VIEW(message));
|
||||
}
|
||||
});
|
||||
if (!queued) {
|
||||
return req.Fail("Could not queue savestate save");
|
||||
}
|
||||
req.Respond();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user