Skip to content

cheats: fall back to content path for game-specific files - #19089

Open
Splaser wants to merge 12 commits into
libretro:masterfrom
Splaser:cheats-content-basename-fallback
Open

cheats: fall back to content path for game-specific files#19089
Splaser wants to merge 12 commits into
libretro:masterfrom
Splaser:cheats-content-basename-fallback

Conversation

@Splaser

@Splaser Splaser commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Runtime-created cheats may fail to persist when no cheat file has been loaded beforehand.

Game-specific cheat filenames were derived from runloop_st->name.cheatfile only. When a cheat is created from the menu without first loading an existing .cht file, this value can be empty, causing cheat_manager_get_game_specific_filename() to return 0 and preventing the cheat list from being saved.

Fall back to the current content basename/path when no cheatfile name is available, while preserving the existing cheatfile-based behavior when it is set.

Tested on Android aarch64:

  • launched content without loading an existing .cht file
  • added a runtime cheat entry from Quick Menu > Cheats
  • closed content and verified a game-specific .cht file was created
  • relaunched the same content and verified the cheat list persisted

@RobLoach

Copy link
Copy Markdown
Member

Wouldn't we want to save the new cheat into the cheats folder rather than the content directory? I may have misinterpretted it.

@Splaser

Splaser commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Wouldn't we want to save the new cheat into the cheats folder rather than the content directory? I may have misinterpretted it.

It still saves into the configured cheats directory.

The content path is only used as a fallback source for the game-specific filename when runloop_st->name.cheatfile is empty. It is passed through path_basename_nocompression(), while the destination directory is still built from path_cheat_database and core_name.

So the resulting path remains:

<cheats directory>/<core name>/<game-specific filename>.cht

@Splaser Splaser closed this Jun 26, 2026
@Splaser Splaser reopened this Aug 6, 2026
@Splaser

Splaser commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Reopening after rechecking this against current master.

To clarify the scope: RetroArch already has game-specific cheat autosave/autoload infrastructure. This PR fixes a gap where runtime-created cheats may not persist when no .cht file has been loaded first. In that case, runloop_st->name.cheatfile can be empty, so cheat_manager_get_game_specific_filename() returns 0 and the close-content save is skipped.

The fallback only derives the game-specific filename from the runtime content basename/path. The destination remains:

<cheat directory>/<core name>/<content basename>.cht

This was validated on Android aarch64 by launching content without loading an existing cheat file, adding a cheat from the Quick Menu, closing the content, and relaunching it. With this patch, the cheat file is created and is automatically loaded on the next launch.

This does not change the Save Cheat File As dialog and does not save cheats into the content directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants