Author: tschmitz
Date: Thu Jul 21 21:10:12 2011
New Revision: 50365

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50365&view=rev
Log:
Eliminated the non-pathfinding whiteboard mapbuilding mode.

Accordingly, changed scoped_planned_pathfind_map to scoped_planned_unit_map.

Modified:
    trunk/src/game_display.cpp
    trunk/src/menu_events.cpp
    trunk/src/mouse_events.cpp
    trunk/src/play_controller.cpp
    trunk/src/reports.cpp
    trunk/src/whiteboard/manager.cpp
    trunk/src/whiteboard/manager.hpp

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=50365&r1=50364&r2=50365&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Thu Jul 21 21:10:12 2011
@@ -221,7 +221,7 @@
 
 void game_display::highlight_hex(map_location hex)
 {
-       wb::scoped_planned_pathfind_map future; //< Lasts for whole method.
+       wb::scoped_planned_unit_map future; //< Lasts for whole method.
 
        const unit *u = get_visible_unit(hex, teams_[viewing_team()], 
!viewpoint_);
        if (u) {
@@ -245,7 +245,7 @@
 
 void game_display::display_unit_hex(map_location hex)
 {
-       wb::scoped_planned_pathfind_map future; //< Lasts for whole method.
+       wb::scoped_planned_unit_map future; //< Lasts for whole method.
 
        const unit *u = get_visible_unit(hex, teams_[viewing_team()], 
!viewpoint_);
        if (u) {
@@ -437,7 +437,7 @@
 
 void game_display::draw_sidebar()
 {
-       wb::scoped_planned_pathfind_map future; //< Lasts for whole method.
+       wb::scoped_planned_unit_map future; //< Lasts for whole method.
 
        draw_report("report_clock");
        draw_report("report_countdown");

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=50365&r1=50364&r2=50365&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Thu Jul 21 21:10:12 2011
@@ -698,12 +698,12 @@
                item_keys.push_back(*it);
 
                char prefix;
-               { wb::scoped_planned_pathfind_map future; //< start planned 
pathfind map scope
+               { wb::scoped_planned_unit_map future; //< start planned unit 
map scope
                        int wb_gold = 
resources::whiteboard->get_spent_gold_for(side_num);
                        //display units that we can't afford to recruit in red
                        prefix = (type->cost() > current_team.gold() - wb_gold
                                        ? font::BAD_TEXT : font::NULL_MARKUP);
-               } // end planned pathfind map scope
+               } // end planned unit map scope
 
                std::stringstream description;
                description << font::IMAGE << type->image();
@@ -781,22 +781,22 @@
        const unit_type *u_type = unit_types.find(name);
        assert(u_type);
 
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                if (u_type->cost() > current_team.gold() - 
resources::whiteboard->get_spent_gold_for(side_num)) {
                        gui2::show_transient_message(gui_->video(), "",
                                _("You don’t have enough gold to recruit that 
unit"));
                        return;
                }
-       } // end planned pathfind map scope
+       } // end planned unit map scope
 
        last_recruit_ = name;
        const events::command_disabler disable_commands;
 
        map_location loc = last_hex;
        std::string msg;
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                msg = find_recruit_location(side_num, loc, u_type->id());
-       } // end planned pathfind map scope
+       } // end planned unit map scope
        if (!msg.empty()) {
                gui2::show_transient_message(gui_->video(), "", msg);
                return;
@@ -851,7 +851,7 @@
 
        gui_->draw(); //clear the old menu
 
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                DBG_WB <<"menu_handler::recall: Contents of wb-modified recall 
list:\n";
                foreach(const unit* unit, recall_list_team)
                {
@@ -864,7 +864,7 @@
                                " veteran survivors from a previous 
scenario)"));
                        return;
                }
-       } // end planned pathfind map scope
+       } // end planned unit map scope
 
        std::vector<std::string> options, options_to_filter;
 
@@ -882,7 +882,7 @@
        options.push_back(heading.str());
        options_to_filter.push_back(options.back());
 
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                foreach (const unit* u, recall_list_team)
                {
                        std::stringstream option, option_to_filter;
@@ -928,12 +928,12 @@
                        options.push_back(option.str());
                        options_to_filter.push_back(option_to_filter.str());
                }
-       } // end planned pathfind map scope
+       } // end planned unit map scope
 
        int res = 0;
 
        {
-               { wb::scoped_planned_pathfind_map future; //< start planned 
pathfind map scope
+               { wb::scoped_planned_unit_map future; //< start planned unit 
map scope
                        gui::dialog rmenu(*gui_, _("Recall") + 
get_title_suffix(side_num),
                                _("Select unit:") + std::string("\n"),
                                gui::OK_CANCEL, gui::dialog::default_style);
@@ -972,10 +972,10 @@
                        sort_reversed = rmenu.get_menu().get_sort_reversed();
 
                        if (res < 0) return;
-               } // end planned pathfind map scope
-       }
-
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+               } // end planned unit map scope
+       }
+
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                int wb_gold = 
resources::whiteboard->get_spent_gold_for(side_num);
                if (current_team.gold() - wb_gold < current_team.recall_cost()) 
{
                        utils::string_map i18n_symbols;
@@ -987,24 +987,24 @@
                        gui2::show_transient_message(gui_->video(), "", msg);
                        return;
                }
-       } // end planned pathfind map scope
+       } // end planned unit map scope
 
        LOG_NG << "recall index: " << res << "\n";
        const events::command_disabler disable_commands;
 
        map_location recall_location = last_hex;
        std::string err;
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                err = find_recall_location(side_num, recall_location, 
*(recall_list_team[res]));
-       } // end planned pathfind map scope
+       } // end planned unit map scope
        if(!err.empty()) {
                gui2::show_transient_message(gui_->video(), "", err);
                return;
        }
        unit* recalled_unit;
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                recalled_unit = new unit(*(recall_list_team[res]));
-       } // end planned pathfind map scope
+       } // end planned unit map scope
 
        if (!resources::whiteboard->save_recall(*recalled_unit, side_num, 
recall_location)) {
                do_recall(*recalled_unit, side_num, recall_location);
@@ -1327,7 +1327,7 @@
 // Highlights squares that an enemy could move to on their turn, showing how 
many can reach each square.
 void menu_handler::show_enemy_moves(bool ignore_units, int side_num)
 {
-       wb::scoped_planned_pathfind_map wb_modifiers;
+       wb::scoped_planned_unit_map wb_modifiers;
 
        gui_->unhighlight_reach();
 

Modified: trunk/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=50365&r1=50364&r2=50365&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Thu Jul 21 21:10:12 2011
@@ -115,12 +115,12 @@
                        // we store the previous hexes used to propose attack 
direction
                        previous_hex_ = last_hex_;
                        // the hex of the selected unit is also "free"
-                       { // start planned pathfind map scope
-                               wb::scoped_planned_pathfind_map 
planned_pathfind_map;
+                       { // start planned unit map scope
+                               wb::scoped_planned_unit_map raii;
                                if (last_hex_ == selected_hex_ || 
find_unit(last_hex_) == units_.end()) {
                                        previous_free_hex_ = last_hex_;
                                }
-                       } // end planned pathfind map scope
+                       } // end planned unit map scope
                }
                last_hex_ = new_hex;
        }
@@ -217,8 +217,8 @@
                // used to attack it
                map_location dest;
                unit_map::const_iterator dest_un;
-               { // start planned pathfind map scope
-                       wb::scoped_planned_pathfind_map planned_pathfind_map;
+               { // start planned unit map scope
+                       wb::scoped_planned_unit_map raii;
                        if (attack_from.valid()) {
                                dest = attack_from;
                                dest_un = find_unit(dest);
@@ -226,7 +226,7 @@
                                dest = new_hex;
                                dest_un = find_unit(new_hex);
                        }
-               } // end planned pathfind map scope
+               } // end planned unit map scope
 
                if(dest == selected_hex_ || dest_un != units_.end()) {
                        current_route_.steps.clear();
@@ -245,9 +245,9 @@
                                unit_movement_resetter 
move_reset(*selected_unit,
                                                selected_unit->side() != 
side_num_);
 
-                               { wb::scoped_planned_pathfind_map future; //< 
start planned pathfind map scope
+                               { wb::scoped_planned_unit_map future; //< start 
planned unit map scope
                                        current_route_ = 
get_route(&*selected_unit, dest, waypoints_, viewing_team());
-                               } // end planned pathfind map scope
+                               } // end planned unit map scope
 
                                resources::whiteboard->create_temp_move();
 
@@ -278,7 +278,7 @@
 
 
                                { // start planned unit map scope
-                                       wb::scoped_planned_pathfind_map 
planned_pathfind_map;
+                                       wb::scoped_planned_unit_map raii;
                                        current_paths_ = 
pathfind::paths(map_,units_,new_hex,teams_,
                                                                                
                                false,true,viewing_team(),path_turns_);
                                } // end planned unit map scope
@@ -291,7 +291,7 @@
                                if(map_.on_board(go_to)) {
                                        pathfind::marked_route route;
                                        { // start planned unit map scope
-                                               wb::scoped_planned_pathfind_map 
planned_pathfind_map;
+                                               wb::scoped_planned_unit_map 
raii;
                                                route = get_route(un, go_to, 
un->waypoints(), current_team());
                                        } // end planned unit map scope
                                        gui().set_route(&route);

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=50365&r1=50364&r2=50365&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Thu Jul 21 21:10:12 2011
@@ -1199,7 +1199,7 @@
        case hotkey::HOTKEY_RECRUIT:
        case hotkey::HOTKEY_REPEAT_RECRUIT:
        case hotkey::HOTKEY_RECALL: {
-               wb::scoped_planned_pathfind_map future; //< lasts until method 
returns.
+               wb::scoped_planned_unit_map future; //< lasts until method 
returns.
                // last_hex_ is set by mouse_events::mouse_motion
                // Enable recruit/recall on castle/keep tiles
                for(unit_map::const_iterator leader = units_.begin();

Modified: trunk/src/reports.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/reports.cpp?rev=50365&r1=50364&r2=50365&view=diff
==============================================================================
--- trunk/src/reports.cpp (original)
+++ trunk/src/reports.cpp Thu Jul 21 21:10:12 2011
@@ -621,7 +621,7 @@
 {
        std::ostringstream str;
        int viewing_side = resources::screen->viewing_side();
-       // Suppose the full/"pathfind" unit map is applied.
+       // Suppose the full unit map is applied.
        int fake_gold = (*resources::teams)[viewing_side - 1].gold() -
                resources::whiteboard->get_spent_gold_for(viewing_side);
        char const *end = naps;

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=50365&r1=50364&r2=50365&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Thu Jul 21 21:10:12 2011
@@ -389,9 +389,9 @@
 
        map_location selected_hex = resources::screen->selected_hex();
        unit_map::iterator it;
-       { wb::scoped_planned_pathfind_map future; //< start planned pathfind 
map scope
+       { wb::scoped_planned_unit_map future; //< start planned unit map scope
                it = resources::units->find(selected_hex);
-       } // end planned pathfind map scope
+       } // end planned unit map scope
        if (!((selected_hex.valid() && it != resources::units->end())
                        || has_temp_move() || wait_for_side_init_ || 
executing_actions_))
        {
@@ -830,12 +830,12 @@
 {
        if (!has_planned_unit_map_)
        {
-               resources::whiteboard->set_planned_unit_map();
-       }
-       else if (is_map_for_pathfinding_)
+               resources::whiteboard->set_planned_unit_map(true);
+       }
+       else if (!is_map_for_pathfinding_)
        {
                resources::whiteboard->set_real_unit_map();
-               resources::whiteboard->set_planned_unit_map();
+               resources::whiteboard->set_planned_unit_map(true);
        }
 }
 
@@ -868,36 +868,6 @@
                
resources::whiteboard->set_planned_unit_map(is_map_for_pathfinding_);
 }
 
-scoped_planned_pathfind_map::scoped_planned_pathfind_map():
-               
has_planned_unit_map_(resources::whiteboard->has_planned_unit_map()),
-               
is_map_for_pathfinding_(resources::whiteboard->is_map_for_pathfinding())
-{
-       if (!has_planned_unit_map_)
-       {
-               resources::whiteboard->set_planned_unit_map(true);
-       }
-       else if (!is_map_for_pathfinding_)
-       {
-               resources::whiteboard->set_real_unit_map();
-               resources::whiteboard->set_planned_unit_map(true);
-       }
-}
-
-scoped_planned_pathfind_map::~scoped_planned_pathfind_map()
-{
-       if (has_planned_unit_map_ && is_map_for_pathfinding_)
-       {
-       }
-       else
-       {
-               resources::whiteboard->set_real_unit_map();
-               if (has_planned_unit_map_)
-               {
-                       resources::whiteboard->set_planned_unit_map(false);
-               }
-       }
-}
-
 bool unit_comparator_predicate::operator()(unit const& unit)
 {
        return unit_.id() == unit.id();

Modified: trunk/src/whiteboard/manager.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.hpp?rev=50365&r1=50364&r2=50365&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Thu Jul 21 21:10:12 2011
@@ -214,18 +214,6 @@
        bool is_map_for_pathfinding_;
 };
 
-/** A variant on the regular planned unit map, that includes units only useful 
for pathfinding,
- * such as those from planned recruits and recalls.
- * It replaces the regular planned unit map, and rebuilds it afterwards if 
needed.
- *  */
-struct scoped_planned_pathfind_map
-{
-       scoped_planned_pathfind_map();
-       ~scoped_planned_pathfind_map();
-       bool has_planned_unit_map_;
-       bool is_map_for_pathfinding_;
-};
-
 /// Predicate that compares the id() of two units. Useful for searches in unit 
vectors with std::find_if()
 struct unit_comparator_predicate {
        unit_comparator_predicate(unit const& unit) : unit_(unit) {}


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

Reply via email to