|
@@ -45,14 +45,12 @@ int main() {
|
|
|
std::cout << "Using .dat file from dat_file_path.txt...\n";
|
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
|
|
|
- if (file.InitDatFile(filename, 0) == false) {
|
|
|
- std::cout << "Dat file path from dat_file_path.txt - " << filename << " may be incorrect (cannot open "
|
|
|
- "DatFile due to error. See it in errors.log)\n";
|
|
|
- file.CloseDatFile();
|
|
|
- }
|
|
|
+ auto operation = file.Initialise(filename, 0);
|
|
|
+ if (operation.result == false)
|
|
|
+ std::cout << "Dat initialisation failed. Error message: " << operation.msg << "\n";
|
|
|
}
|
|
|
|
|
|
- while (file.DatFileState() == CLOSED) {
|
|
|
+ while (!file.Initialized()) {
|
|
|
std::cout << "Please, tell, where the .dat file is\n";
|
|
|
std::cout << "Enter path to file (including filename): ";
|
|
|
std::string filename;
|
|
@@ -60,25 +58,15 @@ int main() {
|
|
|
|
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
|
|
|
- if (file.InitDatFile(filename, 0) == false) {
|
|
|
- std::cout << "Some error caused while opening the file... "
|
|
|
- "Could you enter .dat filename once more?" << std::endl;
|
|
|
- file.CloseDatFile();
|
|
|
- }
|
|
|
+ auto operation = file.Initialise(filename, 0);
|
|
|
+ if (operation.result == false)
|
|
|
+ std::cout << "Dat initialisation failed. Error message: " << operation.msg << "\nTo try again enter path to .dat file\n";
|
|
|
}
|
|
|
|
|
|
std::cout << "Great! File initialised successfully!\n";
|
|
|
- if (file.CheckIfNotPatched())
|
|
|
- std::cout << "MESSAGE: Dat file is new and haven't been patched yet\n";
|
|
|
-
|
|
|
- if (file.CheckIfPatchedByOldLauncher())
|
|
|
- std::cout << "MESSAGE: Dat file was patched by old launcher. Capability isn't guaranteed! Some functions may not work properly!!!\n";
|
|
|
-
|
|
|
- if (file.CheckIfUpdatedByGame())
|
|
|
- std::cout << "MESSAGE: .dat file was updated by game! Need to repair patches with functions RepairPatches() and FinishRepairingPatches()\n";
|
|
|
-
|
|
|
- std::cout << "Files number: " << file.files_number() << std::endl;
|
|
|
-
|
|
|
+ std::cout << "Gathering file information...";
|
|
|
+ file.GatherInformation("dat_info.log");
|
|
|
+
|
|
|
int cmd = 0;
|
|
|
while (true) {
|
|
|
std::cout << "Please, choose, what should I do. I can extract .dat file to files (press 1), "
|
|
@@ -107,13 +95,13 @@ int main() {
|
|
|
memcpy(out_time, ttime, 24);
|
|
|
out_time[24] = '\0';
|
|
|
|
|
|
- std::string output_dir = std::string("Extracted data\\") + file.filename().substr(file.filename().length() - 16, 16) + " " + std::string(out_time) + "\\";
|
|
|
+ std::string filename = file.getIO().GetFilename().value;
|
|
|
+
|
|
|
+ std::string output_dir = std::string("Extracted data\\") + filename.substr(filename.length() - 16, 16) + " " + std::string(out_time) + "\\";
|
|
|
std::replace(output_dir.begin(), output_dir.end(), ':', '-');
|
|
|
|
|
|
mkdir(output_dir.c_str(), 744);
|
|
|
|
|
|
- std::cout << "Total files found: " << file.files_number() << std::endl << std::flush;
|
|
|
- file.WriteUnorderedDictionary(output_dir);
|
|
|
std::cout << "Beginning unpacking... Please, wait for some minutes."
|
|
|
"\nMaybe it's a good idea to have a cup of tea, while unpacker is working...\n" << std::flush;
|
|
|
|
|
@@ -121,63 +109,63 @@ int main() {
|
|
|
|
|
|
if (exportImagesToDb) {
|
|
|
output_db.InitDatabase(output_dir + std::string("Images.db"));
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(JPG, &output_db) << " .jpg files to Images.db" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(JPG, &output_db).value << " .jpg files to Images.db" << std::endl << std::flush;
|
|
|
output_db.CloseDatabase();
|
|
|
}
|
|
|
|
|
|
if (exportSoundsToDb) {
|
|
|
output_db.InitDatabase(output_dir + std::string("Sounds.db"));
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(WAV, &output_db) << " .wav files to Sounds.db" << std::endl << std::flush;
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(OGG, &output_db) << " .ogg files to Sounds.db" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(WAV, &output_db).value << " .wav files to Sounds.db" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(OGG, &output_db).value << " .ogg files to Sounds.db" << std::endl << std::flush;
|
|
|
output_db.CloseDatabase();
|
|
|
}
|
|
|
|
|
|
if (exportTextsToDb) {
|
|
|
output_db.InitDatabase(output_dir + std::string("Texts.db"));
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(TEXT, &output_db) << " text files to Texts.db" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(TEXT, &output_db).value << " text files to Texts.db" << std::endl << std::flush;
|
|
|
output_db.CloseDatabase();
|
|
|
}
|
|
|
|
|
|
if (exportFontsToDb) {
|
|
|
output_db.InitDatabase(output_dir + std::string("Fonts.db"));
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(FONT, &output_db) << " font files to Fonts.db" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(FONT, &output_db).value << " font files to Fonts.db" << std::endl << std::flush;
|
|
|
output_db.CloseDatabase();
|
|
|
}
|
|
|
|
|
|
if (exportTexturesToDb) {
|
|
|
output_db.InitDatabase(output_dir + std::string("Textures.db"));
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(DDS, &output_db) << " .dds files to Textures.db" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(DDS, &output_db).value << " .dds files to Textures.db" << std::endl << std::flush;
|
|
|
output_db.CloseDatabase();
|
|
|
}
|
|
|
|
|
|
if (exportImagesToFiles) {
|
|
|
mkdir((output_dir + "jpg").c_str(), 744);
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(JPG, output_dir + "jpg\\") << " .jpg files to directory" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(JPG, output_dir + "jpg\\").value << " .jpg files to directory" << std::endl << std::flush;
|
|
|
}
|
|
|
|
|
|
if (exportTexturesToFiles) {
|
|
|
mkdir((output_dir + "dds").c_str(), 744);
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(DDS, output_dir + "dds\\") << " .dds files to directory" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(DDS, output_dir + "dds\\").value << " .dds files to directory" << std::endl << std::flush;
|
|
|
}
|
|
|
|
|
|
if (exportSoundsToFiles) {
|
|
|
mkdir((output_dir + "wav").c_str(), 744);
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(WAV, output_dir + "wav\\") << " .wav files to directory" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(WAV, output_dir + "wav\\").value << " .wav files to directory" << std::endl << std::flush;
|
|
|
mkdir((output_dir + "ogg").c_str(), 744);
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(OGG, output_dir + "ogg\\") << " .ogg files to directory" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(OGG, output_dir + "ogg\\").value << " .ogg files to directory" << std::endl << std::flush;
|
|
|
}
|
|
|
|
|
|
if (exportFontsToFiles) {
|
|
|
mkdir((output_dir + "fonts").c_str(), 744);
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(FONT, output_dir + "fonts\\") << " font files to directory" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(FONT, output_dir + "fonts\\").value << " font files to directory" << std::endl << std::flush;
|
|
|
}
|
|
|
|
|
|
if (exportUnknownToFiles) {
|
|
|
mkdir((output_dir + "unknown").c_str(), 744);
|
|
|
- std::cout << "Extracted " << file.ExtractAllFilesByType(UNKNOWN, output_dir + "unknown\\") << " unknown files to directory" << std::endl << std::flush;
|
|
|
+ std::cout << "Extracted " << file.getExporter().ExtractAllFilesByType(UNKNOWN, output_dir + "unknown\\").value << " unknown files to directory" << std::endl << std::flush;
|
|
|
}
|
|
|
|
|
|
- file.CloseDatFile();
|
|
|
+ file.Deinitialize();
|
|
|
|
|
|
fprintf(stdout, "Spent %f seconds on running unpacker! Thank you for your patience!\n",
|
|
|
float(clock() - begin_time) / CLOCKS_PER_SEC);
|
|
@@ -185,10 +173,9 @@ int main() {
|
|
|
|
|
|
if (cmd == 2) {
|
|
|
std::cout << "Closing file...\n";
|
|
|
- if (!file.CloseDatFile())
|
|
|
- std::cout << "An error occured while closing the file!!!\n";
|
|
|
+ file.Deinitialize();
|
|
|
|
|
|
- while (file.DatFileState() == CLOSED) {
|
|
|
+ while (!file.Initialized()) {
|
|
|
std::cout << "Please, tell, where the .dat file is\n";
|
|
|
std::cout << "Enter path to file (including filename): ";
|
|
|
std::string filename;
|
|
@@ -196,10 +183,12 @@ int main() {
|
|
|
|
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
|
|
|
- if (file.InitDatFile(filename, 0) == false) {
|
|
|
+ auto operation = file.Initialise(filename, 0);
|
|
|
+ if (operation.result == false) {
|
|
|
std::cout << "Some error caused while opening the file... "
|
|
|
"Could you enter .dat filename once more?" << std::endl;
|
|
|
- file.CloseDatFile();
|
|
|
+ std::cout << "Error message: " << operation.msg << std::endl;
|
|
|
+ file.Deinitialize();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -275,7 +264,7 @@ int main() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- file.CloseDatFile();
|
|
|
+ file.Deinitialize();
|
|
|
system("pause");
|
|
|
return 0;
|
|
|
}
|