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

Fix problem with saving

This commit is contained in:
nordsoft 2022-09-07 01:44:22 +04:00
parent 59f38fc43a
commit 0849f93d88
2 changed files with 32 additions and 7 deletions

View File

@ -67,6 +67,17 @@ MinimapScene * MapController::miniScene(int level)
void MapController::setMap(std::unique_ptr<CMap> cmap)
{
_map = std::move(cmap);
//fix map
for(auto obj : _map->objects)
if(obj->getOwner() == PlayerColor::UNFLAGGABLE)
if(dynamic_cast<CGMine*>(obj.get()) ||
dynamic_cast<CGDwelling*>(obj.get()) ||
dynamic_cast<CGTownInstance*>(obj.get()) ||
dynamic_cast<CGGarrison*>(obj.get()) ||
dynamic_cast<CGHeroInstance*>(obj.get()))
obj->tempOwner = PlayerColor::NEUTRAL;
_scenes[0].reset(new MapScene(0));
_scenes[1].reset(new MapScene(1));
_miniscenes[0].reset(new MinimapScene(0));

View File

@ -61,10 +61,16 @@ std::list<Validator::Issue> Validator::validate(const CMap * map)
for(auto o : map->objects)
{
if(auto * ins = dynamic_cast<CArmedInstance*>(o.get()))
if(o->getOwner() == PlayerColor::UNFLAGGABLE)
{
if(ins->getOwner() == PlayerColor::UNFLAGGABLE)
issues.emplace_back(QString("Armored instance %1 is UNFLAGGABLE but must have NEUTRAL or player owner").arg(ins->instanceName.c_str()), true);
if(dynamic_cast<CGMine*>(o.get()) ||
dynamic_cast<CGDwelling*>(o.get()) ||
dynamic_cast<CGTownInstance*>(o.get()) ||
dynamic_cast<CGGarrison*>(o.get()) ||
dynamic_cast<CGHeroInstance*>(o.get()))
{
issues.emplace_back(QString("Armored instance %1 is UNFLAGGABLE but must have NEUTRAL or player owner").arg(o->instanceName.c_str()), true);
}
}
if(auto * ins = dynamic_cast<CGTownInstance*>(o.get()))
{
@ -76,11 +82,19 @@ std::list<Validator::Issue> Validator::validate(const CMap * map)
}
if(auto * ins = dynamic_cast<CGHeroInstance*>(o.get()))
{
bool has = amountOfCastles.count(ins->getOwner().getNum());
if(!has)
issues.emplace_back(QString("Hero %1 must have an owner").arg(ins->instanceName.c_str()), true);
if(ins->ID == Obj::PRISON)
{
if(ins->getOwner() != PlayerColor::NEUTRAL)
issues.emplace_back(QString("Prison %1 must be a NEUTRAL").arg(ins->instanceName.c_str()), true);
}
else
issues.emplace_back(QString("Hero %1: heroes on map are not supported in current version").arg(ins->instanceName.c_str()), false);
{
bool has = amountOfCastles.count(ins->getOwner().getNum());
if(!has)
issues.emplace_back(QString("Hero %1 must have an owner").arg(ins->instanceName.c_str()), true);
else
issues.emplace_back(QString("Hero %1: heroes on map are not supported in current version").arg(ins->instanceName.c_str()), false);
}
}
}