1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Verifying mods before starting map

This commit is contained in:
nordsoft
2023-04-16 15:38:13 +04:00
parent 67e1b48d47
commit 954a2abb71
7 changed files with 60 additions and 3 deletions

View File

@@ -15,6 +15,7 @@
#include "mapping/CMapInfo.h"
#include "mapping/CCampaignHandler.h"
#include "mapping/CMap.h"
#include "mapping/CMapService.h"
VCMI_LIB_NAMESPACE_BEGIN
@@ -67,8 +68,16 @@ std::string StartInfo::getCampaignName() const
void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
{
if(!mi)
if(!mi || !mi->mapHeader)
throw std::domain_error("ExceptionMapMissing");
auto missingMods = CMapService::verifyMapHeaderMods(*mi->mapHeader);
CModHandler::Incompatibility::ModList modList;
for(const auto & m : missingMods)
modList.push_back({m.first, m.second.toString()});
if(!modList.empty())
throw CModHandler::Incompatibility(std::move(modList));
//there must be at least one human player before game can be started
std::map<PlayerColor, PlayerSettings>::const_iterator i;