mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
Correctly iterate over allowed spells set (was vector originally)
This commit is contained in:
@ -158,17 +158,17 @@ void CPrivilegedInfoCallback::pickAllowedArtsSet(std::vector<const CArtifact *>
|
|||||||
|
|
||||||
void CPrivilegedInfoCallback::getAllowedSpells(std::vector<SpellID> & out, std::optional<ui16> level)
|
void CPrivilegedInfoCallback::getAllowedSpells(std::vector<SpellID> & out, std::optional<ui16> level)
|
||||||
{
|
{
|
||||||
for (ui32 i = 0; i < gs->map->allowedSpells.size(); i++) //spellh size appears to be greater (?)
|
for (auto const & spellID : gs->map->allowedSpells)
|
||||||
{
|
{
|
||||||
const spells::Spell * spell = SpellID(i).toSpell();
|
const auto * spell = spellID.toEntity(VLC);
|
||||||
|
|
||||||
if (!isAllowed(spell->getId()))
|
if (!isAllowed(spellID))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (level.has_value() && spell->getLevel() != level)
|
if (level.has_value() && spell->getLevel() != level)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
out.push_back(spell->getId());
|
out.push_back(spellID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,12 +368,7 @@ ui32 RmgMap::getTotalZoneCount() const
|
|||||||
bool RmgMap::isAllowedSpell(const SpellID & sid) const
|
bool RmgMap::isAllowedSpell(const SpellID & sid) const
|
||||||
{
|
{
|
||||||
assert(sid.getNum() >= 0);
|
assert(sid.getNum() >= 0);
|
||||||
if (sid.getNum() < mapInstance->allowedSpells.size())
|
return mapInstance->allowedSpells.count(sid);
|
||||||
{
|
|
||||||
return mapInstance->allowedSpells.count(sid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RmgMap::dump(bool zoneId) const
|
void RmgMap::dump(bool zoneId) const
|
||||||
|
Reference in New Issue
Block a user