Author: sapient
Date: Mon Apr 30 01:52:06 2007
New Revision: 17177

URL: http://svn.gna.org/viewcvs/wesnoth?rev=17177&view=rev
Log:
[store_villages] now uses the standard location filter instead of its own code
-note: the key 'side' has been replaced by 'owner_side'

Modified:
    trunk/src/game_events.cpp
    trunk/src/gamestatus.cpp
    trunk/src/gamestatus.hpp
    trunk/src/map.cpp
    trunk/src/play_controller.cpp

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=17177&r1=17176&r2=17177&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Mon Apr 30 01:52:06 2007
@@ -1962,27 +1962,27 @@
        else if(cmd == "store_villages" ) {
                //TODO - add wildcard support
                log_scope("store_villages");
-               std::string side = cfg["side"];
                std::string variable = cfg["variable"];
                if (variable.empty()) {
                        variable="location";
                }
-               std::string wml_terrain = cfg["terrain"];
-               wassert(state_of_game != NULL);
-               const int side_index = lexical_cast_default<int>(side,1)-1;
-               const t_translation::t_list& terrain = 
t_translation::read_list(wml_terrain);
-
                state_of_game->clear_variable_cfg(variable);
 
                std::vector<gamemap::location> locs = game_map->villages();
 
                for(std::vector<gamemap::location>::const_iterator j = 
locs.begin(); j != locs.end(); ++j) {
-                       if (!terrain.empty()) {
-                               const t_translation::t_letter c = 
game_map->get_terrain(*j);
-                               if(std::find(terrain.begin(), terrain.end(), c) 
== terrain.end())
-                                       continue;
-                       }
-                       if (side.empty() || village_owner(*j,*teams) == 
side_index) {
+                       bool matches = false;
+                       if(cfg.has_attribute("side")) { //deprecated, use 
owner_side instead
+                               lg::wml_error << "side key is no longer 
accepted in [store_villages],"
+                                       << " use owner_side instead.\n";
+                               config temp_cfg(cfg.get_config());
+                               temp_cfg["owner_side"] = temp_cfg["side"];
+                               temp_cfg["side"] = "";
+                               matches = game_map->terrain_matches_filter(*j, 
&temp_cfg, *status_ptr, *units);
+                       } else {
+                               matches = game_map->terrain_matches_filter(*j, 
cfg, *status_ptr, *units);
+                       }
+                       if(matches) {
                                config &loc_store = 
state_of_game->add_variable_cfg(variable);
                                j->write(loc_store);
                                game_map->write_terrain(*j, loc_store);

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=17177&r1=17176&r2=17177&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Mon Apr 30 01:52:06 2007
@@ -178,6 +178,7 @@
 gamestatus::gamestatus(const config& time_cfg, int num_turns, game_state* 
s_o_g) :
                  turn_(1),numTurns_(num_turns),currentTime_(0)
 {
+       teams = NULL;
     std::string turn_at = time_cfg["turn_at"];
        std::string current_tod = time_cfg["current_tod"];
        std::string random_start_time = time_cfg["random_start_time"];

Modified: trunk/src/gamestatus.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.hpp?rev=17177&r1=17176&r2=17177&view=diff
==============================================================================
--- trunk/src/gamestatus.hpp (original)
+++ trunk/src/gamestatus.hpp Mon Apr 30 01:52:06 2007
@@ -14,10 +14,10 @@
 #define GAME_STATUS_HPP_INCLUDED
 
 #include "filesystem.hpp"
+#include "team.hpp"
 #include "unit.hpp"
 
 #include <time.h>
-
 #include <string>
 #include <vector>
 
@@ -157,7 +157,7 @@
 class gamestatus
 {
 public:
-        gamestatus(const config& time_cfg, int num_turns, game_state* s_o_g = 
0);
+       gamestatus(const config& time_cfg, int num_turns, game_state* s_o_g = 
0);
        void write(config& cfg) const;
 
        time_of_day get_time_of_day() const;
@@ -176,6 +176,8 @@
        
        static bool is_start_ToD(const std::string&);
 
+       std::vector<team> *teams;
+
 private:
        void set_start_ToD(config&, game_state*);
        time_of_day get_time_of_day_turn(int nturn) const;

Modified: trunk/src/map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/map.cpp?rev=17177&r1=17176&r2=17177&view=diff
==============================================================================
--- trunk/src/map.cpp (original)
+++ trunk/src/map.cpp Mon Apr 30 01:52:06 2007
@@ -668,6 +668,17 @@
                        }
                }
        }
+
+       //allow filtering on owner (for villages)
+       const t_string& t_owner_side = cfg["owner_side"];
+       const std::string& owner_side = t_owner_side;
+       if(!owner_side.empty()) {
+               const int side_index = lexical_cast_default<int>(owner_side,0) 
- 1;
+               wassert(game_status.teams != NULL);
+               if(village_owner(loc, *(game_status.teams)) != side_index) {
+                       return false;
+               }
+       }
        return true; 
 }
 

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=17177&r1=17176&r2=17177&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Mon Apr 30 01:52:06 2007
@@ -39,6 +39,7 @@
        first_player_ (lexical_cast_default<unsigned 
int,std::string>(level_["playing_team"], 0) + 1),
        start_turn_(status_.turn()), skip_replay_(skip_replay), browse_(false), 
scrolling_(false)
 {
+       status_.teams = &teams_;
        game_config::add_color_info(level);
 
        init(video);


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

Reply via email to