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())
|
if (!castle.isValid())
|
||||||
return FactionID(0);
|
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 castle;
|
||||||
|
|
||||||
return FactionID(0);
|
return FactionID(0);
|
||||||
|
@ -240,7 +240,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RangeGenerator obidgen(0, VLC->obstacleHandler->objects.size() - 1, ourRand);
|
RangeGenerator obidgen(0, VLC->obstacleHandler->size() - 1, ourRand);
|
||||||
auto obstPtr = std::make_shared<CObstacleInstance>();
|
auto obstPtr = std::make_shared<CObstacleInstance>();
|
||||||
obstPtr->obstacleType = CObstacleInstance::ABSOLUTE_OBSTACLE;
|
obstPtr->obstacleType = CObstacleInstance::ABSOLUTE_OBSTACLE;
|
||||||
obstPtr->ID = obidgen.getSuchNumber(appropriateAbsoluteObstacle);
|
obstPtr->ID = obidgen.getSuchNumber(appropriateAbsoluteObstacle);
|
||||||
@ -262,7 +262,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
|||||||
{
|
{
|
||||||
while(tilesToBlock > 0)
|
while(tilesToBlock > 0)
|
||||||
{
|
{
|
||||||
RangeGenerator obidgen(0, VLC->obstacleHandler->objects.size() - 1, ourRand);
|
RangeGenerator obidgen(0, VLC->obstacleHandler->size() - 1, ourRand);
|
||||||
auto tileAccessibility = curB->getAccesibility();
|
auto tileAccessibility = curB->getAccesibility();
|
||||||
const int obid = obidgen.getSuchNumber(appropriateUsualObstacle);
|
const int obid = obidgen.getSuchNumber(appropriateUsualObstacle);
|
||||||
const ObstacleInfo &obi = *Obstacle(obid).getInfo();
|
const ObstacleInfo &obi = *Obstacle(obid).getInfo();
|
||||||
|
@ -99,7 +99,7 @@ HeroTypeID CGameState::pickUnusedHeroTypeRandomly(const PlayerColor & owner)
|
|||||||
const PlayerSettings &ps = scenarioOps->getIthPlayersSettings(owner);
|
const PlayerSettings &ps = scenarioOps->getIthPlayersSettings(owner);
|
||||||
for(const HeroTypeID & hid : getUnusedAllowedHeroes())
|
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);
|
factionHeroes.push_back(hid);
|
||||||
else
|
else
|
||||||
otherHeroes.push_back(hid);
|
otherHeroes.push_back(hid);
|
||||||
|
@ -1261,7 +1261,7 @@ EDiggingStatus CGHeroInstance::diggingStatus() const
|
|||||||
{
|
{
|
||||||
if(static_cast<int>(movement) < movementPointsLimit(true))
|
if(static_cast<int>(movement) < movementPointsLimit(true))
|
||||||
return EDiggingStatus::LACK_OF_MOVEMENT;
|
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 EDiggingStatus::BACKPACK_IS_FULL;
|
||||||
return cb->getTileDigStatus(visitablePos());
|
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:
|
case EMarketMode::CREATURE_EXP:
|
||||||
{
|
{
|
||||||
val1 = 1;
|
val1 = 1;
|
||||||
val2 = (VLC->creh->objects[id1]->getAIValue() / 40) * 5;
|
val2 = (CreatureID(id1).toEntity(VLC)->getAIValue() / 40) * 5;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EMarketMode::ARTIFACT_EXP:
|
case EMarketMode::ARTIFACT_EXP:
|
||||||
{
|
{
|
||||||
val1 = 1;
|
val1 = 1;
|
||||||
|
|
||||||
int givenClass = VLC->arth->objects[id1]->getArtClassSerial();
|
int givenClass = ArtifactID(id1).toArtifact()->getArtClassSerial();
|
||||||
if(givenClass < 0 || givenClass > 3)
|
if(givenClass < 0 || givenClass > 3)
|
||||||
{
|
{
|
||||||
val2 = 0;
|
val2 = 0;
|
||||||
|
@ -350,7 +350,7 @@ void ObjectTemplate::writeJson(JsonNode & node, const bool withTerrain) const
|
|||||||
if(withTerrain)
|
if(withTerrain)
|
||||||
{
|
{
|
||||||
//assumed that ROCK and WATER terrains are not included
|
//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();
|
JsonVector & data = node["allowedTerrains"].Vector();
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ CMap::CMap(IGameCallback * cb)
|
|||||||
, grailRadius(0)
|
, grailRadius(0)
|
||||||
, uidCounter(0)
|
, uidCounter(0)
|
||||||
{
|
{
|
||||||
allHeroes.resize(VLC->heroh->objects.size());
|
allHeroes.resize(VLC->heroh->size());
|
||||||
allowedAbilities = VLC->skillh->getDefaultAllowed();
|
allowedAbilities = VLC->skillh->getDefaultAllowed();
|
||||||
allowedArtifact = VLC->arth->getDefaultAllowed();
|
allowedArtifact = VLC->arth->getDefaultAllowed();
|
||||||
allowedSpells = VLC->spellh->getDefaultAllowed();
|
allowedSpells = VLC->spellh->getDefaultAllowed();
|
||||||
|
Loading…
Reference in New Issue
Block a user