123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- //
- // 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 "LotroDat.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 = false;
- const bool exportFontsToFiles = false;
- const bool exportSoundsToFiles = false;
- const bool exportTexturesToFiles = false;
- const bool exportUnknownToFiles = true;
- // Change these variables to true if you want export catecory to databases.
- const bool exportTextsToDb = false;
- const bool exportImagesToDb = false;
- const bool exportFontsToDb = false;
- const bool exportSoundsToDb = false;
- const bool exportTexturesToDb = false;
- const bool exportUnknownToDb = false;
- // There is no need to change anything else
- int main() {
- std::cout << "Gi1dor's LotRO .dat extractor ver. 3.1.0" << std::endl;
- const clock_t begin_time = clock();
- mkdir("Extracted data", 744);
- std::time_t result = std::time(nullptr);
- char *ttime = std::asctime(std::localtime(&result));
- auto *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);
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
- setvbuf (stdout, NULL, _IONBF, BUFSIZ);
- setvbuf (stderr, NULL, _IONBF, BUFSIZ);
- std::cout << "Starting search...\n" << std::flush;
- DatFile a;
- if (!a.InitDatFile(path + filename, 0)) {
- std::cout << "Unable to initialize .dat file in " << path + filename << std::endl;
- system("pause");
- return 0;
- }
- std::cout << "Total files found: " << a.files_number() << std::endl << std::flush;
- 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" << std::flush;
- Database output_db;
- if (exportImagesToDb) {
- output_db.InitDatabase(output_dir + std::string("Images.db"));
- std::cout << "Extracted " << a.ExtractAllFilesByType(JPG, &output_db) << " .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 " << a.ExtractAllFilesByType(WAV, &output_db) << " .wav files to Sounds.db" << std::endl << std::flush;
- std::cout << "Extracted " << a.ExtractAllFilesByType(OGG, &output_db) << " .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 " << a.ExtractAllFilesByType(TEXT, &output_db) << " 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 " << a.ExtractAllFilesByType(FONT, &output_db) << " 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 " << a.ExtractAllFilesByType(DDS, &output_db) << " .dds files to Textures.db" << std::endl << std::flush;
- output_db.CloseDatabase();
- }
- if (exportImagesToFiles) {
- mkdir((output_dir + "jpg").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(JPG, output_dir + "jpg\\") << " .jpg files to directory" << std::endl << std::flush;
- }
- if (exportTexturesToFiles) {
- mkdir((output_dir + "dds").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(DDS, output_dir + "dds\\") << " .dds files to directory" << std::endl << std::flush;
- }
- if (exportSoundsToFiles) {
- mkdir((output_dir + "wav").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(WAV, output_dir + "wav\\") << " .wav files to directory" << std::endl << std::flush;
- mkdir((output_dir + "ogg").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(OGG, output_dir + "ogg\\") << " .ogg files to directory" << std::endl << std::flush;
- }
- if (exportFontsToFiles) {
- mkdir((output_dir + "fonts").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(FONT, output_dir + "fonts\\") << " font files to directory" << std::endl << std::flush;
- }
- if (exportUnknownToFiles) {
- mkdir((output_dir + "unknown").c_str(), 744);
- std::cout << "Extracted " << a.ExtractAllFilesByType(UNKNOWN, output_dir + "unknown\\") << " unknown files to directory" << std::endl << std::flush;
- }
- a.CloseDatFile();
- 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;
- }
|