1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Merge pull request #4825 from godric3/map-editor-fix-copying-town

Map editor: fix duplicated spells in copy-pasted town
This commit is contained in:
Ivan Savenko 2024-10-27 21:16:23 +02:00 committed by GitHub
commit 2fa0021c28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -172,10 +172,12 @@ void Initializer::initialize(CGTownInstance * o)
if(lvl > 2) o->addBuilding(BuildingID::CASTLE);
if(lvl > 3) o->addBuilding(BuildingID::CAPITOL);
for(auto const & spell : VLC->spellh->objects) //add all regular spells to town
if(o->possibleSpells.empty())
{
if(!spell->isSpecial() && !spell->isCreatureAbility())
o->possibleSpells.push_back(spell->id);
for(auto const & spellId : VLC->spellh->getDefaultAllowed()) //add all regular spells to town
{
o->possibleSpells.push_back(spellId);
}
}
}

View File

@ -369,6 +369,7 @@ void MapController::pasteFromClipboard(int level)
if (!canPlaceObject(level, obj, errorMsg))
{
errors.push_back(std::move(errorMsg));
continue;
}
auto newPos = objUniquePtr->pos + shift;
if(_map->isInTheMap(newPos))
@ -380,8 +381,8 @@ void MapController::pasteFromClipboard(int level)
_scenes[level]->selectionObjectsView.selectObject(obj);
_mapHandler->invalidate(obj);
}
QMessageBox::warning(main, QObject::tr("Can't place object"), errors.join('\n'));
if(!errors.isEmpty())
QMessageBox::warning(main, QObject::tr("Can't place object"), errors.join('\n'));
_scenes[level]->objectsView.draw();
_scenes[level]->passabilityView.update();