2010-10-28 11:00:52 +02:00
|
|
|
#include <string.h>
|
2023-01-01 18:00:14 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2010-10-28 11:00:52 +02:00
|
|
|
#include "GameTitles.h"
|
2010-12-03 19:38:57 +01:00
|
|
|
#include "CSettings.h"
|
|
|
|
#include "usbloader/GameList.h"
|
2011-11-12 19:14:09 +01:00
|
|
|
#include "Channels/channels.h"
|
2011-10-21 20:48:10 +02:00
|
|
|
#include "xml/GameTDB.hpp"
|
2012-01-08 19:24:46 +01:00
|
|
|
#include "svnrev.h"
|
2023-01-01 18:00:14 +01:00
|
|
|
#include "FileOperations/fileops.h"
|
2012-01-08 19:24:46 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
#define VALID_CACHE_REVISION 1280
|
2010-10-28 11:00:52 +02:00
|
|
|
|
|
|
|
CGameTitles GameTitles;
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
bool dbExists = false;
|
|
|
|
|
|
|
|
void CGameTitles::SortTitleList()
|
2010-10-28 11:00:52 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
std::sort(TitleList.begin(), TitleList.end(), [](const GameTitle &x, const GameTitle &y)
|
|
|
|
{ return (strncasecmp(x.GameID, y.GameID, 6) < 0); });
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameTitles::SetGameTitle(const char *id, const char *title, char TitleType, const std::string region, int ParentalRating, int PlayersCount)
|
|
|
|
{
|
|
|
|
if (!id || !title)
|
2011-07-26 00:28:22 +02:00
|
|
|
return;
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < TitleList.size(); ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp(TitleList[i].GameID, id, 6) == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
TitleList[i].Title = title;
|
2023-01-01 18:00:12 +01:00
|
|
|
TitleList[i].Region = region;
|
2023-01-01 18:00:14 +01:00
|
|
|
if (ParentalRating != -1)
|
|
|
|
TitleList[i].ParentalRating = ParentalRating;
|
|
|
|
if (PlayersCount != 1)
|
|
|
|
TitleList[i].PlayersCount = PlayersCount;
|
|
|
|
TitleList[i].TitleType = TitleType;
|
2011-07-26 00:28:22 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GameTitle newTitle;
|
|
|
|
snprintf(newTitle.GameID, sizeof(newTitle.GameID), id);
|
2012-01-08 19:24:46 +01:00
|
|
|
newTitle.Title = title;
|
2023-01-01 18:00:12 +01:00
|
|
|
newTitle.Region = region;
|
2023-01-01 18:00:14 +01:00
|
|
|
newTitle.ParentalRating = ParentalRating;
|
|
|
|
newTitle.PlayersCount = PlayersCount;
|
|
|
|
newTitle.TitleType = TitleType;
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
TitleList.push_back(newTitle);
|
2010-10-28 11:00:52 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
const char *CGameTitles::GetTitle(const char *id, bool allow_access) const
|
2010-10-28 11:00:52 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!id)
|
2011-07-26 00:28:22 +02:00
|
|
|
return "";
|
2010-10-28 11:00:52 +02:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
auto game = std::lower_bound(TitleList.begin(), TitleList.end(), id, [](const GameTitle >, const char *gameid)
|
|
|
|
{ return (strncasecmp(gt.GameID, gameid, 6) < 0); });
|
|
|
|
if (game != TitleList.end())
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp((const char *)game->GameID, (const char *)id, 6) == 0)
|
|
|
|
{
|
|
|
|
if ((dbExists && Settings.TitlesType == TITLETYPE_FROMWIITDB) || game->TitleType == TITLETYPE_MANUAL_OVERRIDE || (Settings.TitlesType == TITLETYPE_FORCED_DISC && game->TitleType == TITLETYPE_FORCED_DISC) || allow_access)
|
|
|
|
return game->Title.c_str();
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2010-10-28 11:00:52 +02:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (int i = 0; i < gameList.size(); ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp((const char *)gameList[i]->id, id, 6) == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
return gameList[i]->title;
|
|
|
|
}
|
2011-06-26 23:38:05 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return "";
|
2010-10-28 11:00:52 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
const char *CGameTitles::GetTitle(const struct discHdr *header) const
|
2010-10-28 11:00:52 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!header)
|
2011-07-26 00:28:22 +02:00
|
|
|
return "";
|
2010-10-28 11:00:52 +02:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
auto game = std::lower_bound(TitleList.begin(), TitleList.end(), (const char *)header->id, [](const GameTitle >, const char *gameid)
|
|
|
|
{ return (strncasecmp(gt.GameID, gameid, 6) < 0); });
|
|
|
|
if (game != TitleList.end())
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp(game->GameID, (const char *)header->id, 6) == 0)
|
|
|
|
{
|
|
|
|
if ((dbExists && Settings.TitlesType == TITLETYPE_FROMWIITDB) || game->TitleType == TITLETYPE_MANUAL_OVERRIDE || (Settings.TitlesType == TITLETYPE_FORCED_DISC && game->TitleType == TITLETYPE_FORCED_DISC))
|
|
|
|
return game->Title.c_str();
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2010-10-28 11:00:52 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return header->title;
|
2010-10-28 11:00:52 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
char CGameTitles::GetTitleType(const char *id) const
|
2023-01-01 18:00:12 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!id)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (u32 i = 0; i < TitleList.size(); ++i)
|
|
|
|
{
|
|
|
|
if (strncasecmp(TitleList[i].GameID, id, 6) == 0)
|
|
|
|
return TitleList[i].TitleType;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *CGameTitles::GetRegion(const char *id) const
|
|
|
|
{
|
|
|
|
if (!id || Settings.TitlesType != TITLETYPE_FROMWIITDB)
|
2023-01-01 18:00:12 +01:00
|
|
|
return "NULL";
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < TitleList.size(); ++i)
|
2023-01-01 18:00:12 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp(TitleList[i].GameID, id, 6) == 0)
|
2023-01-01 18:00:12 +01:00
|
|
|
return TitleList[i].Region.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
return "NULL";
|
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
int CGameTitles::GetParentalRating(const char *id) const
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!id)
|
2011-07-26 00:28:22 +02:00
|
|
|
return -1;
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < TitleList.size(); ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp(TitleList[i].GameID, id, 6) == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
return TitleList[i].ParentalRating;
|
|
|
|
}
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return -1;
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
int CGameTitles::GetPlayersCount(const char *id) const
|
2011-02-02 19:30:15 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!id)
|
2011-07-26 00:28:22 +02:00
|
|
|
return 1;
|
2011-02-02 19:30:15 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < TitleList.size(); ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp(TitleList[i].GameID, id, 6) == 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
return TitleList[i].PlayersCount;
|
|
|
|
}
|
2011-02-02 19:30:15 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return 1;
|
2011-02-02 19:30:15 +01:00
|
|
|
}
|
|
|
|
|
2010-10-28 11:00:52 +02:00
|
|
|
void CGameTitles::SetDefault()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
TitleList.clear();
|
|
|
|
//! Free vector memory
|
|
|
|
std::vector<GameTitle>().swap(TitleList);
|
2010-10-28 11:00:52 +02:00
|
|
|
}
|
2010-12-03 19:38:57 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
void CGameTitles::Reset()
|
2011-02-11 18:41:52 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (TitleList.empty())
|
|
|
|
return;
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < TitleList.size(); ++i)
|
|
|
|
{
|
|
|
|
if (TitleList[i].TitleType < TITLETYPE_MANUAL_OVERRIDE)
|
|
|
|
TitleList[i].TitleType = TITLETYPE_DEFAULT;
|
|
|
|
}
|
|
|
|
}
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
u32 CGameTitles::ReadCachedTitles(const char *path)
|
2011-02-11 18:41:52 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
std::string dbpath(Settings.titlestxt_path);
|
|
|
|
if (dbpath.back() != '/')
|
|
|
|
dbpath += '/';
|
|
|
|
dbpath += "wiitdb.xml";
|
|
|
|
dbExists = CheckFile(dbpath.c_str());
|
|
|
|
|
|
|
|
std::string Cachepath(path);
|
|
|
|
if (Cachepath.back() != '/')
|
2012-01-08 19:24:46 +01:00
|
|
|
Cachepath += '/';
|
|
|
|
Cachepath += "TitlesCache.bin";
|
|
|
|
|
2023-01-01 18:00:12 +01:00
|
|
|
//! Load cached last so that the titles are preloaded before reading list
|
2023-01-01 18:00:14 +01:00
|
|
|
FILE *f = fopen(Cachepath.c_str(), "rb");
|
|
|
|
if (!f)
|
|
|
|
return 0;
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2012-01-08 19:24:46 +01:00
|
|
|
u32 revision = 0;
|
|
|
|
|
|
|
|
fread(&revision, 1, 4, f);
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
if (revision < VALID_CACHE_REVISION)
|
2012-01-08 19:24:46 +01:00
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char LangCode[11];
|
|
|
|
memset(LangCode, 0, sizeof(LangCode));
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
fread(LangCode, 1, 10, f);
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
//! Check if cache has correct language code
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strcmp(LangCode, Settings.db_language) != 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
u32 count = 0;
|
|
|
|
fread(&count, 1, 4, f);
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
std::vector<CacheTitle> CachedList(count);
|
|
|
|
TitleList.resize(count);
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
fread(&CachedList[0], 1, count * sizeof(CacheTitle), f);
|
2011-07-26 00:28:22 +02:00
|
|
|
fclose(f);
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < count; ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
strcpy(TitleList[i].GameID, CachedList[i].GameID);
|
|
|
|
TitleList[i].Title = CachedList[i].Title;
|
2023-01-01 18:00:12 +01:00
|
|
|
TitleList[i].Region = CachedList[i].Region;
|
2011-07-26 00:28:22 +02:00
|
|
|
TitleList[i].ParentalRating = CachedList[i].ParentalRating;
|
|
|
|
TitleList[i].PlayersCount = CachedList[i].PlayersCount;
|
2023-01-01 18:00:14 +01:00
|
|
|
TitleList[i].TitleType = CachedList[i].TitleType;
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return count;
|
2011-02-11 18:41:52 +01:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
void CGameTitles::WriteCachedTitles(const char *path)
|
2011-02-11 18:41:52 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
std::string Cachepath(path);
|
|
|
|
if (Cachepath.back() != '/')
|
2012-01-08 19:24:46 +01:00
|
|
|
Cachepath += '/';
|
|
|
|
Cachepath += "TitlesCache.bin";
|
|
|
|
|
|
|
|
FILE *f = fopen(Cachepath.c_str(), "wb");
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!f)
|
2011-07-26 00:28:22 +02:00
|
|
|
return;
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
CacheTitle Cache;
|
|
|
|
u32 count = TitleList.size();
|
2012-01-08 19:24:46 +01:00
|
|
|
u32 revision = atoi(GetRev());
|
|
|
|
fwrite(&revision, 1, 4, f);
|
2011-07-26 00:28:22 +02:00
|
|
|
fwrite(Settings.db_language, 1, 10, f);
|
|
|
|
fwrite(&count, 1, 4, f);
|
2023-01-01 18:00:14 +01:00
|
|
|
SortTitleList();
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < count; ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
memset(&Cache, 0, sizeof(CacheTitle));
|
2020-12-12 22:35:12 +01:00
|
|
|
snprintf(Cache.GameID, sizeof(Cache.GameID), "%s", TitleList[i].GameID);
|
|
|
|
snprintf(Cache.Title, sizeof(Cache.Title), "%s", TitleList[i].Title.c_str());
|
2023-01-01 18:00:12 +01:00
|
|
|
snprintf(Cache.Region, sizeof(Cache.Region), "%s", TitleList[i].Region.c_str());
|
2011-07-26 00:28:22 +02:00
|
|
|
Cache.ParentalRating = TitleList[i].ParentalRating;
|
|
|
|
Cache.PlayersCount = TitleList[i].PlayersCount;
|
2023-01-01 18:00:14 +01:00
|
|
|
Cache.TitleType = TitleList[i].TitleType;
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
fwrite(&Cache, 1, sizeof(CacheTitle), f);
|
|
|
|
}
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
fclose(f);
|
2011-02-11 18:41:52 +01:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
int CGameTitles::GetMissingTitles(std::vector<std::string> &MissingTitles, std::vector<struct discHdr *> &headerlist)
|
2011-02-11 18:41:52 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < headerlist.size(); ++i)
|
2011-11-12 19:14:09 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
bool found = false;
|
|
|
|
for (u32 n = 0; n < TitleList.size(); ++n)
|
2011-11-12 19:14:09 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (strncasecmp(TitleList[n].GameID, (const char *)headerlist[i]->id, 6) == 0)
|
2011-11-12 19:14:09 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (TitleList[n].TitleType >= TITLETYPE_FROMWIITDB)
|
|
|
|
found = true;
|
2011-11-12 19:14:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!found /*&& !headerlist[i]->tid*/)
|
|
|
|
MissingTitles.push_back((std::string)(const char *)headerlist[i]->id);
|
2011-11-12 19:14:09 +01:00
|
|
|
}
|
2023-01-01 18:00:14 +01:00
|
|
|
return MissingTitles.size();
|
|
|
|
}
|
2011-11-12 19:14:09 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
void CGameTitles::CleanTitles(std::vector<struct discHdr *> &headerlist)
|
|
|
|
{
|
|
|
|
if (TitleList.empty())
|
2011-12-22 23:44:48 +01:00
|
|
|
return;
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 n = 0; n < TitleList.size(); ++n)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
bool isCached = false;
|
|
|
|
for (u32 i = 0; i < headerlist.size(); ++i)
|
|
|
|
{
|
|
|
|
if (strncasecmp(TitleList[n].GameID, (const char *)headerlist[i]->id, 6) == 0)
|
|
|
|
{
|
|
|
|
isCached = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isCached)
|
2011-12-22 23:44:48 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
TitleList.erase(TitleList.begin() + n);
|
2011-12-22 23:44:48 +01:00
|
|
|
n--;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2023-01-01 18:00:14 +01:00
|
|
|
return;
|
2011-02-11 18:41:52 +01:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
void CGameTitles::LoadTitlesFromGameTDB(const char *path)
|
2010-12-03 19:38:57 +01:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!path || Settings.TitlesType != TITLETYPE_FROMWIITDB)
|
2011-07-26 00:28:22 +02:00
|
|
|
return;
|
2010-12-03 19:38:57 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
std::string Filepath(path);
|
|
|
|
if (Filepath.back() != '/')
|
2011-07-26 00:28:22 +02:00
|
|
|
Filepath += '/';
|
|
|
|
Filepath += "wiitdb.xml";
|
2010-12-03 19:38:57 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
std::vector<struct discHdr *> headerlist;
|
|
|
|
if (!gameList.GetGameListHeaders(headerlist, MODE_ALL))
|
|
|
|
return;
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
//! Removed unused cache titles and get the still missing ones
|
2023-01-01 18:00:14 +01:00
|
|
|
CleanTitles(headerlist);
|
2011-07-26 00:28:22 +02:00
|
|
|
std::vector<std::string> MissingTitles;
|
2023-01-01 18:00:14 +01:00
|
|
|
if (!GetMissingTitles(MissingTitles, headerlist))
|
2011-07-26 00:28:22 +02:00
|
|
|
return;
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
GameTDB XML_DB;
|
|
|
|
if (!XML_DB.OpenFile(Filepath.c_str()))
|
|
|
|
return;
|
|
|
|
dbExists = true;
|
2011-02-11 18:41:52 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
XML_DB.SetLanguageCode(Settings.db_language);
|
2010-12-03 19:38:57 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
for (u32 i = 0; i < MissingTitles.size(); ++i)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2023-01-01 18:00:14 +01:00
|
|
|
std::string Title;
|
|
|
|
std::string Region;
|
|
|
|
std::string RatValTxt;
|
|
|
|
int ParentalRating = -1;
|
|
|
|
int PlayersCount = 1;
|
|
|
|
|
|
|
|
if (!XML_DB.GetTitle(MissingTitles[i].c_str(), Title))
|
2011-07-26 00:28:22 +02:00
|
|
|
continue;
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
// This change allows the game to be sorted correctly
|
|
|
|
if (Title.compare("Ōkami") == 0)
|
|
|
|
Title.assign("Okami");
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
int Rating = XML_DB.GetRating(MissingTitles[i].c_str());
|
|
|
|
if (Rating >= 0)
|
|
|
|
{
|
|
|
|
if (XML_DB.GetRatingValue(MissingTitles[i].c_str(), RatValTxt))
|
|
|
|
ParentalRating = GameTDB::ConvertRating(RatValTxt.c_str(), GameTDB::RatingToString(Rating), "PEGI");
|
|
|
|
}
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
int pc = XML_DB.GetPlayers(MissingTitles[i].c_str());
|
|
|
|
if (pc > 0)
|
|
|
|
PlayersCount = pc;
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
|
2023-01-01 18:00:14 +01:00
|
|
|
if (XML_DB.GetRegion(MissingTitles[i].c_str(), Region))
|
|
|
|
SetGameTitle(MissingTitles[i].c_str(), Title.c_str(), TITLETYPE_FROMWIITDB, Region, ParentalRating, PlayersCount);
|
|
|
|
else
|
|
|
|
SetGameTitle(MissingTitles[i].c_str(), Title.c_str(), TITLETYPE_FROMWIITDB, "NULL", ParentalRating, PlayersCount);
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2023-01-01 18:00:12 +01:00
|
|
|
XML_DB.CloseFile();
|
2023-01-01 18:00:14 +01:00
|
|
|
SortTitleList();
|
2010-12-03 19:38:57 +01:00
|
|
|
}
|