VCMI_Lib.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * VCMI_Lib.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. class CConsoleHandler;
  12. class CArtHandler;
  13. class CHeroHandler;
  14. class CCreatureHandler;
  15. class CSpellHandler;
  16. class CSkillHandler;
  17. class CBuildingHandler;
  18. class CObjectHandler;
  19. class CObjectClassesHandler;
  20. class CTownHandler;
  21. class CGeneralTextHandler;
  22. class CModHandler;
  23. class CContentHandler;
  24. class IBonusTypeHandler;
  25. class CBonusTypeHandler;
  26. class CTerrainViewPatternConfig;
  27. class CRmgTemplateStorage;
  28. /// Loads and constructs several handlers
  29. class DLL_LINKAGE LibClasses
  30. {
  31. CBonusTypeHandler * bth;
  32. void callWhenDeserializing(); //should be called only by serialize !!!
  33. void makeNull(); //sets all handler pointers to null
  34. std::shared_ptr<CContentHandler> getContent() const;
  35. void setContent(std::shared_ptr<CContentHandler> content);
  36. public:
  37. bool IS_AI_ENABLED; //unused?
  38. const IBonusTypeHandler * getBth() const;
  39. CArtHandler * arth;
  40. CHeroHandler * heroh;
  41. CCreatureHandler * creh;
  42. CSpellHandler * spellh;
  43. CSkillHandler * skillh;
  44. CObjectHandler * objh;
  45. CObjectClassesHandler * objtypeh;
  46. CTownHandler * townh;
  47. CGeneralTextHandler * generaltexth;
  48. CModHandler * modh;
  49. CTerrainViewPatternConfig * terviewh;
  50. CRmgTemplateStorage * tplh;
  51. LibClasses(); //c-tor, loads .lods and NULLs handlers
  52. ~LibClasses();
  53. void init(bool onlyEssential); //uses standard config file
  54. void clear(); //deletes all handlers and its data
  55. void loadFilesystem(bool onlyEssential);// basic initialization. should be called before init()
  56. template <typename Handler> void serialize(Handler &h, const int version)
  57. {
  58. h & heroh;
  59. h & arth;
  60. h & creh;
  61. h & townh;
  62. h & objh;
  63. h & objtypeh;
  64. h & spellh;
  65. if(version >= 777)
  66. {
  67. h & skillh;
  68. }
  69. if(!h.saving)
  70. {
  71. //modh will be changed and modh->content will be empty after deserialization
  72. auto content = getContent();
  73. h & modh;
  74. setContent(content);
  75. }
  76. else
  77. h & modh;
  78. h & IS_AI_ENABLED;
  79. h & bth;
  80. if(!h.saving)
  81. {
  82. callWhenDeserializing();
  83. }
  84. }
  85. };
  86. extern DLL_LINKAGE LibClasses * VLC;
  87. DLL_LINKAGE void preinitDLL(CConsoleHandler * Console, bool onlyEssential = false);
  88. DLL_LINKAGE void loadDLLClasses(bool onlyEssential = false);