extract_test.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // Created by Иван_Архипов on 30.10.2017.
  3. //
  4. #define _CRT_SECURE_NO_WARNINGS
  5. #include <iostream>
  6. #include <ctime>
  7. #include <algorithm>
  8. #ifdef WIN32
  9. #include <direct.h>
  10. #define mkdir(dir, mode) _mkdir(dir)
  11. #endif
  12. #include "../LotroDatPatcher.h"
  13. using namespace LOTRO_DAT;
  14. // Change these 2 variables to your path and name of .dat file
  15. const std::string path = "";//"E:\\SteamLibrary\\steamapps\\common\\";//Lord Of The Rings Online\\";
  16. const std::string filename = "client_local_English.dat";
  17. // Change these variables to true if you want export catecory to files.
  18. const bool exportImagesToFiles = true;
  19. const bool exportFontsToFiles = true;
  20. const bool exportSoundsToFiles = true;
  21. const bool exportTexturesToFiles = true;
  22. const bool exportUnknownToFiles = true;
  23. // Change these variables to true if you want export catecory to databases.
  24. const bool exportTextsToDb = true;
  25. const bool exportImagesToDb = true;
  26. const bool exportFontsToDb = true;
  27. const bool exportSoundsToDb = true;
  28. const bool exportTexturesToDb = true;
  29. const bool exportUnknownToDb = true;
  30. // There is no need to change anything else
  31. int main() {
  32. const clock_t begin_time = clock();
  33. std::time_t time = std::time(nullptr);
  34. mkdir("Extracted data", 744);
  35. std::time_t result = std::time(nullptr);
  36. char *ttime = std::asctime(std::localtime(&result));
  37. char *out_time = new char[25];
  38. memcpy(out_time, ttime, 24);
  39. out_time[24] = '\0';
  40. std::string output_dir = std::string("Extracted data\\") + filename + " " + std::string(out_time) + "\\";
  41. std::replace(output_dir.begin(), output_dir.end(), ':', '-');
  42. mkdir(output_dir.c_str(), 744);
  43. freopen((output_dir + std::string("errors.log")).c_str(), "w", stderr);
  44. try {
  45. std::cout << "Starting search...\n";
  46. DatFile a((path + filename).c_str(), 0);
  47. std::cout << "Total files found: " << a.files_number() << std::endl;
  48. std::cout << "Writing unordered dictionary:\n";
  49. a.WriteUnorderedDictionary(output_dir);
  50. std::cout << "Beginning unpacking... Please, wait for some minutes."
  51. "\nMaybe it's a good idea to have a cup of tea, while unpacker is working...\n";
  52. if (exportImagesToDb) {
  53. Database *images = new Database(output_dir + std::string("Images.db"));
  54. std::cout << "Extracted " << a.ExtractAllFilesByType(JPG, images) << " .jpg files to Images.db" << std::endl;
  55. delete images;
  56. }
  57. if (exportSoundsToDb) {
  58. Database *sounds = new Database(output_dir + std::string("Sounds.db"));
  59. std::cout << "Extracted " << a.ExtractAllFilesByType(WAV, sounds) << " .wav files to Sounds.db" << std::endl;
  60. std::cout << "Extracted " << a.ExtractAllFilesByType(OGG, sounds) << " .ogg files to Sounds.db" << std::endl;
  61. delete sounds;
  62. }
  63. if (exportTextsToDb) {
  64. Database *texts = new Database(output_dir + std::string("Texts.db"));
  65. std::cout << "Extracted " << a.ExtractAllFilesByType(TEXT, texts) << " text files to Texts.db" << std::endl;
  66. delete texts;
  67. }
  68. if (exportFontsToDb) {
  69. Database *fonts = new Database(output_dir + std::string("Fonts.db"));
  70. std::cout << "Extracted " << a.ExtractAllFilesByType(FONT, fonts) << " font files to Fonts.db" << std::endl;
  71. delete fonts;
  72. }
  73. if (exportTexturesToDb) {
  74. Database *textures = new Database(output_dir + std::string("Textures.db"));
  75. std::cout << "Extracted " << a.ExtractAllFilesByType(DDS, textures) << " .dds files to Textures.db" << std::endl;
  76. delete textures;
  77. }
  78. if (exportUnknownToDb) {
  79. Database *unknown = new Database(output_dir + std::string("Unknown.db"));
  80. std::cout << "Extracted " << a.ExtractAllFilesByType(UNKNOWN, unknown) << " unknown files to Unknown.db" << std::endl;
  81. }
  82. if (exportImagesToFiles) {
  83. mkdir((output_dir + "jpg").c_str(), 744);
  84. std::cout << "Extracted " << a.ExtractAllFilesByType(JPG, output_dir + "jpg\\") << " .jpg files to directory" << std::endl;
  85. }
  86. if (exportTexturesToFiles) {
  87. mkdir((output_dir + "dds").c_str(), 744);
  88. std::cout << "Extracted " << a.ExtractAllFilesByType(DDS, output_dir + "dds\\") << " .dds files to directory" << std::endl;
  89. }
  90. if (exportSoundsToFiles) {
  91. mkdir((output_dir + "wav").c_str(), 744);
  92. std::cout << "Extracted " << a.ExtractAllFilesByType(WAV, output_dir + "wav\\") << " .wav files to directory" << std::endl;
  93. mkdir((output_dir + "ogg").c_str(), 744);
  94. std::cout << "Extracted " << a.ExtractAllFilesByType(OGG, output_dir + "ogg\\") << " .ogg files to directory" << std::endl;
  95. }
  96. if (exportFontsToFiles) {
  97. mkdir((output_dir + "fonts").c_str(), 744);
  98. std::cout << "Extracted " << a.ExtractAllFilesByType(FONT, output_dir + "fonts\\") << " font files to directory" << std::endl;
  99. }
  100. if (exportUnknownToFiles) {
  101. mkdir((output_dir + "unknown").c_str(), 744);
  102. std::cout << "Extracted " << a.ExtractAllFilesByType(FONT, output_dir + "unknown\\") << " unknown files to directory" << std::endl;
  103. }
  104. } catch (...) {
  105. printf("Some critical errors occured. Need to stop execution. See information in errors.log file");
  106. fprintf(stderr, "Some critical errors occured. Need to stop execution now...");
  107. }
  108. fprintf(stdout, "Spent %f seconds on running unpacker! Thank you for your patience!\n",
  109. float(clock() - begin_time) / CLOCKS_PER_SEC);
  110. system("pause");
  111. return 0;
  112. }