MapFeaturesH3M.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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::CHR:
  25. return getFeaturesCHR();
  26. case EMapFormat::WOG:
  27. return getFeaturesWOG();
  28. case EMapFormat::HOTA:
  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 = 130; // +General Kendal, +Catherine (portrait-only in RoE)
  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 = 41;
  56. result.roadsCount = 3;
  57. result.riversCount = 4;
  58. result.heroIdentifierInvalid = 0xff;
  59. result.artifactIdentifierInvalid = 0xff;
  60. result.creatureIdentifierInvalid = 0xff;
  61. result.spellIdentifierInvalid = 0xff;
  62. return result;
  63. }
  64. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesAB()
  65. {
  66. MapFormatFeaturesH3M result = getFeaturesROE();
  67. result.levelAB = true;
  68. result.factionsBytes = 2; // + Conflux
  69. result.factionsCount = 9;
  70. result.creaturesCount = 145; // + Conflux and new neutrals
  71. result.heroesCount = 156; // + Conflux and campaign heroes
  72. result.heroesPortraitsCount = 159; // +Kendal, +young Cristian, +Ordwald
  73. result.heroesBytes = 20;
  74. result.artifactsCount = 129; // + Armaggedon Blade and Vial of Dragon Blood
  75. result.artifactsBytes = 17;
  76. result.artifactIdentifierInvalid = 0xffff; // Now uses 2 bytes / object
  77. result.creatureIdentifierInvalid = 0xffff; // Now uses 2 bytes / object
  78. return result;
  79. }
  80. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesSOD()
  81. {
  82. MapFormatFeaturesH3M result = getFeaturesAB();
  83. result.levelSOD = true;
  84. result.artifactsCount = 144; // + Combined artifacts + 3 unfinished artifacts (required for some maps)
  85. result.artifactsBytes = 18;
  86. result.heroesPortraitsCount = 163; // +Finneas +young Gem +young Sandro +young Yog
  87. result.artifactSlotsCount = 19; // + MISC_5 slot
  88. return result;
  89. }
  90. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesCHR()
  91. {
  92. MapFormatFeaturesH3M result = getFeaturesSOD();
  93. result.levelCHR = true;
  94. result.heroesPortraitsCount = 169; // +6x tarnum
  95. return result;
  96. }
  97. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesWOG()
  98. {
  99. MapFormatFeaturesH3M result = getFeaturesSOD();
  100. result.levelWOG = true;
  101. return result;
  102. }
  103. MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
  104. {
  105. // even if changes are minimal, we might not be able to parse map header in map selection screen
  106. // throw exception - to be caught by map selection screen & excluded as invalid
  107. if(hotaVersion > 7)
  108. throw std::runtime_error("Invalid map format!");
  109. MapFormatFeaturesH3M result = getFeaturesSOD();
  110. result.levelHOTA0 = true;
  111. result.levelHOTA1 = hotaVersion > 0;
  112. result.levelHOTA2 = hotaVersion > 1;
  113. result.levelHOTA3 = hotaVersion > 2;
  114. result.levelHOTA5 = hotaVersion > 4;
  115. result.levelHOTA6 = hotaVersion > 5;
  116. result.levelHOTA7 = hotaVersion > 6;
  117. result.artifactsBytes = 21;
  118. result.heroesBytes = 23;
  119. result.terrainsCount = 12; // +Highlands +Wasteland
  120. result.skillsCount = 29; // + Interference
  121. result.factionsCount = 10; // + Cove
  122. result.creaturesCount = 171; // + Cove + neutrals
  123. result.artifactsCount = 163; // + HotA artifacts
  124. result.heroesCount = 178; // + Cove
  125. result.heroesPortraitsCount = 186; // + Cove
  126. if(hotaVersion >= 3)
  127. {
  128. result.artifactsCount = 165; // + HotA artifacts
  129. result.heroesCount = 179; // + Giselle
  130. result.heroesPortraitsCount = 188; // + campaign portrait + Giselle
  131. }
  132. if (hotaVersion >= 5)
  133. {
  134. result.factionsCount = 11; // + Factory
  135. result.creaturesCount = 186; // + 16 Factory
  136. result.artifactsCount = 166; // +pendant of reflection, +sleepkeeper
  137. result.heroesCount = 198; // + 16 Factory, +3 campaign
  138. result.heroesPortraitsCount = 208; // + 16 Factory, +10 campaign
  139. result.heroesBytes = 25;
  140. }
  141. assert((result.heroesCount + 7) / 8 == result.heroesBytes);
  142. assert((result.artifactsCount + 7) / 8 == result.artifactsBytes);
  143. return result;
  144. }
  145. VCMI_LIB_NAMESPACE_END