Author: alink
Date: Tue Apr 21 20:27:26 2009
New Revision: 35097

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35097&view=rev
Log:
When used on a village, make debug actions 'create unit' and 'change side'
(of a unit) capture the village (better for debug and prevent impossible cases)

Modified:
    trunk/src/menu_events.cpp

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=35097&r1=35096&r2=35097&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Tue Apr 21 20:27:26 2009
@@ -1417,9 +1417,16 @@
 
                        unit 
chosen(&units_,&map_,&status_,&teams_,unit_choices[choice],1,false,false,gender,"",random_gender);
                        chosen.new_turn();
-                       units_.replace(mousehandler.get_last_hex(), chosen);
-
-                       gui_->invalidate(mousehandler.get_last_hex());
+
+                       const map_location& loc = mousehandler.get_last_hex();
+                       units_.replace(loc, chosen);
+
+                       if(map_.is_village(loc)) {
+                               int team = chosen.side()- 1; // translate to 
0-based team number
+                               get_village(loc, *gui_, teams_, team, units_);
+                       }
+
+                       gui_->invalidate(loc);
                        gui_->invalidate_unit();
                }
        }
@@ -1432,14 +1439,14 @@
                        if(!map_.is_village(loc))
                                return;
 
-                       // village_owner returns -1 for free village, so side 0 
will get it
-                       int side = village_owner(loc, teams_) + 1;
-                       // side is 0-based so side=team::nteams() is not a side
+                       // village_owner returns -1 for free village, so team 0 
will get it
+                       int team = village_owner(loc, teams_) + 1;
+                       // team is 0-based so side=team::nteams() is not a team
                        // but this will make get_village free it
-                       if(side > team::nteams()) {
-                               side = 0;
-                       }
-                       get_village(loc, *gui_, teams_, side, units_);
+                       if(team > team::nteams()) {
+                               team = 0;
+                       }
+                       get_village(loc, *gui_, teams_, team, units_);
                } else {
                        int side = i->second.side();
                        ++side;
@@ -1447,6 +1454,11 @@
                                side = 1;
                        }
                        i->second.set_side(side);
+
+                       if(map_.is_village(loc)) {
+                               int team = side - 1; // translate to 0-based 
team number
+                               get_village(loc, *gui_, teams_, team, units_);
+                       }
                }
        }
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to