← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/port-clearance into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/port-clearance into lp:widelands.

Commit message:
When an expedition ship places a port, a bit of land is cleared of trees to make room for a few buildings.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1230255 in widelands: "Tree growth overcomes port spaces"
  https://bugs.launchpad.net/widelands/+bug/1230255

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/port-clearance/+merge/295236

When an expedition ship places a port, a bit of land is cleared of trees to make room for a few buildings.

Since this happens at the same time as the port is placed, it shouldn't be visually annoying.

If we need a bit more land, the size of the radius can be increased easily.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/port-clearance into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc	2016-04-05 07:51:48 +0000
+++ src/logic/map_objects/tribes/ship.cc	2016-05-19 16:43:04 +0000
@@ -870,10 +870,18 @@
 
 /// Initializes the construction of a port at @arg c
 /// @note only called via player command
-void Ship::exp_construct_port(Game&, const Coords& c) {
+void Ship::exp_construct_port(Game& game, const Coords& c) {
 	assert(expedition_);
-	DescriptionIndex port_idx = get_owner()->tribe().port();
-	get_owner()->force_csite(c, port_idx);
+	get_owner()->force_csite(c, get_owner()->tribe().port());
+
+	// Make sure that we have space to squeeze in a lumberjack
+	std::vector<ImmovableFound> trees;
+	game.map().find_immovables(Area<FCoords>(game.map().get_fcoords(c), 2),
+	                           &trees,
+	                           FindImmovableAttribute(MapObjectDescr::get_attribute_id("tree")));
+	for (auto& tree : trees) {
+		tree.object->remove(game);
+	}
 	ship_state_ = ShipStates::kExpeditionColonizing;
 }
 


Follow ups