patch_test.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. 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. const std::string patch_filename = "image.jpg";
  18. const int file_id = 0;
  19. int main() {
  20. const clock_t begin_time = clock();
  21. freopen("errors.log", "w", stderr);
  22. Database db;
  23. db.InitDatabase("images.db");
  24. DatFile *a;
  25. try {
  26. a = new DatFile((path + filename).c_str(), 0);
  27. std::cout << "Starting magic...\n";
  28. std::cout << "Files number: " << a->files_number() << std::endl;
  29. a->WriteUnorderedDictionary("");
  30. SubfileData data = db.GetNextFile();
  31. while (data != SubfileData()) {
  32. //binary_data.ReadFromFile("1090552107.jpg");
  33. //options["fid"] = "1090552107";
  34. //options["ext"] = ".jpg";
  35. a->PatchFile(data);
  36. data = db.GetNextFile();
  37. //delete a;
  38. }
  39. } catch (std::exception &e) {
  40. fprintf(stderr, "Caught %s exception.", e.what());
  41. printf("Caught %s exception.", e.what());
  42. fflush(stdout);
  43. printf("Some critical errors occured. Need to stop execution. See information in errors.log file");
  44. fprintf(stderr, "Some critical errors occured. Need to stop execution now...");
  45. }
  46. delete a;
  47. fprintf(stdout, "Spent %f seconds on performing magic! Thank you for your patience!\n",
  48. float(clock() - begin_time) / CLOCKS_PER_SEC);
  49. system("pause");
  50. return 0;
  51. }