Skip to content

Cheat files that follow game updates: a new version from its author, with one tap, and nothing you set lost - #740

Open
davdxpx wants to merge 14 commits into
igawa6:mainfrom
davdxpx:mncf-updates
Open

davdxpx wants to merge 14 commits into
igawa6:mainfrom
davdxpx:mncf-updates

Conversation

@davdxpx

@davdxpx davdxpx commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

When a game update breaks cheats, the people who make them often publish a fixed file within days. Today a player never hears of it, and if they find the new file and add it, it becomes a second copy of their cheats: every switch and every number they set is gone, and the old copy still sits there.

With this PR a Mistel cheat file can say where its author puts new versions (Mistel's spec, section 17), and Peanuts brings them to the player:

  • Asks once, then looks for you. When a file that names its new versions is added, Peanuts asks once whether it may look there on its own: at most once a day, and right when a game update stops the file's cheats. Without a yes it looks only when the player taps Check for updates. The request carries nothing about the player or the device.
  • Right when a game update stops the cheats. The file's card says that a newer version of it may know the new game version, and asks the author's address with one tap.
  • Never without you. A new version shows what changed since the player's version, newest first: the author's notes, the cheats it brings and the ones it fixed, the numbers that no longer fit, the cheats it no longer has. One tap installs it.
  • Everything you set stays. The cheats switched on and the numbers set move to the new version, by each cheat's id, also where the author renamed a cheat. A number that no longer fits goes back to the file's own, and the screen says which. A cheat that is new in the version is on where its file says so.
  • New and Fixed marks on the cheats page until the next start.
  • Back to version N. The version it replaced is kept, so the player can go back; Peanuts then offers only a version above the one they left.
  • The same author, never an old file. A new version is taken only for the same game and file, above the version the player has, and where the file is signed, signed by the same key (Mistel's Updates.check). Unsigned files get new versions too, as before without any mark.
  • Added by hand. A file the player adds that is a version of one they have opens the same screen instead of becoming a second copy. A pack's files get new versions with their pack.

Peanuts only ever follows the address the author put into a file the player chose. It offers no cheats of its own.

Builds on #677 (.mncf cheats), so the diff shows its commits too; please read it after #677. The library is Mistel's, copied unchanged from its main with mncf-vendor.sh, which now has spec section 17 and its readers (davdxpx/mistel#18).

1. Adding a file that names its new versions

Add: where its new versions come from Asked once: look there on its own, or only when asked
Bild 1 Bild 2

2. After a game update

The card: a newer version may know 2.1.0
Bild 3

3. A new version

What changed since your version, newest first What changes for you, and that you can go back
Bild 4 Bild 5
After installing: New and Fixed, your switches kept, the new cheat on
Bild 6

4. Versions on the file's sheet

Check for updates, Look on its own, Back to version 3 Back to version 3
Bild 7 Bild 8

Also in this PR

Checked

  • python peanuts/tests/test_cheat_loader.py (CheatLoaderJvmTest.updates and packUpdates: the question, the daily look, a version found and kept, nothing installed without the player, the screen's notes in the player's language, install with a rename, a number that no longer fits and one that does, a removed cheat, the marks, a cheat new in the version on by default, back and not offered again, an older file never taken, another file at the address not taken, a new host asked again, state kept for a cheat this build cannot run, https only and no address of the device; a pack with a file renamed, one gone and one new), peanuts/tests/test_mod_cheats.py, peanuts/tests/test_mncf_vendor.py, the overlay check.
  • The dual-screen emulator (Android 13), Metroid Dread 2.1.0 with a stand-in pack (a zero-filled main of the build ID, no game code), made-up cheat files only: the whole flow in the pictures, a real request to raw.githubusercontent.com (a made-up file of Mistel's test suite, for another game: refused as not a version of this file) from Check for updates and from the look on its own.
  • CheatUpdates.Https on the JVM against the same address with a file that matches it: the new version found and kept.
  • Not on the Thor: nothing in this PR touches the game or the host.

Not in this PR: a hint in the in-game Mods tab (#678 to #680) when a new version is ready.

Every cheat file a player adds is kept as one Mistel Native Cheat Format
file (.mncf) for all of a game's builds. An Atmosphère, Eden, Yuzu or
Ryujinx file is converted as it is added, with the game's own main from
the pack: each patch names the original code at its place, and its place
is found by a pattern, so a cheat keeps working after a game update and
never writes into code that is not what it was made for. A cheat that
cannot work here says why, in a sentence.

- MncfBuild: a file made ready for the build that runs (Mistel's
  evaluator), kept per build, and written as Atmosphère code for the
  host's cheat engine, so the engine is unchanged.
- MncfConvert: Atmosphère to .mncf with the game, the versions, the
  origin and the authors (the credits, else the player who adds it).
- MncfMain: the game's own main from a pack (main.patched.bin with
  main.orig.bin back at main.changed.tsv's runs).
- .mncf and .mncp files are added as they are; a signature stays good,
  and only a verified one gets a mark.
- A value of an .mncf cheat (a number in an instruction too) gets the
  in-game number field; relations (requires, excludes, radio) apply.
- Export writes .mncf (one source) or .mncp (several), with the cheats
  that are on and the numbers set.
- Mistel's MIT library is copied unchanged under io/github/davdxpx/mistel
  (peanuts/scripts/mncf-vendor.sh, checked by test_mncf_vendor.py).
…it brings

- Export sits in the bar beside Add on the Cheats tab, on the game page's
  Mods & Cheats area and on its own page, while there is a source to
  export.
- The Add dialog of an .mncf opens with a card for the file (its name,
  who made it, who signed it when a trusted key did) and what the file
  brings, counted from it: its cheats and versions, the ones checked
  before they write, the ones that follow game updates, the numbers to
  set, the ones that say what they do.
- An Atmosphère pick says it becomes a Mistel cheat file, and the wait
  while it is converted says what is being done.
- After adding, a sheet says how many of the cheats work on the game's
  version, how many cannot (listed with the reason), and what the file
  brings, in place of a toast.
…owned

upstream-update.sh --check flagged every hunk of the mod menu's
CheatLoaderJvmTest (android/app/src/jvmtest/java/dev/peanuts) and of
ModCheats.java (a Peanuts file in upstream's launcher package) since Part
C. The JVM tests of dev.peanuts join the owned paths, as dev/peanuts does
under main; ModCheats.java goes on the allow-list with its reason.
…hat Peanuts cannot run yet

The copy is of Mistel's branch mncf-1-peanuts-gaps (9280c89), the fixes of the
gaps this PR found; mncf-vendor.sh copies it from Mistel's main once igawa6#11 is merged.

- The evaluator refuses what Peanuts' engine lacks with the spec's
  runtime:unsupported:<part> (run once or for a time, toggle buttons, several
  conditions, ...), and a patch over a run Peanuts' rewriter changed with
  runtime:rewritten, so MncfBuild no longer checks those itself.
- The converter reads notes, EdiZon's sections and two builds of one version
  itself, so MncfConvert passes each Atmosphère file as it is.
- A number set in the game's tab reaches toAtmosphere as the player's value,
  checked: one a cheat cannot take leaves only that cheat out.
…e before the game is built is kept

- A source whose file is not made ready for the build yet, or cannot be read,
  may name no other build: its line said "For another version" with the first
  of none, and the page closed. It now says what it is.
- A file made ready while the pack has no main yet (a game not built) was not
  kept, so the page looked it up again on every redraw and stayed at "Looking
  up its cheats". It is kept now, marked, and made again once the pack has
  its main, so its patterns are searched then.
…ther emulator reads

Export opens one dialog with two ways the cheats leave Peanuts:

- Mistel cheat file, with a Recommended badge and picked: one .mncf (an .mncp
  for several sources) with every cheat for every version, the ones that are
  on and the numbers set, as before.
- ZIP for other emulators: atmosphere/contents/<title ID>/cheats/<build ID>.txt,
  one file for each version, as Atmosphere, Eden, Yuzu and Ryujinx read them
  (MncfExport.zip). Each cheat is lowered with Mistel's toAtmosphere for every
  build its file names, and for the running build from the file made ready
  for it: the code Peanuts runs, else the file's own code for the build, else
  code made from its operations, with the number set in the game's tab. One
  master code a file, the groups between EdiZon's section markers, at most
  127 cheats.

What an Atmosphere file cannot hold (a monitor, toggle buttons, a run once
or for a time, several conditions, a place found by a pattern in a version
whose main Peanuts does not have) and what does not fit the game stay out.
Picking the ZIP shows, before anything is written, how many cheats go in for
which version and which stay out, each with its reason.

CheatLoaderJvmTest: the ZIP's layout, its master, number and sections, what
stays out and why, two builds, and the round trip: the ZIP added again gives
the same cheats with the same code and groups.
…inst the game's main, with stable reasons

The library is now davdxpx/mistel#11 at 797d095: toAtmosphereAll writes
every build of a file, and with a build's main it finds the patterns and
checks every patch and override stub against expect before writing, and
Export.reasons() gives each cheat left out a stable reason (spec section 15).

- MncfExport.zip lowers each source with toAtmosphereAll and gives it the
  game's own main for the build that runs, so a cheat whose place holds other
  code stays out of the ZIP (expect-mismatch); a build the game runs that the
  file does not name is written from the patterns with that main.
- The dialog's list of what stays out words those reasons, never shows them.
- MncfBuild reads the converter's codes instead of its English sentences, and
  maps them to Peanuts' reasons (runtime:unsupported:<part>, ...).
- The dialog's ZIP is the one written, so the game's main is read once.

CheatLoaderJvmTest: a patch made for other code stays out with its reason;
without the game's main a pattern stays out with its own.
… Atmosphère's limits

Mistel's library is copied from its main (76d283c), which has davdxpx/mistel#11 and igawa6#16.

- Each source is lowered in one pass: its own raw code for the build first, code made from its
  operations for a cheat with a number set (the converter's preferCheats).
- With the game's main, the pointer at the base of a pointer path is checked too: one past
  main's end stays out of the ZIP with its reason.
- The ZIP keeps Atmosphère's limits across sources, past which a Switch refuses the whole file:
  one master code of at most 256 words (a master past it stays out, with the cheats of its
  source that need it), at most 127 entries, group entries counted, less than 64 KB, and names
  of at most 63 bytes. What goes past them is named in the dialog.
- Groups are written as the spec writes them: the group's name as an empty entry, and an entry
  of only 20000001 where a cheat in no group follows. Where they would cost cheats, the file has
  no groups.
- Peanuts' own engine is not held to Atmosphère's limits: each master keeps its own code, and a
  source of more than 127 cheats is lowered in parts, so every cheat still runs.
…r names them

The one master entry of a file takes the first master's name, and a group entry its group's
name as it is, cut only to what Atmosphère keeps (spec section 15).
…page, and the ZIP words dmnt's size again

- A cheat refused for a key the reader does not know is refused before its name is read, so it had
  no name, and CheatFile.fromMncf crashed the cheats page on it. It is listed by its id now.
- Since davdxpx/mistel#17 Mistel's converter keeps dmnt's 64 KB itself and leaves such cheats out with
  atmosphere:too-big; the ZIP export had no words for that reason and said the Atmosphère file cannot
  say what the cheat does. CheatLoaderJvmTest's 64 KB check failed with Mistel's main for it.
…/mistel#18)

Copied unchanged with peanuts/scripts/mncf-vendor.sh from Mistel's main 4f7a513, which has spec
section 17 and its readers (davdxpx/mistel#18) and the converter's host limits (davdxpx/mistel#17).
…with one tap, and nothing set lost

A Mistel cheat file can name the address of its newest version (Mistel's spec, section 17). Peanuts
now brings that version to the player when the author publishes one for a game update:

- Asked once per file and host whether it may look there on its own: at most once a day, and when a
  game update stops the file's cheats. Without a yes, only Check for updates on the file's sheet
  looks. The request is the spec's: the address as written, User-Agent mncf-update/1, no cookies, no
  cache, https and at most five https redirects, never an address of the device or its network.
- A new version is taken only as Updates.check says (same game and id, a higher version, the same
  signer) and kept beside the file until the player installs it from the update screen: the notes
  since their version in their language, the cheats it brings and fixed, the numbers that no longer
  fit, the cheats it no longer has. The card says when one is ready, or when a game update stopped
  the cheats and a newer version may know the new build.
- Everything the player set moves by cheat id, through the file's renames (Updates.carry). The merged
  file names cheats by their names, so the state waits in the source's carry.tsv until the new file is
  in the merge (CheatsBridge.merged, ModCheats.install); a cheat this build cannot run keeps its state
  for one that can. Cheats new in the version are on where their file says so.
- The version replaced stays as previous.mncf for Back to version N; the version left is not offered
  again. New and Fixed marks show until the next start.
- A file the player adds by hand that is a version of one they have opens the same screen instead of
  becoming a second copy. A pack with an id is kept under <cheats>/packs/, and its files get new
  versions with it: renamed paths followed, new files added, files it no longer has removed.
- "Peanuts never downloads any" is now "Peanuts never offers any of its own".

Tested: CheatLoaderJvmTest.updates and packUpdates, test_mod_cheats, the overlay check; the whole flow
in the dual-screen emulator with made-up files, with real requests to raw.githubusercontent.com from
Check for updates and from the look on its own.
@davdxpx
davdxpx marked this pull request as ready for review November 25, 2026 18:18
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.

1 participant