Fixed updating the owned villages for replace_map.

This disown villages that no longer exist after the replacement.
Capturing villages at places now a village will be added later.

(Fixes bug #20468.)
This commit is contained in:
Mark de Wever 2013-02-09 17:33:56 +00:00
parent 75c7005ac8
commit 91f5a21490
3 changed files with 23 additions and 0 deletions

View file

@ -78,6 +78,7 @@ Version 1.11.1+svn:
halo="pic[1-2,5]:[10,20,30]" expands to halo="pic1:10,pic2:20,pic5:30"
this is used for halos, team flags, animated terrains and unit animations
* Changed default unit halos and macros to use new square bracket expansion
* Fixed bug #20468: Update the owned villages when using [replace_map].
Miscellaneous and bug fixes:
* The undo stack is preserved across a save-reload.
* Removed several unused private member variables.

View file

@ -45,6 +45,10 @@ Version 1.11.1+svn:
* Updating the shroud after delaying shroud updates is done gradually instead
of instantly.
* WML Engine:
* When a map is replaced the number of owned villages for a side is updated
properly updated.
* Miscellaneous and bug fixes:
* The undo stack is preserved across a save-reload.
* Fixed the present in-game command line autocompletion feature so it

View file

@ -53,6 +53,7 @@
#include "wml_exception.hpp"
#include "play_controller.hpp"
#include "persist_var.hpp"
#include "utils/foreach.tpp"
#include "whiteboard/manager.hpp"
#include <boost/scoped_array.hpp>
@ -3058,6 +3059,15 @@ WML_HANDLER_FUNCTION(replace_map, /*event_info*/, cfg)
gamemap map(*game_map);
/* Remember the locations where a village is owned by a side. */
std::map<map_location, int> villages;
FOREACH(const AUTO& village, map.villages()) {
const int owner = village_owner(village);
if(owner != -1) {
villages[village] = owner;
}
}
try {
if (cfg["map"].empty()) {
const vconfig& map_cfg = cfg.child("map");
@ -3097,6 +3107,14 @@ WML_HANDLER_FUNCTION(replace_map, /*event_info*/, cfg)
}
}
}
/* Disown villages that are no longer villages. */
FOREACH(const AUTO& village, villages) {
if(!map.is_village(village.first)) {
(*resources::teams)[village.second].lose_village(village.first);
}
}
*game_map = map;
resources::screen->reload_map();
screen_needs_rebuild = true;