Преглед изворни кода

Fixed #1638 - spells banned in map settings appeared in town guild

DjWarmonger пре 11 година
родитељ
комит
eb337d7407
1 измењених фајлова са 6 додато и 4 уклоњено
  1. 6 4
      lib/mapping/MapFormatH3M.cpp

+ 6 - 4
lib/mapping/MapFormatH3M.cpp

@@ -2134,7 +2134,7 @@ CGTownInstance * CMapLoaderH3M::readTown(int castleID)
 			{
 			{
 				if(i * 8 + yy < GameConstants::SPELLS_QUANTITY)
 				if(i * 8 + yy < GameConstants::SPELLS_QUANTITY)
 				{
 				{
-					if(c == (c | static_cast<ui8>(std::pow(2., yy))))
+					if(c == (c | static_cast<ui8>(std::pow(2., yy)))) //add obligatory spell even if it's banned on a map (?)
 					{
 					{
 						nt->obligatorySpells.push_back(SpellID(i * 8 + yy));
 						nt->obligatorySpells.push_back(SpellID(i * 8 + yy));
 					}
 					}
@@ -2148,16 +2148,18 @@ CGTownInstance * CMapLoaderH3M::readTown(int castleID)
 		ui8 c = reader.readUInt8();
 		ui8 c = reader.readUInt8();
 		for(int yy = 0; yy < 8; ++yy)
 		for(int yy = 0; yy < 8; ++yy)
 		{
 		{
-			if(i * 8 + yy < GameConstants::SPELLS_QUANTITY)
+			int spellid = i * 8 + yy; 
+			if(spellid < GameConstants::SPELLS_QUANTITY)
 			{
 			{
-				if(c != (c | static_cast<ui8>(std::pow(2., yy))))
+				if(c != (c | static_cast<ui8>(std::pow(2., yy))) && map->allowedSpell[spellid]) //add random spell only if it's allowed on entire map
 				{
 				{
-					nt->possibleSpells.push_back(SpellID(i * 8 + yy));
+					nt->possibleSpells.push_back(SpellID(spellid));
 				}
 				}
 			}
 			}
 		}
 		}
 	}
 	}
 	//add all spells from mods
 	//add all spells from mods
+	//TODO: allow customize new spells in towns
 	for (int i = SpellID::AFTER_LAST; i < VLC->spellh->objects.size(); ++i)
 	for (int i = SpellID::AFTER_LAST; i < VLC->spellh->objects.size(); ++i)
 	{
 	{
 		nt->possibleSpells.push_back(SpellID(i));
 		nt->possibleSpells.push_back(SpellID(i));