MapFeaturesH3M.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 "MapFormat.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 = 130; // +General Kendal, +Catherine (portrait-only in RoE)
  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 = 41;
  54. result.roadsCount = 3;
  55. result.riversCount = 4;
  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 = 145; // + Conflux and new neutrals
  69. result.heroesCount = 156; // + Conflux and campaign heroes
  70. result.heroesPortraitsCount = 159; // +Kendal, +young Cristian, +Ordwald
  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 = 144; // + Combined artifacts + 3 unfinished artifacts (required for some maps)
  83. result.artifactsBytes = 18;
  84. result.heroesPortraitsCount = 163; // +Finneas +young Gem +young Sandro +young Yog
  85. result.artifactSlotsCount = 19; // + MISC_5 slot
  86. return result;
  87. }
  88. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesWOG()
  89. {
  90. MapFormatFeaturesH3M result = getFeaturesSOD();
  91. result.levelWOG = true;
  92. return result;
  93. }
  94. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
  95. {
  96. // even if changes are minimal, we might not be able to parse map header in map selection screen
  97. // throw exception - to be caught by map selection screen & excluded as invalid
  98. if(hotaVersion > 3)
  99. throw std::runtime_error("Invalid map format!");
  100. MapFormatFeaturesH3M result = getFeaturesSOD();
  101. result.levelHOTA0 = true;
  102. result.levelHOTA1 = hotaVersion > 0;
  103. //result.levelHOTA2 = hotaVersion > 1; // HOTA2 seems to be identical to HOTA1 so far
  104. result.levelHOTA3 = hotaVersion > 2;
  105. result.artifactsBytes = 21;
  106. result.heroesBytes = 23;
  107. result.terrainsCount = 12; // +Highlands +Wasteland
  108. result.skillsCount = 29; // + Interference
  109. result.factionsCount = 10; // + Cove
  110. result.creaturesCount = 171; // + Cove + neutrals
  111. if(hotaVersion < 3)
  112. {
  113. result.artifactsCount = 163; // + HotA artifacts
  114. result.heroesCount = 178; // + Cove
  115. result.heroesPortraitsCount = 186; // + Cove
  116. }
  117. if(hotaVersion == 3)
  118. {
  119. result.artifactsCount = 165; // + HotA artifacts
  120. result.heroesCount = 179; // + Cove + Giselle
  121. result.heroesPortraitsCount = 188; // + Cove + Giselle
  122. }
  123. assert((result.heroesCount + 7) / 8 == result.heroesBytes);
  124. assert((result.artifactsCount + 7) / 8 == result.artifactsBytes);
  125. return result;
  126. }
  127. VCMI_LIB_NAMESPACE_END