mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-08 23:36:33 +02:00
Merge pull request #5417 from IvanSavenko/hota_h3m
[1.7] Support for loading HotA 1.7.X maps and campaigns
This commit is contained in:
commit
57f16be9a6
@ -20,6 +20,8 @@ enum class CampaignVersion : uint8_t
|
|||||||
WoG = 6,
|
WoG = 6,
|
||||||
Chr = 7,
|
Chr = 7,
|
||||||
|
|
||||||
|
HotA = 10,
|
||||||
|
|
||||||
VCMI = 1,
|
VCMI = 1,
|
||||||
VCMI_MIN = 1,
|
VCMI_MIN = 1,
|
||||||
VCMI_MAX = 1,
|
VCMI_MAX = 1,
|
||||||
|
@ -551,8 +551,25 @@ void CampaignHandler::writeScenarioTravelToJson(JsonNode & node, const CampaignT
|
|||||||
void CampaignHandler::readHeaderFromMemory( CampaignHeader & ret, CBinaryReader & reader, std::string filename, std::string modName, std::string encoding )
|
void CampaignHandler::readHeaderFromMemory( CampaignHeader & ret, CBinaryReader & reader, std::string filename, std::string modName, std::string encoding )
|
||||||
{
|
{
|
||||||
ret.version = static_cast<CampaignVersion>(reader.readUInt32());
|
ret.version = static_cast<CampaignVersion>(reader.readUInt32());
|
||||||
|
|
||||||
|
if (ret.version == CampaignVersion::HotA)
|
||||||
|
{
|
||||||
|
[[maybe_unused]] int32_t unknownA = reader.readInt32();
|
||||||
|
[[maybe_unused]] int32_t unknownB = reader.readInt32();
|
||||||
|
[[maybe_unused]] int32_t unknownC = reader.readInt8();
|
||||||
|
ret.numberOfScenarios = reader.readInt32();
|
||||||
|
|
||||||
|
assert(unknownA == 1);
|
||||||
|
assert(unknownB == 1);
|
||||||
|
assert(unknownC == 0);
|
||||||
|
assert(ret.numberOfScenarios <= 8);
|
||||||
|
|
||||||
|
// TODO. Or they are hardcoded in this hota version?
|
||||||
|
// ret.campaignRegions = ???;
|
||||||
|
}
|
||||||
|
|
||||||
ui8 campId = reader.readUInt8() - 1;//change range of it from [1, 20] to [0, 19]
|
ui8 campId = reader.readUInt8() - 1;//change range of it from [1, 20] to [0, 19]
|
||||||
if(ret.version != CampaignVersion::Chr) // For chronicles: Will be overridden later; Chronicles uses own logic (reusing OH3 ID's)
|
if(ret.version < CampaignVersion::Chr) // For chronicles: Will be overridden later; Chronicles uses own logic (reusing OH3 ID's)
|
||||||
ret.loadLegacyData(campId);
|
ret.loadLegacyData(campId);
|
||||||
ret.name.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "name"));
|
ret.name.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "name"));
|
||||||
ret.description.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "description"));
|
ret.description.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "description"));
|
||||||
@ -561,7 +578,7 @@ void CampaignHandler::readHeaderFromMemory( CampaignHeader & ret, CBinaryReader
|
|||||||
ret.campaignVersion.appendRawString("");
|
ret.campaignVersion.appendRawString("");
|
||||||
ret.creationDateTime = 0;
|
ret.creationDateTime = 0;
|
||||||
if (ret.version > CampaignVersion::RoE)
|
if (ret.version > CampaignVersion::RoE)
|
||||||
ret.difficultyChosenByPlayer = reader.readInt8();
|
ret.difficultyChosenByPlayer = reader.readBool();
|
||||||
else
|
else
|
||||||
ret.difficultyChosenByPlayer = false;
|
ret.difficultyChosenByPlayer = false;
|
||||||
|
|
||||||
@ -576,7 +593,7 @@ CampaignScenario CampaignHandler::readScenarioFromMemory( CBinaryReader & reader
|
|||||||
auto prologEpilogReader = [&](const std::string & identifier) -> CampaignScenarioPrologEpilog
|
auto prologEpilogReader = [&](const std::string & identifier) -> CampaignScenarioPrologEpilog
|
||||||
{
|
{
|
||||||
CampaignScenarioPrologEpilog ret;
|
CampaignScenarioPrologEpilog ret;
|
||||||
ret.hasPrologEpilog = reader.readUInt8();
|
ret.hasPrologEpilog = reader.readBool();
|
||||||
if(ret.hasPrologEpilog)
|
if(ret.hasPrologEpilog)
|
||||||
{
|
{
|
||||||
bool isOriginalCampaign = boost::starts_with(header.getFilename(), "DATA/");
|
bool isOriginalCampaign = boost::starts_with(header.getFilename(), "DATA/");
|
||||||
@ -603,9 +620,18 @@ CampaignScenario CampaignHandler::readScenarioFromMemory( CBinaryReader & reader
|
|||||||
}
|
}
|
||||||
ret.regionColor = reader.readUInt8();
|
ret.regionColor = reader.readUInt8();
|
||||||
ret.difficulty = reader.readUInt8();
|
ret.difficulty = reader.readUInt8();
|
||||||
|
assert(ret.difficulty < 5);
|
||||||
ret.regionText.appendTextID(readLocalizedString(header, reader, header.filename, header.modName, header.encoding, ret.mapName + ".region"));
|
ret.regionText.appendTextID(readLocalizedString(header, reader, header.filename, header.modName, header.encoding, ret.mapName + ".region"));
|
||||||
ret.prolog = prologEpilogReader(ret.mapName + ".prolog");
|
ret.prolog = prologEpilogReader(ret.mapName + ".prolog");
|
||||||
|
if (header.version == CampaignVersion::HotA)
|
||||||
|
prologEpilogReader(ret.mapName + ".prolog2");
|
||||||
|
if (header.version == CampaignVersion::HotA)
|
||||||
|
prologEpilogReader(ret.mapName + ".prolog3");
|
||||||
ret.epilog = prologEpilogReader(ret.mapName + ".epilog");
|
ret.epilog = prologEpilogReader(ret.mapName + ".epilog");
|
||||||
|
if (header.version == CampaignVersion::HotA)
|
||||||
|
prologEpilogReader(ret.mapName + ".epilog2");
|
||||||
|
if (header.version == CampaignVersion::HotA)
|
||||||
|
prologEpilogReader(ret.mapName + ".epilog3");
|
||||||
|
|
||||||
ret.travelOptions = readScenarioTravelFromMemory(reader, header.version);
|
ret.travelOptions = readScenarioTravelFromMemory(reader, header.version);
|
||||||
|
|
||||||
@ -635,8 +661,16 @@ CampaignTravel CampaignHandler::readScenarioTravelFromMemory(CBinaryReader & rea
|
|||||||
ret.whatHeroKeeps.spells = whatHeroKeeps & 8;
|
ret.whatHeroKeeps.spells = whatHeroKeeps & 8;
|
||||||
ret.whatHeroKeeps.artifacts = whatHeroKeeps & 16;
|
ret.whatHeroKeeps.artifacts = whatHeroKeeps & 16;
|
||||||
|
|
||||||
|
if (version == CampaignVersion::HotA)
|
||||||
|
{
|
||||||
|
readContainer(ret.monstersKeptByHero, reader, 24);
|
||||||
|
readContainer(ret.artifactsKeptByHero, reader, 21);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
readContainer(ret.monstersKeptByHero, reader, 19);
|
readContainer(ret.monstersKeptByHero, reader, 19);
|
||||||
readContainer(ret.artifactsKeptByHero, reader, version < CampaignVersion::SoD ? 17 : 18);
|
readContainer(ret.artifactsKeptByHero, reader, version < CampaignVersion::SoD ? 17 : 18);
|
||||||
|
}
|
||||||
|
|
||||||
ret.startOptions = static_cast<CampaignStartOptions>(reader.readUInt8());
|
ret.startOptions = static_cast<CampaignStartOptions>(reader.readUInt8());
|
||||||
|
|
||||||
|
@ -407,12 +407,12 @@ public:
|
|||||||
NO_OBJ = -1,
|
NO_OBJ = -1,
|
||||||
|
|
||||||
NOTHING = 0,
|
NOTHING = 0,
|
||||||
ALTAR_OF_SACRIFICE [[deprecated]] = 2,
|
ALTAR_OF_SACRIFICE = 2,
|
||||||
ANCHOR_POINT = 3,
|
ANCHOR_POINT = 3,
|
||||||
ARENA = 4,
|
ARENA = 4,
|
||||||
ARTIFACT = 5,
|
ARTIFACT = 5,
|
||||||
PANDORAS_BOX = 6,
|
PANDORAS_BOX = 6,
|
||||||
BLACK_MARKET [[deprecated]] = 7,
|
BLACK_MARKET = 7,
|
||||||
BOAT = 8,
|
BOAT = 8,
|
||||||
BORDERGUARD = 9,
|
BORDERGUARD = 9,
|
||||||
KEYMASTER = 10,
|
KEYMASTER = 10,
|
||||||
@ -504,12 +504,12 @@ public:
|
|||||||
TEMPLE = 96,
|
TEMPLE = 96,
|
||||||
DEN_OF_THIEVES = 97,
|
DEN_OF_THIEVES = 97,
|
||||||
TOWN = 98,
|
TOWN = 98,
|
||||||
TRADING_POST [[deprecated]] = 99,
|
TRADING_POST = 99,
|
||||||
LEARNING_STONE = 100,
|
LEARNING_STONE = 100,
|
||||||
TREASURE_CHEST = 101,
|
TREASURE_CHEST = 101,
|
||||||
TREE_OF_KNOWLEDGE = 102,
|
TREE_OF_KNOWLEDGE = 102,
|
||||||
SUBTERRANEAN_GATE = 103,
|
SUBTERRANEAN_GATE = 103,
|
||||||
UNIVERSITY [[deprecated]] = 104,
|
UNIVERSITY = 104,
|
||||||
WAGON = 105,
|
WAGON = 105,
|
||||||
WAR_MACHINE_FACTORY = 106,
|
WAR_MACHINE_FACTORY = 106,
|
||||||
SCHOOL_OF_WAR = 107,
|
SCHOOL_OF_WAR = 107,
|
||||||
@ -545,6 +545,8 @@ public:
|
|||||||
PINE_TREES = 137,
|
PINE_TREES = 137,
|
||||||
PLANT = 138,
|
PLANT = 138,
|
||||||
RIVER_DELTA = 143,
|
RIVER_DELTA = 143,
|
||||||
|
HOTA_CUSTOM_OBJECT_1 = 145,
|
||||||
|
HOTA_CUSTOM_OBJECT_2 = 146,
|
||||||
ROCK = 147,
|
ROCK = 147,
|
||||||
SAND_DUNE = 148,
|
SAND_DUNE = 148,
|
||||||
SAND_PIT = 149,
|
SAND_PIT = 149,
|
||||||
@ -564,7 +566,7 @@ public:
|
|||||||
RANDOM_MONSTER_L6 = 163,
|
RANDOM_MONSTER_L6 = 163,
|
||||||
RANDOM_MONSTER_L7 = 164,
|
RANDOM_MONSTER_L7 = 164,
|
||||||
BORDER_GATE = 212,
|
BORDER_GATE = 212,
|
||||||
FREELANCERS_GUILD [[deprecated]] = 213,
|
FREELANCERS_GUILD = 213,
|
||||||
HERO_PLACEHOLDER = 214,
|
HERO_PLACEHOLDER = 214,
|
||||||
QUEST_GUARD = 215,
|
QUEST_GUARD = 215,
|
||||||
RANDOM_DWELLING = 216,
|
RANDOM_DWELLING = 216,
|
||||||
@ -572,7 +574,7 @@ public:
|
|||||||
RANDOM_DWELLING_FACTION = 218, //subtype = faction
|
RANDOM_DWELLING_FACTION = 218, //subtype = faction
|
||||||
GARRISON2 = 219,
|
GARRISON2 = 219,
|
||||||
ABANDONED_MINE = 220,
|
ABANDONED_MINE = 220,
|
||||||
TRADING_POST_SNOW [[deprecated]] = 221,
|
TRADING_POST_SNOW = 221,
|
||||||
CLOVER_FIELD = 222,
|
CLOVER_FIELD = 222,
|
||||||
CURSED_GROUND2 = 223,
|
CURSED_GROUND2 = 223,
|
||||||
EVIL_FOG = 224,
|
EVIL_FOG = 224,
|
||||||
|
@ -35,6 +35,7 @@ enum class EQuestMission {
|
|||||||
KEYMASTER = 11,
|
KEYMASTER = 11,
|
||||||
HOTA_HERO_CLASS = 12,
|
HOTA_HERO_CLASS = 12,
|
||||||
HOTA_REACH_DATE = 13,
|
HOTA_REACH_DATE = 13,
|
||||||
|
HOTA_GAME_DIFFICULTY = 13,
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE CQuest final : public Serializeable
|
class DLL_LINKAGE CQuest final : public Serializeable
|
||||||
|
@ -131,14 +131,17 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
|
|||||||
{
|
{
|
||||||
// even if changes are minimal, we might not be able to parse map header in map selection screen
|
// even if changes are minimal, we might not be able to parse map header in map selection screen
|
||||||
// throw exception - to be caught by map selection screen & excluded as invalid
|
// throw exception - to be caught by map selection screen & excluded as invalid
|
||||||
if(hotaVersion > 3)
|
if(hotaVersion > 7)
|
||||||
throw std::runtime_error("Invalid map format!");
|
throw std::runtime_error("Invalid map format!");
|
||||||
|
|
||||||
MapFormatFeaturesH3M result = getFeaturesSOD();
|
MapFormatFeaturesH3M result = getFeaturesSOD();
|
||||||
result.levelHOTA0 = true;
|
result.levelHOTA0 = true;
|
||||||
result.levelHOTA1 = hotaVersion > 0;
|
result.levelHOTA1 = hotaVersion > 0;
|
||||||
//result.levelHOTA2 = hotaVersion > 1; // HOTA2 seems to be identical to HOTA1 so far
|
result.levelHOTA2 = hotaVersion > 1;
|
||||||
result.levelHOTA3 = hotaVersion > 2;
|
result.levelHOTA3 = hotaVersion > 2;
|
||||||
|
result.levelHOTA5 = hotaVersion > 4;
|
||||||
|
result.levelHOTA6 = hotaVersion > 5;
|
||||||
|
result.levelHOTA7 = hotaVersion > 6;
|
||||||
|
|
||||||
result.artifactsBytes = 21;
|
result.artifactsBytes = 21;
|
||||||
result.heroesBytes = 23;
|
result.heroesBytes = 23;
|
||||||
@ -147,18 +150,25 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
|
|||||||
result.skillsCount = 29; // + Interference
|
result.skillsCount = 29; // + Interference
|
||||||
result.factionsCount = 10; // + Cove
|
result.factionsCount = 10; // + Cove
|
||||||
result.creaturesCount = 171; // + Cove + neutrals
|
result.creaturesCount = 171; // + Cove + neutrals
|
||||||
|
|
||||||
if(hotaVersion < 3)
|
|
||||||
{
|
|
||||||
result.artifactsCount = 163; // + HotA artifacts
|
result.artifactsCount = 163; // + HotA artifacts
|
||||||
result.heroesCount = 178; // + Cove
|
result.heroesCount = 178; // + Cove
|
||||||
result.heroesPortraitsCount = 186; // + Cove
|
result.heroesPortraitsCount = 186; // + Cove
|
||||||
}
|
|
||||||
if(hotaVersion == 3)
|
if(hotaVersion >= 3)
|
||||||
{
|
{
|
||||||
result.artifactsCount = 165; // + HotA artifacts
|
result.artifactsCount = 165; // + HotA artifacts
|
||||||
result.heroesCount = 179; // + Cove + Giselle
|
result.heroesCount = 179; // + Giselle
|
||||||
result.heroesPortraitsCount = 188; // + Cove + Giselle
|
result.heroesPortraitsCount = 188; // + campaign portrait + Giselle
|
||||||
|
}
|
||||||
|
if (hotaVersion >= 5)
|
||||||
|
{
|
||||||
|
result.factionsCount = 11; // + Factory
|
||||||
|
result.creaturesCount = 186; // + 16 Factory
|
||||||
|
result.artifactsCount = 166; // +pendant of reflection, +sleepkeeper
|
||||||
|
result.heroesCount = 198; // + 16 Factory, +3 campaign
|
||||||
|
result.heroesPortraitsCount = 228; // + 16 Factory, +A LOT campaign
|
||||||
|
|
||||||
|
result.heroesBytes = 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert((result.heroesCount + 7) / 8 == result.heroesBytes);
|
assert((result.heroesCount + 7) / 8 == result.heroesBytes);
|
||||||
|
@ -69,7 +69,12 @@ public:
|
|||||||
bool levelWOG = false;
|
bool levelWOG = false;
|
||||||
bool levelHOTA0 = false;
|
bool levelHOTA0 = false;
|
||||||
bool levelHOTA1 = false;
|
bool levelHOTA1 = false;
|
||||||
bool levelHOTA3 = false;
|
bool levelHOTA2 = false;
|
||||||
|
bool levelHOTA3 = false; // 1.6.0
|
||||||
|
// level 4 - not released publicly?
|
||||||
|
bool levelHOTA5 = false; // 1.7.0
|
||||||
|
bool levelHOTA6 = false; // 1.7.1
|
||||||
|
bool levelHOTA7 = false; // 1.7.2
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -168,7 +168,7 @@ void CMapLoaderH3M::readHeader()
|
|||||||
features = MapFormatFeaturesH3M::find(mapHeader->version, hotaVersion);
|
features = MapFormatFeaturesH3M::find(mapHeader->version, hotaVersion);
|
||||||
reader->setFormatLevel(features);
|
reader->setFormatLevel(features);
|
||||||
|
|
||||||
if(hotaVersion > 0)
|
if(features.levelHOTA1)
|
||||||
{
|
{
|
||||||
bool isMirrorMap = reader->readBool();
|
bool isMirrorMap = reader->readBool();
|
||||||
bool isArenaMap = reader->readBool();
|
bool isArenaMap = reader->readBool();
|
||||||
@ -181,10 +181,35 @@ void CMapLoaderH3M::readHeader()
|
|||||||
logGlobal->warn("Map '%s': Arena maps are not supported!", mapName);
|
logGlobal->warn("Map '%s': Arena maps are not supported!", mapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hotaVersion > 1)
|
if(features.levelHOTA2)
|
||||||
{
|
{
|
||||||
[[maybe_unused]] uint8_t unknown = reader->readUInt32();
|
int32_t terrainTypesCount = reader->readUInt32();
|
||||||
assert(unknown == 12);
|
assert(features.terrainsCount == terrainTypesCount);
|
||||||
|
|
||||||
|
if (features.terrainsCount != terrainTypesCount)
|
||||||
|
logGlobal->warn("Map '%s': Expected %d terrains, but %d found!", mapName, features.terrainsCount, terrainTypesCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
int32_t townTypesCount = reader->readUInt32();
|
||||||
|
int8_t allowedDifficultiesMask = reader->readInt8Checked(0, 31);
|
||||||
|
|
||||||
|
assert(features.factionsCount == townTypesCount);
|
||||||
|
|
||||||
|
if (features.factionsCount != townTypesCount)
|
||||||
|
logGlobal->warn("Map '%s': Expected %d factions, but %d found!", mapName, features.factionsCount, townTypesCount);
|
||||||
|
|
||||||
|
if (allowedDifficultiesMask != 0)
|
||||||
|
logGlobal->warn("Map '%s': List of allowed difficulties (%d) is not implemented!", mapName, static_cast<int>(allowedDifficultiesMask));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(features.levelHOTA7)
|
||||||
|
{
|
||||||
|
bool canHireDefeatedHeroes = reader->readBool();
|
||||||
|
|
||||||
|
if (!canHireDefeatedHeroes)
|
||||||
|
logGlobal->warn("Map '%s': Option to block hiring of defeated heroes is not implemented!", mapName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -249,14 +274,14 @@ void CMapLoaderH3M::readPlayerInfo()
|
|||||||
playerInfo.aiTactic = static_cast<EAiTactic>(reader->readInt8Checked(-1, 3));
|
playerInfo.aiTactic = static_cast<EAiTactic>(reader->readInt8Checked(-1, 3));
|
||||||
|
|
||||||
if(features.levelSOD)
|
if(features.levelSOD)
|
||||||
reader->skipUnused(1); //TODO: check meaning?
|
reader->skipUnused(1); //faction is selectable
|
||||||
|
|
||||||
std::set<FactionID> allowedFactions;
|
std::set<FactionID> allowedFactions;
|
||||||
|
|
||||||
reader->readBitmaskFactions(allowedFactions, false);
|
reader->readBitmaskFactions(allowedFactions, false);
|
||||||
|
|
||||||
const bool isFactionRandom = playerInfo.isFactionRandom = reader->readBool();
|
playerInfo.isFactionRandom = reader->readBool();
|
||||||
const bool allFactionsAllowed = isFactionRandom && allowedFactions.size() == features.factionsCount;
|
const bool allFactionsAllowed = playerInfo.isFactionRandom && allowedFactions.size() == features.factionsCount;
|
||||||
|
|
||||||
if(!allFactionsAllowed)
|
if(!allFactionsAllowed)
|
||||||
playerInfo.allowedFactions = allowedFactions;
|
playerInfo.allowedFactions = allowedFactions;
|
||||||
@ -267,7 +292,7 @@ void CMapLoaderH3M::readPlayerInfo()
|
|||||||
if(features.levelAB)
|
if(features.levelAB)
|
||||||
{
|
{
|
||||||
playerInfo.generateHeroAtMainTown = reader->readBool();
|
playerInfo.generateHeroAtMainTown = reader->readBool();
|
||||||
reader->skipUnused(1); //TODO: check meaning?
|
reader->skipUnused(1); // starting town type, unused
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -721,7 +746,6 @@ void CMapLoaderH3M::readMapOptions()
|
|||||||
|
|
||||||
if(features.levelHOTA0)
|
if(features.levelHOTA0)
|
||||||
{
|
{
|
||||||
//TODO: HotA
|
|
||||||
bool allowSpecialMonths = reader->readBool();
|
bool allowSpecialMonths = reader->readBool();
|
||||||
map->overrideGameSetting(EGameSettings::CREATURES_ALLOW_RANDOM_SPECIAL_WEEKS, JsonNode(allowSpecialMonths));
|
map->overrideGameSetting(EGameSettings::CREATURES_ALLOW_RANDOM_SPECIAL_WEEKS, JsonNode(allowSpecialMonths));
|
||||||
reader->skipZero(3);
|
reader->skipZero(3);
|
||||||
@ -729,12 +753,15 @@ void CMapLoaderH3M::readMapOptions()
|
|||||||
|
|
||||||
if(features.levelHOTA1)
|
if(features.levelHOTA1)
|
||||||
{
|
{
|
||||||
// Unknown, may be another "sized bitmap", e.g
|
int32_t combinedArtifactsCount = reader->readInt32();
|
||||||
// 4 bytes - size of bitmap (16)
|
int32_t combinedArtifactsBytes = (combinedArtifactsCount + 7) / 8;
|
||||||
// 2 bytes - bitmap data (16 bits / 2 bytes)
|
|
||||||
[[maybe_unused]] uint8_t unknownConstant = reader->readUInt8();
|
for (int i = 0; i < combinedArtifactsBytes; ++i)
|
||||||
assert(unknownConstant == 16);
|
{
|
||||||
reader->skipZero(5);
|
uint8_t mask = reader->readUInt8();
|
||||||
|
if (mask != 0)
|
||||||
|
logGlobal->warn("Map '%s': Option to ban specific combined artifacts is not implemented!", mapName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(features.levelHOTA3)
|
if(features.levelHOTA3)
|
||||||
@ -744,6 +771,17 @@ void CMapLoaderH3M::readMapOptions()
|
|||||||
if(roundLimit != -1)
|
if(roundLimit != -1)
|
||||||
logGlobal->warn("Map '%s': roundLimit of %d is not implemented!", mapName, roundLimit);
|
logGlobal->warn("Map '%s': roundLimit of %d is not implemented!", mapName, roundLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
||||||
|
{
|
||||||
|
// unconfirmed, but only remainig option according to changelog
|
||||||
|
bool heroRecruitmentBlocked = reader->readBool();
|
||||||
|
if (heroRecruitmentBlocked)
|
||||||
|
logGlobal->warn("Map '%s': option to ban hero recruitment for %s is not implemented!!", mapName, PlayerColor(i).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapLoaderH3M::readAllowedArtifacts()
|
void CMapLoaderH3M::readAllowedArtifacts()
|
||||||
@ -884,6 +922,26 @@ void CMapLoaderH3M::readPredefinedHeroes()
|
|||||||
|
|
||||||
logGlobal->debug("Map '%s': Hero predefined in map: %s", mapName, hero->getHeroType()->getJsonKey());
|
logGlobal->debug("Map '%s': Hero predefined in map: %s", mapName, hero->getHeroType()->getJsonKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
for(int heroID = 0; heroID < heroesCount; heroID++)
|
||||||
|
{
|
||||||
|
bool alwaysAddSkills = reader->readBool(); // prevent heroes from receiving additional random secondary skills at the start of the map if they are not of the first level
|
||||||
|
bool cannotGainXP = reader->readBool();
|
||||||
|
int32_t level = reader->readInt32(); // Needs investigation how this interacts with usual setting of level via experience
|
||||||
|
assert(level > 0);
|
||||||
|
|
||||||
|
if (!alwaysAddSkills)
|
||||||
|
logGlobal->warn("Map '%s': Option to prevent hero %d from gaining skills on map start is not implemented!", mapName, heroID);
|
||||||
|
|
||||||
|
if (cannotGainXP)
|
||||||
|
logGlobal->warn("Map '%s': Option to prevent hero %d from receiveing experience is not implemented!", mapName, heroID);
|
||||||
|
|
||||||
|
if (level > 1)
|
||||||
|
logGlobal->warn("Map '%s': Option to set level of hero %d to %d is not implemented!", mapName, heroID, level);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
|
void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
|
||||||
@ -921,6 +979,9 @@ void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
|
|||||||
bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
|
bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
|
||||||
{
|
{
|
||||||
ArtifactID artifactID = reader->readArtifact();
|
ArtifactID artifactID = reader->readArtifact();
|
||||||
|
SpellID scrollSpell = SpellID::NONE;
|
||||||
|
if (features.levelHOTA5)
|
||||||
|
scrollSpell = reader->readSpell16();
|
||||||
|
|
||||||
if(artifactID == ArtifactID::NONE)
|
if(artifactID == ArtifactID::NONE)
|
||||||
return false;
|
return false;
|
||||||
@ -944,7 +1005,7 @@ bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
|
|||||||
// Artifact seems to be missing in game, so skip artifacts that don't fit target slot
|
// Artifact seems to be missing in game, so skip artifacts that don't fit target slot
|
||||||
if(ArtifactID(artifactID).toArtifact()->canBePutAt(hero, ArtifactPosition(slot)))
|
if(ArtifactID(artifactID).toArtifact()->canBePutAt(hero, ArtifactPosition(slot)))
|
||||||
{
|
{
|
||||||
auto * artifact = ArtifactUtils::createArtifact(artifactID);
|
auto * artifact = ArtifactUtils::createArtifact(artifactID, scrollSpell);
|
||||||
map->putArtifactInstance(*hero, artifact, slot);
|
map->putArtifactInstance(*hero, artifact, slot);
|
||||||
map->addNewArtifactInstance(artifact);
|
map->addNewArtifactInstance(artifact);
|
||||||
}
|
}
|
||||||
@ -988,16 +1049,21 @@ void CMapLoaderH3M::readObjectTemplates()
|
|||||||
{
|
{
|
||||||
uint32_t defAmount = reader->readUInt32();
|
uint32_t defAmount = reader->readUInt32();
|
||||||
|
|
||||||
templates.reserve(defAmount);
|
originalTemplates.reserve(defAmount);
|
||||||
|
remappedTemplates.reserve(defAmount);
|
||||||
|
|
||||||
// Read custom defs
|
// Read custom defs
|
||||||
for(int defID = 0; defID < defAmount; ++defID)
|
for(int defID = 0; defID < defAmount; ++defID)
|
||||||
{
|
{
|
||||||
auto tmpl = reader->readObjectTemplate();
|
auto tmpl = reader->readObjectTemplate();
|
||||||
templates.push_back(tmpl);
|
originalTemplates.push_back(tmpl);
|
||||||
|
|
||||||
if (!CResourceHandler::get()->existsResource(tmpl->animationFile.addPrefix("SPRITES/")))
|
auto remapped = std::make_shared<ObjectTemplate>(*tmpl);
|
||||||
logMod->warn("Template animation %s of type (%d %d) is missing!", tmpl->animationFile.getOriginalName(), tmpl->id, tmpl->subid );
|
reader->remapTemplate(*remapped);
|
||||||
|
remappedTemplates.push_back(remapped);
|
||||||
|
|
||||||
|
if (!CResourceHandler::get()->existsResource(remapped->animationFile.addPrefix("SPRITES/")))
|
||||||
|
logMod->warn("Template animation %s of type (%d %d) is missing!", remapped->animationFile.getOriginalName(), remapped->id, remapped->subid );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1018,6 +1084,8 @@ CGObjectInstance * CMapLoaderH3M::readEvent(const int3 & mapPosition, const Obje
|
|||||||
else
|
else
|
||||||
object->humanActivate = true;
|
object->humanActivate = true;
|
||||||
|
|
||||||
|
readBoxHotaContent(object, mapPosition, idToBeGiven);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1025,6 +1093,12 @@ CGObjectInstance * CMapLoaderH3M::readPandora(const int3 & mapPosition, const Ob
|
|||||||
{
|
{
|
||||||
auto * object = new CGPandoraBox(map->cb);
|
auto * object = new CGPandoraBox(map->cb);
|
||||||
readBoxContent(object, mapPosition, idToBeGiven);
|
readBoxContent(object, mapPosition, idToBeGiven);
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
reader->skipZero(1); // Unknown value, always 0 so far
|
||||||
|
|
||||||
|
readBoxHotaContent(object, mapPosition, idToBeGiven);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,7 +1129,15 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
|
|||||||
}
|
}
|
||||||
size_t gart = reader->readUInt8(); //number of gained artifacts
|
size_t gart = reader->readUInt8(); //number of gained artifacts
|
||||||
for(size_t oo = 0; oo < gart; ++oo)
|
for(size_t oo = 0; oo < gart; ++oo)
|
||||||
|
{
|
||||||
reward.artifacts.push_back(reader->readArtifact());
|
reward.artifacts.push_back(reader->readArtifact());
|
||||||
|
if (features.levelHOTA5)
|
||||||
|
{
|
||||||
|
SpellID scrollSpell = reader->readSpell16();
|
||||||
|
if (reward.artifacts.back() == ArtifactID::SPELL_SCROLL)
|
||||||
|
logGlobal->warn("Map '%s': Pandora/Event at %s Option to give spell scroll (%s) via event or pandora is not implemented!", mapName, mapPosition.toString(), scrollSpell.toEntity(VLC)->getJsonKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t gspel = reader->readUInt8(); //number of gained spells
|
size_t gspel = reader->readUInt8(); //number of gained spells
|
||||||
for(size_t oo = 0; oo < gspel; ++oo)
|
for(size_t oo = 0; oo < gspel; ++oo)
|
||||||
@ -1076,6 +1158,27 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
|
|||||||
reader->skipZero(8);
|
reader->skipZero(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMapLoaderH3M::readBoxHotaContent(CGPandoraBox * object, const int3 & mapPosition, const ObjectInstanceID & idToBeGiven)
|
||||||
|
{
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
int32_t movementMode = reader->readInt32(); // Give, Take, Nullify, Set, Replenish
|
||||||
|
int32_t movementAmount = reader->readInt32();
|
||||||
|
|
||||||
|
assert(movementMode >= 0 && movementMode <= 4);
|
||||||
|
if (movementMode != 0 || movementAmount != 0)
|
||||||
|
logGlobal->warn("Map '%s': Event/Pandora %s option to modify (mode %d) movement points by %d is not implemented!", mapName, mapPosition.toString(), movementMode, movementAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(features.levelHOTA6)
|
||||||
|
{
|
||||||
|
int32_t allowedDifficultiesMask = reader->readInt32();
|
||||||
|
assert(allowedDifficultiesMask > 0 && allowedDifficultiesMask < 32);
|
||||||
|
if (allowedDifficultiesMask != 31)
|
||||||
|
logGlobal->warn("Map '%s': Event/Pandora %s availability by difficulty (mode %d) is not implemented!", mapName, mapPosition.toString(), allowedDifficultiesMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CGObjectInstance * CMapLoaderH3M::readMonster(const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
|
CGObjectInstance * CMapLoaderH3M::readMonster(const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
|
||||||
{
|
{
|
||||||
auto * object = new CGCreature(map->cb);
|
auto * object = new CGCreature(map->cb);
|
||||||
@ -1092,7 +1195,8 @@ CGObjectInstance * CMapLoaderH3M::readMonster(const int3 & mapPosition, const Ob
|
|||||||
//type will be set during initialization
|
//type will be set during initialization
|
||||||
object->putStack(SlotID(0), hlp);
|
object->putStack(SlotID(0), hlp);
|
||||||
|
|
||||||
object->character = reader->readInt8Checked(0, 4);
|
//TODO: 0-4 is h3 range. 5 is hota extension for exact aggression?
|
||||||
|
object->character = reader->readInt8Checked(0, 5);
|
||||||
|
|
||||||
bool hasMessage = reader->readBool();
|
bool hasMessage = reader->readBool();
|
||||||
if(hasMessage)
|
if(hasMessage)
|
||||||
@ -1127,6 +1231,15 @@ CGObjectInstance * CMapLoaderH3M::readMonster(const int3 & mapPosition, const Ob
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (features.levelHOTA5)
|
||||||
|
{
|
||||||
|
bool sizeByValue = reader->readBool();//FIXME: double-check this flag effect
|
||||||
|
int32_t targetValue = reader->readInt32();
|
||||||
|
|
||||||
|
if (sizeByValue || targetValue)
|
||||||
|
logGlobal->warn( "Map '%s': Wandering monsters %s option to set unit size to %d (%d) AI value is not implemented!", mapName, mapPosition.toString(), targetValue, sizeByValue);
|
||||||
|
}
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1274,23 +1387,37 @@ CGObjectInstance * CMapLoaderH3M::readGarrison(const int3 & mapPosition)
|
|||||||
CGObjectInstance * CMapLoaderH3M::readArtifact(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
CGObjectInstance * CMapLoaderH3M::readArtifact(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
||||||
{
|
{
|
||||||
ArtifactID artID = ArtifactID::NONE; //random, set later
|
ArtifactID artID = ArtifactID::NONE; //random, set later
|
||||||
SpellID spellID = SpellID::NONE;
|
|
||||||
auto * object = new CGArtifact(map->cb);
|
auto * object = new CGArtifact(map->cb);
|
||||||
|
|
||||||
readMessageAndGuards(object->message, object, mapPosition);
|
readMessageAndGuards(object->message, object, mapPosition);
|
||||||
|
|
||||||
if(objectTemplate->id == Obj::SPELL_SCROLL)
|
|
||||||
{
|
|
||||||
spellID = reader->readSpell32();
|
|
||||||
artID = ArtifactID::SPELL_SCROLL;
|
|
||||||
}
|
|
||||||
else if(objectTemplate->id == Obj::ARTIFACT)
|
|
||||||
{
|
|
||||||
//specific artifact
|
//specific artifact
|
||||||
|
if(objectTemplate->id == Obj::ARTIFACT)
|
||||||
artID = ArtifactID(objectTemplate->subid);
|
artID = ArtifactID(objectTemplate->subid);
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
uint32_t pickupMode = reader->readUInt32();
|
||||||
|
uint8_t pickupFlags = reader->readUInt8();
|
||||||
|
|
||||||
|
assert(pickupMode == 0 || pickupMode == 1 || pickupMode == 2); // DISABLED, RANDOM, CUSTOM
|
||||||
|
|
||||||
|
if (pickupMode != 0)
|
||||||
|
logGlobal->warn("Map '%s': Artifact %s: not implemented pickup mode %d (flags: %d)", mapName, mapPosition.toString(), pickupMode, static_cast<int>(pickupFlags));
|
||||||
}
|
}
|
||||||
|
|
||||||
object->storedArtifact = ArtifactUtils::createArtifact(artID, spellID.getNum());
|
object->storedArtifact = ArtifactUtils::createArtifact(artID, SpellID::NONE);
|
||||||
|
map->addNewArtifactInstance(object->storedArtifact);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGObjectInstance * CMapLoaderH3M::readScroll(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
||||||
|
{
|
||||||
|
auto * object = new CGArtifact(map->cb);
|
||||||
|
readMessageAndGuards(object->message, object, mapPosition);
|
||||||
|
SpellID spellID = reader->readSpell32();
|
||||||
|
|
||||||
|
object->storedArtifact = ArtifactUtils::createArtifact(ArtifactID::SPELL_SCROLL, spellID.getNum());
|
||||||
map->addNewArtifactInstance(object->storedArtifact);
|
map->addNewArtifactInstance(object->storedArtifact);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@ -1315,17 +1442,32 @@ CGObjectInstance * CMapLoaderH3M::readResource(const int3 & mapPosition, std::sh
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGObjectInstance * CMapLoaderH3M::readMine(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
CGObjectInstance * CMapLoaderH3M::readMine(const int3 & mapPosition)
|
||||||
{
|
{
|
||||||
auto * object = new CGMine(map->cb);
|
auto * object = new CGMine(map->cb);
|
||||||
if(objectTemplate->subid < 7)
|
|
||||||
{
|
|
||||||
setOwnerAndValidate(mapPosition, object, reader->readPlayer32());
|
setOwnerAndValidate(mapPosition, object, reader->readPlayer32());
|
||||||
}
|
return object;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
|
CGObjectInstance * CMapLoaderH3M::readAbandonedMine(const int3 & mapPosition)
|
||||||
|
{
|
||||||
|
auto * object = new CGMine(map->cb);
|
||||||
object->setOwner(PlayerColor::NEUTRAL);
|
object->setOwner(PlayerColor::NEUTRAL);
|
||||||
reader->readBitmaskResources(object->abandonedMineResources, false);
|
reader->readBitmaskResources(object->abandonedMineResources, false);
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
bool customGuards = reader->readBool();
|
||||||
|
CreatureID guardsUnit = reader->readCreature32();
|
||||||
|
int32_t guardsMin = reader->readInt32();
|
||||||
|
int32_t guardsMax = reader->readInt32();
|
||||||
|
|
||||||
|
if (customGuards)
|
||||||
|
{
|
||||||
|
assert(guardsMin <= guardsMax);
|
||||||
|
assert(guardsUnit.hasValue());
|
||||||
|
logGlobal->warn("Map '%s': Abandoned Mine %s: not implemented guards of %d-%d %s", mapName, mapPosition.toString(), guardsMin, guardsMax, guardsUnit.toEntity(VLC)->getJsonKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@ -1415,21 +1557,48 @@ CGObjectInstance * CMapLoaderH3M::readHeroPlaceholder(const int3 & mapPosition)
|
|||||||
logGlobal->debug("Map '%s': Hero placeholder: %s at %s, owned by %s", mapName, VLC->heroh->getById(htid)->getJsonKey(), mapPosition.toString(), object->getOwner().toString());
|
logGlobal->debug("Map '%s': Hero placeholder: %s at %s, owned by %s", mapName, VLC->heroh->getById(htid)->getJsonKey(), mapPosition.toString(), object->getOwner().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
bool customizedStatingUnits = reader->readBool();
|
||||||
|
|
||||||
|
if (customizedStatingUnits)
|
||||||
|
logGlobal->warn("Map '%s': Hero placeholder: not implemented option to customize starting units", mapName);
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; ++i)
|
||||||
|
{
|
||||||
|
int32_t unitAmount = reader->readInt32();
|
||||||
|
CreatureID unitToGive = reader->readCreature32();
|
||||||
|
|
||||||
|
if (unitToGive.hasValue())
|
||||||
|
logGlobal->warn("Map '%s': Hero placeholder: not implemented option to give %d units of type %d on map start to slot %d is not implemented!", mapName, unitAmount, unitToGive.toEntity(VLC)->getJsonKey(), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t artifactsToGive = reader->readInt32();
|
||||||
|
assert(artifactsToGive >= 0);
|
||||||
|
assert(artifactsToGive < 100); // technically legal, but not possible in h3
|
||||||
|
|
||||||
|
for (int i = 0; i < artifactsToGive; ++i)
|
||||||
|
{
|
||||||
|
// NOTE: this might actually be 2 bytes for artifact ID + 2 bytes for spell scroll
|
||||||
|
ArtifactID startingArtifact = reader->readArtifact32();
|
||||||
|
logGlobal->warn("Map '%s': Hero placeholder: not implemented option to give hero artifact %d", mapName, startingArtifact.toEntity(VLC)->getJsonKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGObjectInstance * CMapLoaderH3M::readGrail(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
CGObjectInstance * CMapLoaderH3M::readGrail(const int3 & mapPosition)
|
||||||
{
|
{
|
||||||
if (objectTemplate->subid < 1000)
|
|
||||||
{
|
|
||||||
map->grailPos = mapPosition;
|
map->grailPos = mapPosition;
|
||||||
map->grailRadius = reader->readInt32();
|
map->grailRadius = reader->readInt32();
|
||||||
}
|
return nullptr;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
|
CGObjectInstance * CMapLoaderH3M::readHotaBattleLocation(const int3 & mapPosition)
|
||||||
|
{
|
||||||
// Battle location for arena mode in HotA
|
// Battle location for arena mode in HotA
|
||||||
logGlobal->warn("Map '%s': Arena mode is not supported!", mapName);
|
logGlobal->warn("Map '%s': Arena mode is not supported!", mapName);
|
||||||
}
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1442,14 +1611,6 @@ CGObjectInstance * CMapLoaderH3M::readGeneric(const int3 & mapPosition, std::sha
|
|||||||
return new CGObjectInstance(map->cb);
|
return new CGObjectInstance(map->cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGObjectInstance * CMapLoaderH3M::readPyramid(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
||||||
{
|
|
||||||
if(objectTemplate->subid == 0)
|
|
||||||
return readGeneric(mapPosition, objectTemplate);
|
|
||||||
|
|
||||||
return new CGObjectInstance(map->cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
CGObjectInstance * CMapLoaderH3M::readQuestGuard(const int3 & mapPosition)
|
CGObjectInstance * CMapLoaderH3M::readQuestGuard(const int3 & mapPosition)
|
||||||
{
|
{
|
||||||
auto * guard = new CGQuestGuard(map->cb);
|
auto * guard = new CGQuestGuard(map->cb);
|
||||||
@ -1498,7 +1659,7 @@ CGObjectInstance * CMapLoaderH3M::readBank(const int3 & mapPosition, std::shared
|
|||||||
|
|
||||||
if(guardsPresetIndex != -1 || upgradedStackPresence != -1 || !artifacts.empty())
|
if(guardsPresetIndex != -1 || upgradedStackPresence != -1 || !artifacts.empty())
|
||||||
logGlobal->warn(
|
logGlobal->warn(
|
||||||
"Map '%s: creature bank at %s settings %d %d %d are not implemented!",
|
"Map '%s': creature bank at %s settings %d %d %d are not implemented!",
|
||||||
mapName,
|
mapName,
|
||||||
mapPosition.toString(),
|
mapPosition.toString(),
|
||||||
guardsPresetIndex,
|
guardsPresetIndex,
|
||||||
@ -1510,9 +1671,101 @@ CGObjectInstance * CMapLoaderH3M::readBank(const int3 & mapPosition, std::shared
|
|||||||
return readGeneric(mapPosition, objectTemplate);
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
|
CGObjectInstance * CMapLoaderH3M::readRewardWithArtifact(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
||||||
{
|
{
|
||||||
switch(objectTemplate->id.toEnum())
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
// TREASURE_CHEST - rewards index, if 3 - then 2nd value is artifact
|
||||||
|
// CORPSE - rewards index, if 1 - then 2nd value is artifact
|
||||||
|
// SHIPWRECK_SURVIVOR - if content = 0 then 2nd value is granted artifact
|
||||||
|
// SEA_CHEST - rewards index, if 2 - then 2nd value is artifact
|
||||||
|
// FLOTSAM - rewards index (0-3) + -1
|
||||||
|
// TREE_OF_KNOWLEDGE - rewards index (0-2) + -1
|
||||||
|
// PYRAMID - if content = 0 then 2nd value is granted spell
|
||||||
|
// WARRIORS_TOMB - if content = 0 then 2nd value is granted artifact
|
||||||
|
// HOTA_JETSAM - rewards index (0-3) + -1
|
||||||
|
// HOTA_VIAL_OF_MANA - rewards index (0-3) + -1
|
||||||
|
|
||||||
|
int32_t content = reader->readInt32();
|
||||||
|
ArtifactID artifact;
|
||||||
|
if (content != -1)
|
||||||
|
{
|
||||||
|
artifact = reader->readArtifact32(); // NOTE: might be 2 byte artifact + 2 bytes scroll spell
|
||||||
|
logGlobal->warn("Map '%s': Object (%d) %s settings %d %d are not implemented!", mapName, objectTemplate->id, mapPosition.toString(), content, artifact);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reader->skipUnused(4); // garbage data, usually -1, but sometimes uninitialized
|
||||||
|
}
|
||||||
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGObjectInstance * CMapLoaderH3M::readBlackMarket(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
||||||
|
{
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 7; ++i)
|
||||||
|
{
|
||||||
|
ArtifactID artifact = reader->readArtifact();
|
||||||
|
SpellID spellID = reader->readSpell16();
|
||||||
|
|
||||||
|
if (artifact.hasValue())
|
||||||
|
{
|
||||||
|
if (artifact != ArtifactID::SPELL_SCROLL)
|
||||||
|
logGlobal->warn("Map '%s': Black Market at %s: option to sell artifact %s is not implemented", mapName, mapPosition.toString(), artifact.toEntity(VLC)->getJsonKey());
|
||||||
|
else
|
||||||
|
logGlobal->warn("Map '%s': Black Market at %s: option to sell scroll %s is not implemented", mapName, mapPosition.toString(), spellID.toEntity(VLC)->getJsonKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGObjectInstance * CMapLoaderH3M::readUniversity(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
||||||
|
{
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
int32_t customized = reader->readInt32();
|
||||||
|
|
||||||
|
std::set<SecondarySkill> allowedSkills;
|
||||||
|
reader->readBitmaskSkills(allowedSkills, false);
|
||||||
|
|
||||||
|
// NOTE: check how this interacts with hota Seafaring Academy that is guaranteed to give Navigation
|
||||||
|
assert(customized == -1 || customized == 0);
|
||||||
|
if (customized != -1)
|
||||||
|
logGlobal->warn("Map '%s': University at %s: option to give specific skills out of %d is not implemented", mapName, mapPosition.toString(), allowedSkills.size());
|
||||||
|
}
|
||||||
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGObjectInstance * CMapLoaderH3M::readRewardWithArtifactAndResources(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
||||||
|
{
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
// Sea Barrel / 0 -> aID = -1, aA = resource amount, rA = resource type, aB = garbage, rB = 0
|
||||||
|
// Sea Barrel / 1 -> aID = -1, aA = 1, rA = 1, aB = garbage, rB = 0
|
||||||
|
// Ancient Lamp / 0 -> aID = -1, aA = amount to recruit, rA = 0, aB = 1, rB = 0
|
||||||
|
// Grave / 0 -> aID = artifact to give, aA = resource amount, rA = resource type, aB = 1, rB = garbage
|
||||||
|
// CAMPFIRE 12 / 0 -> aID = -1, aA = gold amount, rA = gold type, aB = resource amount, rB = resource type
|
||||||
|
// WAGON 105 / 0 -> aID = -1 or artifact, aA = resource amount, rA = resource type, aB = 1, rB = garbage?
|
||||||
|
// WAGON 105 / 1 -> empty / garbage?
|
||||||
|
// LEAN_TO / 39 / 0 -> aID = -1, aA = resource amount, rA = resource type, aB = garbage, rB = 0
|
||||||
|
|
||||||
|
int32_t content = reader->readInt32();
|
||||||
|
int32_t artifact = reader->readInt32();
|
||||||
|
int32_t amountA = reader->readInt32();
|
||||||
|
int8_t resourceA = reader->readInt8();
|
||||||
|
int32_t amountB = reader->readInt32();
|
||||||
|
int8_t resourceB = reader->readInt8();
|
||||||
|
|
||||||
|
if (content != -1)
|
||||||
|
logGlobal->warn("Map '%s': Object (%d) %s settings %d %d %d %d %d %d are not implemented!", mapName, objectTemplate->id, mapPosition.toString(), content, artifact, amountA, static_cast<int>(resourceA), amountB, static_cast<int>(resourceB));
|
||||||
|
}
|
||||||
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGObjectInstance * CMapLoaderH3M::readObject(MapObjectID id, MapObjectSubID subid, std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
|
||||||
|
{
|
||||||
|
switch(id.toEnum())
|
||||||
{
|
{
|
||||||
case Obj::EVENT:
|
case Obj::EVENT:
|
||||||
return readEvent(mapPosition, objectInstanceID);
|
return readEvent(mapPosition, objectInstanceID);
|
||||||
@ -1555,8 +1808,9 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|||||||
case Obj::RANDOM_MINOR_ART:
|
case Obj::RANDOM_MINOR_ART:
|
||||||
case Obj::RANDOM_MAJOR_ART:
|
case Obj::RANDOM_MAJOR_ART:
|
||||||
case Obj::RANDOM_RELIC_ART:
|
case Obj::RANDOM_RELIC_ART:
|
||||||
case Obj::SPELL_SCROLL:
|
|
||||||
return readArtifact(mapPosition, objectTemplate);
|
return readArtifact(mapPosition, objectTemplate);
|
||||||
|
case Obj::SPELL_SCROLL:
|
||||||
|
return readScroll(mapPosition, objectTemplate);
|
||||||
|
|
||||||
case Obj::RANDOM_RESOURCE:
|
case Obj::RANDOM_RESOURCE:
|
||||||
case Obj::RESOURCE:
|
case Obj::RESOURCE:
|
||||||
@ -1567,7 +1821,10 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|||||||
|
|
||||||
case Obj::MINE:
|
case Obj::MINE:
|
||||||
case Obj::ABANDONED_MINE:
|
case Obj::ABANDONED_MINE:
|
||||||
return readMine(mapPosition, objectTemplate);
|
if (subid < 7)
|
||||||
|
return readMine(mapPosition);
|
||||||
|
else
|
||||||
|
return readAbandonedMine(mapPosition);
|
||||||
|
|
||||||
case Obj::CREATURE_GENERATOR1:
|
case Obj::CREATURE_GENERATOR1:
|
||||||
case Obj::CREATURE_GENERATOR2:
|
case Obj::CREATURE_GENERATOR2:
|
||||||
@ -1584,7 +1841,10 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|||||||
return readPandora(mapPosition, objectInstanceID);
|
return readPandora(mapPosition, objectInstanceID);
|
||||||
|
|
||||||
case Obj::GRAIL:
|
case Obj::GRAIL:
|
||||||
return readGrail(mapPosition, objectTemplate);
|
if (subid < 1000)
|
||||||
|
return readGrail(mapPosition);
|
||||||
|
else
|
||||||
|
return readHotaBattleLocation(mapPosition);
|
||||||
|
|
||||||
case Obj::RANDOM_DWELLING:
|
case Obj::RANDOM_DWELLING:
|
||||||
case Obj::RANDOM_DWELLING_LVL:
|
case Obj::RANDOM_DWELLING_LVL:
|
||||||
@ -1600,9 +1860,6 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|||||||
case Obj::HERO_PLACEHOLDER:
|
case Obj::HERO_PLACEHOLDER:
|
||||||
return readHeroPlaceholder(mapPosition);
|
return readHeroPlaceholder(mapPosition);
|
||||||
|
|
||||||
case Obj::PYRAMID:
|
|
||||||
return readPyramid(mapPosition, objectTemplate);
|
|
||||||
|
|
||||||
case Obj::LIGHTHOUSE:
|
case Obj::LIGHTHOUSE:
|
||||||
return readLighthouse(mapPosition, objectTemplate);
|
return readLighthouse(mapPosition, objectTemplate);
|
||||||
|
|
||||||
@ -1613,6 +1870,50 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|||||||
case Obj::SHIPWRECK:
|
case Obj::SHIPWRECK:
|
||||||
return readBank(mapPosition, objectTemplate);
|
return readBank(mapPosition, objectTemplate);
|
||||||
|
|
||||||
|
case Obj::TREASURE_CHEST:
|
||||||
|
case Obj::CORPSE:
|
||||||
|
case Obj::SHIPWRECK_SURVIVOR:
|
||||||
|
case Obj::SEA_CHEST:
|
||||||
|
case Obj::FLOTSAM:
|
||||||
|
case Obj::TREE_OF_KNOWLEDGE:
|
||||||
|
case Obj::PYRAMID:
|
||||||
|
case Obj::WARRIORS_TOMB:
|
||||||
|
return readRewardWithArtifact(mapPosition, objectTemplate);
|
||||||
|
|
||||||
|
case Obj::CAMPFIRE:
|
||||||
|
case Obj::WAGON:
|
||||||
|
case Obj::LEAN_TO:
|
||||||
|
return readRewardWithArtifactAndResources(mapPosition, objectTemplate);
|
||||||
|
|
||||||
|
case Obj::BORDER_GATE:
|
||||||
|
if (subid == 1000) // HotA hacks - Quest Gate
|
||||||
|
return readQuestGuard(mapPosition);
|
||||||
|
if (subid == 1001) // HotA hacks - Grave
|
||||||
|
return readRewardWithArtifactAndResources(mapPosition, objectTemplate);
|
||||||
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
|
|
||||||
|
case Obj::HOTA_CUSTOM_OBJECT_1:
|
||||||
|
// 0 -> Ancient Lamp
|
||||||
|
// 1 -> Sea Barrel
|
||||||
|
// 2 -> Jetsam
|
||||||
|
// 3 -> Vial of Mana
|
||||||
|
if (subid == 0 || subid == 1)
|
||||||
|
return readRewardWithArtifactAndResources(mapPosition, objectTemplate);
|
||||||
|
else
|
||||||
|
return readRewardWithArtifact(mapPosition, objectTemplate);
|
||||||
|
|
||||||
|
case Obj::HOTA_CUSTOM_OBJECT_2:
|
||||||
|
if (subid == 0) // Seafaring Academy
|
||||||
|
return readUniversity(mapPosition, objectTemplate);
|
||||||
|
else
|
||||||
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
|
|
||||||
|
case Obj::BLACK_MARKET:
|
||||||
|
return readBlackMarket(mapPosition, objectTemplate);
|
||||||
|
|
||||||
|
case Obj::UNIVERSITY:
|
||||||
|
return readUniversity(mapPosition, objectTemplate);
|
||||||
|
|
||||||
default: //any other object
|
default: //any other object
|
||||||
return readGeneric(mapPosition, objectTemplate);
|
return readGeneric(mapPosition, objectTemplate);
|
||||||
}
|
}
|
||||||
@ -1625,26 +1926,30 @@ void CMapLoaderH3M::readObjects()
|
|||||||
for(uint32_t i = 0; i < objectsCount; ++i)
|
for(uint32_t i = 0; i < objectsCount; ++i)
|
||||||
{
|
{
|
||||||
int3 mapPosition = reader->readInt3();
|
int3 mapPosition = reader->readInt3();
|
||||||
|
assert(map->isInTheMap(mapPosition) || map->isInTheMap(mapPosition - int3(0,8,0)) || map->isInTheMap(mapPosition - int3(8,0,0)) || map->isInTheMap(mapPosition - int3(8,8,0)));
|
||||||
|
|
||||||
uint32_t defIndex = reader->readUInt32();
|
uint32_t defIndex = reader->readUInt32();
|
||||||
ObjectInstanceID objectInstanceID = ObjectInstanceID(static_cast<si32>(map->objects.size()));
|
ObjectInstanceID objectInstanceID = ObjectInstanceID(static_cast<si32>(map->objects.size()));
|
||||||
|
|
||||||
std::shared_ptr<const ObjectTemplate> objectTemplate = templates.at(defIndex);
|
std::shared_ptr<ObjectTemplate> originalTemplate = originalTemplates.at(defIndex);
|
||||||
|
std::shared_ptr<ObjectTemplate> remappedTemplate = remappedTemplates.at(defIndex);
|
||||||
|
auto originalID = originalTemplate->id;
|
||||||
|
auto originalSubID = originalTemplate->subid;
|
||||||
reader->skipZero(5);
|
reader->skipZero(5);
|
||||||
|
|
||||||
CGObjectInstance * newObject = readObject(objectTemplate, mapPosition, objectInstanceID);
|
CGObjectInstance * newObject = readObject(originalID, originalSubID, remappedTemplate, mapPosition, objectInstanceID);
|
||||||
|
|
||||||
if(!newObject)
|
if(!newObject)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
newObject->setAnchorPos(mapPosition);
|
newObject->setAnchorPos(mapPosition);
|
||||||
newObject->ID = objectTemplate->id;
|
newObject->ID = remappedTemplate->id;
|
||||||
newObject->id = objectInstanceID;
|
newObject->id = objectInstanceID;
|
||||||
if(newObject->ID != Obj::HERO && newObject->ID != Obj::HERO_PLACEHOLDER && newObject->ID != Obj::PRISON)
|
if(newObject->ID != Obj::HERO && newObject->ID != Obj::HERO_PLACEHOLDER && newObject->ID != Obj::PRISON)
|
||||||
{
|
{
|
||||||
newObject->subID = objectTemplate->subid;
|
newObject->subID = remappedTemplate->subid;
|
||||||
}
|
}
|
||||||
newObject->appearance = objectTemplate;
|
newObject->appearance = remappedTemplate;
|
||||||
assert(objectInstanceID == ObjectInstanceID((si32)map->objects.size()));
|
assert(objectInstanceID == ObjectInstanceID((si32)map->objects.size()));
|
||||||
|
|
||||||
if (newObject->isVisitable() && !map->isInTheMap(newObject->visitablePos()))
|
if (newObject->isVisitable() && !map->isInTheMap(newObject->visitablePos()))
|
||||||
@ -1895,6 +2200,23 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
|
|||||||
logGlobal->debug("Map '%s': Hero on map: (random) at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().toString());
|
logGlobal->debug("Map '%s': Hero on map: (random) at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().toString());
|
||||||
|
|
||||||
reader->skipZero(16);
|
reader->skipZero(16);
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
bool alwaysAddSkills = reader->readBool(); // prevent heroes from receiving additional random secondary skills at the start of the map if they are not of the first level
|
||||||
|
bool cannotGainXP = reader->readBool();
|
||||||
|
int32_t level = reader->readInt32(); // Needs investigation how this interacts with usual setting of level via experience
|
||||||
|
assert(level > 0);
|
||||||
|
|
||||||
|
if (!alwaysAddSkills)
|
||||||
|
logGlobal->warn("Map '%s': Option to prevent hero %d from gaining skills on map start is not implemented!", mapName, object->subID.num);
|
||||||
|
|
||||||
|
if (cannotGainXP)
|
||||||
|
logGlobal->warn("Map '%s': Option to prevent hero %d from receiveing experience is not implemented!", mapName, object->subID.num);
|
||||||
|
|
||||||
|
if (level > 1)
|
||||||
|
logGlobal->warn("Map '%s': Option to set level of hero %d to %d is not implemented!", mapName, object->subID.num, level);
|
||||||
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2028,6 +2350,14 @@ void CMapLoaderH3M::readSeerHutQuest(CGSeerHut * hut, const int3 & position, con
|
|||||||
case ESeerHutRewardType::ARTIFACT:
|
case ESeerHutRewardType::ARTIFACT:
|
||||||
{
|
{
|
||||||
reward.artifacts.push_back(reader->readArtifact());
|
reward.artifacts.push_back(reader->readArtifact());
|
||||||
|
if (features.levelHOTA5)
|
||||||
|
{
|
||||||
|
SpellID scrollSpell = reader->readSpell16();
|
||||||
|
if (reward.artifacts.back() == ArtifactID::SPELL_SCROLL)
|
||||||
|
logGlobal->warn("Map '%s': Seer Hut at %s: Option to give spell scroll (%s) as a reward is not implemented!", mapName, position.toString(), scrollSpell.toEntity(VLC)->getJsonKey());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESeerHutRewardType::SPELL:
|
case ESeerHutRewardType::SPELL:
|
||||||
@ -2092,6 +2422,13 @@ EQuestMission CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & positi
|
|||||||
for(size_t yy = 0; yy < artNumber; ++yy)
|
for(size_t yy = 0; yy < artNumber; ++yy)
|
||||||
{
|
{
|
||||||
auto artid = reader->readArtifact();
|
auto artid = reader->readArtifact();
|
||||||
|
if (features.levelHOTA5)
|
||||||
|
{
|
||||||
|
SpellID scrollSpell = reader->readSpell16();
|
||||||
|
if (artid == ArtifactID::SPELL_SCROLL)
|
||||||
|
logGlobal->warn("Map '%s': Seer Hut at %s: Quest to find scroll '%s' is not implemented!", mapName, position.toString(), scrollSpell.toEntity(VLC)->getJsonKey());
|
||||||
|
|
||||||
|
}
|
||||||
guard->quest->mission.artifacts.push_back(artid);
|
guard->quest->mission.artifacts.push_back(artid);
|
||||||
map->allowedArtifact.erase(artid); //these are unavailable for random generation
|
map->allowedArtifact.erase(artid); //these are unavailable for random generation
|
||||||
}
|
}
|
||||||
@ -2128,6 +2465,7 @@ EQuestMission CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & positi
|
|||||||
case EQuestMission::HOTA_MULTI:
|
case EQuestMission::HOTA_MULTI:
|
||||||
{
|
{
|
||||||
uint32_t missionSubID = reader->readUInt32();
|
uint32_t missionSubID = reader->readUInt32();
|
||||||
|
assert(missionSubID < 3);
|
||||||
|
|
||||||
if(missionSubID == 0)
|
if(missionSubID == 0)
|
||||||
{
|
{
|
||||||
@ -2144,6 +2482,14 @@ EQuestMission CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & positi
|
|||||||
guard->quest->mission.daysPassed = reader->readUInt32() + 1;
|
guard->quest->mission.daysPassed = reader->readUInt32() + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(missionSubID == 2)
|
||||||
|
{
|
||||||
|
missionId = EQuestMission::HOTA_GAME_DIFFICULTY;
|
||||||
|
int32_t difficultyMask = reader->readUInt32();
|
||||||
|
assert(difficultyMask > 0 && difficultyMask < 32);
|
||||||
|
logGlobal->warn("Map '%s': Seer Hut at %s: Difficulty-specific quest (%d) is not implemented!", mapName, position.toString(), difficultyMask);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -2223,33 +2569,63 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|||||||
if(features.levelHOTA1)
|
if(features.levelHOTA1)
|
||||||
object->spellResearchAllowed = reader->readBool();
|
object->spellResearchAllowed = reader->readBool();
|
||||||
|
|
||||||
|
if(features.levelHOTA5)
|
||||||
|
{
|
||||||
|
// Most likely customization of special buildings per faction -> 4x11 table
|
||||||
|
// presumably:
|
||||||
|
// 0 -> default / allowed
|
||||||
|
// 1 -> built?
|
||||||
|
// 2 -> banned?
|
||||||
|
uint32_t specialBuildingsSize = reader->readUInt32();
|
||||||
|
|
||||||
|
for (int i = 0; i < specialBuildingsSize; ++i)
|
||||||
|
{
|
||||||
|
int factionID = i / 4;
|
||||||
|
int buildingID = i % 4;
|
||||||
|
|
||||||
|
int8_t specialBuildingBuilt = reader->readInt8Checked(0, 2);
|
||||||
|
if (specialBuildingBuilt != 0)
|
||||||
|
logGlobal->warn("Map '%s': Town at %s: Constructing / banning town-specific special building %d in faction %d on start is not implemented!", mapName, position.toString(), buildingID, factionID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Read castle events
|
// Read castle events
|
||||||
uint32_t eventsCount = reader->readUInt32();
|
uint32_t eventsCount = reader->readUInt32();
|
||||||
|
|
||||||
for(int eventID = 0; eventID < eventsCount; ++eventID)
|
for(int eventID = 0; eventID < eventsCount; ++eventID)
|
||||||
{
|
{
|
||||||
|
// TODO: a lot of copy-pasted code with map event
|
||||||
CCastleEvent event;
|
CCastleEvent event;
|
||||||
event.name = readBasicString();
|
event.creatures.resize(7);
|
||||||
event.message.appendTextID(readLocalizedString(TextIdentifier("town", position.x, position.y, position.z, "event", eventID, "description")));
|
|
||||||
|
|
||||||
reader->readResources(event.resources);
|
readEventCommon(event, TextIdentifier("town", position.x, position.y, position.z, "event", eventID, "description"));
|
||||||
|
|
||||||
reader->readBitmaskPlayers(event.players, false);
|
if(features.levelHOTA5)
|
||||||
if(features.levelSOD)
|
{
|
||||||
event.humanAffected = reader->readBool();
|
int32_t creatureGrowth8 = reader->readInt32();
|
||||||
else
|
|
||||||
event.humanAffected = true;
|
|
||||||
|
|
||||||
event.computerAffected = reader->readBool();
|
// always 44
|
||||||
event.firstOccurrence = reader->readUInt16();
|
int32_t hotaAmount = reader->readInt32();
|
||||||
event.nextOccurrence = reader->readUInt8();
|
|
||||||
|
|
||||||
reader->skipZero(17);
|
// contains bitmask on which town-specific buildings to build
|
||||||
|
// 4 bits / town, for each of special building in town (special 1 - special 4)
|
||||||
|
int32_t hotaSpecialA = reader->readInt32();
|
||||||
|
int16_t hotaSpecialB = reader->readInt16();
|
||||||
|
|
||||||
|
if (hotaSpecialA != 0 || hotaSpecialB != 0 || hotaAmount != 44)
|
||||||
|
logGlobal->warn("Map '%s': Town at %s: Constructing town-specific special buildings in event is not implemented!", mapName, position.toString());;
|
||||||
|
|
||||||
|
event.creatures.push_back(creatureGrowth8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(features.levelHOTA7)
|
||||||
|
{
|
||||||
|
[[maybe_unused]] bool neutralAffected = reader->readBool();
|
||||||
|
}
|
||||||
|
|
||||||
// New buildings
|
// New buildings
|
||||||
reader->readBitmaskBuildings(event.buildings, faction);
|
reader->readBitmaskBuildings(event.buildings, faction);
|
||||||
|
|
||||||
event.creatures.resize(7);
|
|
||||||
for(int i = 0; i < 7; ++i)
|
for(int i = 0; i < 7; ++i)
|
||||||
event.creatures[i] = reader->readUInt16();
|
event.creatures[i] = reader->readUInt16();
|
||||||
|
|
||||||
@ -2270,7 +2646,7 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|||||||
if (mapHeader->players[alignment].canAnyonePlay())
|
if (mapHeader->players[alignment].canAnyonePlay())
|
||||||
object->alignmentToPlayer = PlayerColor(alignment);
|
object->alignmentToPlayer = PlayerColor(alignment);
|
||||||
else
|
else
|
||||||
logGlobal->warn("%s - Alignment of town at %s is invalid! Player %d is not present on map!", mapName, position.toString(), int(alignment));
|
logGlobal->warn("Map '%s': Alignment of town at %s is invalid! Player %d is not present on map!", mapName, position.toString(), int(alignment));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2279,11 +2655,11 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|||||||
|
|
||||||
if(invertedAlignment < PlayerColor::PLAYER_LIMIT.getNum())
|
if(invertedAlignment < PlayerColor::PLAYER_LIMIT.getNum())
|
||||||
{
|
{
|
||||||
logGlobal->warn("%s - Alignment of town at %s 'not as player %d' is not implemented!", mapName, position.toString(), alignment - PlayerColor::PLAYER_LIMIT.getNum());
|
logGlobal->warn("Map '%s': Alignment of town at %s 'not as player %d' is not implemented!", mapName, position.toString(), alignment - PlayerColor::PLAYER_LIMIT.getNum());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->warn("%s - Alignment of town at %s is corrupted!!", mapName, position.toString());
|
logGlobal->warn("Map '%s': Alignment of town at %s is corrupted!!", mapName, position.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2293,30 +2669,45 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMapLoaderH3M::readEventCommon(CMapEvent & event, const TextIdentifier & messageID)
|
||||||
|
{
|
||||||
|
event.name = readBasicString();
|
||||||
|
event.message.appendTextID(readLocalizedString(messageID));
|
||||||
|
|
||||||
|
reader->readResources(event.resources);
|
||||||
|
|
||||||
|
reader->readBitmaskPlayers(event.players, false);
|
||||||
|
if(features.levelSOD)
|
||||||
|
event.humanAffected = reader->readBool();
|
||||||
|
else
|
||||||
|
event.humanAffected = true;
|
||||||
|
|
||||||
|
event.computerAffected = reader->readBool();
|
||||||
|
event.firstOccurrence = reader->readUInt16();
|
||||||
|
event.nextOccurrence = reader->readUInt16();
|
||||||
|
|
||||||
|
reader->skipZero(16);
|
||||||
|
|
||||||
|
if (features.levelHOTA7)
|
||||||
|
{
|
||||||
|
int32_t allowedDifficultiesMask = reader->readInt32();
|
||||||
|
assert(allowedDifficultiesMask > 0 && allowedDifficultiesMask < 32);
|
||||||
|
if (allowedDifficultiesMask != 31)
|
||||||
|
logGlobal->warn("Map '%s': Map event: availability by difficulty (mode %d) is not implemented!", mapName, allowedDifficultiesMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMapLoaderH3M::readEvents()
|
void CMapLoaderH3M::readEvents()
|
||||||
{
|
{
|
||||||
uint32_t eventsCount = reader->readUInt32();
|
uint32_t eventsCount = reader->readUInt32();
|
||||||
for(int eventID = 0; eventID < eventsCount; ++eventID)
|
for(int eventID = 0; eventID < eventsCount; ++eventID)
|
||||||
{
|
{
|
||||||
CMapEvent event;
|
CMapEvent event;
|
||||||
event.name = readBasicString();
|
readEventCommon(event, TextIdentifier("event", eventID, "description"));
|
||||||
event.message.appendTextID(readLocalizedString(TextIdentifier("event", eventID, "description")));
|
|
||||||
|
|
||||||
reader->readResources(event.resources);
|
// garbage bytes that were present in HOTA5 & HOTA6
|
||||||
reader->readBitmaskPlayers(event.players, false);
|
if (features.levelHOTA5 && !features.levelHOTA7)
|
||||||
if(features.levelSOD)
|
reader->skipUnused(14);
|
||||||
{
|
|
||||||
event.humanAffected = reader->readBool();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.humanAffected = true;
|
|
||||||
}
|
|
||||||
event.computerAffected = reader->readBool();
|
|
||||||
event.firstOccurrence = reader->readUInt16();
|
|
||||||
event.nextOccurrence = reader->readUInt8();
|
|
||||||
|
|
||||||
reader->skipZero(17);
|
|
||||||
|
|
||||||
map->events.push_back(event);
|
map->events.push_back(event);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "CMapService.h"
|
#include "CMapService.h"
|
||||||
#include "MapFeaturesH3M.h"
|
#include "MapFeaturesH3M.h"
|
||||||
|
#include "../constants/EntityIdentifiers.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ class CCreatureSet;
|
|||||||
class CInputStream;
|
class CInputStream;
|
||||||
class TextIdentifier;
|
class TextIdentifier;
|
||||||
class CGPandoraBox;
|
class CGPandoraBox;
|
||||||
|
class CMapEvent;
|
||||||
|
|
||||||
class ObjectInstanceID;
|
class ObjectInstanceID;
|
||||||
class BuildingID;
|
class BuildingID;
|
||||||
@ -185,7 +187,7 @@ private:
|
|||||||
void readObjects();
|
void readObjects();
|
||||||
|
|
||||||
/// Reads single object from input stream based on template
|
/// Reads single object from input stream based on template
|
||||||
CGObjectInstance * readObject(std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
CGObjectInstance * readObject(MapObjectID id, MapObjectSubID subid, std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
||||||
|
|
||||||
CGObjectInstance * readEvent(const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
CGObjectInstance * readEvent(const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
||||||
CGObjectInstance * readMonster(const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
CGObjectInstance * readMonster(const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
||||||
@ -197,20 +199,26 @@ private:
|
|||||||
CGObjectInstance * readScholar(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
CGObjectInstance * readScholar(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
CGObjectInstance * readGarrison(const int3 & mapPosition);
|
CGObjectInstance * readGarrison(const int3 & mapPosition);
|
||||||
CGObjectInstance * readArtifact(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
CGObjectInstance * readArtifact(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
||||||
|
CGObjectInstance * readScroll(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
||||||
CGObjectInstance * readResource(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
CGObjectInstance * readResource(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
||||||
CGObjectInstance * readMine(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
CGObjectInstance * readMine(const int3 & position);
|
||||||
|
CGObjectInstance * readAbandonedMine(const int3 & position);
|
||||||
CGObjectInstance * readPandora(const int3 & position, const ObjectInstanceID & idToBeGiven);
|
CGObjectInstance * readPandora(const int3 & position, const ObjectInstanceID & idToBeGiven);
|
||||||
CGObjectInstance * readDwelling(const int3 & position);
|
CGObjectInstance * readDwelling(const int3 & position);
|
||||||
CGObjectInstance * readDwellingRandom(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
CGObjectInstance * readDwellingRandom(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
||||||
CGObjectInstance * readShrine(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
CGObjectInstance * readShrine(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
CGObjectInstance * readHeroPlaceholder(const int3 & position);
|
CGObjectInstance * readHeroPlaceholder(const int3 & position);
|
||||||
CGObjectInstance * readGrail(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
CGObjectInstance * readGrail(const int3 & position);
|
||||||
CGObjectInstance * readPyramid(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
CGObjectInstance * readHotaBattleLocation(const int3 & position);
|
||||||
CGObjectInstance * readQuestGuard(const int3 & position);
|
CGObjectInstance * readQuestGuard(const int3 & position);
|
||||||
CGObjectInstance * readShipyard(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
CGObjectInstance * readShipyard(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
CGObjectInstance * readLighthouse(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
CGObjectInstance * readLighthouse(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
CGObjectInstance * readGeneric(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
CGObjectInstance * readGeneric(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
CGObjectInstance * readBank(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
CGObjectInstance * readBank(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
|
CGObjectInstance * readRewardWithArtifact(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
|
CGObjectInstance * readRewardWithArtifactAndResources(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
|
CGObjectInstance * readBlackMarket(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
|
CGObjectInstance * readUniversity(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a creature set.
|
* Reads a creature set.
|
||||||
@ -220,12 +228,10 @@ private:
|
|||||||
*/
|
*/
|
||||||
void readCreatureSet(CCreatureSet * out, int number);
|
void readCreatureSet(CCreatureSet * out, int number);
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a quest for the given quest guard.
|
|
||||||
*
|
|
||||||
* @param guard the quest guard where that quest should be applied to
|
|
||||||
*/
|
|
||||||
void readBoxContent(CGPandoraBox * object, const int3 & position, const ObjectInstanceID & idToBeGiven);
|
void readBoxContent(CGPandoraBox * object, const int3 & position, const ObjectInstanceID & idToBeGiven);
|
||||||
|
void readBoxHotaContent(CGPandoraBox * object, const int3 & position, const ObjectInstanceID & idToBeGiven);
|
||||||
|
|
||||||
|
void readEventCommon(CMapEvent & object, const TextIdentifier & messageID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a quest for the given quest guard.
|
* Reads a quest for the given quest guard.
|
||||||
@ -260,7 +266,8 @@ private:
|
|||||||
|
|
||||||
/** List of templates loaded from the map, used on later stage to create
|
/** List of templates loaded from the map, used on later stage to create
|
||||||
* objects but not needed for fully functional CMap */
|
* objects but not needed for fully functional CMap */
|
||||||
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
std::vector<std::shared_ptr<ObjectTemplate>> originalTemplates;
|
||||||
|
std::vector<std::shared_ptr<ObjectTemplate>> remappedTemplates;
|
||||||
|
|
||||||
/** ptr to the map object which gets filled by data from the buffer */
|
/** ptr to the map object which gets filled by data from the buffer */
|
||||||
CMap * map;
|
CMap * map;
|
||||||
|
@ -136,6 +136,27 @@ HeroTypeID MapReaderH3M::readHeroPortrait()
|
|||||||
return remapper.remapPortrait(result);
|
return remapper.remapPortrait(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreatureID MapReaderH3M::readCreature32()
|
||||||
|
{
|
||||||
|
CreatureID result= CreatureID(reader->readUInt32());
|
||||||
|
|
||||||
|
if(result.getNum() == features.creatureIdentifierInvalid)
|
||||||
|
return CreatureID::NONE;
|
||||||
|
|
||||||
|
if(result.getNum() < features.creaturesCount)
|
||||||
|
return remapIdentifier(result);
|
||||||
|
|
||||||
|
// this may be random creature in army/town, to be randomized later
|
||||||
|
CreatureID randomIndex(result.getNum() - features.creatureIdentifierInvalid - 1);
|
||||||
|
assert(randomIndex < CreatureID::NONE);
|
||||||
|
|
||||||
|
if (randomIndex.getNum() > -16)
|
||||||
|
return randomIndex;
|
||||||
|
|
||||||
|
logGlobal->warn("Map contains invalid creature %d. Will be removed!", result.getNum());
|
||||||
|
return CreatureID::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
CreatureID MapReaderH3M::readCreature()
|
CreatureID MapReaderH3M::readCreature()
|
||||||
{
|
{
|
||||||
CreatureID result;
|
CreatureID result;
|
||||||
@ -209,6 +230,15 @@ SpellID MapReaderH3M::readSpell()
|
|||||||
return remapIdentifier(result);
|
return remapIdentifier(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpellID MapReaderH3M::readSpell16()
|
||||||
|
{
|
||||||
|
SpellID result(readInt16());
|
||||||
|
if(result.getNum() == features.spellIdentifierInvalid)
|
||||||
|
return SpellID::NONE;
|
||||||
|
assert(result.getNum() < features.spellsCount);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
SpellID MapReaderH3M::readSpell32()
|
SpellID MapReaderH3M::readSpell32()
|
||||||
{
|
{
|
||||||
SpellID result(readInt32());
|
SpellID result(readInt32());
|
||||||
@ -371,10 +401,14 @@ std::shared_ptr<ObjectTemplate> MapReaderH3M::readObjectTemplate()
|
|||||||
{
|
{
|
||||||
auto tmpl = std::make_shared<ObjectTemplate>();
|
auto tmpl = std::make_shared<ObjectTemplate>();
|
||||||
tmpl->readMap(*reader);
|
tmpl->readMap(*reader);
|
||||||
remapper.remapTemplate(*tmpl);
|
|
||||||
return tmpl;
|
return tmpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapReaderH3M::remapTemplate(ObjectTemplate & tmpl)
|
||||||
|
{
|
||||||
|
remapper.remapTemplate(tmpl);
|
||||||
|
}
|
||||||
|
|
||||||
void MapReaderH3M::skipUnused(size_t amount)
|
void MapReaderH3M::skipUnused(size_t amount)
|
||||||
{
|
{
|
||||||
reader->skip(amount);
|
reader->skip(amount);
|
||||||
@ -432,6 +466,11 @@ uint16_t MapReaderH3M::readUInt16()
|
|||||||
return reader->readUInt16();
|
return reader->readUInt16();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t MapReaderH3M::readInt16()
|
||||||
|
{
|
||||||
|
return reader->readInt16();
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t MapReaderH3M::readUInt32()
|
uint32_t MapReaderH3M::readUInt32()
|
||||||
{
|
{
|
||||||
return reader->readUInt32();
|
return reader->readUInt32();
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
ArtifactID readArtifact();
|
ArtifactID readArtifact();
|
||||||
ArtifactID readArtifact8();
|
ArtifactID readArtifact8();
|
||||||
ArtifactID readArtifact32();
|
ArtifactID readArtifact32();
|
||||||
|
CreatureID readCreature32();
|
||||||
CreatureID readCreature();
|
CreatureID readCreature();
|
||||||
HeroTypeID readHero();
|
HeroTypeID readHero();
|
||||||
HeroTypeID readHeroPortrait();
|
HeroTypeID readHeroPortrait();
|
||||||
@ -43,6 +44,7 @@ public:
|
|||||||
PrimarySkill readPrimary();
|
PrimarySkill readPrimary();
|
||||||
SecondarySkill readSkill();
|
SecondarySkill readSkill();
|
||||||
SpellID readSpell();
|
SpellID readSpell();
|
||||||
|
SpellID readSpell16();
|
||||||
SpellID readSpell32();
|
SpellID readSpell32();
|
||||||
GameResID readGameResID();
|
GameResID readGameResID();
|
||||||
PlayerColor readPlayer();
|
PlayerColor readPlayer();
|
||||||
@ -63,6 +65,7 @@ public:
|
|||||||
int3 readInt3();
|
int3 readInt3();
|
||||||
|
|
||||||
std::shared_ptr<ObjectTemplate> readObjectTemplate();
|
std::shared_ptr<ObjectTemplate> readObjectTemplate();
|
||||||
|
void remapTemplate(ObjectTemplate & tmpl);
|
||||||
|
|
||||||
void skipUnused(size_t amount);
|
void skipUnused(size_t amount);
|
||||||
void skipZero(size_t amount);
|
void skipZero(size_t amount);
|
||||||
@ -75,6 +78,7 @@ public:
|
|||||||
int8_t readInt8();
|
int8_t readInt8();
|
||||||
int8_t readInt8Checked(int8_t lowerLimit, int8_t upperLimit);
|
int8_t readInt8Checked(int8_t lowerLimit, int8_t upperLimit);
|
||||||
|
|
||||||
|
int16_t readInt16();
|
||||||
uint16_t readUInt16();
|
uint16_t readUInt16();
|
||||||
|
|
||||||
uint32_t readUInt32();
|
uint32_t readUInt32();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user