Browse Source

Fix spells issue in map editor

nordsoft 2 years ago
parent
commit
50d89dec24
2 changed files with 8 additions and 7 deletions
  1. 5 5
      mapeditor/inspector/inspector.cpp
  2. 3 2
      mapeditor/validator.cpp

+ 5 - 5
mapeditor/inspector/inspector.cpp

@@ -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;

+ 3 - 2
mapeditor/validator.cpp

@@ -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);