Keep saves safe in Import Saves and Quit, draw no traced game art, and recompile the game for a new processor.

Import Saves: the saves folder picked in the dialog imports what waits in it (it had made the folder's README the
save); the save backed up is the one the game would load, in runtime/fs_host.c save_recover's order, so an interrupted
commit's only copy is kept, and the rest of the commit journal moves into the backup instead of being deleted; the
imported save goes into place before the old one is deleted, which comes back if that fails; another NX2navi install's
finished commit counts as its save. Tests cover each.

Quit waits while the game writes a save, as Restart does: the game runs on under the menu, and closing the window
finishes only a commit that has begun. The VSync row says "in use: Immediate" when VSync On falls back to tearing, and
its default follows the device profile (cfg_default). Without the game's textures the menu's divider is a plain line
and diamond of its own, not a tracing of the game's ornament.

make_game.py: the compile key holds the processor's features (cpu_tag), so a game folder moved to a PC without AVX2
compiles again instead of crashing; the main thread gets 16 MiB of stack with GNU ld too; any error waits for the
RomFS image, so its .part file is not cut short. The launcher tests use a neutral title id; tools/menu_preview.cpp
has cfg_default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-08 03:57:02 -05:00
parent 8daedbd806
commit f57a327a86
11 changed files with 166 additions and 93 deletions

View File

@@ -1046,8 +1046,8 @@ class SavesTest(unittest.TestCase):
def test_save_folders_found(self):
plain = self.files(self.tmp / 'backup', {'save.dat': b'1', 'option.dat': b'2'})
self.assertEqual(saves.find_save(plain)[0], plain)
emu = self.files(self.tmp / 'emu', {'0000000000000000/' + 'a' * 32 + '/0100F2C0115B6000/save.dat': b'1'})
self.assertEqual(saves.find_save(emu)[0].name, '0100F2C0115B6000')
emu = self.files(self.tmp / 'emu', {'0000000000000000/' + 'a' * 32 + '/0100000000010000/save.dat': b'1'})
self.assertEqual(saves.find_save(emu)[0].name, '0100000000010000')
other = self.files(self.tmp / 'other', {'profile/save/' + 'b' * 32 + '/save.dat': b'1', 'ocarina.exe': b''})
self.assertEqual(saves.find_save(other)[0].name, 'b' * 32)
self.assertEqual(saves.find_save(other / 'profile')[0].name, 'b' * 32)
@@ -1072,7 +1072,7 @@ class SavesTest(unittest.TestCase):
def test_import_from_the_saves_folder(self):
d = saves.ensure_saves_dir(self.game)
self.assertIsNone(saves.waiting(self.game)[0]) # README.txt alone is no save
self.files(d, {'emu/0000000000000000/' + 'c' * 32 + '/0100F2C0115B6000/save.dat': b'emu'})
self.files(d, {'emu/0000000000000000/' + 'c' * 32 + '/0100000000010000/save.dat': b'emu'})
self.assertIsNotNone(saves.waiting(self.game)[0])
r = saves.import_save(self.game, log=lambda m: None)
self.assertIsNone(r['backup']) # there was no save yet
@@ -1087,6 +1087,58 @@ class SavesTest(unittest.TestCase):
self.assertEqual((r['backup'] / 'save.dat').read_bytes(), b'emu')
self.assertIsNone(saves.waiting(self.game)[0])
def test_picking_the_saves_folder_takes_what_waits_there(self):
acct = saves.account_dir(self.game)
self.files(acct, {'save.dat': b'mine'})
d = saves.ensure_saves_dir(self.game)
with self.assertRaises(saves.SaveError): # README.txt alone is no save
saves.import_save(self.game, d, log=lambda m: None)
self.assertEqual((acct / 'save.dat').read_bytes(), b'mine')
self.files(d, {'save.dat': b'put there'})
r = saves.import_save(self.game, d, log=lambda m: None)
self.assertEqual(sorted(p.name for p in acct.iterdir()), ['save.dat']) # not README.txt or a backup
self.assertEqual((acct / 'save.dat').read_bytes(), b'put there')
self.assertEqual((r['backup'] / 'save.dat').read_bytes(), b'mine')
def test_an_interrupted_commit_is_backed_up(self):
# runtime/fs_host.c save_recover: with no account folder and no finished commit, save-tx/new is the save, and
# without it save-tx/old; the import keeps that only copy
for half in ('new', 'old'):
with self.subTest(half=half):
shutil.rmtree(self.game, ignore_errors=True)
self.game.mkdir()
acct = saves.account_dir(self.game)
tx = self.game / 'profile' / 'save-tx'
self.files(tx, {f'{half}/save.dat': b'only copy'})
src = self.files(self.tmp / f'mine-{half}', {'save.dat': b'imported'})
r = saves.import_save(self.game, src, log=lambda m: None)
self.assertEqual((acct / 'save.dat').read_bytes(), b'imported')
self.assertEqual((r['backup'] / 'save.dat').read_bytes(), b'only copy')
self.assertEqual((r['backup'] / 'save-tx' / half / 'save.dat').read_bytes(), b'only copy')
def test_a_failed_swap_keeps_the_old_save(self):
acct = saves.account_dir(self.game)
self.files(acct, {'save.dat': b'old'})
src = self.files(self.tmp / 'mine', {'save.dat': b'imported'})
real = saves.os.replace
def replace(a, b):
if Path(a).name == 'import': # the imported save going into place: antivirus holds a file
raise PermissionError(5, 'Access is denied')
return real(a, b)
saves.os.replace = replace
try:
with self.assertRaises(PermissionError):
saves.import_save(self.game, src, log=lambda m: None)
finally:
saves.os.replace = real
self.assertEqual((acct / 'save.dat').read_bytes(), b'old')
def test_another_installs_finished_commit_is_its_save(self):
other = self.files(self.tmp / 'other', {'profile/save/' + 'b' * 32 + '/save.dat': b'older',
'profile/save-tx/ready-2/save.dat': b'newest'})
self.assertEqual(saves.find_save(other)[0].name, 'ready-2')
def test_refusals(self):
acct = saves.account_dir(self.game)
self.files(acct, {'save.dat': b'1'})