MapFeaturesH3M.cpp 4.2 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 "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 = 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. // even if changes are minimal, we might not be able to parse map header in map selection screen
  96. // throw exception - to be catched by map selection screen & excluded as invalid
  97. if(hotaVersion > 3)
  98. throw std::runtime_error("Invalid map format!");
  99. MapFormatFeaturesH3M result = getFeaturesSOD();
  100. result.levelHOTA0 = true;
  101. result.levelHOTA1 = hotaVersion > 0;
  102. //result.levelHOTA2 = hotaVersion > 1; // HOTA2 seems to be identical to HOTA1 so far
  103. result.levelHOTA3 = hotaVersion > 2;
  104. result.artifactsBytes = 21;
  105. result.heroesBytes = 23;
  106. result.terrainsCount = 12; // +Highlands +Wasteland
  107. result.skillsCount = 29; // + Interference
  108. result.factionsCount = 10; // + Cove
  109. result.creaturesCount = 171; // + Cove + neutrals
  110. if(hotaVersion < 3)
  111. {
  112. result.artifactsCount = 163; // + HotA artifacts
  113. result.heroesCount = 178; // + Cove
  114. result.heroesPortraitsCount = 186; // + Cove
  115. }
  116. if(hotaVersion == 3)
  117. {
  118. result.artifactsCount = 165; // + HotA artifacts
  119. result.heroesCount = 179; // + Cove + Giselle
  120. result.heroesPortraitsCount = 188; // + Cove + Giselle
  121. }
  122. assert((result.heroesCount + 7) / 8 == result.heroesBytes);
  123. assert((result.artifactsCount + 7) / 8 == result.artifactsBytes);
  124. return result;
  125. }
  126. VCMI_LIB_NAMESPACE_END