MapFeaturesH3M.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * MapFeaturesH3M.cpp, 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. #include "StdInc.h"
  11. #include "MapFeaturesH3M.h"
  12. #include "CMap.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. MapFormatFeaturesH3M MapFormatFeaturesH3M::find(EMapFormat format, uint32_t hotaVersion)
  15. {
  16. switch(format)
  17. {
  18. case EMapFormat::ROE:
  19. return getFeaturesROE();
  20. case EMapFormat::AB:
  21. return getFeaturesAB();
  22. case EMapFormat::SOD:
  23. return getFeaturesSOD();
  24. case EMapFormat::WOG:
  25. return getFeaturesWOG();
  26. //case EMapFormat::HOTA1: //TODO: find such maps? Not present in current HotA release (1.6)
  27. //case EMapFormat::HOTA2:
  28. case EMapFormat::HOTA3:
  29. return getFeaturesHOTA(hotaVersion);
  30. default:
  31. throw std::runtime_error("Invalid map format!");
  32. }
  33. }
  34. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesROE()
  35. {
  36. MapFormatFeaturesH3M result;
  37. result.levelROE = true;
  38. result.factionsBytes = 1;
  39. result.heroesBytes = 16;
  40. result.artifactsBytes = 16;
  41. result.skillsBytes = 4;
  42. result.resourcesBytes = 4;
  43. result.spellsBytes = 9;
  44. result.buildingsBytes = 6;
  45. result.factionsCount = 8;
  46. result.heroesCount = 128;
  47. result.heroesPortraitsCount = 128;
  48. result.artifactsCount = 127;
  49. result.resourcesCount = 7;
  50. result.creaturesCount = 118;
  51. result.spellsCount = 70;
  52. result.skillsCount = 28;
  53. result.terrainsCount = 10;
  54. result.artifactSlotsCount = 18;
  55. result.buildingsCount = 40;
  56. result.heroIdentifierInvalid = 0xff;
  57. result.artifactIdentifierInvalid = 0xff;
  58. result.creatureIdentifierInvalid = 0xff;
  59. result.spellIdentifierInvalid = 0xff;
  60. return result;
  61. }
  62. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesAB()
  63. {
  64. MapFormatFeaturesH3M result = getFeaturesROE();
  65. result.levelAB = true;
  66. result.factionsBytes = 2; // + Conflux
  67. result.factionsCount = 9;
  68. result.creaturesCount = 144; // + Conflux and new neutrals
  69. result.heroesCount = 156; // + Conflux and campaign heroes
  70. result.heroesPortraitsCount = 163;
  71. result.heroesBytes = 20;
  72. result.artifactsCount = 129; // + Armaggedon Blade and Vial of Dragon Blood
  73. result.artifactsBytes = 17;
  74. result.artifactIdentifierInvalid = 0xffff; // Now uses 2 bytes / object
  75. result.creatureIdentifierInvalid = 0xffff; // Now uses 2 bytes / object
  76. return result;
  77. }
  78. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesSOD()
  79. {
  80. MapFormatFeaturesH3M result = getFeaturesAB();
  81. result.levelSOD = true;
  82. result.artifactsCount = 141; // + Combined artifacts
  83. result.artifactsBytes = 18;
  84. result.artifactSlotsCount = 19; // + MISC_5 slot
  85. return result;
  86. }
  87. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesWOG()
  88. {
  89. MapFormatFeaturesH3M result = getFeaturesSOD();
  90. result.levelWOG = true;
  91. return result;
  92. }
  93. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
  94. {
  95. assert(hotaVersion < 4);
  96. MapFormatFeaturesH3M result = getFeaturesSOD();
  97. result.levelHOTA0 = true;
  98. result.levelHOTA1 = hotaVersion > 0;
  99. //result.levelHOTA2 = hotaVersion > 1; // HOTA2 seems to be identical to HOTA1 so far
  100. result.levelHOTA3 = hotaVersion > 2;
  101. result.artifactsBytes = 21;
  102. result.heroesBytes = 23;
  103. result.terrainsCount = 12; // +Highlands +Wasteland
  104. result.skillsCount = 29; // + Interference
  105. result.factionsCount = 10; // + Cove
  106. result.creaturesCount = 171; // + Cove + neutrals
  107. if(hotaVersion == 0 || hotaVersion == 1 || hotaVersion == 2)
  108. {
  109. result.artifactsCount = 163; // + HotA artifacts
  110. result.heroesCount = 178; // + Cove
  111. result.heroesPortraitsCount = 187; // + Cove
  112. }
  113. if(hotaVersion == 3)
  114. {
  115. result.artifactsCount = 165; // + HotA artifacts
  116. result.heroesCount = 179; // + Cove
  117. result.heroesPortraitsCount = 187; // + Cove
  118. }
  119. assert((result.heroesCount + 7) / 8 == result.heroesBytes);
  120. assert((result.artifactsCount + 7) / 8 == result.artifactsBytes);
  121. result.heroesCount = 179; // + Cove
  122. return result;
  123. }
  124. VCMI_LIB_NAMESPACE_END