VCMI_Lib.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. void restoreAllCreaturesNodeType794();
  37. public:
  38. bool IS_AI_ENABLED; //unused?
  39. const IBonusTypeHandler * getBth() const;
  40. CArtHandler * arth;
  41. CHeroHandler * heroh;
  42. CCreatureHandler * creh;
  43. CSpellHandler * spellh;
  44. CSkillHandler * skillh;
  45. CObjectHandler * objh;
  46. CObjectClassesHandler * objtypeh;
  47. CTownHandler * townh;
  48. CGeneralTextHandler * generaltexth;
  49. CModHandler * modh;
  50. CTerrainViewPatternConfig * terviewh;
  51. CRmgTemplateStorage * tplh;
  52. LibClasses(); //c-tor, loads .lods and NULLs handlers
  53. ~LibClasses();
  54. void init(bool onlyEssential); //uses standard config file
  55. void clear(); //deletes all handlers and its data
  56. void loadFilesystem(bool onlyEssential);// basic initialization. should be called before init()
  57. template <typename Handler> void serialize(Handler &h, const int version)
  58. {
  59. h & heroh;
  60. h & arth;
  61. h & creh;
  62. if(!h.saving && version < 794)
  63. restoreAllCreaturesNodeType794();
  64. h & townh;
  65. h & objh;
  66. h & objtypeh;
  67. h & spellh;
  68. if(version >= 777)
  69. {
  70. h & skillh;
  71. }
  72. if(!h.saving)
  73. {
  74. //modh will be changed and modh->content will be empty after deserialization
  75. auto content = getContent();
  76. h & modh;
  77. setContent(content);
  78. }
  79. else
  80. h & modh;
  81. h & IS_AI_ENABLED;
  82. h & bth;
  83. if(!h.saving)
  84. {
  85. callWhenDeserializing();
  86. }
  87. }
  88. };
  89. extern DLL_LINKAGE LibClasses * VLC;
  90. DLL_LINKAGE void preinitDLL(CConsoleHandler * Console, bool onlyEssential = false);
  91. DLL_LINKAGE void loadDLLClasses(bool onlyEssential = false);