ModVerificationInfo.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * ModVerificationInfo.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "CModVersion.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class JsonNode;
  14. struct ModVerificationInfo;
  15. using ModCompatibilityInfo = std::map<std::string, ModVerificationInfo>;
  16. enum class ModVerificationStatus
  17. {
  18. NOT_INSTALLED, /// Mod is not installed locally
  19. DISABLED, /// Mod is installed locally but not enabled
  20. EXCESSIVE, /// Mod is enabled locally but must be disabled
  21. VERSION_MISMATCH, /// Mod is present on both sides, but has different version
  22. FULL_MATCH, /// No issues detected, everything matches
  23. };
  24. using ModListVerificationStatus = std::map<std::string, ModVerificationStatus>;
  25. struct DLL_LINKAGE ModVerificationInfo
  26. {
  27. /// human-readable mod name
  28. std::string name;
  29. /// version of the mod
  30. CModVersion version;
  31. /// CRC-32 checksum of the mod
  32. ui32 checksum = 0;
  33. /// parent mod ID, empty if root-level mod
  34. TModID parent;
  35. /// for serialization purposes
  36. bool impactsGameplay = true;
  37. static JsonNode jsonSerializeList(const ModCompatibilityInfo & input);
  38. static ModCompatibilityInfo jsonDeserializeList(const JsonNode & input);
  39. static ModListVerificationStatus verifyListAgainstLocalMods(const ModCompatibilityInfo & input);
  40. template <typename Handler>
  41. void serialize(Handler & h)
  42. {
  43. h & name;
  44. h & version;
  45. h & checksum;
  46. h & parent;
  47. h & impactsGameplay;
  48. }
  49. };
  50. VCMI_LIB_NAMESPACE_END