diff options
author | 2017-04-08 20:43:15 -0400 | |
---|---|---|
committer | 2017-04-10 20:47:40 -0400 | |
commit | afa6a83728be7339b7f9e76c719736665af611a2 (patch) | |
tree | b4d5c4abc6a41367736cbd57619165f10eeb4b61 /src/emu/hashfile.cpp | |
parent | 5671a5eeab28af55588c0d0e722fd164a89e5f0c (diff) |
Changes to make get_default_card_software() less stupid
The goals with this change is to make get_default_card_software() a bit more standalone by making it a const method that does not mutate the state of the device_image_interface. This is done by passing in a small structure that encapsulates the minimum of information that get_default_card_software() needs.
This also eliminates the need for device_image_interface::open_image_file()
I agree with Sarayan that get_default_card_software() is terrible and needs to ultimately go away. This is a small step in that direction.
Lastly, I don't care for the name of get_default_card_software_hook (or get_default_card_software() for that matter). If anybody has better ideas, let me know.
Diffstat (limited to 'src/emu/hashfile.cpp')
-rw-r--r-- | src/emu/hashfile.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/emu/hashfile.cpp b/src/emu/hashfile.cpp index 6cd51f9997d..0d540f6f1ec 100644 --- a/src/emu/hashfile.cpp +++ b/src/emu/hashfile.cpp @@ -21,10 +21,10 @@ hashfile_lookup -------------------------------------------------*/ -bool read_hash_config(device_image_interface &image, const char *sysname, std::string &result) +static bool read_hash_config(const char *hash_path, const util::hash_collection &hashes, const char *sysname, std::string &result) { /* open a file */ - emu_file file(image.device().mconfig().options().hash_path(), OPEN_FLAG_READ); + emu_file file(hash_path, OPEN_FLAG_READ); if (file.open(sysname, ".hsi") != osd_file::error::NONE) { return false; @@ -37,8 +37,8 @@ bool read_hash_config(device_image_interface &image, const char *sysname, std::s { // Do search by CRC32 and SHA1 std::string query = "/hashfile/hash["; - auto crc = image.hash().internal_string().substr(1,8); - auto sha1 = image.hash().internal_string().substr(10, 40); + auto crc = hashes.internal_string().substr(1,8); + auto sha1 = hashes.internal_string().substr(10, 40); query += "@crc32='" + crc + "' and @sha1='" + sha1 + "']/extrainfo"; pugi::xpath_node_set tools = doc.select_nodes(query.c_str()); for (pugi::xpath_node_set::const_iterator it = tools.begin(); it != tools.end(); ++it) @@ -61,16 +61,16 @@ bool read_hash_config(device_image_interface &image, const char *sysname, std::s return false; } -bool hashfile_extrainfo(device_image_interface &image, std::string &result) + +bool hashfile_extrainfo(const char *hash_path, const game_driver &driver, const util::hash_collection &hashes, std::string &result) { /* now read the hash file */ - image.crc(); - int drv = driver_list::find(image.device().mconfig().gamedrv()); + int drv = driver_list::find(driver); int compat, open = drv; bool hashfound; do { - hashfound = read_hash_config(image, driver_list::driver(open).name, result); + hashfound = read_hash_config(hash_path, hashes, driver_list::driver(open).name, result); // first check if there are compatible systems compat = driver_list::compatible_with(open); // if so, try to open its hashfile @@ -87,3 +87,16 @@ bool hashfile_extrainfo(device_image_interface &image, std::string &result) while (!hashfound && open != -1); return hashfound; } + + + +bool hashfile_extrainfo(device_image_interface &image, std::string &result) +{ + return hashfile_extrainfo( + image.device().mconfig().options().hash_path(), + image.device().mconfig().gamedrv(), + image.hash(), + result); +} + + |