-plugin games now also can stay zipped for cover downloading,

crc will be read from the zip header, still 7z needs to be
extracted
This commit is contained in:
fix94.1 2012-06-08 21:25:54 +00:00
parent a953eddd1b
commit 0f2ca0c34a
2 changed files with 28 additions and 16 deletions

View File

@ -1,29 +1,30 @@
#ifndef _UTILS_H_ #ifndef _UTILS_H_
#define _UTILS_H_ #define _UTILS_H_
#include <gctypes.h> #include <gctypes.h>
/* Constants */
#define KB_SIZE 1024.0
#define MB_SIZE 1048576.0
#define GB_SIZE 1073741824.0
#define MAX_FAT_PATH 1024 #define KB_SIZE 1024.0
#define MB_SIZE 1048576.0
#define GB_SIZE 1073741824.0
/* Macros */ #define MAX_FAT_PATH 1024
#define round_up(x,n) (-(-(x) & -(n)))
#define ALIGN(n, x) (((x) + (n - 1)) & ~(n - 1)) #define round_up(x,n) (-(-(x) & -(n)))
#define ALIGN32(x) (((x) + 31) & ~31)
#define ALIGNED(x) __attribute__((aligned(x))) #define ALIGN(n, x) (((x) + (n - 1)) & ~(n - 1))
#define ALIGN32(x) (((x) + 31) & ~31)
#define ALIGNED(x) __attribute__((aligned(x)))
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y)) #define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
#define TITLE_UPPER(x) ((u32)((x) >> 32)) #define TITLE_UPPER(x) ((u32)((x) >> 32))
#define TITLE_LOWER(x) ((u32)(x) & 0xFFFFFFFF) #define TITLE_LOWER(x) ((u32)(x) & 0xFFFFFFFF)
/* Macros */ #define SWAP32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) >> 24) & 0xff))
#define Write8(addr, val) *(u8 *)addr = val; DCFlushRange((void *)addr, sizeof(u8));
#define Write16(addr, val) *(u16 *)addr = val; DCFlushRange((void *)addr, sizeof(u16)); #define Write8(addr, val) *(u8 *)addr = val; DCFlushRange((void *)addr, sizeof(u8));
#define Write32(addr, val) *(u32 *)addr = val; DCFlushRange((void *)addr, sizeof(u32)); #define Write16(addr, val) *(u16 *)addr = val; DCFlushRange((void *)addr, sizeof(u16));
#define Write32(addr, val) *(u32 *)addr = val; DCFlushRange((void *)addr, sizeof(u32));
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -45,4 +46,3 @@ bool str_replace_all(char *str, const char *olds, const char *news, int size);
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif

View File

@ -84,6 +84,7 @@ bool Plugin::AddPlugin(Config &plugin)
NewPlugin.BannerSound = (u8*)FileReadBuffer; NewPlugin.BannerSound = (u8*)FileReadBuffer;
NewPlugin.BannerSoundSize = size; NewPlugin.BannerSoundSize = size;
Plugins.push_back(NewPlugin); Plugins.push_back(NewPlugin);
infile.close();
return true; return true;
} }
else else
@ -292,7 +293,18 @@ string Plugin::GenerateCoverLink(dir_discHdr gameHeader, string url)
url.replace(url.find(TAG_CONSOLE), strlen(TAG_CONSOLE), (Plugins[Plugin_Pos].consoleCoverID.size() ? Plugins[Plugin_Pos].consoleCoverID.c_str() : "nintendo")); url.replace(url.find(TAG_CONSOLE), strlen(TAG_CONSOLE), (Plugins[Plugin_Pos].consoleCoverID.size() ? Plugins[Plugin_Pos].consoleCoverID.c_str() : "nintendo"));
char crc_string[9]; char crc_string[9];
snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path)); if(strstr(gameHeader.path, ".zip") == NULL)
snprintf(crc_string, sizeof(crc_string), "%08x", crc32file(gameHeader.path));
else
{
u32 crc_buffer;
ifstream infile;
infile.open(gameHeader.path, ios::binary);
infile.seekg(0x0e, ios::beg);
infile.read((char*)&crc_buffer, 8);
infile.close();
snprintf(crc_string, sizeof(crc_string), "%08x", SWAP32(crc_buffer));
}
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str()); url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str());
gprintf("URL: %s\n", url.c_str()); gprintf("URL: %s\n", url.c_str());
return url; return url;