mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Removed unnecessary access to IHandler::objects
This commit is contained in:
parent
6e629a6a5f
commit
ffd604c114
@ -32,7 +32,7 @@ FactionID PlayerSettings::getCastleValidated() const
|
||||
{
|
||||
if (!castle.isValid())
|
||||
return FactionID(0);
|
||||
if (castle.getNum() < VLC->townh->size() && VLC->townh->objects[castle.getNum()]->town != nullptr)
|
||||
if (castle.getNum() < VLC->townh->size() && castle.toEntity(VLC)->hasTown())
|
||||
return castle;
|
||||
|
||||
return FactionID(0);
|
||||
|
@ -240,7 +240,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
||||
{
|
||||
try
|
||||
{
|
||||
RangeGenerator obidgen(0, VLC->obstacleHandler->objects.size() - 1, ourRand);
|
||||
RangeGenerator obidgen(0, VLC->obstacleHandler->size() - 1, ourRand);
|
||||
auto obstPtr = std::make_shared<CObstacleInstance>();
|
||||
obstPtr->obstacleType = CObstacleInstance::ABSOLUTE_OBSTACLE;
|
||||
obstPtr->ID = obidgen.getSuchNumber(appropriateAbsoluteObstacle);
|
||||
@ -262,7 +262,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
||||
{
|
||||
while(tilesToBlock > 0)
|
||||
{
|
||||
RangeGenerator obidgen(0, VLC->obstacleHandler->objects.size() - 1, ourRand);
|
||||
RangeGenerator obidgen(0, VLC->obstacleHandler->size() - 1, ourRand);
|
||||
auto tileAccessibility = curB->getAccesibility();
|
||||
const int obid = obidgen.getSuchNumber(appropriateUsualObstacle);
|
||||
const ObstacleInfo &obi = *Obstacle(obid).getInfo();
|
||||
|
@ -99,7 +99,7 @@ HeroTypeID CGameState::pickUnusedHeroTypeRandomly(const PlayerColor & owner)
|
||||
const PlayerSettings &ps = scenarioOps->getIthPlayersSettings(owner);
|
||||
for(const HeroTypeID & hid : getUnusedAllowedHeroes())
|
||||
{
|
||||
if(VLC->heroh->objects[hid.getNum()]->heroClass->faction == ps.castle)
|
||||
if(hid.toHeroType()->heroClass->faction == ps.castle)
|
||||
factionHeroes.push_back(hid);
|
||||
else
|
||||
otherHeroes.push_back(hid);
|
||||
|
@ -1261,7 +1261,7 @@ EDiggingStatus CGHeroInstance::diggingStatus() const
|
||||
{
|
||||
if(static_cast<int>(movement) < movementPointsLimit(true))
|
||||
return EDiggingStatus::LACK_OF_MOVEMENT;
|
||||
if(!VLC->arth->objects[ArtifactID::GRAIL]->canBePutAt(this))
|
||||
if(ArtifactID(ArtifactID::GRAIL).toArtifact()->canBePutAt(this))
|
||||
return EDiggingStatus::BACKPACK_IS_FULL;
|
||||
return cb->getTileDigStatus(visitablePos());
|
||||
}
|
||||
|
@ -96,14 +96,14 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode)
|
||||
case EMarketMode::CREATURE_EXP:
|
||||
{
|
||||
val1 = 1;
|
||||
val2 = (VLC->creh->objects[id1]->getAIValue() / 40) * 5;
|
||||
val2 = (CreatureID(id1).toEntity(VLC)->getAIValue() / 40) * 5;
|
||||
}
|
||||
break;
|
||||
case EMarketMode::ARTIFACT_EXP:
|
||||
{
|
||||
val1 = 1;
|
||||
|
||||
int givenClass = VLC->arth->objects[id1]->getArtClassSerial();
|
||||
int givenClass = ArtifactID(id1).toArtifact()->getArtClassSerial();
|
||||
if(givenClass < 0 || givenClass > 3)
|
||||
{
|
||||
val2 = 0;
|
||||
|
@ -350,7 +350,7 @@ void ObjectTemplate::writeJson(JsonNode & node, const bool withTerrain) const
|
||||
if(withTerrain)
|
||||
{
|
||||
//assumed that ROCK and WATER terrains are not included
|
||||
if(allowedTerrains.size() < (VLC->terrainTypeHandler->objects.size() - 2))
|
||||
if(allowedTerrains.size() < (VLC->terrainTypeHandler->size() - 2))
|
||||
{
|
||||
JsonVector & data = node["allowedTerrains"].Vector();
|
||||
|
||||
|
@ -169,7 +169,7 @@ CMap::CMap(IGameCallback * cb)
|
||||
, grailRadius(0)
|
||||
, uidCounter(0)
|
||||
{
|
||||
allHeroes.resize(VLC->heroh->objects.size());
|
||||
allHeroes.resize(VLC->heroh->size());
|
||||
allowedAbilities = VLC->skillh->getDefaultAllowed();
|
||||
allowedArtifact = VLC->arth->getDefaultAllowed();
|
||||
allowedSpells = VLC->spellh->getDefaultAllowed();
|
||||
|
Loading…
Reference in New Issue
Block a user