← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~janosch-peters/widelands/bug-1638890-segfault-harbour into lp:widelands

 

Janosch Peters has proposed merging lp:~janosch-peters/widelands/bug-1638890-segfault-harbour into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1638890 in widelands: "Segfault right after colony harbour is constructed"
  https://bugs.launchpad.net/widelands/+bug/1638890

For more details, see:
https://code.launchpad.net/~janosch-peters/widelands/bug-1638890-segfault-harbour/+merge/310092

The harbour now conqueres eevry location where its military influence is higher than the influence of other players. 

This fixes the if there is a portdock location available where the player owning the harbour has highest influence. IMHO this will almost always be the case. If all portdock locations are occupied by another players influence, then it is very likely that the player owning the harbour could not have build the harbour in the first place.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~janosch-peters/widelands/bug-1638890-segfault-harbour into lp:widelands.
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc	2016-10-21 08:21:41 +0000
+++ src/logic/editor_game_base.cc	2016-11-04 18:09:15 +0000
@@ -529,7 +529,7 @@
 
 /// This conquers a given area because of a new (military) building that is set
 /// there.
-void EditorGameBase::conquer_area(PlayerArea<Area<FCoords>> player_area) {
+void EditorGameBase::conquer_area(PlayerArea<Area<FCoords>> player_area, bool conquer_guarded_location) {
 	assert(0 <= player_area.x);
 	assert(player_area.x < map().get_width());
 	assert(0 <= player_area.y);
@@ -539,7 +539,7 @@
 	assert(0 < player_area.player_number);
 	assert(player_area.player_number <= map().get_nrplayers());
 
-	do_conquer_area(player_area, true);
+	do_conquer_area(player_area, true, 0, conquer_guarded_location);
 
 	//  Players are not allowed to have their immovables on their borders.
 	//  Therefore the area must be enlarged before calling
@@ -603,10 +603,10 @@
 // testsuite).
 void EditorGameBase::do_conquer_area(PlayerArea<Area<FCoords>> player_area,
                                      bool const conquer,
-                                     PlayerNumber const preferred_player,
+									 PlayerNumber const preferred_player,
+									 bool const conquer_guarded_location_by_superior_influence,
                                      bool const neutral_when_no_influence,
-                                     bool const neutral_when_competing_influence,
-                                     bool const conquer_guarded_location_by_superior_influence) {
+                                     bool const neutral_when_competing_influence) {
 	assert(0 <= player_area.x);
 	assert(player_area.x < map().get_width());
 	assert(0 <= player_area.y);

=== modified file 'src/logic/editor_game_base.h'
--- src/logic/editor_game_base.h	2016-09-30 09:56:42 +0000
+++ src/logic/editor_game_base.h	2016-11-04 18:09:15 +0000
@@ -171,7 +171,7 @@
 	void inform_players_about_road(FCoords, MapObjectDescr const*);
 
 	void unconquer_area(PlayerArea<Area<FCoords>>, PlayerNumber destroying_player = 0);
-	void conquer_area(PlayerArea<Area<FCoords>>);
+	void conquer_area(PlayerArea<Area<FCoords>>, bool conquer_guarded_location = false);
 	void conquer_area_no_building(PlayerArea<Area<FCoords>> const);
 
 	void cleanup_objects() {
@@ -238,10 +238,10 @@
 	///  influence becomes greater than the owner's influence.
 	virtual void do_conquer_area(PlayerArea<Area<FCoords>> player_area,
 	                             bool conquer,
-	                             PlayerNumber preferred_player = 0,
+								 PlayerNumber preferred_player = 0,
+								 bool conquer_guarded_location_by_superior_influence = false,
 	                             bool neutral_when_no_influence = false,
-	                             bool neutral_when_competing_influence = false,
-	                             bool conquer_guarded_location_by_superior_influence = false);
+	                             bool neutral_when_competing_influence = false);
 	void cleanup_playerimmovables_area(PlayerArea<Area<FCoords>>);
 
 	// Changes the owner of 'fc' from the current player to the new player and

=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
--- src/logic/map_objects/tribes/warehouse.cc	2016-08-04 15:49:05 +0000
+++ src/logic/map_objects/tribes/warehouse.cc	2016-11-04 18:09:15 +0000
@@ -425,7 +425,7 @@
 	if (uint32_t const conquer_radius = descr().get_conquers()) {
 		egbase.conquer_area(PlayerArea<Area<FCoords>>(
 		   player.player_number(),
-		   Area<FCoords>(egbase.map().get_fcoords(get_position()), conquer_radius)));
+		   Area<FCoords>(egbase.map().get_fcoords(get_position()), conquer_radius)), true);
 	}
 
 	if (descr().get_isport()) {


Follow ups