← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-858292-military-influence into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-858292-military-influence into lp:widelands.

Commit message:
Increase the area where the map is recalculated after conquering by 1. This prevents buildings from sitting between borders.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #858292 in widelands: "building will burn down after upgrading and moving soldiers inside"
  https://bugs.launchpad.net/widelands/+bug/858292

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-858292-military-influence/+merge/353834
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-858292-military-influence into lp:widelands.
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc	2018-04-27 06:11:05 +0000
+++ src/logic/editor_game_base.cc	2018-08-28 07:08:04 +0000
@@ -467,19 +467,6 @@
 
 	//  step 1: unconquer area of this building
 	do_conquer_area(player_area, false, destroying_player);
-
-	//  step 5: deal with player immovables in the lost area
-	//  Players are not allowed to have their immovables on their borders.
-	//  Therefore the area must be enlarged before calling
-	//  cleanup_playerimmovables_area, so that those new border locations are
-	//  covered.
-	// TODO(SirVer): In the editor, no buildings should burn down when a military
-	// building is removed. Check this again though
-	if (is_a(Game, this)) {
-		++player_area.radius;
-		player_area.player_number = destroying_player;
-		cleanup_playerimmovables_area(player_area);
-	}
 }
 
 /// This conquers a given area because of a new (military) building that is set
@@ -496,13 +483,6 @@
 	assert(player_area.player_number <= map().get_nrplayers());
 
 	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
-	//  cleanup_playerimmovables_area, so that those new border locations are
-	//  covered.
-	++player_area.radius;
-	cleanup_playerimmovables_area(player_area);
 }
 
 void EditorGameBase::change_field_owner(const FCoords& fc, PlayerNumber const new_owner) {
@@ -623,8 +603,19 @@
 
 	// This must reach one step beyond the conquered area to adjust the borders
 	// of neighbour players.
-	++player_area.radius;
+	player_area.radius += 2;
 	map_.recalc_for_field_area(world(), player_area);
+
+	//  Deal with player immovables in the lost area
+	//  Players are not allowed to have their immovables on their borders.
+	//  Therefore the area must be enlarged before calling
+	//  cleanup_playerimmovables_area, so that those new border locations are
+	//  covered.
+	// TODO(SirVer): In the editor, no buildings should burn down when a military
+	// building is removed. Check this again though
+	if (is_a(Game, this)) {
+		cleanup_playerimmovables_area(player_area);
+	}
 }
 
 /// Makes sure that buildings cannot exist outside their owner's territory.


Follow ups