mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-02 23:07:36 +02:00
Map/Road/River identifiers are now private members
This commit is contained in:
parent
f3985d205b
commit
7c7ae26e67
@ -340,7 +340,7 @@ void CMusicHandler::loadTerrainMusicThemes()
|
||||
{
|
||||
for (const auto & terrain : CGI->terrainTypeHandler->objects)
|
||||
{
|
||||
addEntryToSet("terrain_" + terrain->identifier, "Music/" + terrain->musicFilename);
|
||||
addEntryToSet("terrain_" + terrain->getName(), "Music/" + terrain->musicFilename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
|
||||
{
|
||||
updateAmbientSounds();
|
||||
//We may need to change music - select new track, music handler will change it if needed
|
||||
CCS->musich->playMusicFromSet("terrain", LOCPLINT->cb->getTile(hero->visitablePos())->terType->identifier, true, false);
|
||||
CCS->musich->playMusicFromSet("terrain", LOCPLINT->cb->getTile(hero->visitablePos())->terType->getName(), true, false);
|
||||
|
||||
if(details.result == TryMoveHero::TELEPORTATION)
|
||||
{
|
||||
@ -2436,7 +2436,7 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
||||
sh = CCS->soundh->playSound(soundBase::horseFlying, -1);
|
||||
#endif
|
||||
{
|
||||
newTerrain = cb->getTile(h->convertToVisitablePos(prevCoord))->terType->id;
|
||||
newTerrain = cb->getTile(h->convertToVisitablePos(prevCoord))->terType->getId();
|
||||
if(newTerrain != currentTerrain || wasOnRoad != movingOnRoad)
|
||||
{
|
||||
CCS->soundh->stopSound(sh);
|
||||
|
@ -136,8 +136,8 @@ BattleInterface::~BattleInterface()
|
||||
if (adventureInt && adventureInt->selection)
|
||||
{
|
||||
//FIXME: this should be moved to adventureInt which should restore correct track based on selection/active player
|
||||
const auto & terrain = *(LOCPLINT->cb->getTile(adventureInt->selection->visitablePos())->terType);
|
||||
CCS->musich->playMusicFromSet("terrain", terrain.name, true, false);
|
||||
const auto * terrain = LOCPLINT->cb->getTile(adventureInt->selection->visitablePos())->terType;
|
||||
CCS->musich->playMusicFromSet("terrain", terrain->getName(), true, false);
|
||||
}
|
||||
|
||||
// may happen if user decided to close game while in battle
|
||||
|
@ -177,7 +177,7 @@ void CMapHandler::initTerrainGraphics()
|
||||
std::map<std::string, std::string> roadFiles;
|
||||
for(const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||
{
|
||||
terrainFiles[terrain->identifier] = terrain->tilesFilename;
|
||||
terrainFiles[terrain->getName()] = terrain->tilesFilename;
|
||||
}
|
||||
for(const auto & river : VLC->riverTypeHandler->objects)
|
||||
{
|
||||
@ -606,7 +606,7 @@ void CMapHandler::CMapBlitter::drawTileTerrain(SDL_Surface * targetSurf, const T
|
||||
ui8 rotation = tinfo.extTileFlags % 4;
|
||||
|
||||
//TODO: use ui8 instead of string key
|
||||
auto terrainName = tinfo.terType->identifier;
|
||||
auto terrainName = tinfo.terType->getName();
|
||||
|
||||
if(parent->terrainImages[terrainName].size()<=tinfo.terView)
|
||||
return;
|
||||
@ -786,7 +786,7 @@ void CMapHandler::CMapBlitter::drawObjects(SDL_Surface * targetSurf, const Terra
|
||||
|
||||
void CMapHandler::CMapBlitter::drawRoad(SDL_Surface * targetSurf, const TerrainTile & tinfo, const TerrainTile * tinfoUpper) const
|
||||
{
|
||||
if (tinfoUpper && tinfoUpper->roadType->id != Road::NO_ROAD)
|
||||
if (tinfoUpper && tinfoUpper->roadType->getId() != Road::NO_ROAD)
|
||||
{
|
||||
ui8 rotation = (tinfoUpper->extTileFlags >> 4) % 4;
|
||||
Rect source(0, tileSize / 2, tileSize, tileSize / 2);
|
||||
@ -795,7 +795,7 @@ void CMapHandler::CMapBlitter::drawRoad(SDL_Surface * targetSurf, const TerrainT
|
||||
&source, targetSurf, &dest);
|
||||
}
|
||||
|
||||
if(tinfo.roadType->id != Road::NO_ROAD) //print road from this tile
|
||||
if(tinfo.roadType->getId() != Road::NO_ROAD) //print road from this tile
|
||||
{
|
||||
ui8 rotation = (tinfo.extTileFlags >> 4) % 4;
|
||||
Rect source(0, 0, tileSize, halfTileSizeCeil);
|
||||
@ -860,7 +860,7 @@ void CMapHandler::CMapBlitter::blit(SDL_Surface * targetSurf, const MapDrawingIn
|
||||
if(isVisible || info->showAllTerrain)
|
||||
{
|
||||
drawTileTerrain(targetSurf, tinfo, tile);
|
||||
if(tinfo.riverType->id != River::NO_RIVER)
|
||||
if(tinfo.riverType->getId() != River::NO_RIVER)
|
||||
drawRiver(targetSurf, tinfo);
|
||||
drawRoad(targetSurf, tinfo, tinfoUpper);
|
||||
}
|
||||
@ -1390,7 +1390,7 @@ void CMapHandler::getTerrainDescr(const int3 & pos, std::string & out, bool isRM
|
||||
}
|
||||
|
||||
if(!isTile2Terrain || out.empty())
|
||||
out = VLC->terrainTypeHandler->getById(t.terType->id)->nameTranslated;
|
||||
out = t.terType->getName();
|
||||
|
||||
if(t.getDiggingStatus(false) == EDiggingStatus::CAN_DIG)
|
||||
{
|
||||
|
@ -390,7 +390,7 @@ const SDL_Color & CMinimapInstance::getTileColor(const int3 & pos)
|
||||
}
|
||||
|
||||
// else - use terrain color (blocked version or normal)
|
||||
const auto & colorPair = parent->colors.find(tile->terType->id)->second;
|
||||
const auto & colorPair = parent->colors.find(tile->terType->getId())->second;
|
||||
if (tile->blocked && (!tile->visitable))
|
||||
return colorPair.second;
|
||||
else
|
||||
@ -517,7 +517,7 @@ std::map<TerrainId, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors()
|
||||
ui8(255)
|
||||
};
|
||||
|
||||
ret[terrain->id] = std::make_pair(normal, blocked);
|
||||
ret[terrain->getId()] = std::make_pair(normal, blocked);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1414,7 +1414,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView)
|
||||
auto pos = sel->visitablePos();
|
||||
auto tile = LOCPLINT->cb->getTile(pos);
|
||||
if(tile)
|
||||
CCS->musich->playMusicFromSet("terrain", tile->terType->identifier, true, false);
|
||||
CCS->musich->playMusicFromSet("terrain", tile->terType->getName(), true, false);
|
||||
}
|
||||
if(centerView)
|
||||
centerOn(sel);
|
||||
|
@ -132,7 +132,7 @@
|
||||
"transitionRequired" : true,
|
||||
"terrainViewPatterns" : "water",
|
||||
"horseSound" : "horse08",
|
||||
"horseSoundPenalty" : "horse28"
|
||||
"horseSoundPenalty" : "horse28",
|
||||
"sounds": {
|
||||
"ambient": ["LOOPOCEA"]
|
||||
}
|
||||
|
@ -2134,7 +2134,7 @@ void CGameState::updateRumor()
|
||||
rumorId = *RandomGeneratorUtil::nextItem(sRumorTypes, rand);
|
||||
if(rumorId == RumorState::RUMOR_GRAIL)
|
||||
{
|
||||
rumorExtra = getTile(map->grailPos)->terType->id.getNum();
|
||||
rumorExtra = getTile(map->grailPos)->terType->getIndex();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ TurnInfo::BonusCache::BonusCache(TConstBonusListPtr bl)
|
||||
for(const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||
{
|
||||
noTerrainPenalty.push_back(static_cast<bool>(
|
||||
bl->getFirst(Selector::type()(Bonus::NO_TERRAIN_PENALTY).And(Selector::subtype()(terrain->id.getNum())))));
|
||||
bl->getFirst(Selector::type()(Bonus::NO_TERRAIN_PENALTY).And(Selector::subtype()(terrain->getIndex())))));
|
||||
}
|
||||
|
||||
freeShipBoarding = static_cast<bool>(bl->getFirst(Selector::type()(Bonus::FREE_SHIP_BOARDING)));
|
||||
|
@ -2136,7 +2136,7 @@ int CreatureTerrainLimiter::limit(const BonusLimitationContext &context) const
|
||||
std::string CreatureTerrainLimiter::toString() const
|
||||
{
|
||||
boost::format fmt("CreatureTerrainLimiter(terrainType=%s)");
|
||||
auto terrainName = VLC->terrainTypeHandler->getById(terrainType)->identifier;
|
||||
auto terrainName = VLC->terrainTypeHandler->getById(terrainType)->getName();
|
||||
fmt % (terrainType == ETerrainId::NATIVE_TERRAIN ? "native" : terrainName);
|
||||
return fmt.str();
|
||||
}
|
||||
@ -2146,7 +2146,7 @@ JsonNode CreatureTerrainLimiter::toJsonNode() const
|
||||
JsonNode root(JsonNode::JsonType::DATA_STRUCT);
|
||||
|
||||
root["type"].String() = "CREATURE_TERRAIN_LIMITER";
|
||||
auto terrainName = VLC->terrainTypeHandler->getById(terrainType)->identifier;
|
||||
auto terrainName = VLC->terrainTypeHandler->getById(terrainType)->getName();
|
||||
root["parameters"].Vector().push_back(JsonUtils::stringNode(terrainName));
|
||||
|
||||
return root;
|
||||
|
@ -735,7 +735,7 @@ DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
|
||||
else
|
||||
{
|
||||
const TerrainTile & t = gs->map->getTile(pos);
|
||||
terrainType = t.terType->id;
|
||||
terrainType = t.terType->getId();
|
||||
}
|
||||
|
||||
CGObjectInstance *o = nullptr;
|
||||
|
@ -47,7 +47,7 @@ TerrainType * TerrainTypeHandler::loadFromJson( const std::string & scope, const
|
||||
info->horseSoundPenalty = json["horseSoundPenalty"].String();
|
||||
info->transitionRequired = json["transitionRequired"].Bool();
|
||||
info->terrainViewPatterns = json["terrainViewPatterns"].String();
|
||||
info->nameTranslated = json["nameTranslated"].String();
|
||||
//info->nameTranslated = json["nameTranslated"].String();
|
||||
|
||||
const JsonVector & unblockedVec = json["minimapUnblocked"].Vector();
|
||||
info->minimapUnblocked =
|
||||
|
@ -21,6 +21,11 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class DLL_LINKAGE TerrainType : public EntityT<TerrainId>
|
||||
{
|
||||
friend class TerrainTypeHandler;
|
||||
std::string identifier;
|
||||
TerrainId id;
|
||||
ui8 passabilityType;
|
||||
|
||||
public:
|
||||
int32_t getIndex() const override { return id.getNum(); }
|
||||
int32_t getIconIndex() const override { return 0; }
|
||||
@ -29,6 +34,9 @@ public:
|
||||
void registerIcons(const IconRegistar & cb) const override {}
|
||||
TerrainId getId() const override { return id;}
|
||||
|
||||
std::string getNameTextID() const;
|
||||
std::string getNameTranslated() const;
|
||||
|
||||
enum PassabilityType : ui8
|
||||
{
|
||||
LAND = 1,
|
||||
@ -42,20 +50,16 @@ public:
|
||||
std::vector<TerrainId> prohibitTransitions;
|
||||
std::array<int, 3> minimapBlocked;
|
||||
std::array<int, 3> minimapUnblocked;
|
||||
std::string identifier;
|
||||
std::string shortIdentifier;
|
||||
std::string musicFilename;
|
||||
std::string tilesFilename;
|
||||
std::string nameTranslated;
|
||||
std::string terrainViewPatterns;
|
||||
std::string horseSound;
|
||||
std::string horseSoundPenalty;
|
||||
|
||||
TerrainId id;
|
||||
TerrainId rockTerrain;
|
||||
RiverId river;
|
||||
int moveCost;
|
||||
ui8 passabilityType;
|
||||
bool transitionRequired;
|
||||
|
||||
TerrainType();
|
||||
@ -78,7 +82,6 @@ public:
|
||||
h & identifier;
|
||||
h & musicFilename;
|
||||
h & tilesFilename;
|
||||
h & nameTranslated;
|
||||
h & shortIdentifier;
|
||||
h & terrainViewPatterns;
|
||||
h & rockTerrain;
|
||||
@ -95,6 +98,10 @@ public:
|
||||
|
||||
class DLL_LINKAGE RiverType : public EntityT<RiverId>
|
||||
{
|
||||
friend class RiverTypeHandler;
|
||||
std::string identifier;
|
||||
RiverId id;
|
||||
|
||||
public:
|
||||
int32_t getIndex() const override { return id.getNum(); }
|
||||
int32_t getIconIndex() const override { return 0; }
|
||||
@ -103,11 +110,12 @@ public:
|
||||
void registerIcons(const IconRegistar & cb) const override {}
|
||||
RiverId getId() const override { return id;}
|
||||
|
||||
std::string getNameTextID() const;
|
||||
std::string getNameTranslated() const;
|
||||
|
||||
std::string tilesFilename;
|
||||
std::string identifier;
|
||||
std::string shortIdentifier;
|
||||
std::string deltaName;
|
||||
RiverId id;
|
||||
|
||||
RiverType();
|
||||
|
||||
@ -122,6 +130,10 @@ public:
|
||||
|
||||
class DLL_LINKAGE RoadType : public EntityT<RoadId>
|
||||
{
|
||||
friend class RoadTypeHandler;
|
||||
std::string identifier;
|
||||
RoadId id;
|
||||
|
||||
public:
|
||||
int32_t getIndex() const override { return id.getNum(); }
|
||||
int32_t getIconIndex() const override { return 0; }
|
||||
@ -131,9 +143,7 @@ public:
|
||||
RoadId getId() const override { return id;}
|
||||
|
||||
std::string tilesFilename;
|
||||
std::string identifier;
|
||||
std::string shortIdentifier;
|
||||
RoadId id;
|
||||
ui8 movementCost;
|
||||
|
||||
RoadType();
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -358,22 +358,22 @@ bool CDrawRiversOperation::canApplyPattern(const LinePattern & pattern) const
|
||||
|
||||
bool CDrawRoadsOperation::needUpdateTile(const TerrainTile & tile) const
|
||||
{
|
||||
return tile.roadType->id != Road::NO_ROAD;
|
||||
return tile.roadType->getId() != Road::NO_ROAD;
|
||||
}
|
||||
|
||||
bool CDrawRiversOperation::needUpdateTile(const TerrainTile & tile) const
|
||||
{
|
||||
return tile.riverType->id != River::NO_RIVER;
|
||||
return tile.riverType->getId() != River::NO_RIVER;
|
||||
}
|
||||
|
||||
bool CDrawRoadsOperation::tileHasSomething(const int3& pos) const
|
||||
{
|
||||
return map->getTile(pos).roadType->id != Road::NO_ROAD;
|
||||
return map->getTile(pos).roadType->getId() != Road::NO_ROAD;
|
||||
}
|
||||
|
||||
bool CDrawRiversOperation::tileHasSomething(const int3& pos) const
|
||||
{
|
||||
return map->getTile(pos).riverType->id != River::NO_RIVER;
|
||||
return map->getTile(pos).riverType->getId() != River::NO_RIVER;
|
||||
}
|
||||
|
||||
void CDrawRoadsOperation::updateTile(TerrainTile & tile, const LinePattern & pattern, const int flip)
|
||||
|
@ -154,7 +154,7 @@ void CDrawTerrainOperation::updateTerrainTypes()
|
||||
rect.forEach([&](const int3& posToTest)
|
||||
{
|
||||
auto & terrainTile = map->getTile(posToTest);
|
||||
if(centerTile.terType->id != terrainTile.terType->id)
|
||||
if(centerTile.terType->getId() != terrainTile.terType->getId())
|
||||
{
|
||||
auto formerTerType = terrainTile.terType;
|
||||
terrainTile.terType = centerTile.terType;
|
||||
@ -257,7 +257,7 @@ void CDrawTerrainOperation::updateTerrainViews()
|
||||
{
|
||||
for(const auto & pos : invalidatedTerViews)
|
||||
{
|
||||
const auto & patterns = VLC->terviewh->getTerrainViewPatterns(map->getTile(pos).terType->id);
|
||||
const auto & patterns = VLC->terviewh->getTerrainViewPatterns(map->getTile(pos).terType->getId());
|
||||
|
||||
// Detect a pattern which fits best
|
||||
int bestPattern = -1;
|
||||
@ -393,9 +393,9 @@ CDrawTerrainOperation::ValidationResult CDrawTerrainOperation::validateTerrainVi
|
||||
{
|
||||
if(recDepth == 0 && map->isInTheMap(currentPos))
|
||||
{
|
||||
if(terType->id == centerTerType->id)
|
||||
if(terType->getId() == centerTerType->getId())
|
||||
{
|
||||
const auto & patternForRule = VLC->terviewh->getTerrainViewPatternsById(centerTerType->id, rule.name);
|
||||
const auto & patternForRule = VLC->terviewh->getTerrainViewPatternsById(centerTerType->getId(), rule.name);
|
||||
if(auto p = patternForRule)
|
||||
{
|
||||
auto rslt = validateTerrainView(currentPos, &(*p), 1);
|
||||
@ -422,14 +422,14 @@ CDrawTerrainOperation::ValidationResult CDrawTerrainOperation::validateTerrainVi
|
||||
bool nativeTestOk, nativeTestStrongOk;
|
||||
nativeTestOk = nativeTestStrongOk = (rule.isNativeStrong() || rule.isNativeRule()) && !isAlien;
|
||||
|
||||
if(centerTerType->id == ETerrainId::DIRT)
|
||||
if(centerTerType->getId() == ETerrainId::DIRT)
|
||||
{
|
||||
nativeTestOk = rule.isNativeRule() && !terType->isTransitionRequired();
|
||||
bool sandTestOk = (rule.isSandRule() || rule.isTransition())
|
||||
&& terType->isTransitionRequired();
|
||||
applyValidationRslt(rule.isAnyRule() || sandTestOk || nativeTestOk || nativeTestStrongOk);
|
||||
}
|
||||
else if(centerTerType->id == ETerrainId::SAND)
|
||||
else if(centerTerType->getId() == ETerrainId::SAND)
|
||||
{
|
||||
applyValidationRslt(true);
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ void CMapLoaderH3M::readTerrain()
|
||||
tile.roadType = const_cast<RoadType*>(VLC->roadTypeHandler->getByIndex(reader.readUInt8()));
|
||||
tile.roadDir = reader.readUInt8();
|
||||
tile.extTileFlags = reader.readUInt8();
|
||||
tile.blocked = ((!tile.terType->isPassable() || tile.terType->id == ETerrainId::BORDER ) ? true : false); //underground tiles are always blocked
|
||||
tile.blocked = ((!tile.terType->isPassable() || tile.terType->getId() == ETerrainId::BORDER ) ? true : false); //underground tiles are always blocked
|
||||
tile.visitable = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1322,10 +1322,10 @@ std::string CMapSaverJson::writeTerrainTile(const TerrainTile & tile)
|
||||
|
||||
out << tile.terType->shortIdentifier << (int)tile.terView << flipCodes[tile.extTileFlags % 4];
|
||||
|
||||
if(tile.roadType->id != Road::NO_ROAD)
|
||||
if(tile.roadType->getId() != Road::NO_ROAD)
|
||||
out << tile.roadType << (int)tile.roadDir << flipCodes[(tile.extTileFlags >> 4) % 4];
|
||||
|
||||
if(tile.riverType->id != River::NO_RIVER)
|
||||
if(tile.riverType->getId() != River::NO_RIVER)
|
||||
out << tile.riverType << (int)tile.riverDir << flipCodes[(tile.extTileFlags >> 2) % 4];
|
||||
|
||||
return out.str();
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
|
||||
static std::string encode(const si32 index)
|
||||
{
|
||||
return VLC->terrainTypeHandler->getByIndex(index)->identifier;
|
||||
return VLC->terrainTypeHandler->getByIndex(index)->getName();
|
||||
}
|
||||
};
|
||||
|
||||
@ -154,7 +154,7 @@ ZoneOptions::ZoneOptions()
|
||||
{
|
||||
for(const auto & terr : VLC->terrainTypeHandler->objects)
|
||||
if(terr->isLand() && terr->isPassable())
|
||||
terrainTypes.insert(terr->id);
|
||||
terrainTypes.insert(terr->getId());
|
||||
}
|
||||
|
||||
ZoneOptions & ZoneOptions::operator=(const ZoneOptions & other)
|
||||
@ -365,7 +365,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
||||
for(auto & ttype : terrainTypes)
|
||||
{
|
||||
JsonNode n;
|
||||
n.String() = VLC->terrainTypeHandler->getById(ttype)->identifier;
|
||||
n.String() = VLC->terrainTypeHandler->getById(ttype)->getName();
|
||||
node.Vector().push_back(n);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ void initTerrainType(Zone & zone, CMapGenerator & gen)
|
||||
std::vector<TerrainId> waterTerrains;
|
||||
for(const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||
if(terrain->isWater())
|
||||
waterTerrains.push_back(terrain->id);
|
||||
waterTerrains.push_back(terrain->getId());
|
||||
|
||||
zone.setTerrainType(*RandomGeneratorUtil::nextItem(waterTerrains, gen.rand));
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ void RiverPlacer::connectRiver(const int3 & tile)
|
||||
{
|
||||
auto riverType = VLC->terrainTypeHandler->getById(zone.getTerrainType())->river;
|
||||
const auto * river = VLC->riverTypeHandler->getById(riverType);
|
||||
if(river->id == River::NO_RIVER)
|
||||
if(river->getId() == River::NO_RIVER)
|
||||
return;
|
||||
|
||||
rmg::Area roads;
|
||||
|
@ -121,7 +121,7 @@ void Object::Instance::setTemplate(TerrainId terrain)
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrain);
|
||||
if (templates.empty())
|
||||
{
|
||||
auto terrainName = VLC->terrainTypeHandler->getById(terrain)->identifier;
|
||||
auto terrainName = VLC->terrainTypeHandler->getById(terrain)->getName();
|
||||
throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s") % dObject.ID % dObject.subID % terrainName));
|
||||
}
|
||||
dObject.appearance = templates.front();
|
||||
@ -293,14 +293,14 @@ void Object::Instance::finalize(RmgMap & map)
|
||||
if (!dObject.appearance)
|
||||
{
|
||||
auto terrainType = map.map().getTile(getPosition(true)).terType;
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrainType->id);
|
||||
auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrainType->getId());
|
||||
if (templates.empty())
|
||||
{
|
||||
throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s (terrain %d)") % dObject.ID % dObject.subID % getPosition(true).toString() % terrainType));
|
||||
}
|
||||
else
|
||||
{
|
||||
setTemplate(terrainType->id);
|
||||
setTemplate(terrainType->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ void WaterProxy::process()
|
||||
{
|
||||
MAYBE_UNUSED(t);
|
||||
assert(map.isOnMap(t));
|
||||
assert(map.map().getTile(t).terType->id == zone.getTerrainType());
|
||||
assert(map.map().getTile(t).terType->getId() == zone.getTerrainType());
|
||||
}
|
||||
|
||||
for(auto z : map.getZones())
|
||||
@ -54,7 +54,7 @@ void WaterProxy::process()
|
||||
|
||||
for(auto & t : z.second->area().getTilesVector())
|
||||
{
|
||||
if(map.map().getTile(t).terType->id == zone.getTerrainType())
|
||||
if(map.map().getTile(t).terType->getId() == zone.getTerrainType())
|
||||
{
|
||||
z.second->areaPossible().erase(t);
|
||||
z.second->area().erase(t);
|
||||
|
@ -545,12 +545,12 @@ void MainWindow::loadObjectsTree()
|
||||
//adding terrains
|
||||
for(auto & terrain : VLC->terrainTypeHandler->objects)
|
||||
{
|
||||
QPushButton *b = new QPushButton(QString::fromStdString(terrain->identifier));
|
||||
QPushButton *b = new QPushButton(QString::fromStdString(terrain->getName()));
|
||||
ui->terrainLayout->addWidget(b);
|
||||
connect(b, &QPushButton::clicked, this, [this, terrain]{ terrainButtonClicked(terrain->id); });
|
||||
connect(b, &QPushButton::clicked, this, [this, terrain]{ terrainButtonClicked(terrain->getId()); });
|
||||
|
||||
//filter
|
||||
ui->terrainFilterCombo->addItem(QString::fromStdString(terrain->identifier));
|
||||
ui->terrainFilterCombo->addItem(QString::fromStdString(terrain->getName()));
|
||||
}
|
||||
//add spacer to keep terrain button on the top
|
||||
ui->terrainLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
@ -559,7 +559,7 @@ void MainWindow::loadObjectsTree()
|
||||
{
|
||||
QPushButton *b = new QPushButton(QString::fromStdString(road->tilesFilename));
|
||||
ui->roadLayout->addWidget(b);
|
||||
connect(b, &QPushButton::clicked, this, [this, road]{ roadOrRiverButtonClicked(road->id.getNum(), true); });
|
||||
connect(b, &QPushButton::clicked, this, [this, road]{ roadOrRiverButtonClicked(road->getIndex(), true); });
|
||||
}
|
||||
//add spacer to keep terrain button on the top
|
||||
ui->roadLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
@ -568,7 +568,7 @@ void MainWindow::loadObjectsTree()
|
||||
{
|
||||
QPushButton *b = new QPushButton(QString::fromStdString(river->tilesFilename));
|
||||
ui->riverLayout->addWidget(b);
|
||||
connect(b, &QPushButton::clicked, this, [this, river]{ roadOrRiverButtonClicked(river->id.getNum(), false); });
|
||||
connect(b, &QPushButton::clicked, this, [this, river]{ roadOrRiverButtonClicked(river->getIndex(), false); });
|
||||
}
|
||||
//add spacer to keep terrain button on the top
|
||||
ui->riverLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
@ -919,8 +919,8 @@ void MainWindow::on_terrainFilterCombo_currentTextChanged(const QString &arg1)
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
for (auto const & terrain : VLC->terrainTypeHandler->objects)
|
||||
if (terrain->identifier == arg1.toStdString())
|
||||
objectBrowser->terrain = terrain->id;
|
||||
if (terrain->getName() == arg1.toStdString())
|
||||
objectBrowser->terrain = terrain->getId();
|
||||
}
|
||||
objectBrowser->invalidate();
|
||||
objectBrowser->sort(0);
|
||||
@ -1113,7 +1113,7 @@ void MainWindow::on_actionUpdate_appearance_triggered()
|
||||
if(handler->isStaticObject())
|
||||
{
|
||||
staticObjects.insert(obj);
|
||||
if(obj->appearance->canBePlacedAt(terrain->id))
|
||||
if(obj->appearance->canBePlacedAt(terrain->getId()))
|
||||
{
|
||||
controller.scene(mapLevel)->selectionObjectsView.deselectObject(obj);
|
||||
continue;
|
||||
@ -1124,13 +1124,13 @@ void MainWindow::on_actionUpdate_appearance_triggered()
|
||||
}
|
||||
else
|
||||
{
|
||||
auto app = handler->getOverride(terrain->id, obj);
|
||||
auto app = handler->getOverride(terrain->getId(), obj);
|
||||
if(!app)
|
||||
{
|
||||
if(obj->appearance->canBePlacedAt(terrain->id))
|
||||
if(obj->appearance->canBePlacedAt(terrain->getId()))
|
||||
continue;
|
||||
|
||||
auto templates = handler->getTemplates(terrain->id);
|
||||
auto templates = handler->getTemplates(terrain->getId());
|
||||
if(templates.empty())
|
||||
{
|
||||
++errors;
|
||||
|
@ -408,7 +408,7 @@ void MapController::commitObstacleFill(int level)
|
||||
if(tl.blocked || tl.visitable)
|
||||
continue;
|
||||
|
||||
terrainSelected[tl.terType->id].blockedArea.add(t);
|
||||
terrainSelected[tl.terType->getId()].blockedArea.add(t);
|
||||
}
|
||||
|
||||
for(auto & sel : terrainSelected)
|
||||
|
@ -80,7 +80,7 @@ void MapHandler::initTerrainGraphics()
|
||||
std::map<std::string, std::string> riverFiles;
|
||||
for(const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||
{
|
||||
terrainFiles[terrain->identifier] = terrain->tilesFilename;
|
||||
terrainFiles[terrain->getName()] = terrain->tilesFilename;
|
||||
}
|
||||
for(const auto & river : VLC->riverTypeHandler->objects)
|
||||
{
|
||||
@ -101,7 +101,7 @@ void MapHandler::drawTerrainTile(QPainter & painter, int x, int y, int z)
|
||||
auto & tinfo = map->getTile(int3(x, y, z));
|
||||
ui8 rotation = tinfo.extTileFlags % 4;
|
||||
|
||||
auto terrainName = tinfo.terType->identifier;
|
||||
auto terrainName = tinfo.terType->getName();
|
||||
|
||||
if(terrainImages.at(terrainName).size() <= tinfo.terView)
|
||||
return;
|
||||
@ -115,7 +115,7 @@ void MapHandler::drawRoad(QPainter & painter, int x, int y, int z)
|
||||
auto & tinfo = map->getTile(int3(x, y, z));
|
||||
auto * tinfoUpper = map->isInTheMap(int3(x, y - 1, z)) ? &map->getTile(int3(x, y - 1, z)) : nullptr;
|
||||
|
||||
if(tinfoUpper && tinfoUpper->roadType->id != Road::NO_ROAD)
|
||||
if(tinfoUpper && tinfoUpper->roadType->getId() != Road::NO_ROAD)
|
||||
{
|
||||
auto roadName = tinfoUpper->roadType->tilesFilename;
|
||||
QRect source(0, tileSize / 2, tileSize, tileSize / 2);
|
||||
@ -127,7 +127,7 @@ void MapHandler::drawRoad(QPainter & painter, int x, int y, int z)
|
||||
}
|
||||
}
|
||||
|
||||
if(tinfo.roadType->id != Road::NO_ROAD) //print road from this tile
|
||||
if(tinfo.roadType->getId() != Road::NO_ROAD) //print road from this tile
|
||||
{
|
||||
auto roadName = tinfo.roadType->tilesFilename;
|
||||
QRect source(0, 0, tileSize, tileSize / 2);
|
||||
@ -144,7 +144,7 @@ void MapHandler::drawRiver(QPainter & painter, int x, int y, int z)
|
||||
{
|
||||
auto & tinfo = map->getTile(int3(x, y, z));
|
||||
|
||||
if(tinfo.riverType->id == River::NO_RIVER)
|
||||
if(tinfo.riverType->getId() == River::NO_RIVER)
|
||||
return;
|
||||
|
||||
//TODO: use ui8 instead of string key
|
||||
|
@ -2242,7 +2242,7 @@ void CGameHandler::setupBattle(int3 tile, const CArmedInstance *armies[2], const
|
||||
battleResult.set(nullptr);
|
||||
|
||||
const auto & t = *getTile(tile);
|
||||
TerrainId terrain = t.terType->id;
|
||||
TerrainId terrain = t.terType->getId();
|
||||
if (gs->map->isCoastalTile(tile)) //coastal tile is always ground
|
||||
terrain = ETerrainId::SAND;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user