For people who use two partitions (FAT32 and WBFS), wiitdb.zip won't be overwritten anymore when they update. The file is now loaded and saved as wiitdb_(partition).zip, so you can switch partitions and keep titles/infos. If wiitdb_(partition).zip is not found it loads wiitdb.zip. When exiting settings, the partition is now reloaded only when needed. WiiTDB update should work again for people who own more than 240 games. Fixed a rare crash that could be issue 1083.

This commit is contained in:
lustar.mii 2009-11-22 16:42:53 +00:00
parent b70af2d71d
commit c97c887775
8 changed files with 59 additions and 49 deletions

View File

@ -146,6 +146,13 @@ int MenuCheck() {
USBDevice_Init();
SDCard_Init();
}
// open database if needed, load titles if needed
OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true);
// titles.txt loaded after database to override database titles with custom titles
//snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path);
//cfg_parsefile(pathname, &title_set);
return menu;
}

View File

@ -175,8 +175,8 @@ struct block downloadfile(const char *url) {
//Form a nice request header to send to the webserver
char* headerformat = "GET %s HTTP/1.0\r\nHost: %s\r\nReferer: %s\r\nUser-Agent: USBLoaderGX r%s\r\n\r\n";;
char header[strlen(headerformat) + strlen(domain) + strlen(path)+strlen(url)];
sprintf(header, headerformat, path, domain, url, GetRev());
char header[strlen(headerformat) + strlen(path) + strlen(domain) + strlen(domain)];
sprintf(header, headerformat, path, domain, domain, GetRev());
//Do the request and get the response
send_message(connection, header);

View File

@ -57,6 +57,7 @@ extern u8 shutdown;
extern u8 reset;
extern u8 mountMethod;
extern struct discHdr *dvdheader;
extern char game_partition[6];
/*** Extern functions ***/
extern void ResumeGui();
@ -2640,8 +2641,8 @@ int ProgressUpdateWindow() {
char wiitdbpathtmp[200];
struct block file = downloadfile(XMLurl);
if (file.data != NULL) {
snprintf(wiitdbpath, sizeof(wiitdbpath), "%swiitdb.zip", Settings.titlestxt_path);
snprintf(wiitdbpathtmp, sizeof(wiitdbpathtmp), "%swiitmp.zip", Settings.titlestxt_path);
snprintf(wiitdbpath, sizeof(wiitdbpath), "%swiitdb_%s.zip", Settings.titlestxt_path,game_partition);
snprintf(wiitdbpathtmp, sizeof(wiitdbpathtmp), "%swiitmp_%s.zip", Settings.titlestxt_path,game_partition);
rename(wiitdbpath,wiitdbpathtmp);
pfile = fopen(wiitdbpath, "wb");
fwrite(file.data,1,file.size,pfile);
@ -3020,8 +3021,8 @@ int ProgressUpdateWindow() {
file = downloadfile(XMLurl);
if (file.data != NULL) {
subfoldercreate(Settings.titlestxt_path);
snprintf(wiitdbpath, sizeof(wiitdbpath), "%swiitdb.zip", Settings.titlestxt_path);
snprintf(wiitdbpathtmp, sizeof(wiitdbpathtmp), "%swiitmp.zip", Settings.titlestxt_path);
snprintf(wiitdbpath, sizeof(wiitdbpath), "%swiitdb_%s.zip", Settings.titlestxt_path,game_partition);
snprintf(wiitdbpathtmp, sizeof(wiitdbpathtmp), "%swiitmp_%s.zip", Settings.titlestxt_path,game_partition);
rename(wiitdbpath,wiitdbpathtmp);
pfile = fopen(wiitdbpath, "wb");
fwrite(file.data,1,file.size,pfile);
@ -3058,8 +3059,8 @@ int ProgressUpdateWindow() {
struct block file = downloadfile(XMLurl);
if (file.data != NULL) {
subfoldercreate(Settings.titlestxt_path);
snprintf(wiitdbpath, sizeof(wiitdbpath), "%swiitdb.zip", Settings.titlestxt_path);
snprintf(wiitdbpathtmp, sizeof(wiitdbpathtmp), "%swiitmp.zip", Settings.titlestxt_path);
snprintf(wiitdbpath, sizeof(wiitdbpath), "%swiitdb_%s.zip", Settings.titlestxt_path,game_partition);
snprintf(wiitdbpathtmp, sizeof(wiitdbpathtmp), "%swiitmp_%s.zip", Settings.titlestxt_path,game_partition);
rename(wiitdbpath,wiitdbpathtmp);
FILE *pfile = fopen(wiitdbpath, "wb");
fwrite(file.data,1,file.size,pfile);

View File

@ -42,13 +42,11 @@ int showGameInfo(char *ID) {
HaltGui();//put this first to try to get rid of the code dump caused by loading this window at the same time as loading images from the SD card
mainWindow->SetState(STATE_DISABLED);
ResumeGui();
//load the xml shit
bool databaseopened = true;
//OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, false, true); // open file, do not load titles, keep in memory
if (databaseopened) {
LoadGameInfoFromXML(ID, Settings.db_language);
//CloseXMLDatabase();
bool showmeminfo = false;
@ -711,17 +709,19 @@ int showGameInfo(char *ID) {
wifiY-=20;
gameinfoWindow.Append(wifiTxt[i]);
}
if (strcmp(gameinfo.wififeatures[1],"") != 0) {
if (strcmp(gameinfo.wififeatures[1],"") !=0) {
snprintf(linebuf, sizeof(linebuf), "%s:",tr("WiFi Features"));
wifiTxt[0] = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
wifiTxt[0]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
wifiTxt[0]->SetPosition(205,200+wifiY);
gameinfoWindow.Append(wifiTxt[0]);
}
} else {
strcpy(linebuf,"");
}
wifiTxt[0] = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
wifiTxt[0]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
wifiTxt[0]->SetPosition(205,200+wifiY);
gameinfoWindow.Append(wifiTxt[0]);
//synopsis
int pagesize=12;
if (strcmp(gameinfo.synopsis,"") != 0) {
if (strcmp(gameinfo.synopsis,"") !=0) {
snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.synopsis);
synopsisTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
synopsisTxt->SetMaxWidth(350,GuiText::WRAP);
@ -1112,7 +1112,7 @@ void MemInfoPrompt()
void build_XML_URL(char *XMLurl, int XMLurlsize) {
__Menu_GetEntries(1);
// NET_BUFFER_SIZE in http.c needs to be set to size of XMLurl + 40
// NET_BUFFER_SIZE in http.c needs to be set to size of XMLurl + headerformat
char url[3540];
char filename[10];
snprintf(url,sizeof(url),"http://wiitdb.com/wiitdb.zip?LANG=%s&ID=", Settings.db_language);

View File

@ -19,13 +19,13 @@
#include "cfg.h"
#include "usbloader/partition_usbloader.h"
#include "usbloader/utils.h"
#include "xml/xml.h"
#define MAXOPTIONS 13
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
extern bool Database(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool keepopen);
extern void titles_default();
/*** Extern variables ***/
@ -73,6 +73,9 @@ int MenuSettings()
strcpy(opt_lang,Settings.language_path);
// backup title override setting
int opt_override = Settings.titlesOverride;
// backup partition index
u8 settingspartitionold = Settings.partition;
enum
{
@ -2052,23 +2055,30 @@ int MenuSettings()
w.SetEffect(EFFECT_FADE, -20);
while (w.GetEffect()>0) usleep(50);
// if partition has changed, Reinitialize it
PartInfo pinfo = partitions.pinfo[Settings.partition];
load_from_fat = pinfo.fs_type == FS_TYPE_FAT32;
if (Settings.partition != settingspartitionold) {
WBFS_Close();
WBFS_OpenPart(load_from_fat, Settings.partition, partitions.pentry[Settings.partition].sector, partitions.pentry[Settings.partition].size, (char *) &game_partition);
}
// if language has changed, reload titles
char opt_langnew[100];
strcpy(opt_langnew,Settings.language_path);
int opt_overridenew = Settings.titlesOverride;
if (strcmp(opt_lang,opt_langnew) || (opt_override != opt_overridenew && Settings.titlesOverride==1))
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, false, Settings.titlesOverride==1?true:false, true); // open file, reload titles, keep in memory
// disable titles from database
bool reloaddatabasefile = false;
if (strcmp(opt_lang,opt_langnew) || (opt_override != opt_overridenew && Settings.titlesOverride==1) || (Settings.partition != settingspartitionold)) {
if (Settings.partition != settingspartitionold) {
reloaddatabasefile = true;
CloseXMLDatabase();
}
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, reloaddatabasefile, Settings.titlesOverride==1?true:false, true); // open file, reload titles, keep in memory
}
// disable titles from database if setting has changed
if (opt_override != opt_overridenew && Settings.titlesOverride==0)
titles_default();
// Reinitialize WBFS partition, it might have changed
PartInfo pinfo = partitions.pinfo[Settings.partition];
load_from_fat = pinfo.fs_type == FS_TYPE_FAT32;
WBFS_Close();
WBFS_OpenPart(load_from_fat, Settings.partition, partitions.pentry[Settings.partition].sector, partitions.pentry[Settings.partition].size, (char *) &game_partition);
HaltGui();
mainWindow->RemoveAll();

View File

@ -5,7 +5,6 @@
#include <sys/stat.h>
#include <ctype.h>
#include <ogcsys.h>
#include <mxml.h>
#include "language/gettext.h"
#include "listfiles.h"
@ -1771,15 +1770,6 @@ void CFG_Load(void) {
if (CONF_GetArea() == CONF_AREA_AUS)
strcpy(Settings.db_language,"AU");
// open database if needed, load titles if needed
OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true);
// titles.txt loaded after database to override database titles with custom titles
//took out this titles.txt shit because it is useless now. teh xml has all the titles in it
//snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path);
//cfg_parsefile(pathname, &title_set);
// cfg_parsearg(argc, argv);
// if GUI language is set to default Settings.language_path needs to remain "notset" (if the detected setting was kept detection wouldn't work next time)
if (langisdefault)
sprintf(Settings.language_path, "notset");

View File

@ -11,18 +11,18 @@ Load game information from XML - Lustar
//#include "cfg.h"
//#include "xml.h"
extern struct SSettings Settings; // for loader GX
extern void title_set(char *id, char *title);
extern char* trimcopy(char *dest, char *src, int size);
extern char game_partition[6];
/* config */
static bool xmldebug = false;
static char xmlcfg_filename[100] = "wiitdb.zip";
static char xmlcfg_filename[100] = "wiitdb";
static int xmlmaxsize = 1572864;
extern struct SSettings Settings; // for loader GX
extern void title_set(char *id, char *title);
extern char* trimcopy(char *dest, char *src, int size);
struct gameXMLinfo gameinfo;
struct gameXMLinfo gameinfo_reset;
@ -72,9 +72,11 @@ bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool op
char pathname[200];
snprintf(pathname, sizeof(pathname), "%s", xmlfilepath);
if (xmlfilepath[strlen(xmlfilepath) - 1] != '/') snprintf(pathname, sizeof(pathname), "%s/",pathname);
snprintf(pathname, sizeof(pathname), "%s%s", pathname, xmlcfg_filename);
snprintf(pathname, sizeof(pathname), "%s%s_%s.zip", pathname, xmlcfg_filename, game_partition);
if (openfile) opensuccess = OpenXMLFile(pathname);
if (!opensuccess) {
snprintf(pathname, sizeof(pathname), "%s", xmlfilepath);
if (xmlfilepath[strlen(xmlfilepath) - 1] != '/') snprintf(pathname, sizeof(pathname), "%s/",pathname);
snprintf(pathname, sizeof(pathname), "%swiitdb.zip", pathname);
if (openfile) opensuccess = OpenXMLFile(pathname);
}
@ -387,7 +389,7 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
char langcode[100] = "";
if (!strcmp(langtxt,""))
langtxt = GetLangSettingFromGame(gameid);
strcpy(langcode,ConvertLangTextToCode(langtxt));
strlcpy(langcode,ConvertLangTextToCode(langtxt),sizeof(langcode));
/* reset all game info */
gameinfo = gameinfo_reset;

View File

@ -36,7 +36,7 @@ EOF
echo >&2
rev_new=`expr $rev_new + 1`
rev_date=`date +%Y%m%d%k%M`
rev_date=`date +%Y%m%d%H%M -u`
cat <<EOF > ./HBC/META.XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>