MapFeaturesH3M.cpp 4.1 KB

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