From ffd604c1148fcef29fd5b1d700ced2e5d80e2be6 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 16 Jan 2024 19:06:41 +0200 Subject: [PATCH] Removed unnecessary access to IHandler::objects --- lib/StartInfo.cpp | 2 +- lib/battle/BattleInfo.cpp | 4 ++-- lib/gameState/CGameState.cpp | 2 +- lib/mapObjects/CGHeroInstance.cpp | 2 +- lib/mapObjects/IMarket.cpp | 4 ++-- lib/mapObjects/ObjectTemplate.cpp | 2 +- lib/mapping/CMap.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/StartInfo.cpp b/lib/StartInfo.cpp index cf1a70112..194f7d561 100644 --- a/lib/StartInfo.cpp +++ b/lib/StartInfo.cpp @@ -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); diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index cebbaeeeb..7a9dcbe82 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -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(); 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(); diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index 0a52f96fc..1d1a10aa9 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -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); diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index dd4e8c974..6af40312e 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -1261,7 +1261,7 @@ EDiggingStatus CGHeroInstance::diggingStatus() const { if(static_cast(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()); } diff --git a/lib/mapObjects/IMarket.cpp b/lib/mapObjects/IMarket.cpp index 907d90378..02b6d4631 100644 --- a/lib/mapObjects/IMarket.cpp +++ b/lib/mapObjects/IMarket.cpp @@ -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; diff --git a/lib/mapObjects/ObjectTemplate.cpp b/lib/mapObjects/ObjectTemplate.cpp index 3f284bbb4..817ca57c7 100644 --- a/lib/mapObjects/ObjectTemplate.cpp +++ b/lib/mapObjects/ObjectTemplate.cpp @@ -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(); diff --git a/lib/mapping/CMap.cpp b/lib/mapping/CMap.cpp index 01a0478f7..6e6d95b39 100644 --- a/lib/mapping/CMap.cpp +++ b/lib/mapping/CMap.cpp @@ -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();