Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Savedata iteration order doesn't match the real PSP? #16939

Closed
hrydgard opened this issue Feb 8, 2023 · 7 comments · Fixed by #19340
Closed

Savedata iteration order doesn't match the real PSP? #16939

hrydgard opened this issue Feb 8, 2023 · 7 comments · Fixed by #19340
Labels
HLE/Kernel Kernel, memory manager, other HLE issues Saving issue Prevents or obstructs saving game (not save states.)
Milestone

Comments

@hrydgard
Copy link
Owner

hrydgard commented Feb 8, 2023

NABN00B on Discord:

After booting GTA LCS/VCS, the save file with the lowest slot number is loaded, on PSP the save file with the most recent date - does that happen in other games as well?

Sergey confirms that the order is different.

Should be looked into.

@hrydgard hrydgard added Saving issue Prevents or obstructs saving game (not save states.) HLE/Kernel Kernel, memory manager, other HLE issues labels Feb 8, 2023
@hrydgard hrydgard added this to the v1.16.0 milestone Feb 8, 2023
@unknownbrackets
Copy link
Collaborator

unknownbrackets commented Feb 9, 2023

Hm, this is probably a setting then? What I recall happening on a PSP is that the latest save is highlighted by default (see SceUtilitySavedataFocus) but that it's sorted in 0, 1, 2, 3 order - at least in the games I played. You could even have gaps. Maybe GTA sends a different flag?

Also, this says "loaded" - is it really the "iteration order" or is there some issue with one of the focus methods (maybe SCE_UTILITY_SAVEDATA_FOCUS_FIRSTDATA should be by date rather than order, etc.)?

-[Unknown]

@NABN00B
Copy link
Contributor

NABN00B commented May 19, 2023

Hm, this is probably a setting then? What I recall happening on a PSP is that the latest save is highlighted by default (see SceUtilitySavedataFocus) but that it's sorted in 0, 1, 2, 3 order - at least in the games I played. You could even have gaps. Maybe GTA sends a different flag?

Also, this says "loaded" - is it really the "iteration order" or is there some issue with one of the focus methods (maybe SCE_UTILITY_SAVEDATA_FOCUS_FIRSTDATA should be by date rather than order, etc.)?

-[Unknown]

There are two different things here:

  • The game automatically loads a save file upon booting. Which save file it loads (lowest slot) is different to a real PSP.
  • When manually selecting the Load Game option from the (ingame) pause menu, a save file is highlighted. This is the correct (latest) one.

@hrydgard hrydgard modified the milestones: v1.16.0, v1.17.0 Jul 6, 2023
@Domiiniik
Copy link
Contributor

Bump, this is actually a really annoying problem in GTA, in hopes it can be fixed up for 1.16..

@ThirteenAG
Copy link
Contributor

I'm not sure how to debug this properly, but I tried to follow where the code goes wrong and managed to make a workaround for gtavcs:
master...ThirteenAG:ppsspp:master

What's going on is:
Startup:

  1. call to SavedataParam::SetPspParam with param->mode == SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD && param->focus == SCE_UTILITY_SAVEDATA_FOCUS_LATEST.
    param->saveNameList is not nullptr.
  2. call to SavedataParam::SetPspParam with param->mode == SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD && param->focus == SCE_UTILITY_SAVEDATA_FOCUS_LATEST.
    At this point, ppsspp can't construct a list of available saves, so it defaults to slot 0 here.

Ingame:

  1. Only one call to SavedataParam::SetPspParam with param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD && param->focus == SCE_UTILITY_SAVEDATA_FOCUS_LATEST.
    param->saveNameList is not nullptr.
    The key difference here, UI is gonna show up, which doesn't happen on startup and ppsspp handles these calls in PSPSaveDialog::ExecuteNotVisibleIOAction. Could be related to the underlying issue.

So, to workaround:

  1. On startup, on first call of SetPspParam, I cached param->saveNameList, then inserted cached value during second call.
  2. In order to get latest save path, I had to comment case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD: in two functions:
    PSPSaveDialog::GetSelectedSaveDirName()
    SavedataParam::WouldHaveMultiSaveName(const SceUtilitySavedataParam *param)

Hope this helps to get to the root of the problem somehow.

@hrydgard hrydgard modified the milestones: v1.17.0, v1.18.0 Jan 23, 2024
@Parik27
Copy link

Parik27 commented Jul 18, 2024

The VCS bug is not related to the savedata iteration. The game does its own by calling sceIoGetstat on directories in "ms0:PSP/SAVEDATA" and picking up the one with the lowest m_time. On Linux at least, this always seems to return year=1900, month=1, day=0, so the game ends up picking the first one it finds in the directory.

I don't know how @ThirteenAG 's workaround works, but the game does not set saveNameList on autoloads, only the saveName.

@hrydgard
Copy link
Owner Author

Oh, that's good information!

I'll look into the mtime issue, we should not be returning 1900..

@ThirteenAG
Copy link
Contributor

We've been looking at the wrong thing, good to see this finally figured out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HLE/Kernel Kernel, memory manager, other HLE issues Saving issue Prevents or obstructs saving game (not save states.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants