From c78e60ed468ada685498961cafc774f3965222aa Mon Sep 17 00:00:00 2001 From: etabeta78 Date: Tue, 2 Jun 2015 11:41:14 +0200 Subject: [PATCH] cheat: improved cheat support for games in softlist. XML cheats for home systems should now be stored in a subfolder (or a compressed archive), named after the software list, inside the cheatpath. this allows for loading cheats for consoles / home computers without interfering with arcade cheats when games have identical shortnames. For instance, loading Galaga in NES allows now to use its specific cheats even if a galaga.xml is available in the arcade cheat.7z (previously you'd get an error due to the arcade cheat referring to a cpu not present in the NES). [Pugsy, Fabio Priuli] --- src/emu/cheat.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/emu/cheat.c b/src/emu/cheat.c index fc19df4e83c..c5cce57604b 100644 --- a/src/emu/cheat.c +++ b/src/emu/cheat.c @@ -1134,25 +1134,30 @@ void cheat_manager::reload() m_lastline = 0; m_disabled = false; - // load the cheat file, MESS will load a crc32.xml ( eg. 01234567.xml ) - // and MAME will load gamename.xml + // load the cheat file, if it's a system that has a software list then try softlist_name/shortname.xml first, + // if it fails to load then try to load via crc32 - basename/crc32.xml ( eg. 01234567.xml ) image_interface_iterator iter(machine().root_device()); for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) if (image->exists()) { - // if we are loading through software lists, try to load shortname.xml + // if we are loading through a software list, try to load softlist_name/shortname.xml + // this allows the coexistence of arcade cheats with cheats for home conversions which + // have the same shortname if (image->software_entry() != NULL) { - load_cheats(image->basename()); + std::string filename; + strprintf(filename, "%s%s%s", image->software_list_name(), PATH_SEPARATOR, image->basename()); + load_cheats(filename.c_str()); break; } + // else we are loading outside the software list, try to load machine_basename/crc32.xml else { UINT32 crc = image->crc(); if (crc != 0) { std::string filename; - strprintf(filename,"%08X", crc); + strprintf(filename, "%s%s%08X", machine().basename(), PATH_SEPARATOR, crc); load_cheats(filename.c_str()); break; }