Author: dragonking Date: Fri Apr 10 13:07:31 2009 New Revision: 34671 URL: http://svn.gna.org/viewcvs/wesnoth?rev=34671&view=rev Log: Improved the way how move maps work for formula_ai
Modified: trunk/src/ai.cpp trunk/src/callable_objects.cpp trunk/src/callable_objects.hpp trunk/src/formula_ai.cpp Modified: trunk/src/ai.cpp URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai.cpp?rev=34671&r1=34670&r2=34671&view=diff ============================================================================== --- trunk/src/ai.cpp (original) +++ trunk/src/ai.cpp Fri Apr 10 13:07:31 2009 @@ -769,7 +769,7 @@ const unit_movement_resetter move_resetter(*held_unit,enemy || assume_full_movement); // Insert the trivial moves of staying on the same location. - if(un_it->second.movement_left() == un_it->second.total_movement()) { + if(un_it->second.movement_left() > 0 ) { std::pair<location,location> trivial_mv(un_it->first,un_it->first); srcdst.insert(trivial_mv); dstsrc.insert(trivial_mv); Modified: trunk/src/callable_objects.cpp URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/callable_objects.cpp?rev=34671&r1=34670&r2=34671&view=diff ============================================================================== --- trunk/src/callable_objects.cpp (original) +++ trunk/src/callable_objects.cpp Fri Apr 10 13:07:31 2009 @@ -81,8 +81,10 @@ if(key == "moves") { std::vector<variant> vars; for(move_map::const_iterator i = srcdst_.begin(); i != srcdst_.end(); ++i) { - move_callable* item = new move_callable(i->first, i->second); - vars.push_back(variant(item)); + if( i->first == i->second || units_.count(i->second) == 0) { + move_callable* item = new move_callable(i->first, i->second); + vars.push_back(variant(item)); + } } return variant(&vars); Modified: trunk/src/callable_objects.hpp URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/callable_objects.hpp?rev=34671&r1=34670&r2=34671&view=diff ============================================================================== --- trunk/src/callable_objects.hpp (original) +++ trunk/src/callable_objects.hpp Fri Apr 10 13:07:31 2009 @@ -168,12 +168,13 @@ typedef std::multimap<map_location, map_location> move_map; const move_map& srcdst_; const move_map& dstsrc_; - - variant get_value(const std::string& key) const; - void get_inputs(std::vector<game_logic::formula_input>* inputs) const; -public: - move_map_callable(const move_map& srcdst, const move_map& dstsrc) - : srcdst_(srcdst), dstsrc_(dstsrc) + const unit_map& units_; + + variant get_value(const std::string& key) const; + void get_inputs(std::vector<game_logic::formula_input>* inputs) const; +public: + move_map_callable(const move_map& srcdst, const move_map& dstsrc, const unit_map& units) + : srcdst_(srcdst), dstsrc_(dstsrc), units_(units) {} const move_map& srcdst() const { return srcdst_; } Modified: trunk/src/formula_ai.cpp URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_ai.cpp?rev=34671&r1=34670&r2=34671&view=diff ============================================================================== --- trunk/src/formula_ai.cpp (original) +++ trunk/src/formula_ai.cpp Fri Apr 10 13:07:31 2009 @@ -2394,12 +2394,12 @@ } else if(key == "my_moves") { prepare_move(); - return variant(new move_map_callable(srcdst_, dstsrc_)); + return variant(new move_map_callable(srcdst_, dstsrc_, get_info().units)); } else if(key == "enemy_moves") { prepare_move(); - return variant(new move_map_callable(enemy_srcdst_, enemy_dstsrc_)); + return variant(new move_map_callable(enemy_srcdst_, enemy_dstsrc_, get_info().units)); } else if(key == "my_leader") { _______________________________________________ Wesnoth-commits mailing list Wesnoth-commits@gna.org https://mail.gna.org/listinfo/wesnoth-commits