1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix spells issue in map editor

This commit is contained in:
nordsoft 2023-09-04 03:33:01 +04:00
parent 8f5594613b
commit 50d89dec24
2 changed files with 8 additions and 7 deletions

View File

@ -172,7 +172,7 @@ void Initializer::initialize(CGArtifact * o)
std::vector<SpellID> out;
for(auto spell : VLC->spellh->objects) //spellh size appears to be greater (?)
{
//if(map->isAllowedSpell(spell->id))
if(VLC->spellh->getDefaultAllowed().at(spell->id))
{
out.push_back(spell->id);
}
@ -300,10 +300,10 @@ void Inspector::updateProperties(CGArtifact * o)
auto * delegate = new InspectorDelegate;
for(auto spell : VLC->spellh->objects)
{
//if(map->isAllowedSpell(spell->id))
delegate->options << QObject::tr(spell->getJsonKey().c_str());
if(map->allowedSpells.at(spell->id))
delegate->options << QObject::tr(spell->getNameTranslated().c_str());
}
addProperty("Spell", VLC->spellh->getById(spellId)->getJsonKey(), delegate, false);
addProperty("Spell", VLC->spellh->getById(spellId)->getNameTranslated(), delegate, false);
}
}
}
@ -540,7 +540,7 @@ void Inspector::setProperty(CGArtifact * o, const QString & key, const QVariant
{
for(auto spell : VLC->spellh->objects)
{
if(spell->getJsonKey() == value.toString().toStdString())
if(spell->getNameTranslated() == value.toString().toStdString())
{
o->storedArtifact = ArtifactUtils::createScroll(spell->getId());
break;

View File

@ -16,6 +16,7 @@
#include "../lib/mapObjects/MapObjects.h"
#include "../lib/modding/CModHandler.h"
#include "../lib/modding/CModInfo.h"
#include "../lib/spells/CSpellHandler.h"
#include "../lib/CHeroHandler.h"
Validator::Validator(const CMap * map, QWidget *parent) :
@ -141,8 +142,8 @@ std::list<Validator::Issue> Validator::validate(const CMap * map)
{
if(ins->storedArtifact)
{
if(!map->allowedSpells[ins->storedArtifact->getId().getNum()])
issues.emplace_back(QString(tr("Spell scroll %1 is prohibited by map settings")).arg(ins->getObjectName().c_str()), false);
if(!map->allowedSpells[ins->storedArtifact->getScrollSpellID()])
issues.emplace_back(QString(tr("Spell scroll %1 is prohibited by map settings")).arg(ins->storedArtifact->getScrollSpellID().toSpell(VLC->spells())->getNameTranslated().c_str()), false);
}
else
issues.emplace_back(QString(tr("Spell scroll %1 doesn't have instance assigned and must be removed")).arg(ins->instanceName.c_str()), true);