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

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

This commit is contained in:
DjWarmonger 2014-05-16 12:15:35 +02:00
parent ccc5c69fa2
commit eb337d7407

View File

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