Skip to content

Commit

Permalink
- Accommodate for USB Loader GX/WiiFlow "full" dumps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Aug 19, 2023
1 parent d67969f commit 5f3f8e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions cube/swiss/include/nkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* with Swiss. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef __NKIT_H
#define __NKIT_H
#ifndef __NKIT_H__
#define __NKIT_H__

#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -46,7 +46,8 @@ bool valid_gcm_boot(const DiskHeader *header);
bool valid_gcm_crc32(const DiskHeader *header, uint32_t crc);
bool valid_gcm_magic(const DiskHeader *header);
bool valid_gcm_size(const DiskHeader *header, off_t size);
bool valid_gcm_size2(const DiskHeader *header, off_t size);

bool needs_nkit_reencode(const DiskHeader *header, off_t size);

#endif /* __NKIT_H */
#endif /* __NKIT_H__ */
8 changes: 7 additions & 1 deletion cube/swiss/source/nkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,8 @@ bool get_gcm_banner_fast(const DiskHeader *header, uint32_t *offset, uint32_t *s
!memcmp(header, nkit_dat[i].header, 6) &&
header->DiscID == nkit_dat[i].disknum &&
header->Version == nkit_dat[i].gamever &&
*size == nkit_dat[i].size + nkit_dat[i]._size) {
(*size == nkit_dat[i].size + nkit_dat[i]._size ||
*size == header->UserPos + header->UserLength)) {

for (int j = i + 1; j < TOTAL_COUNT; j++)
if (nkit_dat[i].header_sum16 == nkit_dat[j].header_sum16 &&
Expand Down Expand Up @@ -2541,6 +2542,11 @@ bool valid_gcm_size(const DiskHeader *header, off_t size)
return size == DISC_SIZE;
}

bool valid_gcm_size2(const DiskHeader *header, off_t size)
{
return size == header->UserPos + header->UserLength;
}

bool needs_nkit_reencode(const DiskHeader *header, off_t size)
{
if (!is_nkit_format(header))
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ void load_game() {
return;
}
else if(is_redump_disc(curFile.meta) && !valid_gcm_size(&GCMDisk, curFile.size)) {
if(swissSettings.audioStreaming) {
if(swissSettings.audioStreaming && !valid_gcm_size2(&GCMDisk, curFile.size)) {
DrawDispose(msgBox);
msgBox = DrawPublish(DrawMessageBox(D_WARN, "File is a bad dump and is not playable.\nPlease attempt recovery using NKit."));
sleep(5);
Expand Down

0 comments on commit 5f3f8e1

Please sign in to comment.