mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Implemented boat selection for town shipyards
This commit is contained in:
@@ -953,13 +953,8 @@ si32 CGHeroInstance::getManaNewTurn() const
|
||||
|
||||
BoatId CGHeroInstance::getBoatType() const
|
||||
{
|
||||
switch (type->heroClass->getAlignment())
|
||||
{
|
||||
case EAlignment::EVIL: return EBoatId::BOAT_EVIL;
|
||||
case EAlignment::GOOD: return EBoatId::BOAT_GOOD;
|
||||
case EAlignment::NEUTRAL: return EBoatId::BOAT_NEUTRAL;
|
||||
default: return EBoatId::NONE;
|
||||
}
|
||||
// hero can only generate boat via "Summon Boat" spell which always create same boat as in Necropolis shipyard
|
||||
return EBoatId::NECROPOLIS;
|
||||
}
|
||||
|
||||
void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const
|
||||
|
||||
@@ -682,13 +682,7 @@ void CGTownInstance::clearArmy() const
|
||||
|
||||
BoatId CGTownInstance::getBoatType() const
|
||||
{
|
||||
switch (town->faction->alignment)
|
||||
{
|
||||
case EAlignment::EVIL : return EBoatId::BOAT_EVIL;
|
||||
case EAlignment::GOOD : return EBoatId::BOAT_GOOD;
|
||||
case EAlignment::NEUTRAL : return EBoatId::BOAT_NEUTRAL;
|
||||
default: return EBoatId::NONE;
|
||||
}
|
||||
return town->shipyardBoat;
|
||||
}
|
||||
|
||||
int CGTownInstance::getMarketEfficiency() const
|
||||
|
||||
@@ -1961,7 +1961,8 @@ void CGShipyard::serializeJsonOptions(JsonSerializeFormat& handler)
|
||||
|
||||
BoatId CGShipyard::getBoatType() const
|
||||
{
|
||||
return EBoatId::BOAT_GOOD;
|
||||
// In H3, external shipyard will always create same boat as castle
|
||||
return EBoatId::CASTLE;
|
||||
}
|
||||
|
||||
void CCartographer::onHeroVisit( const CGHeroInstance * h ) const
|
||||
|
||||
@@ -164,7 +164,7 @@ void ObjectTemplate::readTxt(CLegacyConfigParser & parser)
|
||||
}
|
||||
|
||||
//assuming that object can be placed on other land terrains
|
||||
anyTerrain = allowedTerrains.size() >= 8 && !allowedTerrains.count(ETerrainId::WATER);
|
||||
anyLandTerrain = allowedTerrains.size() >= 8 && !allowedTerrains.count(ETerrainId::WATER);
|
||||
|
||||
id = Obj(boost::lexical_cast<int>(strings[5]));
|
||||
subid = boost::lexical_cast<int>(strings[6]);
|
||||
@@ -230,7 +230,7 @@ void ObjectTemplate::readMap(CBinaryReader & reader)
|
||||
}
|
||||
|
||||
//assuming that object can be placed on other land terrains
|
||||
anyTerrain = allowedTerrains.size() >= 8 && !allowedTerrains.count(ETerrainId::WATER);
|
||||
anyLandTerrain = allowedTerrains.size() >= 8 && !allowedTerrains.count(ETerrainId::WATER);
|
||||
|
||||
id = Obj(reader.readUInt32());
|
||||
subid = reader.readUInt32();
|
||||
@@ -277,11 +277,11 @@ void ObjectTemplate::readJson(const JsonNode &node, const bool withTerrain)
|
||||
allowedTerrains.insert(TerrainId(identifier));
|
||||
});
|
||||
}
|
||||
anyTerrain = false;
|
||||
anyLandTerrain = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
anyTerrain = true;
|
||||
anyLandTerrain = true;
|
||||
}
|
||||
|
||||
auto charToTile = [&](const char & ch) -> ui8
|
||||
@@ -557,7 +557,7 @@ void ObjectTemplate::calculateVisitableOffset()
|
||||
|
||||
bool ObjectTemplate::canBePlacedAt(TerrainId terrainID) const
|
||||
{
|
||||
if (anyTerrain)
|
||||
if (anyLandTerrain)
|
||||
{
|
||||
const auto & terrain = VLC->terrainTypeHandler->getById(terrainID);
|
||||
return terrain->isLand() && terrain->isPassable();
|
||||
|
||||
@@ -36,7 +36,7 @@ class DLL_LINKAGE ObjectTemplate
|
||||
std::set<TerrainId> allowedTerrains;
|
||||
|
||||
/// or, allow placing object on any terrain
|
||||
bool anyTerrain;
|
||||
bool anyLandTerrain;
|
||||
|
||||
void afterLoadFixup();
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
|
||||
inline bool canBePlacedAtAnyTerrain() const
|
||||
{
|
||||
return anyTerrain;
|
||||
return anyLandTerrain;
|
||||
};
|
||||
|
||||
const std::set<TerrainId>& getAllowedTerrains() const
|
||||
@@ -159,6 +159,7 @@ public:
|
||||
{
|
||||
h & usedTiles;
|
||||
h & allowedTerrains;
|
||||
h & anyLandTerrain;
|
||||
h & animationFile;
|
||||
h & stringID;
|
||||
h & id;
|
||||
|
||||
Reference in New Issue
Block a user