mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-13 01:20:34 +02:00
Map objects now use shared_ptr (rmg)
This commit is contained in:
@ -250,8 +250,8 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, bool createRoad, Rout
|
||||
for(auto subObj : subObjects)
|
||||
{
|
||||
//making a temporary object
|
||||
std::unique_ptr<CGObjectInstance> obj(LIBRARY->objtypeh->getHandlerFor(Obj::BOAT, subObj)->create(map.mapInstance->cb, nullptr));
|
||||
if(auto * testBoat = dynamic_cast<CGBoat *>(obj.get()))
|
||||
auto obj(LIBRARY->objtypeh->getHandlerFor(Obj::BOAT, subObj)->create(map.mapInstance->cb, nullptr));
|
||||
if(auto testBoat = dynamic_cast<CGBoat *>(obj.get()))
|
||||
{
|
||||
if(testBoat->layer == EPathfindingLayer::SAIL)
|
||||
sailingBoatTypes.insert(subObj);
|
||||
@ -261,9 +261,9 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, bool createRoad, Rout
|
||||
if(sailingBoatTypes.empty())
|
||||
return false;
|
||||
|
||||
auto * boat = dynamic_cast<CGBoat *>(LIBRARY->objtypeh->getHandlerFor(Obj::BOAT, *RandomGeneratorUtil::nextItem(sailingBoatTypes, zone.getRand()))->create(map.mapInstance->cb, nullptr));
|
||||
auto boat = std::dynamic_pointer_cast<CGBoat>(LIBRARY->objtypeh->getHandlerFor(Obj::BOAT, *RandomGeneratorUtil::nextItem(sailingBoatTypes, zone.getRand()))->create(map.mapInstance->cb, nullptr));
|
||||
|
||||
rmg::Object rmgObject(*boat);
|
||||
rmg::Object rmgObject(boat);
|
||||
rmgObject.setTemplate(zone.getTerrainType(), zone.getRand());
|
||||
|
||||
auto waterAvailable = zone.areaForRoads();
|
||||
@ -325,10 +325,10 @@ bool WaterProxy::placeShipyard(Zone & land, const Lake & lake, si32 guard, bool
|
||||
return false;
|
||||
|
||||
int subtype = chooseRandomAppearance(zone.getRand(), Obj::SHIPYARD, land.getTerrainType());
|
||||
auto * shipyard = dynamic_cast<CGShipyard *>(LIBRARY->objtypeh->getHandlerFor(Obj::SHIPYARD, subtype)->create(map.mapInstance->cb, nullptr));
|
||||
auto shipyard = std::dynamic_pointer_cast<CGShipyard>(LIBRARY->objtypeh->getHandlerFor(Obj::SHIPYARD, subtype)->create(map.mapInstance->cb, nullptr));
|
||||
shipyard->tempOwner = PlayerColor::NEUTRAL;
|
||||
|
||||
rmg::Object rmgObject(*shipyard);
|
||||
rmg::Object rmgObject(shipyard);
|
||||
rmgObject.setTemplate(land.getTerrainType(), zone.getRand());
|
||||
bool guarded = manager->addGuard(rmgObject, guard);
|
||||
|
||||
|
Reference in New Issue
Block a user