patch_test.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Created by Иван_Архипов on 23.11.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. #include "../Subfile.h"
  14. using namespace LOTRO_DAT;
  15. // Change these 2 variables to your path and name of .dat file
  16. const std::string path = "";//"E:\\SteamLibrary\\steamapps\\common\\";//Lord Of The Rings Online\\";
  17. const std::string filename = "client_local_English.dat";
  18. int main() {
  19. const clock_t begin_time = clock();
  20. freopen("errors.log", "w", stderr);
  21. //freopen("stdout.log", "w", stdout);
  22. setbuf(stdout, NULL);
  23. setbuf(stderr, NULL);
  24. setvbuf (stdout, NULL, _IONBF, BUFSIZ);
  25. setvbuf (stderr, NULL, _IONBF, BUFSIZ);
  26. Database db;
  27. db.InitDatabase("out.db");
  28. DatFile *a;
  29. try {
  30. a = new DatFile((path + filename).c_str(), 0);
  31. std::cout << "Starting magic...\n";
  32. std::cout << "Files number: " << a->files_number() << std::endl;
  33. a->WriteUnorderedDictionary("");
  34. a->PatchAllDatabase(&db);
  35. } catch (std::exception &e) {
  36. fprintf(stderr, "Caught %s exception.", e.what());
  37. printf("Caught %s exception.", e.what());
  38. fflush(stdout);
  39. printf("Some critical errors occured. Need to stop execution. See information in errors.log file");
  40. fprintf(stderr, "Some critical errors occured. Need to stop execution now...");
  41. }
  42. delete a;
  43. fprintf(stdout, "Spent %f seconds on performing magic! Thank you for your patience!\n",
  44. float(clock() - begin_time) / CLOCKS_PER_SEC);
  45. system("pause");
  46. return 0;
  47. }