123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // Created by Иван_Архипов on 30.10.2017.
- //
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <ctime>
- #include <algorithm>
- #ifdef WIN32
- #include <direct.h>
- #define mkdir(dir, mode) _mkdir(dir)
- #endif
- #include "../LotroDatPatcher.h"
- using namespace LOTRO_DAT;
- // Change these 2 variables to your path and name of .dat file
- const std::string path = "";//"E:\\SteamLibrary\\steamapps\\common\\";//Lord Of The Rings Online\\";
- const std::string filename = "client_local_English.dat";
- // Change these variables to true if you want export catecory to files.
- const bool exportImagesToFiles = true;
- const bool exportFontsToFiles = true;
- const bool exportSoundsToFiles = true;
- const bool exportTexturesToFiles = true;
- const bool exportUnknownToFiles = true;
- // Change these variables to true if you want export catecory to databases.
- const bool exportTextsToDb = true;
- const bool exportImagesToDb = true;
- const bool exportFontsToDb = true;
- const bool exportSoundsToDb = true;
- const bool exportTexturesToDb = true;
- const bool exportUnknownToDb = true;
- // There is no need to change anything else
- int main() {
- const clock_t begin_time = clock();
- std::time_t time = std::time(nullptr);
- mkdir("Extracted data", 744);
- std::time_t result = std::time(nullptr);
- char *ttime = std::asctime(std::localtime(&result));
- char *out_time = new char[25];
- memcpy(out_time, ttime, 24);
- out_time[24] = '\0';
- std::string output_dir = std::string("Extracted data\\") + filename + " " + std::string(out_time) + "\\";
- std::replace(output_dir.begin(), output_dir.end(), ':', '-');
- mkdir(output_dir.c_str(), 744);
- freopen((output_dir + std::string("errors.log")).c_str(), "w", stderr);
- try {
- std::cout << "Starting search...\n";
- DatFile a((path + filename).c_str(), 0);
- std::cout << "Total files found: " << a.files_number() << std::endl;
- std::cout << "Writing unordered dictionary:\n";
- a.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";
- if (exportImagesToDb) {
- Database *images = new Database(output_dir + std::string("Images.db"));
- std::cout << "Extracted " << a.ExtractAllFilesByType(JPG, images) << " .jpg files to Images.db" << std::endl;
- delete images;
- }
- if (exportSoundsToDb) {
- Database *sounds = new Database(output_dir + std::string("Sounds.db"));
- std::cout << "Extracted " << a.ExtractAllFilesByType(WAV, sounds) << " .wav files to Sounds.db" << std::endl;
- std::cout << "Extracted " << a.ExtractAllFilesByType(OGG, sounds) << " .ogg files to Sounds.db" << std::endl;
- delete sounds;
- }
- if (exportTextsToDb) {
- Database *texts = new Database(output_dir + std::string("Texts.db"));
- std::cout << "Extracted " << a.ExtractAllFilesByType(TEXT, texts) << " text files to Texts.db" << std::endl;
- delete texts;
- }
- if (exportFontsToDb) {
- Database *fonts = new Database(output_dir + std::string("Fonts.db"));
- std::cout << "Extracted " << a.ExtractAllFilesByType(FONT, fonts) << " font files to Fonts.db" << std::endl;
- delete fonts;
- }
- if (exportTexturesToDb) {
- Database *textures = new Database(output_dir + std::string("Textures.db"));
- std::cout << "Extracted " << a.ExtractAllFilesByType(DDS, textures) << " .dds files to Textures.db" << std::endl;
- delete textures;
- }
- if (exportUnknownToDb) {
- Database *unknown = new Database(output_dir + std::string("Unknown.db"));
- std::cout << "Extracted " << a.ExtractAllFilesByType(UNKNOWN, unknown) << " unknown files to Unknown.db" << std::endl;
- }
- if (exportImagesToFiles) {
- mkdir((output_dir + "jpg").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(JPG, output_dir + "jpg\\") << " .jpg files to directory" << std::endl;
- }
- if (exportTexturesToFiles) {
- mkdir((output_dir + "dds").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(DDS, output_dir + "dds\\") << " .dds files to directory" << std::endl;
- }
- if (exportSoundsToFiles) {
- mkdir((output_dir + "wav").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(WAV, output_dir + "wav\\") << " .wav files to directory" << std::endl;
- mkdir((output_dir + "ogg").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(OGG, output_dir + "ogg\\") << " .ogg files to directory" << std::endl;
- }
- if (exportFontsToFiles) {
- mkdir((output_dir + "fonts").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(FONT, output_dir + "fonts\\") << " font files to directory" << std::endl;
- }
- if (exportUnknownToFiles) {
- mkdir((output_dir + "unknown").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(FONT, output_dir + "unknown\\") << " unknown files to directory" << std::endl;
- }
- } catch (...) {
- printf("Some critical errors occured. Need to stop execution. See information in errors.log file");
- fprintf(stderr, "Some critical errors occured. Need to stop execution now...");
- }
- fprintf(stdout, "Spent %f seconds on running unpacker! Thank you for your patience!\n",
- float(clock() - begin_time) / CLOCKS_PER_SEC);
- system("pause");
- return 0;
- }
|