-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,15 +1,15 @@
#ifndef _UTILS_H_
#define _UTILS_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
/* Macros */
#define round_up(x,n) (-(-(x) & -(n)))
#define ALIGN(n, x) (((x) + (n - 1)) & ~(n - 1))
@ -20,7 +20,8 @@
#define TITLE_UPPER(x) ((u32)((x) >> 32))
#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 Write32(addr, val) *(u32 *)addr = val; DCFlushRange((void *)addr, sizeof(u32));
@ -45,4 +46,3 @@ bool str_replace_all(char *str, const char *olds, const char *news, int size);
#endif /* __cplusplus */
#endif

View File

@ -84,6 +84,7 @@ bool Plugin::AddPlugin(Config &plugin)
NewPlugin.BannerSound = (u8*)FileReadBuffer;
NewPlugin.BannerSoundSize = size;
Plugins.push_back(NewPlugin);
infile.close();
return true;
}
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"));
char crc_string[9];
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());
gprintf("URL: %s\n", url.c_str());
return url;