ソースを参照

Fixed http://bugs.vcmi.eu/view.php?id=2297
* allow banned spells by Tomes (XXX_SPELLS bonus), Spelbinders Hat (SPELLS_OF_LEVEL bonus)
* allow banned spells by cheat-code (now also SPELLS_OF_LEVEL bonus)

AlexVinS 10 年 前
コミット
b94432b4ba
2 ファイル変更12 行追加11 行削除
  1. 1 1
      lib/mapObjects/CGHeroInstance.cpp
  2. 11 10
      server/CGameHandler.cpp

+ 1 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -966,7 +966,7 @@ bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
         {//hero has this spell in spellbook
             logGlobal->errorStream() << "Banned spell " << spell->name << " in spellbook.";
         }
-        return specificBonus;
+        return specificBonus || schoolBonus || levelBonus;
     }
     else
     {

+ 11 - 10
server/CGameHandler.cpp

@@ -3900,21 +3900,23 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
 	if(message == "vcmiistari") //give all spells and 999 mana
 	{
 		SetMana sm;
-		ChangeSpells cs;
-
+		GiveBonus giveBonus(GiveBonus::HERO);
+		
 		CGHeroInstance *h = gs->getHero(currObj);
 		if(!h && complain("Cannot realize cheat, no hero selected!")) return;
 
-		sm.hid = cs.hid = h->id;
+		sm.hid = h->id;
+		
+		giveBonus.id = h->id.getNum();
 
-		//give all spells
-		cs.learn = 1;
-		for(auto spell : VLC->spellh->objects)
+		//give all spells with bonus (to allow banned spells)
+		giveBonus.bonus = Bonus(Bonus::PERMANENT, Bonus::SPELLS_OF_LEVEL, Bonus::OTHER, 0, 0);
+		//start with level 0 to skip abilities
+		for(int level = 1; level <= GameConstants::SPELL_LEVELS; level++)
 		{
-			if(!spell->creatureAbility)
-				cs.spells.insert(spell->id);
+			giveBonus.bonus.subtype = level;
+			sendAndApply(&giveBonus);
 		}
-
 		//give mana
 		sm.val = 999;
 		sm.absolute = true;
@@ -3922,7 +3924,6 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
 		if(!h->hasSpellbook()) //hero doesn't have spellbook
 			giveHeroNewArtifact(h, VLC->arth->artifacts.at(0), ArtifactPosition::SPELLBOOK); //give spellbook
 
-		sendAndApply(&cs);
 		sendAndApply(&sm);
 	}
 	else if (message == "vcmiarmenelos") //build all buildings in selected town