1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Map format support status can now be loaded from gameSettings

This commit is contained in:
Ivan Savenko 2023-05-20 15:46:40 +03:00
parent 402823e3d5
commit fb55719671
5 changed files with 42 additions and 8 deletions

View File

@ -528,6 +528,26 @@ void SelectionTab::restoreLastSelection()
}
}
bool SelectionTab::isMapSupported(const CMapInfo & info)
{
switch (info.mapHeader->version)
{
case EMapFormat::ROE:
return CGI->settings()->getValue(EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA)["supported"].Bool();
case EMapFormat::AB:
return CGI->settings()->getValue(EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE)["supported"].Bool();
case EMapFormat::SOD:
return CGI->settings()->getValue(EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH)["supported"].Bool();
case EMapFormat::WOG:
return CGI->settings()->getValue(EGameSettings::MAP_FORMAT_IN_THE_WAKE_OF_GODS)["supported"].Bool();
case EMapFormat::HOTA:
return CGI->settings()->getValue(EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS)["supported"].Bool();
case EMapFormat::VCMI:
return true;
}
return false;
}
void SelectionTab::parseMaps(const std::unordered_set<ResourceID> & files)
{
logGlobal->debug("Parsing %d maps", files.size());
@ -539,9 +559,7 @@ void SelectionTab::parseMaps(const std::unordered_set<ResourceID> & files)
auto mapInfo = std::make_shared<CMapInfo>();
mapInfo->mapInit(file.getName());
EMapFormat maxSupported = static_cast<EMapFormat>(CGI->settings()->getInteger(EGameSettings::TEXTS_MAP_VERSION));
if(mapInfo->mapHeader->version == EMapFormat::VCMI || mapInfo->mapHeader->version <= maxSupported)
if (isMapSupported(*mapInfo))
allItems.push_back(mapInfo);
}
catch(std::exception & e)

View File

@ -93,6 +93,7 @@ private:
ESelectionScreen tabType;
Rect inputNameRect;
bool isMapSupported(const CMapInfo & info);
void parseMaps(const std::unordered_set<ResourceID> & files);
void parseSaves(const std::unordered_set<ResourceID> & files);
void parseCampaigns(const std::unordered_set<ResourceID> & files);

View File

@ -84,7 +84,7 @@
],
"skills" :
[
"config/skills.json"
"config/skills.json"
],
"terrains":
[
@ -122,7 +122,14 @@
"terrain" : 10,
"river" : 5,
"road" : 4,
"mapVersion" : 28 // max supported version, SoD
},
"mapFormat" : {
"restorationOfErathia" : { "supported" : true },
"armageddonsBlade" : { "supported" : true },
"shadowOfDeath" : { "supported" : true },
"hornOfTheAbyss" : { "supported" : false },
"inTheWakeOfGods" : { "supported" : false }
},
"heroes" :

View File

@ -58,7 +58,7 @@ void GameSettings::load(const JsonNode & input)
{EGameSettings::COMBAT_DEFENSE_POINT_DAMAGE_FACTOR_CAP, "combat", "defensePointDamageFactorCap"},
{EGameSettings::COMBAT_GOOD_LUCK_DICE, "combat", "goodLuckDice" },
{EGameSettings::COMBAT_GOOD_MORALE_DICE, "combat", "goodMoraleDice" },
{EGameSettings::COMBAT_ONE_HEX_TRIGGERS_OBSTACLES, "combat", "oneHexTriggersObstacles" },
{EGameSettings::COMBAT_ONE_HEX_TRIGGERS_OBSTACLES, "combat", "oneHexTriggersObstacles" },
{EGameSettings::CREATURES_ALLOW_ALL_FOR_DOUBLE_MONTH, "creatures", "allowAllForDoubleMonth" },
{EGameSettings::CREATURES_ALLOW_RANDOM_SPECIAL_WEEKS, "creatures", "allowRandomSpecialWeeks" },
{EGameSettings::CREATURES_DAILY_STACK_EXPERIENCE, "creatures", "dailyStackExperience" },
@ -71,6 +71,11 @@ void GameSettings::load(const JsonNode & input)
{EGameSettings::HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS, "heroes", "retreatOnWinWithoutTroops" },
{EGameSettings::HEROES_STARTING_STACKS_CHANCES, "heroes", "startingStackChances" },
{EGameSettings::HEROES_BACKPACK_CAP, "heroes", "backpackSize" },
{EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA, "mapFormat", "restorationOfErathia" },
{EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" },
{EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH, "mapFormat", "shadowOfDeath" },
{EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS, "mapFormat", "hornOfTheAbyss" },
{EGameSettings::MAP_FORMAT_IN_THE_WAKE_OF_GODS, "mapFormat", "inTheWakeOfGods" },
{EGameSettings::MARKETS_BLACK_MARKET_RESTOCK_PERIOD, "markets", "blackMarketRestockPeriod" },
{EGameSettings::MODULE_COMMANDERS, "modules", "commanders" },
{EGameSettings::MODULE_STACK_ARTIFACT, "modules", "stackArtifact" },
@ -80,7 +85,6 @@ void GameSettings::load(const JsonNode & input)
{EGameSettings::TEXTS_FACTION, "textData", "faction" },
{EGameSettings::TEXTS_HERO, "textData", "hero" },
{EGameSettings::TEXTS_HERO_CLASS, "textData", "heroClass" },
{EGameSettings::TEXTS_MAP_VERSION, "textData", "mapVersion" },
{EGameSettings::TEXTS_OBJECT, "textData", "object" },
{EGameSettings::TEXTS_RIVER, "textData", "river" },
{EGameSettings::TEXTS_ROAD, "textData", "road" },

View File

@ -46,12 +46,16 @@ enum class EGameSettings
TEXTS_FACTION,
TEXTS_HERO,
TEXTS_HERO_CLASS,
TEXTS_MAP_VERSION,
TEXTS_OBJECT,
TEXTS_RIVER,
TEXTS_ROAD,
TEXTS_SPELL,
TEXTS_TERRAIN,
MAP_FORMAT_RESTORATION_OF_ERATHIA,
MAP_FORMAT_ARMAGEDDONS_BLADE,
MAP_FORMAT_SHADOW_OF_DEATH,
MAP_FORMAT_HORN_OF_THE_ABYSS,
MAP_FORMAT_IN_THE_WAKE_OF_GODS,
TOWNS_BUILDINGS_PER_TURN_CAP,
TOWNS_STARTING_DWELLING_CHANCES,
COMBAT_ONE_HEX_TRIGGERS_OBSTACLES,