Skip to content

Commit

Permalink
- Fix cheat file detection
Browse files Browse the repository at this point in the history
  • Loading branch information
emukidid committed Aug 14, 2017
1 parent e5dea5c commit 012a4f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions cube/swiss/source/cheats/cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,9 @@ int findCheats(bool silent) {
memset(trimmedGameId, 0, 8);
memcpy(trimmedGameId, (char*)&GCMDisk, 6);
file_handle *cheatsFile = memalign(32,sizeof(file_handle));
memcpy(cheatsFile, devices[DEVICE_CUR]->initial, sizeof(file_handle));
memset(cheatsFile, 0, sizeof(file_handle));
sprintf(cheatsFile->name, "%s/cheats/%s.txt", devices[DEVICE_CUR]->initial->name, trimmedGameId);
print_gecko("Looking for cheats file @ %s\r\n", cheatsFile->name);
cheatsFile->size = -1;

devices[DEVICE_TEMP] = devices[DEVICE_CUR];

Expand All @@ -206,20 +205,20 @@ int findCheats(bool silent) {
// Try SD slots now
devices[DEVICE_TEMP] = &__device_sd_a;
file_handle *slotFile = devices[DEVICE_TEMP]->initial;
memcpy(cheatsFile, slotFile, sizeof(file_handle));
memset(cheatsFile, 0, sizeof(file_handle));
sprintf(cheatsFile->name, "%s/cheats/%s.txt", slotFile->name, trimmedGameId);
print_gecko("Looking for cheats file @ %s\r\n", cheatsFile->name);
cheatsFile->size = -1;

devices[DEVICE_TEMP]->init(cheatsFile);
if(devices[DEVICE_TEMP]->readFile(cheatsFile, &trimmedGameId, 8) != 8) {
devices[DEVICE_TEMP] = NULL;
}
devices[DEVICE_TEMP] = &__device_sd_b;
slotFile = devices[DEVICE_TEMP]->initial;
memcpy(cheatsFile, slotFile, sizeof(file_handle));
memset(cheatsFile, 0, sizeof(file_handle));
sprintf(cheatsFile->name, "%s/cheats/%s.txt", slotFile->name, trimmedGameId);
print_gecko("Looking for cheats file @ %s\r\n", cheatsFile->name);
cheatsFile->size = -1;

devices[DEVICE_TEMP]->init(cheatsFile);
if(devices[DEVICE_TEMP]->readFile(cheatsFile, &trimmedGameId, 8) != 8) {
devices[DEVICE_TEMP] = NULL;
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/devices/fat/deviceHandler-FAT.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ s32 deviceHandler_FAT_seekFile(file_handle* file, u32 where, u32 type){
s32 deviceHandler_FAT_readFile(file_handle* file, void* buffer, u32 length){
if(!file->fp) {
file->fp = fopen( file->name, "r+" );
if(file->size == 0) {
if(file->size <= 0) {
struct stat fstat;
stat(file->name,&fstat);
file->size = fstat.st_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ s32 deviceHandler_WKF_seekFile(file_handle* file, u32 where, u32 type){
s32 deviceHandler_WKF_readFile(file_handle* file, void* buffer, u32 length){
if(!file->fp) {
file->fp = fopen( file->name, "rb" );
if(file->size == -1) {
if(file->size <= 0) {
struct stat fstat;
stat(file->name,&fstat);
file->size = fstat.st_size;
Expand Down

0 comments on commit 012a4f7

Please sign in to comment.