-general code cleanup

-added crc32 buffer and limited checked filesize to 1gb
This commit is contained in:
fix94.1 2012-11-18 13:40:26 +00:00
parent f61d9dac0c
commit f57507c4f3
20 changed files with 281 additions and 282 deletions

View File

@ -73,7 +73,6 @@ protected:
bool reducedVol;
int returnVal;
int gameSelected;
dir_discHdr dvdheader;
float Brightness;
int MaxAnimSteps;

View File

@ -35,7 +35,7 @@ static u64 folderSize = 0;
u64 FolderProgressBytes;
// return false if the file doesn't exist
bool fsop_GetFileSizeBytes(char *path, size_t *filesize) // for me stats st_size report always 0 :(
bool fsop_GetFileSizeBytes(const char *path, size_t *filesize) // for me stats st_size report always 0 :(
{
FILE *f;
size_t size = 0;
@ -73,11 +73,9 @@ u64 fsop_GetFolderBytes(const char *source)
while((pent = readdir(pdir)) != NULL)
{
// Skip it
if(strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0)
if(pent->d_name[0] == '.')
continue;
snprintf(newSource, sizeof(newSource), "%s/%s", source, pent->d_name);
// If it is a folder... recurse...
if(fsop_DirExist(newSource))
bytes += fsop_GetFolderBytes(newSource);
@ -138,7 +136,7 @@ bool fsop_DirExist(const char *path)
}
void fsop_MakeFolder(char *path)
void fsop_MakeFolder(const char *path)
{
if(fsop_DirExist(path))
return;
@ -168,9 +166,9 @@ static void *thread_CopyFileReader()
return 0;
}
bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void *spinner_data)
bool fsop_CopyFile(const char *source, const char *target, progress_callback_t spinner, void *spinner_data)
{
gprintf("Creating file: %s\n",target);
gprintf("Creating file: %s\n", target);
int err = 0;
u32 size;
@ -282,7 +280,7 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
/*
Recursive copyfolder
*/
static bool doCopyFolder(char *source, char *target, progress_callback_t spinner, void *spinner_data)
static bool doCopyFolder(const char *source, const char *target, progress_callback_t spinner, void *spinner_data)
{
DIR *pdir;
struct dirent *pent;
@ -290,20 +288,15 @@ static bool doCopyFolder(char *source, char *target, progress_callback_t spinner
bool ret = true;
// If target folder doesn't exist, create it !
if(!fsop_DirExist(target))
{
gprintf("Creating directory: %s\n",target);
fsop_MakeFolder(target);
}
fsop_MakeFolder(target);
pdir = opendir(source);
while((pent = readdir(pdir)) != NULL && ret == true)
{
// Skip it
if(strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0)
if(pent->d_name[0] == '.')
continue;
snprintf(newSource, sizeof(newSource), "%s/%s", source, pent->d_name);
snprintf(newTarget, sizeof(newTarget), "%s/%s", target, pent->d_name);
@ -319,7 +312,7 @@ static bool doCopyFolder(char *source, char *target, progress_callback_t spinner
return ret;
}
bool fsop_CopyFolder(char *source, char *target, progress_callback_t spinner, void *spinner_data)
bool fsop_CopyFolder(const char *source, const char *target, progress_callback_t spinner, void *spinner_data)
{
gprintf("DML game USB->SD job started!\n");
@ -328,6 +321,11 @@ bool fsop_CopyFolder(char *source, char *target, progress_callback_t spinner, vo
return doCopyFolder(source, target, spinner, spinner_data);
}
static inline void fsop_silentDelete(const char *source)
{
remove(source);
}
void fsop_deleteFolder(const char *source)
{
DIR *pdir;
@ -339,27 +337,32 @@ void fsop_deleteFolder(const char *source)
while((pent = readdir(pdir)) != NULL)
{
// Skip it
if(strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0)
if(pent->d_name[0] == '.')
continue;
snprintf(newSource, sizeof(newSource), "%s/%s", source, pent->d_name);
// If it is a folder... recurse...
if(fsop_DirExist(newSource))
{
closedir(pdir);
fsop_deleteFolder(newSource);
else // It is a file !
fsop_deleteFile(newSource);
pdir = opendir(source);
}
else // It is a file !
{
closedir(pdir);
fsop_silentDelete(newSource);
pdir = opendir(source);
}
}
closedir(pdir);
gprintf("Deleting directory: %s\n",source);
gprintf("Deleting directory: %s\n", source);
unlink(source);
}
void fsop_deleteFile(const char *source)
{
if(fsop_FileExist(source))
{
gprintf("Deleting file: %s\n",source);
remove(source);
}
if(!fsop_FileExist(source))
return;
gprintf("Deleting file: %s\n", source);
fsop_silentDelete(source);
}

View File

@ -8,15 +8,15 @@ extern "C"
typedef void (*progress_callback_t)(int status,int total,void *user_data);
bool fsop_GetFileSizeBytes(char *path, size_t *filesize);
bool fsop_GetFileSizeBytes(const char *path, size_t *filesize);
u64 fsop_GetFolderBytes(const char *source);
u32 fsop_GetFolderKb(const char *source);
u32 fsop_GetFreeSpaceKb(const char *path);
bool fsop_FileExist(const char *fn);
bool fsop_DirExist(const char *path);
void fsop_MakeFolder(char *path);
bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void *spinner_data);
bool fsop_CopyFolder(char *source, char *target, progress_callback_t spinner, void *spinner_data);
void fsop_MakeFolder(const char *path);
bool fsop_CopyFile(const char *source, const char *target, progress_callback_t spinner, void *spinner_data);
bool fsop_CopyFolder(const char *source, const char *target, progress_callback_t spinner, void *spinner_data);
void fsop_deleteFile(const char *source);
void fsop_deleteFolder(const char *source);

View File

@ -18,7 +18,6 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <malloc.h>
#include <ogc/machine/processor.h>
// for directory parsing and low-level file I/O
@ -36,6 +35,7 @@
#include "loader/disc.h"
#include "loader/sys.h"
#include "memory/memory.h"
#include "memory/mem2.hpp"
// DIOS-MIOS
DML_CFG DMLCfg;
@ -70,14 +70,14 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCh
if(CheatPath != NULL && NewCheatPath != NULL && cheats)
{
char *ptr;
if(strstr(CheatPath, partition) == NULL)
const char *ptr = NULL;
if(strncasecmp(CheatPath, partition, strlen(partition)) != 0)
{
fsop_CopyFile(CheatPath, (char*)NewCheatPath, NULL, NULL);
ptr = strstr(NewCheatPath, ":/") + 1;
fsop_CopyFile(CheatPath, NewCheatPath, NULL, NULL);
ptr = strchr(NewCheatPath, '/');
}
else
ptr = strstr(CheatPath, ":/") + 1;
ptr = strchr(CheatPath, '/');
strncpy(DMLCfg.CheatPath, ptr, sizeof(DMLCfg.CheatPath));
gprintf("DIOS-MIOS: Cheat Path %s\n", ptr);
DMLCfg.Config |= DML_CFG_CHEAT_PATH;
@ -109,8 +109,7 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCh
void DML_Old_SetOptions(const char *GamePath)
{
gprintf("DIOS-MIOS: Launch game '%s' through boot.bin (old method)\n", GamePath);
FILE *f;
f = fopen("sd:/games/boot.bin", "wb");
FILE *f = fopen("sd:/games/boot.bin", "wb");
fwrite(GamePath, 1, strlen(GamePath) + 1, f);
fclose(f);
@ -124,7 +123,6 @@ void DML_Old_SetOptions(const char *GamePath)
void DML_New_SetBootDiscOption(bool new_dm_cfg)
{
gprintf("DIOS-MIOS: Booting Disc in Drive\n");
memset(&DMLCfg, 0, sizeof(DML_CFG));
DMLCfg.Magicbytes = 0xD1050CF6;
@ -150,7 +148,9 @@ void DML_New_WriteOptions()
// Devolution
u8 *tmp_buffer = NULL;
u8 *loader_bin = NULL;
u32 loader_size = 0;
extern "C" { extern void __exception_closeall(); }
static gconfig *DEVO_CONFIG = (gconfig*)0x80000020;
#define DEVO_Entry() ((void(*)(void))loader_bin)()
@ -183,11 +183,10 @@ void DEVO_GetLoader(const char *path)
{
gprintf("Devolution: Reading %s\n", loader_path);
fseek(f, 0, SEEK_END);
u32 size = ftell(f);
loader_size = ftell(f);
rewind(f);
loader_bin = (u8*)memalign(32, size);
fread(loader_bin, 1, size, f);
DCFlushRange(loader_bin, size);
tmp_buffer = (u8*)MEM2_alloc(loader_size);
fread(tmp_buffer, 1, loader_size, f);
fclose(f);
}
else
@ -195,7 +194,6 @@ void DEVO_GetLoader(const char *path)
gprintf("Devolution: Loader not found!\n");
return;
}
gprintf("%s\n", (u8*)loader_bin + 4);
}
void DEVO_SetOptions(const char *isopath, const char *gameID, bool memcard_emu)
@ -292,9 +290,15 @@ void DEVO_SetOptions(const char *isopath, const char *gameID, bool memcard_emu)
void DEVO_Boot()
{
/* Move our loader into low MEM1 */
loader_bin = (u8*)MEM1_lo_alloc(loader_size);
memcpy(loader_bin, tmp_buffer, loader_size);
DCFlushRange(loader_bin, ALIGN32(loader_size));
MEM2_free(tmp_buffer);
gprintf("%s\n", (loader_bin+4));
/* cleaning up and load bin */
u32 cookie;
/* cleaning up and load dol */
gprintf("Jumping to Entry 0x%08x\n", loader_bin);
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
_CPU_ISR_Disable(cookie);
__exception_closeall();

View File

@ -28,9 +28,6 @@ Config CustomTitles;
GameTDB gameTDB;
dir_discHdr ListElement;
discHdr WiiGameHeader;
gc_discHdr GCGameHeader;
void ListGenerator::Init(const char *settingsDir, const char *Language)
{
if(settingsDir != NULL)
@ -94,10 +91,10 @@ static void Create_Wii_WBFS_List(wbfs_t *handle)
{
for(u32 i = 0; i < wbfs_count_discs(handle); i++)
{
memset((void*)&WiiGameHeader, 0, sizeof(discHdr));
s32 ret = wbfs_get_disc_info(handle, i, (u8*)&WiiGameHeader, sizeof(discHdr), NULL);
if(ret == 0 && WiiGameHeader.magic == WII_MAGIC)
AddISO((const char*)WiiGameHeader.id, (const char*)WiiGameHeader.title,
memset((void*)&wii_hdr, 0, sizeof(discHdr));
s32 ret = wbfs_get_disc_info(handle, i, (u8*)&wii_hdr, sizeof(discHdr), NULL);
if(ret == 0 && wii_hdr.magic == WII_MAGIC)
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
NULL, 1, TYPE_WII_GAME);
}
}
@ -108,9 +105,9 @@ static void Create_Wii_EXT_List(char *FullPath)
if(fp)
{
fseek(fp, strcasestr(FullPath, ".wbfs") != NULL ? 512 : 0, SEEK_SET);
fread((void*)&WiiGameHeader, 1, sizeof(discHdr), fp);
if(WiiGameHeader.magic == WII_MAGIC)
AddISO((const char*)WiiGameHeader.id, (const char*)WiiGameHeader.title,
fread((void*)&wii_hdr, 1, sizeof(discHdr), fp);
if(wii_hdr.magic == WII_MAGIC)
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
FullPath, 1, TYPE_WII_GAME);
fclose(fp);
}
@ -130,10 +127,10 @@ static void Create_GC_List(char *FullPath)
}
if(fp)
{
fread((void*)&GCGameHeader, 1, sizeof(gc_discHdr), fp);
if(GCGameHeader.magic == GC_MAGIC)
fread((void*)&gc_hdr, 1, sizeof(gc_discHdr), fp);
if(gc_hdr.magic == GC_MAGIC)
{
AddISO((const char*)GCGameHeader.id, (const char*)GCGameHeader.title,
AddISO((const char*)gc_hdr.id, (const char*)gc_hdr.title,
FullPath, 0, TYPE_GC_GAME);
/* Check for disc 2 */
fseek(fp, 6, SEEK_SET);

View File

@ -23,15 +23,9 @@
#include "gecko/gecko.h"
#include "memory/memory.h"
/* Constants */
#define PTABLE_OFFSET 0x40000
//appentrypoint
u32 appentrypoint;
/* Disc pointers */
static u32 *buffer = (u32 *)0x93000000;
static u8 *diskid = (u8 *)0x80000000;
struct discHdr wii_hdr ATTRIBUTE_ALIGN(32);
struct gc_discHdr gc_hdr ATTRIBUTE_ALIGN(32);
static u8 *diskid = (u8*)0x80000000;
s32 Disc_Open(bool boot_disc)
{
@ -95,19 +89,17 @@ s32 Disc_Type(bool gc)
if (!gc)
{
check = WII_MAGIC;
struct discHdr *header = (struct discHdr *)buffer;
ret = Disc_ReadHeader(header);
magic = header->magic;
ret = Disc_ReadHeader(&wii_hdr);
magic = wii_hdr.magic;
}
else
{
check = GC_MAGIC;
struct gc_discHdr *header = (struct gc_discHdr *)buffer;
ret = Disc_ReadGCHeader(header);
if(strcmp((char *)header->id, "GCOPDV") == 0)
ret = Disc_ReadGCHeader(&gc_hdr);
if(strcmp((char *)gc_hdr.id, "GCOPDV") == 0)
magic = GC_MAGIC;
else
magic = header->magic;
magic = gc_hdr.magic;
}
if (ret < 0)

View File

@ -102,6 +102,10 @@ s32 Disc_Type(bool);
s32 Disc_IsWii(void);
s32 Disc_IsGC(void);
/* Headers for general usage */
extern struct discHdr wii_hdr;
extern struct gc_discHdr gc_hdr;
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -44,7 +44,6 @@
using namespace std;
static u8 *FSTable ATTRIBUTE_ALIGN(32);
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
void GCDump::__AnalizeMultiDisc()
{
@ -292,7 +291,7 @@ s32 GCDump::DumpGame()
NextOffset = 0;
Disc = 0;
char *FSTNameOff = (char *)NULL;
char *FSTNameOff = NULL;
char folder[MAX_FAT_PATH];
bzero(folder, MAX_FAT_PATH);
@ -303,17 +302,17 @@ s32 GCDump::DumpGame()
{
u8 *FSTBuffer;
u32 wrote = 0;
memset(&gcheader, 0, sizeof(gcheader));
s32 ret = Disc_ReadGCHeader(&gcheader);
if(memcmp((char *)gcheader.id, "GCOPDV", 6) == 0)
memset(&gc_hdr, 0, sizeof(gc_hdr));
s32 ret = Disc_ReadGCHeader(&gc_hdr);
if(memcmp(gc_hdr.id, "GCOPDV", 6) == 0)
{
multigamedisc = true;
__AnalizeMultiDisc();
__DiscReadRaw(ReadBuffer, NextOffset, sizeof(gc_discHdr));
memcpy(gcheader.id, ReadBuffer, 6);
strcpy(gcheader.title, (char *)ReadBuffer+0x20);
memcpy(gc_hdr.id, ReadBuffer, 6);
strcpy(gc_hdr.title, (char *)ReadBuffer+0x20);
}
Asciify2(gcheader.title);
Asciify2(gc_hdr.title);
if(!Disc)
{
@ -324,7 +323,7 @@ s32 GCDump::DumpGame()
fsop_MakeFolder(folder);
}
memset(folder, 0, sizeof(folder));
snprintf(folder, sizeof(folder), "%s/%s [%.06s]", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gcheader.title, (char *)gcheader.id);
snprintf(folder, sizeof(folder), "%s/%s [%.06s]", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gc_hdr.title, gc_hdr.id);
if(!fsop_DirExist(folder))
{
gprintf("Creating directory: %s\n", folder);
@ -332,7 +331,7 @@ s32 GCDump::DumpGame()
}
else
{
gprintf("Skipping game: %s (Already installed)(%d)\n", gcheader.title, Gamesize[MultiGameDump]);
gprintf("Skipping game: %s (Already installed)(%d)\n", gc_hdr.title, Gamesize[MultiGameDump]);
break;
}
}
@ -377,14 +376,14 @@ s32 GCDump::DumpGame()
FSTNameOff = (char*)(FSTable + FSTEnt * 0x0C);
FST *fst = (FST *)(FSTable);
snprintf(minfo, sizeof(minfo), "[%.06s] %s", (char *)gcheader.id, gcheader.title);
snprintf(minfo, sizeof(minfo), "[%.06s] %s", gc_hdr.id, gc_hdr.title);
if(FSTTotal > FSTSize)
message(4, Disc+1, minfo, u_data);
else
message(3, 0, minfo, u_data);
gprintf("Dumping: %s %s\n", gcheader.title, compressed ? "compressed" : "full");
gprintf("Dumping: %s %s\n", gc_hdr.title, compressed ? "compressed" : "full");
gprintf("Apploader size : %d\n", ApploaderSize);
gprintf("DOL offset : 0x%08x\n", DOLOffset);
@ -398,7 +397,7 @@ s32 GCDump::DumpGame()
if(writeexfiles && !Disc)
{
memset(folder, 0, sizeof(folder));
snprintf(folder, sizeof(folder), "%s/%s [%.06s]/sys", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gcheader.title, (char *)gcheader.id);
snprintf(folder, sizeof(folder), "%s/%s [%.06s]/sys", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gc_hdr.title, gc_hdr.id);
if(!fsop_DirExist(folder))
{
gprintf("Creating directory: %s\n", folder);
@ -418,7 +417,7 @@ s32 GCDump::DumpGame()
gc_done += __DiscWrite(gamepath, 0x2440+NextOffset, ApploaderSize, ReadBuffer);
}
snprintf(gamepath, sizeof(gamepath), "%s/%s [%.06s]/game.iso", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gcheader.title, (char *)gcheader.id);
snprintf(gamepath, sizeof(gamepath), "%s/%s [%.06s]/game.iso", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gc_hdr.title, gc_hdr.id);
if(Disc)
{
char *ptz = strstr(gamepath, "game.iso");
@ -554,17 +553,17 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
while(!gamedone)
{
u32 multisize = 0;
memset(&gcheader, 0, sizeof(gcheader));
Disc_ReadGCHeader(&gcheader);
if(memcmp((char *)gcheader.id, "GCOPDV", 6) == 0)
memset(&gc_hdr, 0, sizeof(gc_hdr));
Disc_ReadGCHeader(&gc_hdr);
if(memcmp(gc_hdr.id, "GCOPDV", 6) == 0)
{
multigamedisc = true;
__AnalizeMultiDisc();
__DiscReadRaw(ReadBuffer, NextOffset, sizeof(gc_discHdr));
memcpy(gcheader.id, ReadBuffer, sizeof(gcheader.id));
strcpy(gcheader.title, (char *)ReadBuffer+0x20);
memcpy(gc_hdr.id, ReadBuffer, sizeof(gc_hdr.id));
strcpy(gc_hdr.title, (char *)ReadBuffer+0x20);
}
Asciify2(gcheader.title);
Asciify2(gc_hdr.title);
s32 ret = __DiscReadRaw(ReadBuffer, NextOffset, 0x440);
if(ret > 0)
@ -585,7 +584,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
DataSize = *(vu32*)(ReadBuffer+0x438);
DiscSize = DataSize + GamePartOffset;
snprintf(minfo, sizeof(minfo), "[%.06s] %s", (char *)gcheader.id, gcheader.title);
snprintf(minfo, sizeof(minfo), "[%.06s] %s", gc_hdr.id, gc_hdr.title);
message( 2, 0, minfo, u_data);

View File

@ -186,7 +186,6 @@ void CMenu::init()
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS)
{
drive = DeviceName[i];
fsop_MakeFolder((char *)fmt("%s:/%s", DeviceName[i], APPDATA_DIR2)); //Make the apps dir, so saving wiiflow.ini does not fail.
break;
}
loadDefaultFont();
@ -198,21 +197,22 @@ void CMenu::init()
m_exit = true;
return;
}
m_appDir = sfmt("%s:/%s", drive, APPDATA_DIR2);
m_cfg.load(sfmt("%s/" CFG_FILENAME, m_appDir.c_str()).c_str());
/* Handle apps dir first, so handling wiiflow.ini does not fail */
m_appDir = fmt("%s:/%s", drive, APPDATA_DIR2);
gprintf("Wiiflow boot.dol Location: %s\n", m_appDir.c_str());
fsop_MakeFolder(m_appDir.c_str());
/* Load/Create our wiiflow.ini */
m_cfg.load(fmt("%s/" CFG_FILENAME, m_appDir.c_str()));
/* Check if we want WiFi/SD Gecko */
m_use_wifi_gecko = m_cfg.getBool("DEBUG", "wifi_gecko");
if (m_cfg.getBool("GENERAL", "async_network") || has_enabled_providers() || m_use_wifi_gecko)
_reload_wifi_gecko();
gprintf("Wiiflow boot.dol Location: %s\n", m_appDir.c_str());
//Gecko Output to SD
if(!WriteToSD)
{
WriteToSD = m_cfg.getBool("DEBUG", "sd_write_log", false);
bufferMessages = WriteToSD;
}
/* Check if we want a cIOS loaded */
int ForceIOS = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
if(ForceIOS > 0)
{
@ -220,37 +220,45 @@ void CMenu::init()
mainIOS = ForceIOS;
}
useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false);
/* Do our USB HDD Checks */
bool onUSB = m_cfg.getBool("GENERAL", "data_on_usb", strncmp(drive, "usb", 3) == 0);
drive = check; //reset the drive variable for the check
if (onUSB)
if(onUSB)
{
for(int i = USB1; i <= USB8; i++) //Look for first partition with a wiiflow folder in root
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR), &dummy) == 0)
for(u8 i = USB1; i <= USB8; i++) //Look for first partition with a wiiflow folder in root
{
if(DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR), &dummy) == 0)
{
drive = DeviceName[i];
break;
}
}
}
else if(DeviceHandle.IsInserted(SD)) drive = DeviceName[SD];
else if(DeviceHandle.IsInserted(SD))
drive = DeviceName[SD];
if(drive == check && onUSB) //No wiiflow folder found in root of any usb partition, and data_on_usb=yes
for(int i = USB1; i <= USB8; i++) // Try first USB partition with wbfs folder.
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt(GAMES_DIR, DeviceName[i]), &dummy) == 0)
{
for(u8 i = USB1; i <= USB8; i++) // Try first USB partition with wbfs folder.
{
if(DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt(GAMES_DIR, DeviceName[i]), &dummy) == 0)
{
drive = DeviceName[i];
break;
}
}
}
if(drive == check && onUSB) // No wbfs folder found and data_on_usb=yes
for(int i = USB1; i <= USB8; i++) // Try first available USB partition.
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS)
{
for(u8 i = USB1; i <= USB8; i++) // Try first available USB partition.
{
if(DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS)
{
drive = DeviceName[i];
break;
}
}
}
if(drive == check)
{
_buildMenus();
@ -266,7 +274,7 @@ void CMenu::init()
return;
}
}
/* DIOS_MIOS stuff */
if(m_cfg.getBool(GC_DOMAIN, "always_show_button", false))
{
gprintf("Force enabling DML view\n");
@ -274,15 +282,14 @@ void CMenu::init()
}
else
m_show_dml = MIOSisDML();
m_new_dml = m_cfg.getBool(GC_DOMAIN, "dml_r52+", true);
m_new_dm_cfg = m_cfg.getBool(GC_DOMAIN, "dm_r2.1+", true);
m_DMLgameDir = sfmt("%%s:/%s", m_cfg.getString(GC_DOMAIN, "dir_usb_games", "games").c_str());
m_DMLgameDir = fmt("%%s:/%s", m_cfg.getString(GC_DOMAIN, "dir_usb_games", "games").c_str());
/* Emu NAND */
m_cfg.getString(CHANNEL_DOMAIN, "path", "");
m_cfg.getInt(CHANNEL_DOMAIN, "partition", 1);
m_cfg.getBool(CHANNEL_DOMAIN, "disable", true);
/* Load cIOS Map */
_installed_cios.clear();
if(!neek2o())
_load_installed_cioses();
@ -290,35 +297,35 @@ void CMenu::init()
_installed_cios[CurrentIOS.Version] = CurrentIOS.Version;
snprintf(m_app_update_drive, sizeof(m_app_update_drive), "%s:/", drive);
m_dataDir = sfmt("%s:/%s", drive, APPDATA_DIR);
m_dataDir = fmt("%s:/%s", drive, APPDATA_DIR);
gprintf("Data Directory: %s\n", m_dataDir.c_str());
m_dol = sfmt("%s/boot.dol", m_appDir.c_str());
m_ver = sfmt("%s/versions", m_appDir.c_str());
m_app_update_zip = sfmt("%s/update.zip", m_appDir.c_str());
m_data_update_zip = sfmt("%s/update.zip", m_dataDir.c_str());
m_dol = fmt("%s/boot.dol", m_appDir.c_str());
m_ver = fmt("%s/versions", m_appDir.c_str());
m_app_update_zip = fmt("%s/update.zip", m_appDir.c_str());
m_data_update_zip = fmt("%s/update.zip", m_dataDir.c_str());
m_customBnrDir = m_cfg.getString("GENERAL", "dir_custom_banners", sfmt("%s/custom_banners", m_dataDir.c_str()));
m_pluginsDir = m_cfg.getString("GENERAL", "dir_plugins", sfmt("%s/plugins", m_dataDir.c_str()));
m_customBnrDir = m_cfg.getString("GENERAL", "dir_custom_banners", fmt("%s/custom_banners", m_dataDir.c_str()));
m_pluginsDir = m_cfg.getString("GENERAL", "dir_plugins", fmt("%s/plugins", m_dataDir.c_str()));
m_cacheDir = m_cfg.getString("GENERAL", "dir_cache", sfmt("%s/cache", m_dataDir.c_str()));
m_listCacheDir = m_cfg.getString("GENERAL", "dir_list_cache", sfmt("%s/lists", m_cacheDir.c_str()));
m_bnrCacheDir = m_cfg.getString("GENERAL", "dir_banner_cache", sfmt("%s/banners", m_cacheDir.c_str()));
m_cacheDir = m_cfg.getString("GENERAL", "dir_cache", fmt("%s/cache", m_dataDir.c_str()));
m_listCacheDir = m_cfg.getString("GENERAL", "dir_list_cache", fmt("%s/lists", m_cacheDir.c_str()));
m_bnrCacheDir = m_cfg.getString("GENERAL", "dir_banner_cache", fmt("%s/banners", m_cacheDir.c_str()));
m_txtCheatDir = m_cfg.getString("GENERAL", "dir_txtcheat", sfmt("%s/codes", m_dataDir.c_str()));
m_cheatDir = m_cfg.getString("GENERAL", "dir_cheat", sfmt("%s/gct", m_txtCheatDir.c_str()));
m_wipDir = m_cfg.getString("GENERAL", "dir_wip", sfmt("%s/wip", m_txtCheatDir.c_str()));
m_txtCheatDir = m_cfg.getString("GENERAL", "dir_txtcheat", fmt("%s/codes", m_dataDir.c_str()));
m_cheatDir = m_cfg.getString("GENERAL", "dir_cheat", fmt("%s/gct", m_txtCheatDir.c_str()));
m_wipDir = m_cfg.getString("GENERAL", "dir_wip", fmt("%s/wip", m_txtCheatDir.c_str()));
m_settingsDir = m_cfg.getString("GENERAL", "dir_settings", sfmt("%s/settings", m_dataDir.c_str()));
m_languagesDir = m_cfg.getString("GENERAL", "dir_languages", sfmt("%s/languages", m_dataDir.c_str()));
m_boxPicDir = m_cfg.getString("GENERAL", "dir_box_covers", sfmt("%s/boxcovers", m_dataDir.c_str()));
m_picDir = m_cfg.getString("GENERAL", "dir_flat_covers", sfmt("%s/covers", m_dataDir.c_str()));
m_themeDir = m_cfg.getString("GENERAL", "dir_themes", sfmt("%s/themes", m_dataDir.c_str()));
m_musicDir = m_cfg.getString("GENERAL", "dir_music", sfmt("%s/music", m_dataDir.c_str()));
m_videoDir = m_cfg.getString("GENERAL", "dir_trailers", sfmt("%s/trailers", m_dataDir.c_str()));
m_fanartDir = m_cfg.getString("GENERAL", "dir_fanart", sfmt("%s/fanart", m_dataDir.c_str()));
m_screenshotDir = m_cfg.getString("GENERAL", "dir_screenshot", sfmt("%s/screenshots", m_dataDir.c_str()));
m_helpDir = m_cfg.getString("GENERAL", "dir_help", sfmt("%s/help", m_dataDir.c_str()));
m_settingsDir = m_cfg.getString("GENERAL", "dir_settings", fmt("%s/settings", m_dataDir.c_str()));
m_languagesDir = m_cfg.getString("GENERAL", "dir_languages", fmt("%s/languages", m_dataDir.c_str()));
m_boxPicDir = m_cfg.getString("GENERAL", "dir_box_covers", fmt("%s/boxcovers", m_dataDir.c_str()));
m_picDir = m_cfg.getString("GENERAL", "dir_flat_covers", fmt("%s/covers", m_dataDir.c_str()));
m_themeDir = m_cfg.getString("GENERAL", "dir_themes", fmt("%s/themes", m_dataDir.c_str()));
m_musicDir = m_cfg.getString("GENERAL", "dir_music", fmt("%s/music", m_dataDir.c_str()));
m_videoDir = m_cfg.getString("GENERAL", "dir_trailers", fmt("%s/trailers", m_dataDir.c_str()));
m_fanartDir = m_cfg.getString("GENERAL", "dir_fanart", fmt("%s/fanart", m_dataDir.c_str()));
m_screenshotDir = m_cfg.getString("GENERAL", "dir_screenshot", fmt("%s/screenshots", m_dataDir.c_str()));
m_helpDir = m_cfg.getString("GENERAL", "dir_help", fmt("%s/help", m_dataDir.c_str()));
//DeviceHandler::SetWatchdog(m_cfg.getUInt("GENERAL", "watchdog_timeout", 10));
@ -348,35 +355,35 @@ void CMenu::init()
}
CoverFlow.init(m_base_font, m_base_font_size, m_vid.vid_50hz());
//Make important folders first.
fsop_MakeFolder((char *)m_dataDir.c_str()); //D'OH!
/* Create our Folder Structure */
fsop_MakeFolder(m_dataDir.c_str()); //D'OH!
fsop_MakeFolder((char *)m_customBnrDir.c_str());
fsop_MakeFolder((char *)m_pluginsDir.c_str());
fsop_MakeFolder(m_customBnrDir.c_str());
fsop_MakeFolder(m_pluginsDir.c_str());
fsop_MakeFolder((char *)m_cacheDir.c_str());
fsop_MakeFolder((char *)m_listCacheDir.c_str());
fsop_MakeFolder((char *)m_bnrCacheDir.c_str());
fsop_MakeFolder(m_cacheDir.c_str());
fsop_MakeFolder(m_listCacheDir.c_str());
fsop_MakeFolder(m_bnrCacheDir.c_str());
fsop_MakeFolder((char *)m_txtCheatDir.c_str());
fsop_MakeFolder((char *)m_cheatDir.c_str());
fsop_MakeFolder((char *)m_wipDir.c_str());
fsop_MakeFolder(m_txtCheatDir.c_str());
fsop_MakeFolder(m_cheatDir.c_str());
fsop_MakeFolder(m_wipDir.c_str());
fsop_MakeFolder((char *)m_settingsDir.c_str());
fsop_MakeFolder((char *)m_languagesDir.c_str());
fsop_MakeFolder((char *)m_boxPicDir.c_str());
fsop_MakeFolder((char *)m_picDir.c_str());
fsop_MakeFolder((char *)m_themeDir.c_str());
fsop_MakeFolder((char *)m_musicDir.c_str());
fsop_MakeFolder((char *)m_videoDir.c_str());
fsop_MakeFolder((char *)m_fanartDir.c_str());
fsop_MakeFolder((char *)m_screenshotDir.c_str());
fsop_MakeFolder((char *)m_helpDir.c_str());
fsop_MakeFolder(m_settingsDir.c_str());
fsop_MakeFolder(m_languagesDir.c_str());
fsop_MakeFolder(m_boxPicDir.c_str());
fsop_MakeFolder(m_picDir.c_str());
fsop_MakeFolder(m_themeDir.c_str());
fsop_MakeFolder(m_musicDir.c_str());
fsop_MakeFolder(m_videoDir.c_str());
fsop_MakeFolder(m_fanartDir.c_str());
fsop_MakeFolder(m_screenshotDir.c_str());
fsop_MakeFolder(m_helpDir.c_str());
// INI files
m_cat.load(fmt("%s/" CAT_FILENAME, m_settingsDir.c_str()));
string themeName = m_cfg.getString("GENERAL", "theme", "default");
m_themeDataDir = sfmt("%s/%s", m_themeDir.c_str(), themeName.c_str());
m_themeDataDir = fmt("%s/%s", m_themeDir.c_str(), themeName.c_str());
m_theme.load(fmt("%s.ini", m_themeDataDir.c_str()));
m_plugin.init(m_pluginsDir);
@ -441,7 +448,7 @@ void CMenu::init()
}
m_btnMgr.init();
MusicPlayer.Init(m_cfg, m_musicDir, sfmt("%s/music", m_themeDataDir.c_str()));
MusicPlayer.Init(m_cfg, m_musicDir, fmt("%s/music", m_themeDataDir.c_str()));
m_music_info = m_cfg.getBool("GENERAL", "display_music_info", true);
_buildMenus();
@ -668,10 +675,10 @@ void CMenu::_loadCFCfg()
new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "sound_cancel").c_str()))
);
// Textures
string texLoading = sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "loading_cover_box").c_str());
string texNoCover = sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "missing_cover_box").c_str());
string texLoadingFlat = sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "loading_cover_flat").c_str());
string texNoCoverFlat = sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "missing_cover_flat").c_str());
string texLoading = fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "loading_cover_box").c_str());
string texNoCover = fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "missing_cover_box").c_str());
string texLoadingFlat = fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "loading_cover_flat").c_str());
string texNoCoverFlat = fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "missing_cover_flat").c_str());
CoverFlow.setTextures(texLoading, texLoadingFlat, texNoCover, texNoCoverFlat);
// Font
CoverFlow.setFont(_font(theme.fontSet, domain, "font", TITLEFONT), m_theme.getColor(domain, "font_color", CColor(0xFFFFFFFF)));
@ -1584,7 +1591,7 @@ void CMenu::_addUserLabels(s16 *ids, u32 start, u32 size, const char *domain)
for(u32 i = start; i < start + size; ++i)
{
string dom(sfmt("%s/USER%i", domain, i + 1));
string dom(fmt("%s/USER%i", domain, i + 1));
if (m_theme.hasDomain(dom))
{
STexture emptyTex;
@ -1620,7 +1627,7 @@ void CMenu::_initCF(void)
gameAgeList.load(fmt("%s/" AGE_LOCK_FILENAME, m_settingsDir.c_str()));
if (m_current_view == COVERFLOW_USB || m_current_view == COVERFLOW_CHANNEL)
{
gametdb.OpenFile(sfmt("%s/wiitdb.xml", m_settingsDir.c_str()).c_str());
gametdb.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str()));
gametdb.SetLanguageCode(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
}
}

View File

@ -175,8 +175,8 @@ void CMenu::_showCFTheme(u32 curParam, int version, bool wide)
{
const CMenu::SCFParamDesc &p = CMenu::_cfParams[curParam];
bool selected = CoverFlow.selected();
string domUnsel(sfmt(_cfDomain(), version));
string domSel(sfmt(_cfDomain(true), version));
string domUnsel(fmt(_cfDomain(), version));
string domSel(fmt(_cfDomain(true), version));
CoverFlow.simulateOtherScreenFormat(p.scrnFmt && wide != m_vid.wide());
_setBg(m_mainBg, m_mainBgLQ);
@ -343,8 +343,8 @@ void CMenu::_cfTheme(void)
}
else if(copyVersion > 0 && BTN_B_HELD && BTN_2_PRESSED)
{
string domSrc(sfmt(_cfDomain(copySelected), copyVersion));
string domDst(sfmt(_cfDomain(CoverFlow.selected()), cfVersion));
string domSrc(fmt(_cfDomain(copySelected), copyVersion));
string domDst(fmt(_cfDomain(CoverFlow.selected()), cfVersion));
if (copyVersion != cfVersion || copySelected != CoverFlow.selected())
m_theme.copyDomain(domDst, domSrc);
else if (copyWide != wide)
@ -474,7 +474,7 @@ void CMenu::_cfParam(bool inc, int i, const CMenu::SCFParamDesc &p, int cfVersio
int k = i / 4;
string key(p.key[k]);
const char *d = _cfDomain((p.domain != CMenu::SCFParamDesc::PDD_NORMAL && CoverFlow.selected()) || p.domain == CMenu::SCFParamDesc::PDD_SELECTED);
string domain(sfmt(d, cfVersion));
string domain(fmt(d, cfVersion));
float step = p.step[k];
if (!wide && p.scrnFmt && (p.paramType[k] == CMenu::SCFParamDesc::PDT_V3D || p.paramType[k] == CMenu::SCFParamDesc::PDT_FLOAT || p.paramType[k] == CMenu::SCFParamDesc::PDT_INT))
key += "_4_3";
@ -581,7 +581,7 @@ void CMenu::_initCFThemeMenu()
//
for (int i = 0; i < 16; ++i)
{
domain = sfmt("CFTHEME/VAL%i%c_%%s", i / 3 + 1, (char)(i % 3) + 'A');
domain = fmt("CFTHEME/VAL%i%c_%%s", i / 3 + 1, (char)(i % 3) + 'A');
x = 20 + (i / 4) * 150;
y = 340 + (i % 4) * 32;
m_cfThemeLblVal[i] = _addLabel(fmt(domain.c_str(), "BTN"), theme.btnFont, L"", x + 32, y, 86, 32, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);

View File

@ -507,13 +507,13 @@ int CMenu::_coverDownloader(bool missingOnly)
strncpy(gamePath, &m_gameList[i].path[string(m_gameList[i].path).find_last_of("/")+1], sizeof(gamePath));
else
strncpy(gamePath, m_gameList[i].path, sizeof(gamePath));
path = sfmt("%s/%s.png", m_boxPicDir.c_str(), gamePath);
path = fmt("%s/%s.png", m_boxPicDir.c_str(), gamePath);
id = path;
}
else
{
id = (const char *)m_gameList[i].id;
path = sfmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str());
path = fmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str());
}
if(!missingOnly || (!CoverFlow.fullCoverCached(id.c_str()) && !checkPNGFile(path.c_str())))
{
@ -596,7 +596,7 @@ int CMenu::_coverDownloader(bool missingOnly)
original = false;
if (!success && !m_thrdStop && original)
{
path = sfmt("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
path = fmt("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
if (!checkPNGFile(path.c_str()))
{
for (u32 j = 0; !success && j < fmtURLBox.size() && !m_thrdStop; ++j)
@ -742,7 +742,7 @@ int CMenu::_coverDownloader(bool missingOnly)
c_altCase = c_gameTDB.GetCaseVersions( coverList[i].c_str() );
if (!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
{
path = sfmt("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
path = fmt("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
if (!checkPNGFile(path.c_str()))
{
for (u32 j = 0; !success && j < fmtURLCBox.size() && !m_thrdStop; ++j)
@ -889,7 +889,7 @@ int CMenu::_coverDownloader(bool missingOnly)
original = false;
if (!success && !m_thrdStop && original)
{
path = sfmt("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
path = fmt("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
if (!checkPNGFile(path.c_str()))
{
// Try to get the front cover
@ -1036,7 +1036,7 @@ int CMenu::_coverDownloader(bool missingOnly)
custom = true;
if (!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
{
path = sfmt("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
path = fmt("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
if (!checkPNGFile(path.c_str()))
{
// Try to get the front cover
@ -2019,7 +2019,7 @@ int CMenu::_gametdbDownloaderAsync()
}
else
{
string zippath = sfmt("%s/wiitdb.zip", m_settingsDir.c_str());
string zippath = fmt("%s/wiitdb.zip", m_settingsDir.c_str());
gprintf("Downloading file to '%s'\n", zippath.c_str());
@ -2051,7 +2051,7 @@ int CMenu::_gametdbDownloaderAsync()
remove(zippath.c_str());
// We should always remove the offsets file to make sure it's reloaded
string offsetspath = sfmt("%s/gametdb_offsets.bin", m_settingsDir.c_str());
string offsetspath = fmt("%s/gametdb_offsets.bin", m_settingsDir.c_str());
remove(offsetspath.c_str());
// Update cache

View File

@ -611,10 +611,10 @@ void CMenu::_game(bool launch)
}
if(hdr->type != TYPE_HOMEBREW && hdr->type != TYPE_PLUGIN)
{
if(Playlog_Update((char *)hdr->id, banner_title) < 0)
if(Playlog_Update(hdr->id, banner_title) < 0)
Playlog_Delete();
}
gprintf("Launching game %s\n", (char *)hdr->id);
gprintf("Launching game %s\n", hdr->id);
_launch(hdr);
if(m_exit)
@ -813,14 +813,14 @@ void CMenu::_launch(dir_discHdr *hdr)
void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
{
string id(hdr->id);
string path(hdr->path);
const char *id = hdr->id;
const char *path = hdr->path;
m_cfg.setString(GC_DOMAIN, "current_item", id);
m_gcfg1.setInt("PLAYCOUNT", id, m_gcfg1.getInt("PLAYCOUNT", id, 0) + 1);
m_gcfg1.setUInt("LASTPLAYED", id, time(NULL));
if(has_enabled_providers() && _initNetwork() == 0)
add_game_to_card(id.c_str());
add_game_to_card(id);
u8 videoSetting = min(m_cfg.getInt(GC_DOMAIN, "video_setting", 1), 2);
@ -831,7 +831,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
videoMode = (videoMode == 0) ? min((u32)m_cfg.getInt(GC_DOMAIN, "video_mode", 0), ARRAY_SIZE(CMenu::_GlobalDMLvideoModes) - 1u) : videoMode-1;
if(videoMode == 0)
{
if(id.c_str()[3] == 'E' || id.c_str()[3] == 'J')
if(id[3] == 'E' || id[3] == 'J')
videoMode = 2; //NTSC 480i
else
videoMode = 1; //PAL 576i
@ -843,9 +843,10 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
if(disc)
{
loader = 1;
gprintf("Booting GC Disc: %s\n", id);
DML_New_SetBootDiscOption(m_new_dm_cfg);
}
else if(loader == 1 || strcasestr(path.c_str(), "boot.bin") != NULL || !m_devo_installed)
else if(loader == 1 || strcasestr(path, "boot.bin") != NULL || !m_devo_installed)
{
loader = 1;
m_cfg.setString(GC_DOMAIN, "current_item", id);
@ -855,28 +856,29 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
u8 nodisc = min((u32)m_gcfg2.getInt(id, "no_disc_patch", 0), ARRAY_SIZE(CMenu::_NoDVD) - 1u);
nodisc = (nodisc == 0) ? m_cfg.getInt(GC_DOMAIN, "no_disc_patch", 0) : nodisc-1;
bool cheats = m_gcfg2.testOptBool(id, "cheat", m_cfg.getBool(GC_DOMAIN, "cheat", false));
string NewCheatPath;
bool DML_debug = m_gcfg2.getBool(id, "debugger", false);
bool DM_Widescreen = m_gcfg2.getBool(id, "dm_widescreen", false);
bool activity_led = m_cfg.getBool(GC_DOMAIN, "dml_activity_led", true);
if(strcasestr(path.c_str(), "boot.bin") != NULL)
/* Generate gct path */
char GC_Path[1024];
GC_Path[1023] = '\0';
strncpy(GC_Path, path, 1023);
if(strcasestr(path, "boot.bin") != NULL)
{
path.erase(path.end() - 12, path.end());
NewCheatPath = sfmt("%s%s", path.c_str(), fmt("%s.gct", id.c_str()));
*strrchr(GC_Path, '/') = '\0'; //boot.bin
*(strrchr(GC_Path, '/')+1) = '\0'; //sys
}
else
{
NewCheatPath = sfmt("%s/%s", path.c_str(), fmt("%s.gct", id.c_str()));
NewCheatPath.erase(NewCheatPath.end() - 19, NewCheatPath.end() - 10);
}
*(strrchr(GC_Path, '/')+1) = '\0'; //iso path
const char *NewCheatPath = fmt("%s%s.gct", GC_Path, id);
if(cheats)
snprintf(CheatPath, sizeof(CheatPath), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", id.c_str()));
string newPath = &path[path.find_first_of(":/")+1];
snprintf(CheatPath, sizeof(CheatPath), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", id));
const char *newPath = strcasestr(path, "boot.bin") == NULL ? strchr(path, '/') : strchr(GC_Path, '/');
if(m_new_dml)
DML_New_SetOptions(newPath.c_str(), CheatPath, NewCheatPath.c_str(), DeviceName[currentPartition],
DML_New_SetOptions(newPath, CheatPath, NewCheatPath, DeviceName[currentPartition],
cheats, DML_debug, NMM, nodisc, videoMode, videoSetting, DM_Widescreen, m_new_dm_cfg, activity_led);
else
DML_Old_SetOptions(newPath.c_str());
DML_Old_SetOptions(newPath);
if(!nodisc || !m_new_dml)
WDVD_StopMotor();
}
@ -910,7 +912,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
else //use cIOS instead to make sure Devolution works anyways
loadIOS(mainIOS, false);
ShutdownBeforeExit();
DEVO_SetOptions(path.c_str(), id.c_str(), memcard_emu);
DEVO_SetOptions(path, id, memcard_emu);
DEVO_Boot();
}
Sys_Exit();
@ -1185,21 +1187,18 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
else
{
/* Read GC disc header */
struct gc_discHdr *gcHeader = (struct gc_discHdr *)memalign(32, sizeof(struct gc_discHdr));
Disc_ReadGCHeader(gcHeader);
strncpy(hdr->id, (char*)gcHeader->id, 6);
free(gcHeader);
Disc_ReadGCHeader(&gc_hdr);
memcpy(hdr->id, gc_hdr.id, 6);
/* Launching GC Game */
_launchGC(hdr, true);
return;
}
}
else
{
/* Read header */
struct discHdr *header = (struct discHdr *)memalign(32, sizeof(struct discHdr));
Disc_ReadHeader(header);
id = string((const char*)header->id);
free(header);
Disc_ReadHeader(&wii_hdr);
id = string((char*)wii_hdr.id, 6);
}
gprintf("Game ID: %s\n", id.c_str());
}

View File

@ -276,14 +276,14 @@ void CMenu::_initGameInfoMenu()
for(u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControlsReq); ++i)
{
string dom(sfmt("GAMEINFO/CONTROLSREQ%i", i + 1));
string dom(fmt("GAMEINFO/CONTROLSREQ%i", i + 1));
m_gameinfoLblControlsReq[i] = _addLabel(dom.c_str(), theme.txtFont, L"", 40 + (i*60), 310, 60, 40, theme.txtFontColor, 0, emptyTex);
_setHideAnim(m_gameinfoLblControlsReq[i], dom.c_str(), 0, -100, 0.f, 0.f);
}
for(u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControls); ++i)
{
string dom(sfmt("GAMEINFO/CONTROLS%i", i + 1));
string dom(fmt("GAMEINFO/CONTROLS%i", i + 1));
m_gameinfoLblControls[i] = _addLabel(dom.c_str(), theme.txtFont, L"", 40 + (i*60), 380, 60, 40, theme.txtFontColor, 0, emptyTex);
_setHideAnim(m_gameinfoLblControls[i], dom.c_str(), 0, -100, 0.f, 0.f);
}

View File

@ -168,8 +168,8 @@ bool CMenu::_checkSave(string id, bool nand)
if(nand)
{
u32 temp = 0;
if(ISFS_ReadDir(sfmt("/title/00010000/%08x", savePath).c_str(), NULL, &temp) < 0)
if(ISFS_ReadDir(sfmt("/title/00010004/%08x", savePath).c_str(), NULL, &temp) < 0)
if(ISFS_ReadDir(fmt("/title/00010000/%08x", savePath), NULL, &temp) < 0)
if(ISFS_ReadDir(fmt("/title/00010004/%08x", savePath), NULL, &temp) < 0)
return false;
}
else
@ -180,8 +180,8 @@ bool CMenu::_checkSave(string id, bool nand)
return false;
struct stat fstat;
if((stat(sfmt("%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath.c_str(), savePath).c_str(), &fstat) != 0 )
&& (stat(sfmt("%s:%s/title/00010004/%08x", DeviceName[emuPartition], emuPath.c_str(), savePath).c_str(), &fstat) != 0))
if((stat(fmt("%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath.c_str(), savePath), &fstat) != 0 )
&& (stat(fmt("%s:%s/title/00010004/%08x", DeviceName[emuPartition], emuPath.c_str(), savePath), &fstat) != 0))
return false;
}
return true;
@ -708,15 +708,16 @@ int CMenu::_NandFlasher(void *obj)
else if(m.m_current_view == COVERFLOW_USB)
m.m_partRequest = m.m_cfg.getInt(WII_DOMAIN, "savepartition", -1);
const char *SaveGameID = m.m_saveExtGameId.c_str();
int emuPartition = m._FindEmuPart(&emuPath, m.m_partRequest, false);
int flashID = m.m_saveExtGameId.c_str()[0] << 24 | m.m_saveExtGameId.c_str()[1] << 16 | m.m_saveExtGameId.c_str()[2] << 8 | m.m_saveExtGameId.c_str()[3];
int flashID = SaveGameID[0] << 24 | SaveGameID[1] << 16 | SaveGameID[2] << 8 | SaveGameID[3];
if(_saveExists(sfmt("%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath.c_str(), flashID).c_str()))
if(_saveExists(fmt("%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath.c_str(), flashID)))
{
snprintf(source, sizeof(source), "%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath.c_str(), flashID);
snprintf(dest, sizeof(dest), "/title/00010000/%08x", flashID);
}
else if(_saveExists(sfmt("%s:%s/title/00010004/%08x", DeviceName[emuPartition], emuPath.c_str(), flashID).c_str()))
else if(_saveExists(fmt("%s:%s/title/00010004/%08x", DeviceName[emuPartition], emuPath.c_str(), flashID)))
{
snprintf(source, sizeof(source), "%s:%s/title/00010004/%08x", DeviceName[emuPartition], emuPath.c_str(), flashID);
snprintf(dest, sizeof(dest), "/title/00010004/%08x", flashID);

View File

@ -148,8 +148,8 @@ bool CMenu::_Source()
while((pent = readdir(pdir)) != NULL)
{
if(strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0
|| strcasecmp(pent->d_name, "plugins.ini") == 0 || strcasecmp(pent->d_name, "scummvm.ini") == 0)
if(pent->d_name[0] == '.'|| strcasecmp(pent->d_name, "plugins.ini") == 0 ||
strcasecmp(pent->d_name, "scummvm.ini") == 0)
continue;
if(strcasestr(pent->d_name, ".ini") != NULL)
{
@ -412,7 +412,7 @@ void CMenu::_initSourceMenu()
m_sourceBtnPageM = _addPicButton("SOURCE/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 10, 400, 52, 56);
m_sourceBtnPageP = _addPicButton("SOURCE/PAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 160, 400, 52, 56);
m_sourceDir = m_cfg.getString("GENERAL", "dir_Source", sfmt("%s/source_menu", m_dataDir.c_str()));
m_sourceDir = m_cfg.getString("GENERAL", "dir_Source", fmt("%s/source_menu", m_dataDir.c_str()));
if(!m_source.loaded())
m_source.load(fmt("%s/%s", m_sourceDir.c_str(), SOURCE_FILENAME));

View File

@ -267,8 +267,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
lwp_t thread = 0;
char GameID[7];
GameID[6] = '\0';
static discHdr header ATTRIBUTE_ALIGN(32);
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
bool done = false;
bool upd_usb = false;
bool upd_dml = false;
@ -335,8 +334,8 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
}
if (Disc_IsWii() == 0)
{
Disc_ReadHeader(&header);
memcpy(GameID, header.id, 6);
Disc_ReadHeader(&wii_hdr);
memcpy(GameID, wii_hdr.id, 6);
if(_searchGamesByID(GameID))
{
error(_t("wbfsoperr4", L"Game already installed"));
@ -344,7 +343,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
break;
}
cfPos = string(GameID);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, header.title));
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, wii_hdr.title));
done = true;
upd_usb = true;
m_thrdWorking = true;
@ -354,8 +353,8 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
}
else if(Disc_IsGC() == 0)
{
Disc_ReadGCHeader(&gcheader);
memcpy(GameID, gcheader.id, 6);
Disc_ReadGCHeader(&gc_hdr);
memcpy(GameID, gc_hdr.id, 6);
if(_searchGamesByID(GameID))
{
error(_t("wbfsoperr4", L"Game already installed"));
@ -363,7 +362,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
break;
}
cfPos = string(GameID);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gcheader.title));
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gc_hdr.title));
done = true;
upd_dml = true;
m_thrdWorking = true;

View File

@ -48,6 +48,9 @@
#include <stdio.h>
#include <ogc/system.h>
#include "crc32.h"
#include "memory/mem2.hpp"
#define FILEBUFFER 0x200000 /* 2MB */
static u32 crc_32_tab[] = { /* CRC polynomial 0xedb88320 */
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@ -95,44 +98,37 @@ static u32 crc_32_tab[] = { /* CRC polynomial 0xedb88320 */
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
u32 crc32file(char *name)
{
FILE *fin;
s32 c;
u32 oldcrc32 = 0xFFFFFFFF;
s32 charcnt = 0;
if((fin = fopen(name, "rb")) == NULL)
{
perror(name);
return oldcrc32;
}
while((c = getc(fin)) != EOF)
{
++charcnt;
oldcrc32 = UPDC32(c, oldcrc32);
}
if(ferror(fin))
{
perror(name);
charcnt = -1;
}
fclose(fin);
u32 crc32 = oldcrc32 = ~oldcrc32;
return crc32;
}
u32 crc32buffer(const u8 *buffer, const u32 len)
u32 crc32buffer(const u8 *buffer, const u32 len, u32 oldcrc32)
{
u32 i;
u32 oldcrc32 = 0xFFFFFFFF;
for(i = 0; i < len; i++)
oldcrc32 = UPDC32(buffer[i], oldcrc32);
u32 crc32 = oldcrc32 = ~oldcrc32;
return crc32;
return oldcrc32;
}
u32 crc32file(const char *name)
{
FILE *fp = fopen(name, "rb");
if(fp == NULL)
return 0;
u32 Length = 0;
u32 oldcrc32 = 0xFFFFFFFF;
/* Check our filesize */
fseek(fp, 0, SEEK_END);
if(ftell(fp) > 0x40000000) //pfff over 1gb would take ages
return oldcrc32;
rewind(fp);
/* Get a Buffer and begin */
u8 *Buffer = (u8*)MEM2_alloc(FILEBUFFER);
while(1)
{
Length = fread(Buffer, 1, FILEBUFFER, fp);
if(Length == 0)
break;
oldcrc32 = crc32buffer(Buffer, Length, oldcrc32);
}
MEM2_free(Buffer);
fclose(fp);
return oldcrc32 = ~oldcrc32;
}

View File

@ -10,8 +10,7 @@ extern "C"
#define UPDC32(octet, crc) (crc_32_tab[((crc)\
^ (octet)) & 0xff] ^ ((crc) >> 8))
u32 crc32file(char *name);
u32 crc32buffer(const u8 *s, const u32 len);
u32 crc32file(const char *name);
#ifdef __cplusplus
}

View File

@ -122,17 +122,17 @@ u32 Plugin::GetBannerSoundSize()
return 0;
}
char* Plugin::GetDolName(u32 magic)
const char *Plugin::GetDolName(u32 magic)
{
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
return (char*)Plugins[Plugin_Pos].DolName.c_str();
return Plugins[Plugin_Pos].DolName.c_str();
return NULL;
}
char* Plugin::GetCoverFolderName(u32 magic)
const char *Plugin::GetCoverFolderName(u32 magic)
{
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
return (char*)Plugins[Plugin_Pos].coverFolder.c_str();
return Plugins[Plugin_Pos].coverFolder.c_str();
return NULL;
}
@ -207,7 +207,7 @@ vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32
continue;
}
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
strncpy((char*)ListElement.id, PLUGIN_INI_DEF, 6);
strncpy(ListElement.id, PLUGIN_INI_DEF, 6);
ListElement.casecolor = Plugins.back().caseColor;
mbstowcs(ListElement.title, GameName.c_str(), 63);
strncpy(ListElement.path, GameDomain->c_str(), sizeof(ListElement.path));

View File

@ -54,10 +54,10 @@ class Plugin
{
public:
bool AddPlugin(Config &plugin);
u8* GetBannerSound(u32 magic);
u8 *GetBannerSound(u32 magic);
u32 GetBannerSoundSize();
char* GetDolName(u32 magic);
char* GetCoverFolderName(u32 magic);
const char *GetDolName(u32 magic);
const char *GetCoverFolderName(u32 magic);
string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums);
wstringEx GetPluginName(u8 pos);
u32 getPluginMagic(u8 pos);