MapFeaturesH3M.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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::HOTA:
  27. return getFeaturesHOTA(hotaVersion);
  28. default:
  29. throw std::runtime_error("Invalid map format!");
  30. }
  31. }
  32. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesROE()
  33. {
  34. MapFormatFeaturesH3M result;
  35. result.levelROE = true;
  36. result.factionsBytes = 1;
  37. result.heroesBytes = 16;
  38. result.artifactsBytes = 16;
  39. result.skillsBytes = 4;
  40. result.resourcesBytes = 4;
  41. result.spellsBytes = 9;
  42. result.buildingsBytes = 6;
  43. result.factionsCount = 8;
  44. result.heroesCount = 128;
  45. result.heroesPortraitsCount = 128;
  46. result.artifactsCount = 127;
  47. result.resourcesCount = 7;
  48. result.creaturesCount = 118;
  49. result.spellsCount = 70;
  50. result.skillsCount = 28;
  51. result.terrainsCount = 10;
  52. result.artifactSlotsCount = 18;
  53. result.buildingsCount = 40;
  54. result.heroIdentifierInvalid = 0xff;
  55. result.artifactIdentifierInvalid = 0xff;
  56. result.creatureIdentifierInvalid = 0xff;
  57. result.spellIdentifierInvalid = 0xff;
  58. return result;
  59. }
  60. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesAB()
  61. {
  62. MapFormatFeaturesH3M result = getFeaturesROE();
  63. result.levelAB = true;
  64. result.factionsBytes = 2; // + Conflux
  65. result.factionsCount = 9;
  66. result.creaturesCount = 145; // + Conflux and new neutrals
  67. result.heroesCount = 156; // + Conflux and campaign heroes
  68. result.heroesPortraitsCount = 163;
  69. result.heroesBytes = 20;
  70. result.artifactsCount = 129; // + Armaggedon Blade and Vial of Dragon Blood
  71. result.artifactsBytes = 17;
  72. result.artifactIdentifierInvalid = 0xffff; // Now uses 2 bytes / object
  73. result.creatureIdentifierInvalid = 0xffff; // Now uses 2 bytes / object
  74. return result;
  75. }
  76. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesSOD()
  77. {
  78. MapFormatFeaturesH3M result = getFeaturesAB();
  79. result.levelSOD = true;
  80. result.artifactsCount = 141; // + Combined artifacts
  81. result.artifactsBytes = 18;
  82. result.artifactSlotsCount = 19; // + MISC_5 slot
  83. return result;
  84. }
  85. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesWOG()
  86. {
  87. MapFormatFeaturesH3M result = getFeaturesSOD();
  88. result.levelWOG = true;
  89. return result;
  90. }
  91. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
  92. {
  93. // even if changes are minimal, we might not be able to parse map header in map selection screen
  94. // throw exception - to be catched by map selection screen & excluded as invalid
  95. if(hotaVersion > 3)
  96. throw std::runtime_error("Invalid map format!");
  97. MapFormatFeaturesH3M result = getFeaturesSOD();
  98. result.levelHOTA0 = true;
  99. result.levelHOTA1 = hotaVersion > 0;
  100. //result.levelHOTA2 = hotaVersion > 1; // HOTA2 seems to be identical to HOTA1 so far
  101. result.levelHOTA3 = hotaVersion > 2;
  102. result.artifactsBytes = 21;
  103. result.heroesBytes = 23;
  104. result.terrainsCount = 12; // +Highlands +Wasteland
  105. result.skillsCount = 29; // + Interference
  106. result.factionsCount = 10; // + Cove
  107. result.creaturesCount = 171; // + Cove + neutrals
  108. if(hotaVersion < 3)
  109. {
  110. result.artifactsCount = 163; // + HotA artifacts
  111. result.heroesCount = 178; // + Cove
  112. result.heroesPortraitsCount = 187; // + Cove
  113. }
  114. if(hotaVersion == 3)
  115. {
  116. result.artifactsCount = 165; // + HotA artifacts
  117. result.heroesCount = 179; // + Cove
  118. result.heroesPortraitsCount = 187; // + Cove
  119. }
  120. assert((result.heroesCount + 7) / 8 == result.heroesBytes);
  121. assert((result.artifactsCount + 7) / 8 == result.artifactsBytes);
  122. result.heroesCount = 179; // + Cove
  123. return result;
  124. }
  125. VCMI_LIB_NAMESPACE_END