void SetRightTerrain(GameWorldGame& world, const MapPoint& pt, Direction dir, TerrainType t) { switch(Direction::Type(dir)) { case Direction::WEST: world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NORTHWEST)).t1 = t; break; case Direction::NORTHWEST: world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NORTHWEST)).t2 = t; break; case Direction::NORTHEAST: world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NORTHEAST)).t1 = t; break; case Direction::EAST: world.GetNodeWriteable(pt).t2 = t; break; case Direction::SOUTHEAST: world.GetNodeWriteable(pt).t1 = t; break; case Direction::SOUTHWEST: world.GetNodeWriteable(world.GetNeighbour(pt, Direction::WEST)).t2 = t; break; } }
/// Check if we can walk on the point if it is completely covered in terrain boost::test_tools::predicate_result checkWalkOnPoint(GameWorldGame& world, const MapPoint& startPt, const MapPoint& targetPt, Direction dir, TerrainType t) { // Block whole point const MapPoint nextPt = world.GetNeighbour(startPt, dir); for(unsigned i=0; i<6; i++) SetRightTerrain(world, nextPt, Direction::fromInt(i), t); if(world.FindHumanPath(startPt, targetPt) != INVALID_DIR) { boost::test_tools::predicate_result result(false); result.message() << "Failed for fwd direction"; return result; } if(world.FindHumanPath(targetPt, startPt) != INVALID_DIR) { boost::test_tools::predicate_result result(false); result.message() << "Failed for bwd direction"; return result; } for(unsigned i = 0; i < 6; i++) SetRightTerrain(world, nextPt, Direction::fromInt(i), TT_STEPPE); return true; }