Skip to content

Commit 45082a4

Browse files
committed
Minor fixes
1 parent 83a6402 commit 45082a4

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,17 @@ int main(int argc, char* argv[])
9898
verbose("======================\n");
9999
verbose("Options: (1=enabled/0=disabled)\n");
100100
verbose("bDecodeFile:%d\n", bDecodeFile);
101+
verbose("bGetSwav:%d\n", bGetSwav);
101102
verbose("bVerboseMessages:%d\n", bVerboseMessages);
102103
verbose("bUseFname:%d\n", bUseFname);
104+
verbose("bExtractSdat:%d\n", bExtractSdat);
103105
verbose("======================\n");
104106

105107
/* input files */
106108
for(; optind < argc; optind++) {
107109
bool isNds = false;
108110

109-
std::vector<SdatX> sdats;
110-
SdatX::Init(argv[optind], sdats, isNds);
111+
std::vector<SdatX> sdats = SdatX::Init(argv[optind], isNds);
111112
if (!sdats.size()) {
112113
warning("No SDATs found in file: %s\n", argv[optind]);
113114
} else {

src/sdatxtract.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ extern "C" {
1313
#include "decoder/sseq2mid.h"
1414
}
1515

16-
bool SdatXI_FindSdat(const std::string &filepath, std::vector<SdatX> &sdats) {
16+
std::vector<SdatX> SdatXI_FindSdat(const std::string &filepath) {
17+
std::vector<SdatX> sdats;
1718
uint8_t sdatMagic[] = {'S','D','A','T',0xFF,0xFE,0x00,0x01};
1819

1920
std::ifstream ifs(filepath, std::ios::binary | std::ios::ate);
2021
uint32_t mlength = ifs.tellg();
2122

2223
if (!ifs.good() || mlength < 0x400)
23-
return false;
24+
return sdats;
2425

2526
MemFile mfile = MemFile(filepath, mlength);
2627

@@ -53,22 +54,23 @@ bool SdatXI_FindSdat(const std::string &filepath, std::vector<SdatX> &sdats) {
5354
}
5455

5556
printf("Total SDATs found: %d\n", sdats.size());
56-
return true;
57+
return sdats;
5758
}
5859

59-
bool SdatX::Init(const std::string &filepath, std::vector<SdatX> &sdats, bool &isNds) {
60+
std::vector<SdatX> SdatX::Init(const std::string &filepath, bool &isNds) {
61+
std::vector<SdatX> sdats;
6062
if (!File::Exists(filepath)) {
6163
error("Failed to open file.\n");
62-
return false;
64+
return sdats;
6365
}
6466

6567
if (!SDAT::Verify(filepath)) {
6668
isNds = true;
67-
SdatXI_FindSdat(filepath, sdats);
69+
sdats = SdatXI_FindSdat(filepath);
6870
} else
6971
sdats.emplace_back(filepath);
7072

71-
return true;
73+
return sdats;
7274
}
7375

7476
SdatX::SdatX(const std::string &filepath) : m_Filepath(filepath)
@@ -206,9 +208,9 @@ bool SdatX::Extract()
206208
int ret = 0;
207209
if((ret = SWAREX_init(&swarx, swar.Offset, swar.Length))) {
208210
if (ret == SWARE_BAD)
209-
printf("SWAR open error: Did not pass validation.\nMay be corrupted?\n");
211+
error("SWAR: Did not pass validation.\nMay be corrupted?\n");
210212
if (ret == SWARE_EMPTY)
211-
printf("SWAR open error: No files found to extract.\n");
213+
warning("SWAR: No files found to extract.\n");
212214

213215
SWAREX_exit(&swarx);
214216
fs::current_path("..");
@@ -301,7 +303,7 @@ bool SdatX::Extract()
301303
printf("Total written files:\n");
302304
printf(" SSEQ:%d\n", numSSEQ);
303305
printf(" SBNK:%d\n", numSBNK);
304-
printf(" %s:%d\n", bDecodeFile ? "SWAV" : "SWAR", numSWAR);
306+
printf(" %s:%d\n", (bDecodeFile || bGetSwav) ? "SWAV" : "SWAR", numSWAR);
305307
printf(" STRM:%d\n", numSTRM);
306308

307309
return true;

src/sdatxtract.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SdatX {
1212
bool Extract();
1313
bool Write();
1414

15-
static bool Init(const std::string &filepath, std::vector<SdatX> &sdats, bool &isNds);
15+
static std::vector<SdatX> Init(const std::string &filepath, bool &isNds);
1616

1717
private:
1818

0 commit comments

Comments
 (0)