|
@@ -5,7 +5,7 @@
|
|
#include <ctime>
|
|
#include <ctime>
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
|
|
|
-#ifdef WIN32
|
|
|
|
|
|
+#ifdef _WIN32
|
|
#include <direct.h>
|
|
#include <direct.h>
|
|
#define mkdir(dir, mode) _mkdir(dir)
|
|
#define mkdir(dir, mode) _mkdir(dir)
|
|
#endif
|
|
#endif
|
|
@@ -31,7 +31,56 @@ bool exportTexturesToDb = false;
|
|
bool exportUnknownToDb = false;
|
|
bool exportUnknownToDb = false;
|
|
// There is no need to change anything else
|
|
// There is no need to change anything else
|
|
|
|
|
|
|
|
+void DatStatusChangedHandler(DatStatus::ProgressInfo info) {
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_FREE) {
|
|
|
|
+ std::cout << "DatStatus: operation finished" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_BACKUP_CREATING) {
|
|
|
|
+ std::cout << "DatStatus: creating backup " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_BACKUP_REMOVING) {
|
|
|
|
+ std::cout << "DatStatus: removing backup " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_BACKUP_RESTORING) {
|
|
|
|
+ std::cout << "DatStatus: restoring backup " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_COMMITING) {
|
|
|
|
+ std::cout << "DatStatus: applying locales " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_EXTRACTING) {
|
|
|
|
+ std::cout << "DatStatus: extracting data " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_GATHERING_INFO) {
|
|
|
|
+ std::cout << "DatStatus: gathering info " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_INITIALISING) {
|
|
|
|
+ std::cout << "DatStatus: initialising " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (info.status == DatStatus::DAT_STATUS::E_PATCHING) {
|
|
|
|
+ std::cout << "DatStatus: applying patch " << info.percentage << "% "
|
|
|
|
+ << "(" << info.finished_parts << "/" << info.total_parts << ")" << std::endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
int main() {
|
|
int main() {
|
|
|
|
+ std::cout.precision(1);
|
|
|
|
+ std::cout << fixed;
|
|
std::cout << "Gi1dor's LotRO .dat extractor ver. " << LOTRO_DAT_VERSION << std::endl;
|
|
std::cout << "Gi1dor's LotRO .dat extractor ver. " << LOTRO_DAT_VERSION << std::endl;
|
|
|
|
|
|
std::cout << "Hello! I'm a basic shell version of .dat file extractor. I can open .dat file directly, "
|
|
std::cout << "Hello! I'm a basic shell version of .dat file extractor. I can open .dat file directly, "
|
|
@@ -42,13 +91,13 @@ int main() {
|
|
if (!in.fail()) {
|
|
if (!in.fail()) {
|
|
std::string filename;
|
|
std::string filename;
|
|
getline(in, filename);
|
|
getline(in, filename);
|
|
-
|
|
|
|
std::cout << "Using .dat file from dat_file_path.txt...\n";
|
|
std::cout << "Using .dat file from dat_file_path.txt...\n";
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
|
|
|
auto operation = file.Initialise(filename, 0);
|
|
auto operation = file.Initialise(filename, 0);
|
|
- if (operation.result == false)
|
|
|
|
|
|
+ if (operation.result == false) {
|
|
std::cout << "Dat initialisation failed. Error message: " << operation.msg << "\n";
|
|
std::cout << "Dat initialisation failed. Error message: " << operation.msg << "\n";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
while (!file.Initialized()) {
|
|
while (!file.Initialized()) {
|
|
@@ -60,12 +109,14 @@ int main() {
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
std::cout << "Opening file " << filename << std::endl;
|
|
|
|
|
|
auto operation = file.Initialise(filename, 0);
|
|
auto operation = file.Initialise(filename, 0);
|
|
- if (operation.result == false)
|
|
|
|
|
|
+ if (operation.result == false) {
|
|
std::cout << "Dat initialisation failed. Error message: " << operation.msg << "\nTo try again enter path to .dat file\n";
|
|
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";
|
|
std::cout << "Great! File initialised successfully!\n";
|
|
- std::cout << "Gathering file information...";
|
|
|
|
|
|
+ file.GetStatusModule().AddStatusChangedCallbackFunction(&DatStatusChangedHandler);
|
|
|
|
+ std::cout << "Gathering file information...\n";
|
|
file.GatherInformation("dat_info.log");
|
|
file.GatherInformation("dat_info.log");
|
|
|
|
|
|
int cmd = 0;
|
|
int cmd = 0;
|
|
@@ -111,65 +162,78 @@ int main() {
|
|
|
|
|
|
if (exportImagesToDb) {
|
|
if (exportImagesToDb) {
|
|
output_db.InitDatabase(output_dir + std::string("Images.db"));
|
|
output_db.InitDatabase(output_dir + std::string("Images.db"));
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(JPG, &output_db).value << " .jpg files to Images.db" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_jpg_files_num = file.GetExporter().ExtractAllFilesByType(JPG, &output_db).value;
|
|
|
|
+ std::cout << "Extracted " << extracted_jpg_files_num << " .jpg files to Images.db" << std::endl << std::flush;
|
|
output_db.CloseDatabase();
|
|
output_db.CloseDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
if (exportSoundsToDb) {
|
|
if (exportSoundsToDb) {
|
|
output_db.InitDatabase(output_dir + std::string("Sounds.db"));
|
|
output_db.InitDatabase(output_dir + std::string("Sounds.db"));
|
|
- 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;
|
|
|
|
|
|
+ int extracted_wav_files_num = file.GetExporter().ExtractAllFilesByType(WAV, &output_db).value;
|
|
|
|
+ int extracted_ogg_files_num = file.GetExporter().ExtractAllFilesByType(OGG, &output_db).value;
|
|
|
|
+ std::cout << "Extracted " << extracted_wav_files_num << " .wav files to Sounds.db" << std::endl << std::flush;
|
|
|
|
+ std::cout << "Extracted " << extracted_ogg_files_num << " .ogg files to Sounds.db" << std::endl << std::flush;
|
|
output_db.CloseDatabase();
|
|
output_db.CloseDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
if (exportTextsToDb) {
|
|
if (exportTextsToDb) {
|
|
output_db.InitDatabase(output_dir + std::string("Texts.db"));
|
|
output_db.InitDatabase(output_dir + std::string("Texts.db"));
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(TEXT, &output_db).value << " text files to Texts.db" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_text_files_num = file.GetExporter().ExtractAllFilesByType(TEXT, &output_db).value;
|
|
|
|
+ std::cout << "Extracted " << extracted_text_files_num << " text files to Texts.db" << std::endl << std::flush;
|
|
output_db.CloseDatabase();
|
|
output_db.CloseDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
if (exportFontsToDb) {
|
|
if (exportFontsToDb) {
|
|
output_db.InitDatabase(output_dir + std::string("Fonts.db"));
|
|
output_db.InitDatabase(output_dir + std::string("Fonts.db"));
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(FONT, &output_db).value << " font files to Fonts.db" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_font_files_num = file.GetExporter().ExtractAllFilesByType(FONT, &output_db).value;
|
|
|
|
+ std::cout << "Extracted " << extracted_font_files_num << " font files to Fonts.db" << std::endl << std::flush;
|
|
output_db.CloseDatabase();
|
|
output_db.CloseDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
if (exportTexturesToDb) {
|
|
if (exportTexturesToDb) {
|
|
output_db.InitDatabase(output_dir + std::string("Textures.db"));
|
|
output_db.InitDatabase(output_dir + std::string("Textures.db"));
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(DDS, &output_db).value << " .dds files to Textures.db" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_dds_files_num = file.GetExporter().ExtractAllFilesByType(DDS, &output_db).value;
|
|
|
|
+ std::cout << "Extracted " << extracted_dds_files_num << " .dds files to Textures.db" << std::endl << std::flush;
|
|
output_db.CloseDatabase();
|
|
output_db.CloseDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
if (exportImagesToFiles) {
|
|
if (exportImagesToFiles) {
|
|
mkdir((output_dir + "jpg").c_str(), 744);
|
|
mkdir((output_dir + "jpg").c_str(), 744);
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(JPG, output_dir + "jpg\\").value << " .jpg files to directory" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_jpg_files_num = file.GetExporter().ExtractAllFilesByType(JPG, output_dir + "jpg\\").value;
|
|
|
|
+ std::cout << "Extracted " << extracted_jpg_files_num << " .jpg files to directory" << std::endl << std::flush;
|
|
}
|
|
}
|
|
|
|
|
|
if (exportTexturesToFiles) {
|
|
if (exportTexturesToFiles) {
|
|
mkdir((output_dir + "dds").c_str(), 744);
|
|
mkdir((output_dir + "dds").c_str(), 744);
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(DDS, output_dir + "dds\\").value << " .dds files to directory" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_dds_files_num = file.GetExporter().ExtractAllFilesByType(DDS, output_dir + "dds\\").value;
|
|
|
|
+ std::cout << "Extracted " << extracted_dds_files_num << " .dds files to directory" << std::endl << std::flush;
|
|
}
|
|
}
|
|
|
|
|
|
if (exportSoundsToFiles) {
|
|
if (exportSoundsToFiles) {
|
|
mkdir((output_dir + "wav").c_str(), 744);
|
|
mkdir((output_dir + "wav").c_str(), 744);
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(WAV, output_dir + "wav\\").value << " .wav files to directory" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_wav_files_num = file.GetExporter().ExtractAllFilesByType(WAV, output_dir + "wav\\").value;
|
|
|
|
+ std::cout << "Extracted " << extracted_wav_files_num << " .wav files to directory" << std::endl << std::flush;
|
|
mkdir((output_dir + "ogg").c_str(), 744);
|
|
mkdir((output_dir + "ogg").c_str(), 744);
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(OGG, output_dir + "ogg\\").value << " .ogg files to directory" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_ogg_files_num = file.GetExporter().ExtractAllFilesByType(OGG, output_dir + "ogg\\").value;
|
|
|
|
+ std::cout << "Extracted " << extracted_ogg_files_num << " .ogg files to directory" << std::endl << std::flush;
|
|
}
|
|
}
|
|
|
|
|
|
if (exportFontsToFiles) {
|
|
if (exportFontsToFiles) {
|
|
mkdir((output_dir + "fonts").c_str(), 744);
|
|
mkdir((output_dir + "fonts").c_str(), 744);
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(FONT, output_dir + "fonts\\").value << " font files to directory" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_font_files_num = file.GetExporter().ExtractAllFilesByType(FONT, output_dir + "fonts\\").value;
|
|
|
|
+ std::cout << "Extracted " << extracted_font_files_num << " font files to directory" << std::endl << std::flush;
|
|
}
|
|
}
|
|
|
|
|
|
if (exportUnknownToFiles) {
|
|
if (exportUnknownToFiles) {
|
|
mkdir((output_dir + "unknown").c_str(), 744);
|
|
mkdir((output_dir + "unknown").c_str(), 744);
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(UNKNOWN, output_dir + "unknown\\").value << " unknown files to directory" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_unknown_files_num = file.GetExporter().ExtractAllFilesByType(UNKNOWN, output_dir + "unknown\\").value;
|
|
|
|
+ std::cout << "Extracted " << extracted_unknown_files_num << " unknown files to directory" << std::endl << std::flush;
|
|
}
|
|
}
|
|
|
|
|
|
if (exportTextsToFiles) {
|
|
if (exportTextsToFiles) {
|
|
mkdir((output_dir + "texts").c_str(), 744);
|
|
mkdir((output_dir + "texts").c_str(), 744);
|
|
- std::cout << "Extracted " << file.GetExporter().ExtractAllFilesByType(TEXT, output_dir + "texts\\").value << " text files to directory" << std::endl << std::flush;
|
|
|
|
|
|
+ int extracted_text_files_num = file.GetExporter().ExtractAllFilesByType(TEXT, output_dir + "texts\\").value;
|
|
|
|
+ std::cout << "Extracted " << extracted_text_files_num << " text files to directory" << std::endl << std::flush;
|
|
}
|
|
}
|
|
|
|
|
|
fprintf(stdout, "Spent %f seconds on running unpacker! Thank you for your patience!\n",
|
|
fprintf(stdout, "Spent %f seconds on running unpacker! Thank you for your patience!\n",
|