diff --git a/out/boot.dol b/out/boot.dol index 4107cf6b..297b9552 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/list/ListGenerator.cpp b/source/list/ListGenerator.cpp index bef93945..86adbbbf 100644 --- a/source/list/ListGenerator.cpp +++ b/source/list/ListGenerator.cpp @@ -28,9 +28,12 @@ ListGenerator m_cacheList; Config CustomTitles; GameTDB gameTDB; +Config romNamesDB; +string platformName; +string pluginsDataDir; dir_discHdr ListElement; -void ListGenerator::Init(const char *settingsDir, const char *Language) +void ListGenerator::Init(const char *settingsDir, const char *Language, const char *plgnsDataDir) { if(settingsDir != NULL) { @@ -38,6 +41,7 @@ void ListGenerator::Init(const char *settingsDir, const char *Language) CustomTitlesPath = fmt("%s/" CTITLES_FILENAME, settingsDir); } if(Language != NULL) gameTDB_Language = Language; + if(plgnsDataDir != NULL) pluginsDataDir = fmt("%s", plgnsDataDir); } void ListGenerator::Clear(void) @@ -179,36 +183,6 @@ static void Add_GameCube_Game(char *FullPath) } } -/* add plugin rom, song, or video to the list */ -const char *RomTitle = NULL; -static void Add_Plugin_Game(char *FullPath) -{ - memset((void*)&ListElement, 0, sizeof(dir_discHdr)); - - strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1); - memcpy(ListElement.id, "PLUGIN", 6); - - RomTitle = strrchr(FullPath, '/') + 1; - *strrchr(RomTitle, '.') = '\0'; - - char PluginMagicWord[9]; - memset(PluginMagicWord, 0, sizeof(PluginMagicWord)); - strncpy(PluginMagicWord, fmt("%08x", m_cacheList.Magic), 8); - char CustomTitle[64]; - memset(CustomTitle, 0, sizeof(CustomTitle)); - strncpy(CustomTitle, CustomTitles.getString(PluginMagicWord, RomTitle).c_str(), 63); - if(strlen(CustomTitle) > 0) - mbstowcs(ListElement.title, CustomTitle, 63); - else - mbstowcs(ListElement.title, RomTitle, 63); - Asciify(ListElement.title); - - ListElement.settings[0] = m_cacheList.Magic; //Plugin magic - ListElement.casecolor = m_cacheList.Color; - ListElement.type = TYPE_PLUGIN; - m_cacheList.push_back(ListElement); -} - /* add homebrew boot.dol to the list */ static void Add_Homebrew_Dol(char *FullPath) { @@ -278,6 +252,105 @@ static void Create_Channel_List(bool realNAND) } } +/* add plugin rom, song, or video to the list. */ +static void Add_Plugin_Game(char *FullPath) +{ + /* Get roms's title without the extra ()'s or []'s */ + string ShortName = m_plugin.GetRomName(FullPath); + //gprintf("shortName=%s\n", ShortName.c_str()); + + /* get rom's ID */ + string romID = ""; + if(gameTDB.IsLoaded()) + { + /* Get 6 character unique romID (from Screenscraper.fr) using shortName. if fails then use CRC or CD serial to get romID */ + romID = m_plugin.GetRomId(FullPath, m_cacheList.Magic, romNamesDB, pluginsDataDir.c_str(), platformName.c_str(), ShortName.c_str()); + } + if(romID.empty()) + romID = "PLUGIN"; + //gprintf("romID=%s\n", romID.c_str()); + + /* add rom to list */ + memset((void*)&ListElement, 0, sizeof(dir_discHdr)); + + strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1); + strncpy(ListElement.id, romID.c_str(), 6); + + /* Get titles - Rom filename, custom title, and database xml title */ + const char *RomFilename = strrchr(FullPath, '/') + 1; + *strrchr(RomFilename, '.') = '\0'; + + char CustomTitle[64]; + memset(CustomTitle, 0, sizeof(CustomTitle)); + strncpy(CustomTitle, CustomTitles.getString(m_plugin.PluginMagicWord, RomFilename).c_str(), 63); + + const char *gameTDB_Title = NULL; + if(gameTDB.IsLoaded() && strlen(CustomTitle) == 0) + gameTDB.GetName(ListElement.id, gameTDB_Title); + + /* set the roms title */ + if(strlen(CustomTitle) > 0) + mbstowcs(ListElement.title, CustomTitle, 63); + else if(gameTDB_Title != NULL && gameTDB_Title[0] != '\0') + mbstowcs(ListElement.title, gameTDB_Title, 63); + else + mbstowcs(ListElement.title, RomFilename, 63); + Asciify(ListElement.title); + + ListElement.settings[0] = m_cacheList.Magic; //Plugin magic + ListElement.casecolor = m_cacheList.Color; + ListElement.type = TYPE_PLUGIN; + m_cacheList.push_back(ListElement); +} + +/* note: scummvm games have list generator in plugin.cpp */ +void ListGenerator::CreateRomList(Config &platform_cfg, const string& romsDir, const vector& FileTypes, const string& DBName, bool UpdateCache) +{ + Clear(); + if(!DBName.empty()) + { + if(UpdateCache) + fsop_deleteFile(DBName.c_str()); + else + { + CCache(*this, DBName, LOAD); + if(!this->empty()) + return; + fsop_deleteFile(DBName.c_str()); + } + } + + if(platform_cfg.loaded()) + { + /* Search platform.ini to find plugin magic to get platformName */ + platformName = platform_cfg.getString("PLUGINS", m_plugin.PluginMagicWord); + if(!platformName.empty()) + { + /* check COMBINED for platform names that mean the same system just different region */ + /* some platforms have different names per country (ex. Genesis/Megadrive) */ + /* but we use only one platform name for both */ + string newName = platform_cfg.getString("COMBINED", platformName); + if(newName.empty()) + platform_cfg.remove("COMBINED", platformName); + else + platformName = newName; + + /* Load rom names and crc database */ + romNamesDB.load(fmt("%s/%s/%s.ini", pluginsDataDir.c_str(), platformName.c_str(), platformName.c_str())); + /* Load platform name.xml database to get game's info using the gameID */ + gameTDB.OpenFile(fmt("%s/%s/%s.xml", pluginsDataDir.c_str(), platformName.c_str(), platformName.c_str())); + if(gameTDB.IsLoaded()) + gameTDB.SetLanguageCode(gameTDB_Language.c_str()); + } + } + CustomTitles.load(CustomTitlesPath.c_str()); + GetFiles(romsDir.c_str(), FileTypes, Add_Plugin_Game, false, 30);//wow 30 subfolders! really? + CloseConfigs(); + romNamesDB.unload(); + if(!this->empty() && !DBName.empty()) /* Write a new Cache */ + CCache(*this, DBName, SAVE); +} + void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector& FileTypes, const string& DBName, bool UpdateCache) { @@ -314,8 +387,6 @@ void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const v { if(Flow == COVERFLOW_GAMECUBE) GetFiles(Path.c_str(), FileTypes, Add_GameCube_Game, true);// true means to look for a folder (/root) - else if(Flow == COVERFLOW_PLUGIN) - GetFiles(Path.c_str(), FileTypes, Add_Plugin_Game, false, 30);//wow 30 subfolders! really? else if(Flow == COVERFLOW_HOMEBREW) GetFiles(Path.c_str(), FileTypes, Add_Homebrew_Dol, false); } diff --git a/source/list/ListGenerator.hpp b/source/list/ListGenerator.hpp index 46785d67..98ad8383 100644 --- a/source/list/ListGenerator.hpp +++ b/source/list/ListGenerator.hpp @@ -27,6 +27,7 @@ #include "loader/wbfs.h" #include "loader/disc.h" #include "gui/GameTDB.hpp" +#include "plugin/plugin.hpp" using namespace std; @@ -34,8 +35,9 @@ class ListGenerator : public vector { public: void createSFList(u8 maxBtns, Config &m_sourceMenuCfg, const string& sourceDir); - void Init(const char *settingsDir, const char *Language); + void Init(const char *settingsDir, const char *Language, const char *plgnsDataDir); void Clear(); + void CreateRomList(Config &platform_cfg, const string& romsDir, const vector& FileTypes, const string& DBName, bool UpdateCache); void CreateList(u32 Flow, u32 Device, const string& Path, const vector& FileTypes, const string& DBName, bool UpdateCache); u32 Color; diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index bb1316f4..1ed4e3ec 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -369,7 +369,7 @@ bool CMenu::init() } /* Init gametdb and custom titles for game list making */ - m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()); + m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str(), m_pluginDataDir.c_str()); /* Init the onscreen pointer */ m_aa = 3; @@ -2434,7 +2434,7 @@ bool CMenu::_loadPluginList() for(u8 i = 0; m_plugin.PluginExist(i); ++i) { u32 Magic = m_plugin.getPluginMagic(i); - if(!m_plugin.GetEnableStatus(m_cfg, Magic)) + if(!m_plugin.GetEnableStatus(m_cfg, Magic))// m_plugin.PluginMagicWord is set here. continue; int romsPartition = m_plugin.GetRomPartition(i); if(romsPartition < 0) @@ -2479,29 +2479,31 @@ bool CMenu::_loadPluginList() } else { - string gameDir(fmt("%s:/%s", DeviceName[currentPartition], romDir)); - string cacheDir(fmt("%s/%s_%s.db", m_listCacheDir.c_str(), DeviceName[currentPartition], m_plugin.PluginMagicWord)); - if(updateCache || !fsop_FileExist(cacheDir.c_str())) + string romsDir(fmt("%s:/%s", DeviceName[currentPartition], romDir)); + string cachedListFile(fmt("%s/%s_%s.db", m_listCacheDir.c_str(), DeviceName[currentPartition], m_plugin.PluginMagicWord)); + if(updateCache || !fsop_FileExist(cachedListFile.c_str())) cacheCovers = true; vector FileTypes = stringToVector(m_plugin.GetFileTypes(i), '|'); m_cacheList.Color = m_plugin.GetCaseColor(i); m_cacheList.Magic = Magic; - m_cacheList.CreateList(COVERFLOW_PLUGIN, currentPartition, gameDir, FileTypes, cacheDir, updateCache); + m_cacheList.CreateRomList(m_platform, romsDir, FileTypes, cachedListFile, updateCache); for(vector::iterator tmp_itr = m_cacheList.begin(); tmp_itr != m_cacheList.end(); tmp_itr++) m_gameList.push_back(*tmp_itr); } } else { - Config scummvm; vector scummvmList; + Config scummvm; if(!scummvm.load(fmt("%s/scummvm.ini", m_pluginsDir.c_str()))) { if(!scummvm.load(fmt("%s/scummvm/scummvm.ini", m_pluginsDir.c_str()))) scummvm.load(fmt("%s:/apps/scummvm/scummvm.ini", DeviceName[currentPartition])); } - //also check if in apps folder - scummvmList = m_plugin.ParseScummvmINI(scummvm, DeviceName[currentPartition], Magic); + string platformName = ""; + if(m_platform.loaded())/* convert plugin magic to platform name */ + platformName = m_platform.getString("PLUGINS", m_plugin.PluginMagicWord); + scummvmList = m_plugin.ParseScummvmINI(scummvm, DeviceName[currentPartition], Magic, m_pluginDataDir.c_str(), platformName.c_str()); for(vector::iterator tmp_itr = scummvmList.begin(); tmp_itr != scummvmList.end(); tmp_itr++) m_gameList.push_back(*tmp_itr); scummvmList.clear(); diff --git a/source/menu/menu_config_adv.cpp b/source/menu/menu_config_adv.cpp index fbbfa1b2..84f07043 100644 --- a/source/menu/menu_config_adv.cpp +++ b/source/menu/menu_config_adv.cpp @@ -176,7 +176,7 @@ int CMenu::_configAdv(void) _hideConfigAdv(); if(m_curLanguage != prevLanguage) { - m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()); + m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str(), m_pluginDataDir.c_str()); fsop_deleteFolder(m_listCacheDir.c_str());// delete cache lists folder and remake it so all lists update. fsop_MakeFolder(m_listCacheDir.c_str()); m_refreshGameList = true; diff --git a/source/menu/menu_gameinfo.cpp b/source/menu/menu_gameinfo.cpp index 60a19484..5da0c45b 100644 --- a/source/menu/menu_gameinfo.cpp +++ b/source/menu/menu_gameinfo.cpp @@ -343,7 +343,8 @@ void CMenu::_textGameInfo(void) snprintf(platformName, sizeof(platformName), "%s", m_platform.getString("PLUGINS", m_plugin.PluginMagicWord).c_str()); if(strstr(platformName, "multi") != NULL)// if multi platform ie. vbagx, genplusgx, get file extension { - char ext[4]; + return; //if multi found (old platform.ini) + /*char ext[4]; if(strstr(GameHdr->path, ".zip") != NULL)// if zip get internal filename extension { ZipFile zFile(GameHdr->path); @@ -354,7 +355,7 @@ void CMenu::_textGameInfo(void) { strcpy(ext, strrchr(GameHdr->path, '.') + 1); } - snprintf(platformName, sizeof(platformName), "%s", m_platform.getString("ext", ext).c_str()); + snprintf(platformName, sizeof(platformName), "%s", m_platform.getString("ext", ext).c_str());*/ } if(strlen(platformName) == 0) return;// no platform name found to match plugin magic # @@ -369,17 +370,12 @@ void CMenu::_textGameInfo(void) snprintf(platformName, sizeof(platformName), "%s", newName.c_str()); /* Get roms's title without the extra ()'s or []'s */ - string ShortName = m_plugin.GetRomName(GameHdr); + string ShortName = m_plugin.GetRomName(GameHdr->path); - /* Get 6 character unique romID (from Screenscraper.fr) using shortName. if fails then use CRC or CD serial */ - string romID; - if(!ShortName.empty()) - romID = m_plugin.GetRomId(GameHdr, m_pluginDataDir.c_str(), platformName, ShortName); - else - return;// no romID. short name and crc/serial not found - - /* copy romID to be used as gameID to get game info from xml */ - strncpy(GameID, romID.c_str(), 6); + /* copy rom ID to be used as gameID to get game info from xml */ + strncpy(GameID, GameHdr->id, 6); + if(strcasecmp(GameID, "PLUGIN") == 0) + return; /* Load platform name.xml database to get game's info using the gameID */ gametdb.OpenFile(fmt("%s/%s/%s.xml", m_pluginDataDir.c_str(), platformName, platformName)); diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index 6f5066a6..457977d5 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -227,18 +227,22 @@ const vector &Plugin::GetEnabledPlugins(Config &cfg, u8 *num) } /* notes: "description" is used as the title because it basically is the title */ -/* the [GameDomain] is used as the path even thought it isn't the path */ +/* the [GameDomain] is used as the path even though it isn't the path */ /* the [GameDomain] is usually short without any '/' */ /* in scummvm.ini the path is the path without the exe or main app file added on */ -vector Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 Magic) +vector Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 Magic, const char *datadir, const char *platform) { gprintf("Parsing scummvm.ini\n"); - vector gameHeader; + vector ScummvmList; if(!ini.loaded()) - return gameHeader; + return ScummvmList; - const char *GameDomain = ini.firstDomain().c_str(); + Config m_crc; + if(platform != NULL) + m_crc.load(fmt("%s/%s/%s.ini", datadir, platform, platform)); dir_discHdr ListElement; + + const char *GameDomain = ini.firstDomain().c_str(); while(1) { if(strlen(GameDomain) < 2) @@ -251,18 +255,35 @@ vector Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 GameDomain = ini.nextDomain().c_str(); continue; } + + /* get shortName */ + char *cp; + if((cp = strstr(GameName, " (")) != NULL) + *cp = '\0'; + + /* get Game ID */ + string GameID = "PLUGIN"; + // Get game ID based on GameName + if(m_crc.loaded() && m_crc.has(platform, GameName)) + { + vector searchID = m_crc.getStrings(platform, GameName, '|'); + if(!searchID[0].empty()) + GameID = searchID[0]; + } + memset((void*)&ListElement, 0, sizeof(dir_discHdr)); - memcpy(ListElement.id, PLUGIN, 6); + memcpy(ListElement.id, GameID.c_str(), 6); ListElement.casecolor = Plugins.back().caseColor; mbstowcs(ListElement.title, GameName, 63); strncpy(ListElement.path, GameDomain, sizeof(ListElement.path)); - gprintf("Found: %s\n", GameDomain); + //gprintf("Found: %s\n", GameDomain); ListElement.settings[0] = Magic; ListElement.type = TYPE_PLUGIN; - gameHeader.push_back(ListElement); + ScummvmList.push_back(ListElement); GameDomain = ini.nextDomain().c_str(); } - return gameHeader; + m_crc.unload(); + return ScummvmList; } vector Plugin::CreateArgs(const char *device, const char *path, @@ -292,31 +313,15 @@ vector Plugin::CreateArgs(const char *device, const char *path, } /* Give the current game a simplified name */ -string Plugin::GetRomName(const dir_discHdr *gameHeader) +string Plugin::GetRomName(const char *FullPath) { - if(strrchr(gameHeader->path, '/') != NULL) - { - // Remove extension - string FullName = strrchr(gameHeader->path, '/') + 1; - FullName = FullName.substr(0, FullName.find_last_of(".")); + string FullName = strrchr(FullPath, '/') + 1; + FullName = FullName.substr(0, FullName.find_last_of(".")); - // Remove common suffixes and replace unwanted characters. - string ShortName = FullName.substr(0, FullName.find(" (")).substr(0, FullName.find(" [")); - replace(ShortName.begin(), ShortName.end(), '_', ' '); - return ShortName; - } - else - { - // ScummVM - char title[64]; - wcstombs(title, gameHeader->title, 63); - title[63] = '\0'; - - string FullName = title; - - string ShortName = FullName.substr(0, FullName.find(" (")).substr(0, FullName.find(" [")); - return ShortName; - } + // Remove common suffixes and replace unwanted characters. + string ShortName = FullName.substr(0, FullName.find(" (")).substr(0, FullName.find(" [")); + replace(ShortName.begin(), ShortName.end(), '_', ' '); + return ShortName; } /* Get serial from PS1 header's iso (Borrowed from Retroarch with a few c++ changes)*/ @@ -460,39 +465,26 @@ void GetSerialMegaCD(const char *path, string &Serial) * and can also be used for snapshots/cartriges/discs images. * The Game ID is a 6 length alphanumerical value. It's screenscraper ID filled with 'A' letter. */ -string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char *platform, const string &name) +string Plugin::GetRomId(char *romPath, u32 Magic, Config &m_crc, const char *datadir, const char *platform, const char *name) { - string GameID; - string CRC_Serial(12, '*'); + string GameID = ""; + string CRC_Serial(12, '*');// 12 digits because of ps1 and megaCD serials which can be 10 or more digits - // Load a platform list that is used to identify the current game. + // Search a platform list that is used to identify the current game. // It contains a default filename(preferably No-intro without region flag), the GameID and then all known CRC32/serials. // filename=GameID|crc1|crc2|etc... // For example in SUPERNES.ini : Super Aleste=2241AA|5CA5781B|... - Config m_crc; - m_crc.unload(); - m_crc.load(fmt("%s/%s/%s.ini", datadir, platform, platform) ); - - bool found_name = false; - found_name = m_crc.has(platform, name.c_str()); // Get game ID based on the filename - if(found_name) + if(m_crc.has(platform, name)) { - vector searchID = m_crc.getStrings(platform, name.c_str(), '|'); - - if(!searchID.empty()) - { + vector searchID = m_crc.getStrings(platform, name, '|'); + if(!searchID[0].empty()) GameID = searchID[0]; - } - - m_crc.unload(); } // Get game ID by CRC or serial else { - m_crc.unload(); - char crc_string[9]; crc_string[0] = '\0'; u32 buffer; @@ -501,15 +493,15 @@ string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char // For arcade games use the crc zip if(strcasestr(platform, "ARCADE") || strcasestr(platform, "CPS") || !strncasecmp(platform, "NEOGEO", 6)) { - strncpy(crc_string, fmt("%08x", crc32file(gameHeader->path)), 8); + strncpy(crc_string, fmt("%08x", crc32file(romPath)), 8); crc_string[8] = '\0'; } else { // Look for for the file's crc inside the archive - if(strstr(gameHeader->path, ".zip") != NULL) + if(strstr(romPath, ".zip") != NULL) { - infile.open(gameHeader->path, ios::binary); + infile.open(romPath, ios::binary); infile.seekg(0x0e, ios::beg); infile.read((char*)&buffer, 8); infile.close(); @@ -522,19 +514,19 @@ string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char // CRC calculation would take up to 30 seconds! if(!strcasecmp(platform, "MEGACD")) { - GetSerialMegaCD(gameHeader->path, CRC_Serial); + GetSerialMegaCD(romPath, CRC_Serial); } else if(!strcasecmp(platform, "PS1")) { bool found; - found = GetSerialPS1(gameHeader->path, CRC_Serial, 0); + found = GetSerialPS1(romPath, CRC_Serial, 0); if(!found) - GetSerialPS1(gameHeader->path, CRC_Serial, 1); + GetSerialPS1(romPath, CRC_Serial, 1); } else if(!strcasecmp(platform, "ATARIST")) { - s8 pos = m_plugin.GetPluginPosition(gameHeader->settings[0]); + s8 pos = m_plugin.GetPluginPosition(Magic); string FileTypes = m_plugin.GetFileTypes(pos); string path; @@ -543,7 +535,7 @@ string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char { Config m_cfg; m_cfg.unload(); - m_cfg.load(fmt("%s", gameHeader->path) ); + m_cfg.load(fmt("%s", romPath) ); path = m_cfg.getString("Floppy", "szDiskAFileName", ""); m_cfg.unload(); @@ -555,7 +547,7 @@ string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char } else { - path = gameHeader->path; + path = romPath; } if (path.find(".zip") != std::string::npos) @@ -575,13 +567,13 @@ string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char } else if(!strcasecmp(platform, "DOS")) { - s8 pos = m_plugin.GetPluginPosition(gameHeader->settings[0]); + s8 pos = m_plugin.GetPluginPosition(Magic); string FileTypes = m_plugin.GetFileTypes(pos); if(strcasestr(FileTypes.c_str(), ".conf")) { ifstream inputFile; - inputFile.open(gameHeader->path, std::ios::binary); + inputFile.open(romPath, std::ios::binary); string line; std::string dospath; std::string temp; @@ -646,17 +638,22 @@ string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char }// Just check CRC for a regular file on any other system. else { - strncpy(crc_string, fmt("%08x", crc32file(gameHeader->path)), 8); + strncpy(crc_string, fmt("%08x", crc32file(romPath)), 8); crc_string[8] = '\0'; } } } if(crc_string[0] != '\0') + { CRC_Serial = crc_string; + //gprintf("romCRC=%s\n", crc_string); + } - // Now search ID with the obtained CRC/Serial - // Just add 2 pipes in the pattern to be sure we don't find a crc instead of ID + /****************************************************************/ + /* Now search ID with the obtained CRC/Serial */ + /* Just add 2 pipes in the pattern to be sure we don't find a crc instead of ID */ + /* note crc's are 8 digits but serials can be more, thats why we use idx for CRC_Serial length */ size_t idx; idx=CRC_Serial.length(); CRC_Serial.insert(0, "|").insert(idx+1, "|"); @@ -667,24 +664,19 @@ string Plugin::GetRomId(const dir_discHdr *gameHeader, const char *datadir, char while(getline(inputFile, line)) { - // FIXME ahem, ignore case... - if (line.find(lowerCase( CRC_Serial ), 0) != string::npos || line.find(upperCase( CRC_Serial ), 0) != string::npos) + // FIXME ahem, ignore case... - line could contain a mix of lower and upper case. if so this 'if' will not work + if(line.find(lowerCase( CRC_Serial ), 0) != string::npos || line.find(upperCase( CRC_Serial ), 0) != string::npos) { unsigned first = (line.find('=') + 1); - unsigned last = line.find_first_of('|'); + unsigned last = line.find_first_of('|');// we could just use first + 6 since all ID's are 6 digits string ID = line.substr (first,last-first); - if(ID.empty()) - { - return ""; - } - - GameID = ID; + if(!ID.empty()) + GameID = ID; break; } } } - return GameID; } diff --git a/source/plugin/plugin.hpp b/source/plugin/plugin.hpp index 58a7a55d..856ac55f 100644 --- a/source/plugin/plugin.hpp +++ b/source/plugin/plugin.hpp @@ -65,8 +65,8 @@ public: const char *GetDolName(u32 magic); const char *GetCoverFolderName(u32 magic); const char *GetRomDir(u8 pos); - string GetRomName(const dir_discHdr *gameHeader); - string GetRomId(const dir_discHdr *gameHeader,const char *datadir, char *platform, const string &name); + string GetRomName(const char *FullPath); + string GetRomId(char *romPath, u32 Magic, Config &m_crc, const char *datadir, const char *platform, const char *name); int GetRomPartition(u8 pos); const string& GetFileTypes(u8 pos); wstringEx GetPluginName(u8 pos); @@ -85,7 +85,7 @@ public: vector CreateArgs(const char *device, const char *path, const char *title, const char *loader, u32 title_len_no_ext, u32 magic); - vector ParseScummvmINI(Config &ini, const char *Device, u32 Magic); + vector ParseScummvmINI(Config &ini, const char *Device, u32 Magic, const char *datadir, const char *platform); string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums); char PluginMagicWord[9]; diff --git a/wiiflow.pnps b/wiiflow.pnps index 30bdab08..79d2c902 100644 --- a/wiiflow.pnps +++ b/wiiflow.pnps @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file