Repository navigation
player: reset a ROM's memory, and read the game's identity through the packer - #53
Conversation
The identity reader looked the game up by its key name in the packed JSON, and VPE now writes package keys in camelCase. It unpacks the component's packable instead, so it reads whatever names the packer writes.
[Medium impact] The changes affect PinMAME game identity and saved memory for selected games. The PR appears safe to merge, with a non-blocking request for tests around saved memory. Findings
SummaryAdds a selected-game action that backs up a ROM's saved memory and prevents its NVRAM from being imported again from Visual PinMAME.
No runtime tests were run.
|
| internal static string ResetNvram(string romId) | ||
| { | ||
| if (string.IsNullOrEmpty(romId) || romId.Any(c => !(c is >= 'a' and <= 'z' or >= '0' and <= '9' or '_'))) { | ||
| throw new ArgumentException("The selected table has an invalid PinMAME ROM name.", nameof(romId)); | ||
| } | ||
| var dataFolder = DataFolder; | ||
| var backupFolder = Path.Combine(dataFolder, "nvram-backups", romId); | ||
| Directory.CreateDirectory(backupFolder); | ||
| // Keep the import opt-out beside the active save so clearing backups does not re-enable import. | ||
| using (File.Open(NvramImportOptOut(dataFolder, romId), FileMode.OpenOrCreate, FileAccess.Write)) { } | ||
| var backup = Path.Combine(backupFolder, $"{DateTime.UtcNow:yyyyMMdd-HHmmss}-{Guid.NewGuid():N}.nv"); | ||
| try { | ||
| File.Move(Path.Combine(dataFolder, "nvram", romId + ".nv"), backup); |
There was a problem hiding this comment.
ResetNvram changes saved game files but has no automated tests. Add temporary-folder tests for backup bytes, repeated resets, a missing save, and the import opt-out. Also check that resetting one ROM leaves another ROM's files alone. These checks would catch changes that silently lose a backup or bring back memory the user just cleared.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Two changes for the player.
Back up and reset a ROM's memory. Settings > Plugins > PinMAME > Selected game gets "Back up and reset ROM memory". With the table closed in every VPE window, it moves the ROM's
.nvfile tonvram-backups/<rom>and no longer imports that ROM's NVRAM from Visual PinMAME, so the next run starts with fresh memory. The reset applies to every table that uses the same ROM. The README says how to restore the backup.Read the game's identity through the packer. The identity reader looked the game up by its key name in the packed JSON, and VPE now writes package keys in camelCase. It unpacks the component's packable instead, so it reads whatever names the packer writes.