mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Don't place non-sailing boats in RMG
This commit is contained in:
parent
3a731b62b8
commit
58aed364bf
@ -210,7 +210,22 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, RouteInfo & info)
|
||||
return false;
|
||||
|
||||
auto subObjects = VLC->objtypeh->knownSubObjects(Obj::BOAT);
|
||||
auto * boat = dynamic_cast<CGBoat *>(VLC->objtypeh->getHandlerFor(Obj::BOAT, *RandomGeneratorUtil::nextItem(subObjects, generator.rand))->create());
|
||||
std::set<si32> sailingBoatTypes; //RMG shall place only sailing boats on water
|
||||
for(auto subObj : subObjects)
|
||||
{
|
||||
//making a temporary object
|
||||
std::unique_ptr<CGObjectInstance> obj(VLC->objtypeh->getHandlerFor(Obj::BOAT, subObj)->create());
|
||||
if(auto * testBoat = dynamic_cast<CGBoat *>(obj.get()))
|
||||
{
|
||||
if(testBoat->layer == EPathfindingLayer::SAIL)
|
||||
sailingBoatTypes.insert(subObj);
|
||||
}
|
||||
}
|
||||
|
||||
if(sailingBoatTypes.empty())
|
||||
return false;
|
||||
|
||||
auto * boat = dynamic_cast<CGBoat *>(VLC->objtypeh->getHandlerFor(Obj::BOAT, *RandomGeneratorUtil::nextItem(sailingBoatTypes, generator.rand))->create());
|
||||
|
||||
rmg::Object rmgObject(*boat);
|
||||
rmgObject.setTemplate(zone.getTerrainType());
|
||||
|
Loading…
Reference in New Issue
Block a user