2025-05-29 18:12:54 +03:00
|
|
|
/*
|
|
|
|
* MapFormatSettings.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "MapFormatSettings.h"
|
|
|
|
|
|
|
|
#include "MapFeaturesH3M.h"
|
|
|
|
|
|
|
|
#include "../GameLibrary.h"
|
|
|
|
#include "../IGameSettings.h"
|
2025-05-30 18:27:54 +03:00
|
|
|
#include "../json/JsonUtils.h"
|
2025-06-02 15:19:08 +03:00
|
|
|
#include "../modding/ModScope.h"
|
2025-05-29 18:12:54 +03:00
|
|
|
|
2025-06-02 17:24:13 +03:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2025-05-29 18:12:54 +03:00
|
|
|
MapIdentifiersH3M MapFormatSettings::generateMapping(EMapFormat format)
|
|
|
|
{
|
|
|
|
auto features = MapFormatFeaturesH3M::find(format, 0);
|
|
|
|
MapIdentifiersH3M identifierMapper;
|
|
|
|
|
|
|
|
if(features.levelROE)
|
|
|
|
identifierMapper.loadMapping(LIBRARY->engineSettings()->getValue(EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA));
|
|
|
|
if(features.levelAB)
|
|
|
|
identifierMapper.loadMapping(LIBRARY->engineSettings()->getValue(EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE));
|
|
|
|
if(features.levelSOD)
|
|
|
|
identifierMapper.loadMapping(LIBRARY->engineSettings()->getValue(EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH));
|
|
|
|
if(features.levelCHR)
|
|
|
|
identifierMapper.loadMapping(LIBRARY->engineSettings()->getValue(EGameSettings::MAP_FORMAT_CHRONICLES));
|
|
|
|
if(features.levelWOG)
|
|
|
|
identifierMapper.loadMapping(LIBRARY->engineSettings()->getValue(EGameSettings::MAP_FORMAT_IN_THE_WAKE_OF_GODS));
|
|
|
|
if(features.levelHOTA0)
|
|
|
|
identifierMapper.loadMapping(LIBRARY->engineSettings()->getValue(EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS));
|
|
|
|
|
|
|
|
return identifierMapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<CampaignVersion, EMapFormat> MapFormatSettings::generateCampaignMapping()
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
{CampaignVersion::RoE, EMapFormat::ROE },
|
|
|
|
{CampaignVersion::AB, EMapFormat::AB },
|
|
|
|
{CampaignVersion::SoD, EMapFormat::SOD },
|
|
|
|
{CampaignVersion::WoG, EMapFormat::WOG },
|
|
|
|
{CampaignVersion::Chr, EMapFormat::CHR },
|
|
|
|
{CampaignVersion::HotA, EMapFormat::HOTA}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<EMapFormat, MapIdentifiersH3M> MapFormatSettings::generateMappings()
|
|
|
|
{
|
|
|
|
std::map<EMapFormat, MapIdentifiersH3M> result;
|
|
|
|
auto addMapping = [&result](EMapFormat format)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result[format] = generateMapping(format);
|
|
|
|
logMod->trace("Loaded map format support for %d", static_cast<int>(format));
|
|
|
|
}
|
|
|
|
catch(const std::runtime_error &)
|
|
|
|
{
|
|
|
|
// unsupported map format - skip
|
|
|
|
logMod->debug("Failed to load map format support for %d", static_cast<int>(format));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
addMapping(EMapFormat::ROE);
|
|
|
|
addMapping(EMapFormat::AB);
|
|
|
|
addMapping(EMapFormat::SOD);
|
|
|
|
addMapping(EMapFormat::CHR);
|
|
|
|
addMapping(EMapFormat::HOTA);
|
|
|
|
addMapping(EMapFormat::WOG);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
MapFormatSettings::MapFormatSettings()
|
|
|
|
: mapping(generateMappings())
|
|
|
|
, campaignToMap(generateCampaignMapping())
|
2025-05-30 18:27:54 +03:00
|
|
|
, campaignOverridesConfig(JsonUtils::assembleFromFiles("config/campaignOverrides.json"))
|
|
|
|
, mapOverridesConfig(JsonUtils::assembleFromFiles("config/mapOverrides.json"))
|
2025-05-29 18:12:54 +03:00
|
|
|
{
|
2025-06-02 15:19:08 +03:00
|
|
|
for (auto & entry : mapOverridesConfig.Struct())
|
|
|
|
JsonUtils::validate(entry.second, "vcmi:mapHeader", "patch for " + entry.first);
|
|
|
|
|
2025-06-02 17:24:13 +03:00
|
|
|
campaignOverridesConfig.setModScope(ModScope::scopeMap());
|
2025-06-02 15:19:08 +03:00
|
|
|
mapOverridesConfig.setModScope(ModScope::scopeMap());
|
2025-05-29 18:12:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|