← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1559729-lost_portspace into lp:widelands

 

Miroslav Remák has proposed merging lp:~widelands-dev/widelands/bug-1559729-lost_portspace into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1559729 in widelands: "port space not shown"
  https://bugs.launchpad.net/widelands/+bug/1559729

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1559729-lost_portspace/+merge/289626

If:
 1. The second field to the SE of a possible port space is owned by the player,
 2. AND the player hasn't expanded far enough to own the water fields necessary for portdocks or the border is blocking them (i.e. the blue portspace icon is not visible yet),

then when the player saves the game, the saving process incorrectly cleans up this port space, considering it invalid.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1559729-lost_portspace into lp:widelands.
=== modified file 'src/editor/tools/editor_set_port_space_tool.cc'
--- src/editor/tools/editor_set_port_space_tool.cc	2016-01-16 12:55:14 +0000
+++ src/editor/tools/editor_set_port_space_tool.cc	2016-03-21 10:53:08 +0000
@@ -35,7 +35,7 @@
 	NodeCaps const caps = c.field->nodecaps();
 	FCoords f = map.get_fcoords(*c.field);
 	if ((caps & BUILDCAPS_SIZEMASK) == BUILDCAPS_BIG) {
-		if (!map.find_portdock(f).empty())
+		if (!map.find_portdock(f, true).empty())
 			return caps;
 	}
 	return 0;

=== modified file 'src/logic/map.cc'
--- src/logic/map.cc	2016-03-06 21:59:16 +0000
+++ src/logic/map.cc	2016-03-21 10:53:08 +0000
@@ -1330,8 +1330,11 @@
 
 /**
  * Returns a list of portdock fields (if any) that a port built at \p c should have.
+ *
+ * @param disregard_territories When true, fields that the owner of the starting point
+ * does not own and fields that are blocked by a border will also be included in the list.
  */
-std::vector<Coords> Map::find_portdock(const Coords & c) const
+std::vector<Coords> Map::find_portdock(const Coords & c, bool disregard_territories) const
 {
 	static const WalkingDir cycledirs[16] = {
 		WALK_NE, WALK_NE, WALK_NE, WALK_NW, WALK_NW,
@@ -1352,14 +1355,16 @@
 			is_good_water = false;
 		}
 
-		// If starting point is owned we make sure this field has the same owner
-		if (is_good_water && owner > 0 && f.field->get_owned_by() != owner) {
-			is_good_water = false;
-		}
+		if (!disregard_territories) {
+			// If starting point is owned we make sure this field has the same owner
+			if (is_good_water && owner != neutral() && f.field->get_owned_by() != owner) {
+				is_good_water = false;
+			}
 
-		// ... and is not on a border
-		if (is_good_water && owner > 0 && f.field->is_border()) {
-			is_good_water = false;
+			// ... and is not on a border
+			if (is_good_water && owner != neutral() && f.field->is_border()) {
+				is_good_water = false;
+			}
 		}
 
 		if (is_good_water) {

=== modified file 'src/logic/map.h'
--- src/logic/map.h	2016-03-08 15:21:41 +0000
+++ src/logic/map.h	2016-03-21 10:53:08 +0000
@@ -431,7 +431,7 @@
 	bool is_port_space(const Coords& c) const;
 	void set_port_space(Coords c, bool allowed);
 	const PortSpacesSet& get_port_spaces() const {return port_spaces_;}
-	std::vector<Coords> find_portdock(const Widelands::Coords& c) const;
+	std::vector<Coords> find_portdock(const Widelands::Coords& c, bool disregard_territories = false) const;
 	bool allows_seafaring();
 
 	/// Checks whether there are any artifacts on the map

=== modified file 'src/map_io/map_port_spaces_packet.cc'
--- src/map_io/map_port_spaces_packet.cc	2015-10-24 15:42:37 +0000
+++ src/map_io/map_port_spaces_packet.cc	2016-03-21 10:53:08 +0000
@@ -86,7 +86,7 @@
 		if
 			((map.get_max_nodecaps(egbase.world(), fc) & BUILDCAPS_SIZEMASK) != BUILDCAPS_BIG
 			 ||
-			 map.find_portdock(fc).empty())
+			 map.find_portdock(fc, true).empty())
 		{
 			continue;
 		}


References