1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

Map/Road/River identifiers are now private members

This commit is contained in:
Ivan Savenko
2023-01-01 17:10:47 +02:00
parent f3985d205b
commit 7c7ae26e67
31 changed files with 92 additions and 82 deletions

View File

@@ -81,16 +81,16 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f
int64_t ret = GameConstants::BASE_MOVEMENT_COST;
//if there is road both on dest and src tiles - use road movement cost
if(dest.roadType->id != Road::NO_ROAD && from.roadType->id != Road::NO_ROAD)
if(dest.roadType->getId() != Road::NO_ROAD && from.roadType->getId() != Road::NO_ROAD)
{
ret = std::max(dest.roadType->movementCost, from.roadType->movementCost);
}
else if(ti->nativeTerrain != from.terType->id &&//the terrain is not native
else if(ti->nativeTerrain != from.terType->getId() &&//the terrain is not native
ti->nativeTerrain != ETerrainId::ANY_TERRAIN && //no special creature bonus
!ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType->id.getNum())) //no special movement bonus
!ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType->getId().getNum())) //no special movement bonus
{
ret = VLC->heroh->terrCosts[from.terType->id];
ret = VLC->heroh->terrCosts[from.terType->getId()];
ret -= ti->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING);
if(ret < GameConstants::BASE_MOVEMENT_COST)
ret = GameConstants::BASE_MOVEMENT_COST;
@@ -519,7 +519,7 @@ void CGHeroInstance::initObj(CRandomGenerator & rand)
if (ID != Obj::PRISON)
{
auto terrain = cb->gameState()->getTile(visitablePos())->terType->id;
auto terrain = cb->gameState()->getTile(visitablePos())->terType->getId();
auto customApp = VLC->objtypeh->getHandlerFor(ID, type->heroClass->getIndex())->getOverride(terrain, this);
if (customApp)
appearance = customApp;

View File

@@ -1132,7 +1132,7 @@ void CGTownInstance::setType(si32 ID, si32 subID)
void CGTownInstance::updateAppearance()
{
auto terrain = cb->gameState()->getTile(visitablePos())->terType->id;
auto terrain = cb->gameState()->getTile(visitablePos())->terType->getId();
//FIXME: not the best way to do this
auto app = VLC->objtypeh->getHandlerFor(ID, subID)->getOverride(terrain, this);
if (app)

View File

@@ -207,13 +207,13 @@ void CGObjectInstance::setType(si32 ID, si32 subID)
logGlobal->error("Unknown object type %d:%d at %s", ID, subID, visitablePos().toString());
return;
}
if(!handler->getTemplates(tile.terType->id).empty())
if(!handler->getTemplates(tile.terType->getId()).empty())
{
appearance = handler->getTemplates(tile.terType->id)[0];
appearance = handler->getTemplates(tile.terType->getId())[0];
}
else
{
logGlobal->warn("Object %d:%d at %s has no templates suitable for terrain %s", ID, subID, visitablePos().toString(), tile.terType->identifier);
logGlobal->warn("Object %d:%d at %s has no templates suitable for terrain %s", ID, subID, visitablePos().toString(), tile.terType->getName());
appearance = handler->getTemplates()[0]; // get at least some appearance since alternative is crash
}

View File

@@ -84,7 +84,7 @@ CGObjectInstance * CTownInstanceConstructor::create(std::shared_ptr<const Object
void CTownInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const
{
auto templ = getOverride(object->cb->getTile(object->pos)->terType->id, object);
auto templ = getOverride(object->cb->getTile(object->pos)->terType->getId(), object);
if(templ)
object->appearance = templ;
}

View File

@@ -360,7 +360,7 @@ void ObjectTemplate::writeJson(JsonNode & node, const bool withTerrain) const
for(auto type : allowedTerrains)
{
JsonNode value(JsonNode::JsonType::DATA_STRING);
value.String() = VLC->terrainTypeHandler->getById(type)->identifier;
value.String() = VLC->terrainTypeHandler->getById(type)->getName();
data.push_back(value);
}
}