ArtSlotInfo.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * ArtSlotInfo.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 "CArtifactInstance.h"
  12. #include "../../constants/EntityIdentifiers.h"
  13. #include "../../callback/GameCallbackHolder.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. struct DLL_LINKAGE ArtSlotInfo : public GameCallbackHolder
  16. {
  17. ArtifactInstanceID artifactID;
  18. bool locked = false; //if locked, then artifact points to the combined artifact
  19. explicit ArtSlotInfo(IGameInfoCallback * cb);
  20. ArtSlotInfo(const CArtifactInstance * artifact, bool locked);
  21. const CArtifactInstance * getArt() const;
  22. ArtifactInstanceID getID() const;
  23. template<typename Handler>
  24. void serialize(Handler & h)
  25. {
  26. if(h.saving || h.hasFeature(Handler::Version::NO_RAW_POINTERS_IN_SERIALIZER))
  27. {
  28. h & artifactID;
  29. }
  30. else
  31. {
  32. std::shared_ptr<CArtifactInstance> pointer;
  33. h & pointer;
  34. if(pointer->getId() == ArtifactInstanceID())
  35. CArtifactInstance::saveCompatibilityFixArtifactID(pointer);
  36. artifactID = pointer->getId();
  37. }
  38. h & locked;
  39. }
  40. };
  41. VCMI_LIB_NAMESPACE_END