From 777e0394d0d8090607828c6dd29694c41b8fd19b Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Sat, 4 Dec 2010 07:36:23 +0000 Subject: [PATCH] *Fixed crash when trying to set alternate dol from game disc in game settings --- source/language/gettext.c | 1 + source/menu/menu_disclist.cpp | 4 ++-- source/prompts/DiscBrowser.cpp | 20 ++++++++++---------- source/settings/menus/FlyingButtonsMenu.cpp | 2 +- source/settings/menus/IndGameLoadSM.cpp | 12 ++++++------ source/usbloader/apploader.c | 4 ++-- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/source/language/gettext.c b/source/language/gettext.c index 9b327684..2487a2ad 100644 --- a/source/language/gettext.c +++ b/source/language/gettext.c @@ -233,6 +233,7 @@ bool gettextLoadLanguage(const char* langFile) } const char *gettext(const char *msgid) { + if(!msgid) return NULL; MSG *msg = findMSG(hash_string(msgid)); if (msg && msg->msgstr) return msg->msgstr; return msgid; diff --git a/source/menu/menu_disclist.cpp b/source/menu/menu_disclist.cpp index fb548de9..fee839f4 100644 --- a/source/menu/menu_disclist.cpp +++ b/source/menu/menu_disclist.cpp @@ -1383,7 +1383,7 @@ int MenuDiscList() if (Settings.quickboot == ON) //quickboot game { - if (alternatedol == ON) + if (alternatedol == 2) { /* Open dol File and check exist */ sprintf(nipple, "%s%s.dol", Settings.dolpath, IDfull); @@ -1443,7 +1443,7 @@ int MenuDiscList() if (choice == 1) { - if (alternatedol == ON) + if (alternatedol == 2) { /* Open dol File and check exist */ sprintf(nipple, "%s%s.dol", Settings.dolpath, IDfull); diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index 81d694f1..cc2a0fea 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -71,27 +71,27 @@ int DiscBrowse(const char * GameID, char * alternatedname, int alternatedname_si WBFS_CloseDisc(disc); u32 discfilecount = fstbuffer[0].filelen; - u32 dolfilecount = 0; OptionList options3; for (u32 i = 0; i < discfilecount; i++) { - //don't add files that aren't .dol to the list - int len = (strlen(fstfiles(fstbuffer, i))); - if (fstfiles(fstbuffer, i)[len - 4] == '.' && fstfiles(fstbuffer, i)[len - 3] == 'd' && fstfiles(fstbuffer, i)[len - 2] == 'o' - && fstfiles(fstbuffer, i)[len - 1] == 'l') + const char * filename = fstfiles(fstbuffer, i); + const char * fileext = NULL; + + if(filename) + fileext = strrchr(filename, '.'); + + if (fileext && strcasecmp(fileext, ".dol") == 0) { options3.SetName(i, "%i", i); options3.SetValue(i, fstfiles(fstbuffer, i)); - //options3.SetName(i, fstfiles(fst, i)); - - dolfilecount++; } } - gprintf("\n%i alt dols found", dolfilecount); - if (dolfilecount <= 0) + + gprintf("\n%i alt dols found", options3.GetLength()+1); + if (options3.GetLength() <= 0) { WindowPrompt(tr( "ERROR" ), tr( "No DOL file found on disc." ), tr( "OK" )); free(fstbuffer); diff --git a/source/settings/menus/FlyingButtonsMenu.cpp b/source/settings/menus/FlyingButtonsMenu.cpp index b11b47cd..15bc8db1 100644 --- a/source/settings/menus/FlyingButtonsMenu.cpp +++ b/source/settings/menus/FlyingButtonsMenu.cpp @@ -152,7 +152,7 @@ void FlyingButtonsMenu::SetPageIndicators() for(int i = 0; i < IndicatorCount; ++i) { PageindicatorImg.push_back(new GuiImage(PageindicatorImgData)); - PageindicatorTxt.push_back(new GuiText(fmt("%i", i), 22, ( GXColor ) {0, 0, 0, 255})); + PageindicatorTxt.push_back(new GuiText(fmt("%i", i+1), 22, ( GXColor ) {0, 0, 0, 255})); PageIndicatorBtn.push_back(new GuiButton(PageindicatorImgData->GetWidth(), PageindicatorImgData->GetHeight())); PageIndicatorBtn[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); PageIndicatorBtn[i]->SetPosition(270-IndicatorCount*35+35*i, 400); diff --git a/source/settings/menus/IndGameLoadSM.cpp b/source/settings/menus/IndGameLoadSM.cpp index 8c3cfce0..c0b71969 100644 --- a/source/settings/menus/IndGameLoadSM.cpp +++ b/source/settings/menus/IndGameLoadSM.cpp @@ -82,8 +82,8 @@ static const char * ParentalText[5] = static const char * AlternateDOLText[] = { trNOOP( "OFF" ), + trNOOP( "Select a DOL from Game" ), trNOOP( "Load From SD/USB" ), - trNOOP( "Select a DOL" ) }; IndGameLoadSM::IndGameLoadSM(const char * GameID) @@ -216,7 +216,7 @@ void IndGameLoadSM::SetOptionValues() Options->SetValue(Idx++, "%s", tr( AlternateDOLText[GameConfig.loadalternatedol] )); //! Settings: Select DOL Offset - if(GameConfig.loadalternatedol != 2) + if(GameConfig.loadalternatedol != 1) Options->SetValue(Idx++, tr("Not required")); else { @@ -327,12 +327,12 @@ int IndGameLoadSM::GetMenuInternal() //! Settings: Alternate DOL else if (ret == ++Idx) { - if (--GameConfig.loadalternatedol < 0) // 0->2->1->0 - GameConfig.loadalternatedol = 2; + if (++GameConfig.loadalternatedol > 2) + GameConfig.loadalternatedol = 0; } - //! Settings: Select DOL Offset - else if (ret == ++Idx && GameConfig.loadalternatedol == 2) + //! Settings: Select DOL Offset from Game + else if (ret == ++Idx && GameConfig.loadalternatedol == 1) { char filename[10]; snprintf(filename, 7, "%s", GameConfig.id); diff --git a/source/usbloader/apploader.c b/source/usbloader/apploader.c index bec60858..40a19ca2 100644 --- a/source/usbloader/apploader.c +++ b/source/usbloader/apploader.c @@ -118,7 +118,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected *entry = appldr_final(); /** Load alternate dol if set **/ - if (alternatedol == 1) + if (alternatedol == 2) { wip_reset_counter(); void *dolbuffer = NULL; @@ -132,7 +132,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected if (dolbuffer) free(dolbuffer); } - else if (alternatedol == 2) + else if (alternatedol == 1) { wip_reset_counter(); FST_ENTRY *fst = (FST_ENTRY *) *(u32 *) 0x80000038;