mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 10:51:55 +01:00
-added some security checks to list generator
(should fix wbfs partitions) -removed some other unneeded stuff -fixed some wrong code in return to
This commit is contained in:
parent
f365b1080c
commit
cbdd8d7ec8
@ -44,6 +44,8 @@
|
||||
#define RF_NEWS_CHANNEL 0x48414741
|
||||
#define RF_FORECAST_CHANNEL 0x48414641
|
||||
|
||||
Channels ChannelHandle;
|
||||
|
||||
Channels::Channels()
|
||||
{
|
||||
}
|
||||
|
@ -80,4 +80,6 @@ class Channels
|
||||
|
||||
};
|
||||
|
||||
extern Channels ChannelHandle;
|
||||
|
||||
#endif
|
||||
|
@ -27,14 +27,18 @@ ListGenerator m_gameList;
|
||||
|
||||
void ListGenerator::Init(const char *settingsDir, const char *Language)
|
||||
{
|
||||
gameTDB_Path = fmt("%s/wiitdb.xml", settingsDir);
|
||||
CustomTitlesPath = fmt("%s/" CTITLES_FILENAME, settingsDir);
|
||||
gameTDB_Language = Language;
|
||||
if(settingsDir != NULL)
|
||||
{
|
||||
gameTDB_Path = fmt("%s/wiitdb.xml", settingsDir);
|
||||
CustomTitlesPath = fmt("%s/" CTITLES_FILENAME, settingsDir);
|
||||
}
|
||||
if(Language != NULL) gameTDB_Language = Language;
|
||||
}
|
||||
|
||||
void ListGenerator::Cleanup()
|
||||
{
|
||||
this->clear(); //clear gamelist
|
||||
InternalList.clear(); //clear pathlist
|
||||
}
|
||||
|
||||
void ListGenerator::OpenConfigs()
|
||||
@ -53,21 +57,21 @@ void ListGenerator::CloseConfigs()
|
||||
CustomTitles.unload();
|
||||
}
|
||||
|
||||
void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path,
|
||||
const vector<string>& FileTypes, const string& DBName, bool UpdateCache, u32 Color, u32 Magic)
|
||||
void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes,
|
||||
const string& DBName, bool UpdateCache, u32 Color, u32 Magic)
|
||||
{
|
||||
Cleanup();
|
||||
if(UpdateCache)
|
||||
if(!DBName.empty())
|
||||
{
|
||||
gprintf("Force Update Cache\n");
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
CCache(*this, DBName, LOAD);
|
||||
if(!this->empty())
|
||||
return;
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
if(UpdateCache)
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
else
|
||||
{
|
||||
CCache(*this, DBName, LOAD);
|
||||
if(!this->empty())
|
||||
return;
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
}
|
||||
}
|
||||
OpenConfigs();
|
||||
if(Flow == COVERFLOW_USB)
|
||||
@ -78,7 +82,7 @@ const vector<string>& FileTypes, const string& DBName, bool UpdateCache, u32 Col
|
||||
Create_Wii_EXT_List(Path, FileTypes);
|
||||
}
|
||||
else if(Flow == COVERFLOW_CHANNEL)
|
||||
CreateChannelList();
|
||||
Create_Channel_List();
|
||||
else if(DeviceHandle.GetFSType(Device) != PART_FS_WBFS)
|
||||
{
|
||||
if(Flow == COVERFLOW_DML)
|
||||
@ -89,7 +93,7 @@ const vector<string>& FileTypes, const string& DBName, bool UpdateCache, u32 Col
|
||||
Create_Homebrew_List(Path, FileTypes);
|
||||
}
|
||||
CloseConfigs();
|
||||
if(!this->empty()) /* Write a new Cache */
|
||||
if(!this->empty() && !DBName.empty()) /* Write a new Cache */
|
||||
CCache(*this, DBName, SAVE);
|
||||
}
|
||||
|
||||
@ -136,7 +140,6 @@ void ListGenerator::Create_GC_List(const string& Path, const vector<string>& Fil
|
||||
{
|
||||
Name->erase(Name->begin() + Name->find("root"), Name->end());
|
||||
Name->append("sys/boot.bin");
|
||||
gprintf("FST Name: %s\n", Name->c_str());
|
||||
fp = fopen(Name->c_str(), "rb");
|
||||
}
|
||||
if(fp)
|
||||
@ -178,7 +181,7 @@ void ListGenerator::Create_Plugin_List(const string& Path, const vector<string>&
|
||||
void ListGenerator::Create_Homebrew_List(const string& Path, const vector<string>& FileTypes)
|
||||
{
|
||||
dir_discHdr ListElement;
|
||||
GetFiles(Path.c_str(), FileTypes, InternalList, false, 4);
|
||||
GetFiles(Path.c_str(), FileTypes, InternalList, false);
|
||||
for(vector<string>::iterator Name = InternalList.begin(); Name != InternalList.end(); Name++)
|
||||
{
|
||||
if(Name->find("boot.") == string::npos)
|
||||
@ -202,12 +205,12 @@ void ListGenerator::Create_Homebrew_List(const string& Path, const vector<string
|
||||
this->push_back(ListElement);
|
||||
continue;
|
||||
}
|
||||
InternalList.clear();
|
||||
}
|
||||
|
||||
void ListGenerator::CreateChannelList()
|
||||
void ListGenerator::Create_Channel_List()
|
||||
{
|
||||
u32 GameColor = 1;
|
||||
Channels ChannelHandle;
|
||||
dir_discHdr ListElement;
|
||||
ChannelHandle.Init(0, gameTDB_Language, true);
|
||||
for(int i = 0; i < ChannelHandle.Count(); i++)
|
||||
@ -238,6 +241,7 @@ void ListGenerator::CreateChannelList()
|
||||
ListElement.type = TYPE_CHANNEL;
|
||||
this->push_back(ListElement);
|
||||
}
|
||||
InternalList.clear();
|
||||
}
|
||||
|
||||
void ListGenerator::AddISO(const char *GameID, const char *GameTitle, const char *GamePath, u32 GameColor, u8 Type)
|
||||
@ -245,8 +249,8 @@ void ListGenerator::AddISO(const char *GameID, const char *GameTitle, const char
|
||||
dir_discHdr ListElement;
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
ListElement.index = this->size();
|
||||
strncpy(ListElement.id, GameID, 6);
|
||||
strncpy(ListElement.path, GamePath, sizeof(ListElement.path));
|
||||
if(GameID != NULL) strncpy(ListElement.id, GameID, 6);
|
||||
if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path));
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal();
|
||||
string CustomTitle = CustomTitles.getString("TITLES", ListElement.id);
|
||||
if(gameTDB.IsLoaded())
|
||||
@ -260,7 +264,7 @@ void ListGenerator::AddISO(const char *GameID, const char *GameTitle, const char
|
||||
}
|
||||
if(CustomTitle.size() > 0)
|
||||
mbstowcs(ListElement.title, CustomTitle.c_str(), 63);
|
||||
else
|
||||
else if(GameTitle != NULL)
|
||||
mbstowcs(ListElement.title, GameTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
void Create_Plugin_List(const string& Path, const vector<string>& FileTypes,
|
||||
u32 Color, u32 Magic);
|
||||
void Create_Homebrew_List(const string& Path, const vector<string>& FileTypes);
|
||||
void CreateChannelList();
|
||||
void Create_Channel_List();
|
||||
void AddISO(const char *GameID, const char *GameTitle, const char *GamePath, u32 GameColor, u8 Type);
|
||||
bool IsFileSupported(const char *File, const vector<string>& FileTypes);
|
||||
void OpenConfigs();
|
||||
|
@ -2169,8 +2169,10 @@ bool CMenu::_loadChannelList(void)
|
||||
|
||||
if(Nand::Instance()->EmulationEnabled() || disable_emu)
|
||||
{
|
||||
string cacheDir(fmt("%s/%s_channels.db", m_cacheDir.c_str(), disable_emu ? "nand" : DeviceName[currentPartition]));
|
||||
bool updateCache = disable_emu ? true : m_cfg.getBool(_domainFromView(), "update_cache");
|
||||
string cacheDir;
|
||||
if(!disable_emu)
|
||||
cacheDir = fmt("%s/%s_channels.db", m_cacheDir.c_str(), DeviceName[currentPartition]);
|
||||
bool updateCache = m_cfg.getBool(_domainFromView(), "update_cache");
|
||||
vector<string> NullVector;
|
||||
m_gameList.CreateList(m_current_view, currentPartition, std::string(),
|
||||
NullVector, cacheDir, updateCache);
|
||||
|
@ -18,8 +18,6 @@ static inline int loopNum(int i, int s)
|
||||
int currentChannelIndex = -1;
|
||||
int amountOfChannels = -1;
|
||||
|
||||
Channels m_channels;
|
||||
|
||||
const CMenu::SOption CMenu::_exitTo[5] = {
|
||||
{ "def", L"Default" },
|
||||
{ "menu", L"System Menu" },
|
||||
@ -78,29 +76,22 @@ void CMenu::_showConfig4(void)
|
||||
|
||||
wstringEx channelName = m_loc.getWString(m_curLanguage, "disabled", L"Disabled");
|
||||
|
||||
string langCode = m_loc.getString(m_curLanguage, "gametdb_code", "EN");
|
||||
|
||||
Nand::Instance()->Disable_Emu();
|
||||
|
||||
m_channels.Init(0x00010001, langCode, true);
|
||||
amountOfChannels = m_channels.Count();
|
||||
ChannelHandle.Init(0, m_loc.getString(m_curLanguage, "gametdb_code", "EN"), true);
|
||||
amountOfChannels = ChannelHandle.Count();
|
||||
|
||||
string currentChanId = m_cfg.getString("GENERAL", "returnto" );
|
||||
if (currentChanId.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < amountOfChannels; i++)
|
||||
{
|
||||
if (currentChanId == m_channels.GetId(i))
|
||||
if (currentChanId == ChannelHandle.GetId(i))
|
||||
{
|
||||
channelName = custom_titles.getWString("TITLES", currentChanId, titles.getWString("TITLES", currentChanId, m_channels.GetName(i)));
|
||||
channelName = custom_titles.getWString("TITLES", currentChanId, titles.getWString("TITLES", currentChanId, ChannelHandle.GetName(i)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!neek2o() && m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
|
||||
Nand::Instance()->Enable_Emu();
|
||||
|
||||
m_btnMgr.setText(m_config4LblReturnToVal, channelName);
|
||||
}
|
||||
|
||||
@ -139,7 +130,7 @@ int CMenu::_config4(void)
|
||||
if (currentChannelIndex == -1)
|
||||
m_cfg.remove("GENERAL", "returnto");
|
||||
else
|
||||
m_cfg.setString("GENERAL", "returnto", m_channels.GetId(currentChannelIndex));
|
||||
m_cfg.setString("GENERAL", "returnto", ChannelHandle.GetId(currentChannelIndex));
|
||||
_showConfig4();
|
||||
}
|
||||
else if (m_btnMgr.selected(m_config4BtnReturnToM))
|
||||
@ -149,11 +140,13 @@ int CMenu::_config4(void)
|
||||
if (currentChannelIndex == -1)
|
||||
m_cfg.remove("GENERAL", "returnto");
|
||||
else
|
||||
m_cfg.setString("GENERAL", "returnto", m_channels.GetId(currentChannelIndex));
|
||||
m_cfg.setString("GENERAL", "returnto", ChannelHandle.GetId(currentChannelIndex));
|
||||
_showConfig4();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!neek2o() && m_current_view == COVERFLOW_CHANNEL && m_cfg.getBool("NAND", "disable", true) == false)
|
||||
Nand::Instance()->Enable_Emu();
|
||||
_hideConfig4();
|
||||
return change;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ static void _extractBannerTitle(Banner *bnr, int language)
|
||||
|
||||
static Banner *_extractChannelBnr(const u64 chantitle)
|
||||
{
|
||||
return Channels::GetBanner(chantitle);
|
||||
return ChannelHandle.GetBanner(chantitle);
|
||||
}
|
||||
|
||||
static Banner *_extractBnr(dir_discHdr *hdr)
|
||||
@ -1027,7 +1027,6 @@ static const char systems[11] = { 'C', 'E', 'F', 'J', 'L', 'M', 'N', 'P', 'Q', '
|
||||
|
||||
void CMenu::_launchChannel(dir_discHdr *hdr)
|
||||
{
|
||||
Channels channel;
|
||||
u32 gameIOS = 0;
|
||||
string id = string(hdr->id);
|
||||
|
||||
@ -1122,7 +1121,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
|
||||
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
|
||||
Nand::Instance()->Enable_Emu();
|
||||
}
|
||||
gameIOS = channel.GetRequestedIOS(gameTitle);
|
||||
gameIOS = ChannelHandle.GetRequestedIOS(gameTitle);
|
||||
if(!emu_disabled)
|
||||
Nand::Instance()->Disable_Emu();
|
||||
if(_loadIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED)
|
||||
|
Loading…
Reference in New Issue
Block a user