test.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // Created by Иван_Архипов on 30.10.2017.
  3. //
  4. #define _CRT_SECURE_NO_WARNINGS
  5. #include <iostream>
  6. #include <windows.h>
  7. #include "LotroDatPatcher.h"
  8. using namespace LOTRO_DAT;
  9. int main() {
  10. std::ios_base::sync_with_stdio(0);
  11. std::cin.tie(0);
  12. std::string path = "E:\\SteamLibrary\\steamapps\\common\\Lord of the Rings Online\\";
  13. std::string filename = "client_local_English.dat";
  14. std::string output_dir = std::string("Data (") + filename + std::string(")\\");
  15. std::string txt_dir = "txt\\";
  16. std::string jpg_dir = "jpg\\";
  17. std::string dds_dir = "dds\\";
  18. std::string wav_dir = "wav\\";
  19. std::string ogg_dir = "ogg\\";
  20. std::string font_dir = "font\\";
  21. std::string unk_dir = "unk\\";
  22. int txt_all = 0, txt_suc = 0;
  23. int jpg_all = 0, jpg_suc = 0;
  24. int dds_all = 0, dds_suc = 0;
  25. int wav_all = 0, wav_suc = 0;
  26. int ogg_all = 0, ogg_suc = 0;
  27. int font_all = 0, font_suc = 0;
  28. int unk_all = 0, unk_suc = 0;
  29. CreateDirectory(output_dir.c_str(), nullptr);
  30. CreateDirectory((output_dir + txt_dir).c_str(), nullptr);
  31. CreateDirectory((output_dir + jpg_dir).c_str(), nullptr);
  32. CreateDirectory((output_dir + dds_dir).c_str(), nullptr);
  33. CreateDirectory((output_dir + wav_dir).c_str(), nullptr);
  34. CreateDirectory((output_dir + ogg_dir).c_str(), nullptr);
  35. CreateDirectory((output_dir + font_dir).c_str(), nullptr);
  36. CreateDirectory((output_dir + unk_dir).c_str(), nullptr);
  37. std::cerr << "Starting search...\n";
  38. DatFile a(path + filename);
  39. std::cerr << "Total files found: " << a.dictionary().size() << std::endl;
  40. std::cerr << "Writing unordered dictionary:\n";
  41. FILE *f;
  42. fopen_s(&f, (output_dir + "dict.txt").c_str(), "w");
  43. fprintf(f, "file_id | offset | extension\n");
  44. for (auto i : a.dictionary()) {
  45. std::string extension = "unk";
  46. EXTENSION ext = i.second->ext();
  47. if (ext == TXT) extension = "txt";
  48. if (ext == JPG) extension = "jpg";
  49. if (ext == DDS) extension = "dds";
  50. if (ext == WAV) extension = "wav";
  51. if (ext == OGG) extension = "ogg";
  52. if (ext == FONT) extension = "font";
  53. fprintf(f, "%lld %lld %s\n", i.second->file_id(), i.second->file_offset(), extension.c_str());
  54. }
  55. fclose(f);
  56. std::cerr << "Beginning unpacking...\n";
  57. long long all = a.dictionary().size();
  58. long long counter = 0;
  59. for (auto i : a.dictionary())
  60. {
  61. EXTENSION ext = i.second->ext();
  62. if (ext == TXT) {
  63. txt_all++;
  64. //txt_suc += i.second->ExportFile((output_dir + txt_dir + std::to_string(i.second->file_id())).c_str());
  65. }
  66. if (ext == JPG) {
  67. jpg_all++;
  68. jpg_suc += i.second->ExportFile((output_dir + jpg_dir + std::to_string(i.second->file_id())).c_str());
  69. }
  70. if (ext == DDS) {
  71. dds_all++;
  72. dds_suc += i.second->ExportFile((output_dir + dds_dir + std::to_string(i.second->file_id())).c_str());
  73. }
  74. if (ext == WAV) {
  75. wav_all++;
  76. wav_suc += i.second->ExportFile((output_dir + wav_dir + std::to_string(i.second->file_id())).c_str());
  77. }
  78. if (ext == OGG) {
  79. ogg_all++;
  80. ogg_suc += i.second->ExportFile((output_dir + ogg_dir + std::to_string(i.second->file_id())).c_str());
  81. }
  82. if (ext == FONT) {
  83. font_all++;
  84. //font_suc += i.second->ExportFile((output_dir + font_dir + std::to_string(i.second->file_id())).c_str());
  85. }
  86. if (ext == UNKNOWN)
  87. {
  88. //cout << " - unk\n";
  89. unk_all++;
  90. //unk_suc += i.second->ExportFile((output_dir + unk_dir + std::to_string(i.second->file_id())).c_str());
  91. }
  92. counter++;
  93. if ((counter - 1) * 100ll / all != counter * 100ll / all) {
  94. fprintf(stderr, "Done: %lld%%\n", counter * 100ll / all);
  95. }
  96. }
  97. std::cerr << "Total found:" << std::endl;
  98. std::cerr << "Txt: " << txt_all << std::endl
  99. << "JPG: " << jpg_all << std::endl
  100. << "DDS: " << dds_all << std::endl
  101. << "WAV: " << wav_all << std::endl
  102. << "OGG: " << ogg_all << std::endl
  103. << "Fonts " << font_all << std::endl
  104. << "Unknown: " << unk_all << std::endl;
  105. std::cerr << "Total exported:" << std::endl;
  106. std::cerr << "Txt: " << txt_suc << std::endl
  107. << "JPG: " << jpg_suc << std::endl
  108. << "DDS: " << dds_suc << std::endl
  109. << "WAV: " << wav_suc << std::endl
  110. << "OGG: " << ogg_suc << std::endl
  111. << "Fonts " << font_suc << std::endl
  112. << "Unknown: " << unk_suc << std::endl;
  113. std::cerr << "Success. Press enter to close";
  114. system("pause");
  115. return 0;
  116. }