DatLocaleManager.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 {
  17. PATCHED,
  18. ORIGINAL
  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. private:
  32. std::map<long long, SubFile>& GetLocaleDictReference(LOCALE locale);
  33. private:
  34. DatFile *dat;
  35. std::map<long long, SubFile> orig_dict_;
  36. std::map<long long, SubFile> patch_dict_;
  37. std::set<long long> inactive_categories;
  38. LOCALE current_locale_;
  39. };
  40. }
  41. };
  42. /*
  43. * ======== LOCALE DICT STRUCTURE =========
  44. * 4 bytes for block size (in bytes)
  45. * 4 bytes for locale version
  46. * 4 bytes for .dat file size (with patches)
  47. * 15 bytes for "Hi from Gi1dor"
  48. * 4 bytes for LOCALE
  49. * 4 bytes for orig_dict.size()
  50. * (32 + 4) * orig_dict.size() bytes for orig_dict data
  51. * 4 bytes for patch_dict.size()
  52. * (32 + 4) * patch_dict.size() bytes for patch_dict data
  53. * 4 bytes for inactive_categories dict
  54. * 4 * inactive_categories.size() bytes for inactive_categories data
  55. */
  56. #endif //LOTRO_DAT_LIBRARY_DATLOCALEMANAGER_H