DatLocaleManager.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // Created by kikab on 04.06.2018.
  3. //
  4. #ifndef LOTRO_DAT_LIBRARY_DATLOCALEMANAGER_H
  5. #define LOTRO_DAT_LIBRARY_DATLOCALEMANAGER_H
  6. #include <memory>
  7. #include <map>
  8. #include <DatOperationResult.h>
  9. #include <set>
  10. extern "C++" {
  11. namespace LOTRO_DAT {
  12. class DatFile;
  13. class SubFile;
  14. class DatLocaleManager {
  15. public:
  16. enum LOCALE : int {
  17. ORIGINAL = 0,
  18. PATCHED = 1
  19. };
  20. DatLocaleManager() = delete;
  21. DatLocaleManager(const DatLocaleManager &other) = delete;
  22. DatLocaleManager& operator=(const DatLocaleManager &other) = delete;
  23. ~DatLocaleManager() = default;
  24. explicit DatLocaleManager(DatFile *datFilePtr);
  25. DatOperationResult<> Init();
  26. DatOperationResult<> SetLocale(LOCALE locale);
  27. DatOperationResult<> DeInit();
  28. LOCALE GetCurrentLocale();
  29. void UpdateLocaleFile(LOCALE locale, const SubFile& file);
  30. DatOperationResult<SubFile> GetLocaleFile(long long file_id, LOCALE locale);
  31. void PrintInformaion(FILE* file);
  32. private:
  33. std::map<long long, SubFile>& GetLocaleDictReference(LOCALE locale);
  34. private:
  35. DatFile *dat;
  36. std::map<long long, SubFile> orig_dict_;
  37. std::map<long long, SubFile> patch_dict_;
  38. std::set<long long> inactive_categories;
  39. LOCALE current_locale_;
  40. };
  41. }
  42. };
  43. /*
  44. * ======== LOCALE DICT STRUCTURE =========
  45. * 4 bytes for block size (in bytes)
  46. * 4 bytes for locale version
  47. * 4 bytes for .dat file size (with patches)
  48. * 15 bytes for "Hi from Gi1dor"
  49. * 4 bytes for LOCALE
  50. * 4 bytes for orig_dict.size()
  51. * (32 + 4) * orig_dict.size() bytes for orig_dict data
  52. * 4 bytes for patch_dict.size()
  53. * (32 + 4) * patch_dict.size() bytes for patch_dict data
  54. * 4 bytes for inactive_categories dict
  55. * 4 * inactive_categories.size() bytes for inactive_categories data
  56. */
  57. #endif //LOTRO_DAT_LIBRARY_DATLOCALEMANAGER_H