Completely removed the waypoint functionality on 'w' key,

...since the whiteboard is now an adequate replacement.

Fixes bug #17060
This commit is contained in:
Gabriel Morin 2011-09-08 00:52:38 +00:00
parent 0c7dfcc8af
commit 192e7a017e
19 changed files with 28 additions and 173 deletions

View file

@ -6,6 +6,8 @@ Version 1.9.9+svn:
* To the Harbor of Tirigaz: used 24 hour ToD
* Language and i18n:
* Updated translations: British English, Dutch, Galician
* User interface
* Removed waypoints UI feature
Version 1.9.9:
* AI:

View file

@ -101,10 +101,6 @@
key=" "
shift=yes
[/hotkey]
[hotkey]
command=addwaypoint
key=w
[/hotkey]
[hotkey]
command=labelteamterrain
key=l

View file

@ -10,6 +10,8 @@ Version 1.9.9+svn:
* To the Harbor of Tirigaz: used 24 hour ToD
* Language and i18n:
* Updated translations: British English, Dutch, Galician.
* User interface
* Removed waypoints UI feature ('w' key) since the whiteboard provides similar functionality
Version 1.9.9:

View file

@ -2402,7 +2402,6 @@ size_t move_unit(move_unit_spectator *move_spectator,
// See how far along the given path we can move.
const int starting_moves = ui->movement_left();
int moves_left = starting_moves;
std::vector<map_location> starting_waypoints = ui->waypoints();
std::set<map_location> seen_units;
std::set<map_location> petrified_units;
bool discovered_unit = false;
@ -2467,18 +2466,6 @@ size_t move_unit(move_unit_spectator *move_spectator,
moves_left -= cost;
// remove passed waypoints
std::vector<map_location>& waypoints = ui->waypoints();
if(!waypoints.empty() && waypoints.front() == *step) {
waypoints.erase(waypoints.begin());
//if user placed waypoint on a enemy/free village
//assume that he wanted to capture it
if(map.is_village(*step) && !tm->owns_village(*step)) {
// this will stop the unit, and capture should do it anyway
moves_left = 0;
}
}
// If we use fog or shroud, see if we have sighted an enemy unit,
// in which case we should stop immediately.
// Cannot use check shroud, because also need to check if delay shroud is on.
@ -2676,8 +2663,7 @@ size_t move_unit(move_unit_spectator *move_spectator,
} else {
// MP_COUNTDOWN: added param
undo_stack->push_back(
undo_action(*maybe_ui, steps,
starting_waypoints, starting_moves,
undo_action(*maybe_ui, steps, starting_moves,
action_time_bonus, orig_village_owner, orig_dir));
}
}

View file

@ -349,12 +349,10 @@ int combat_modifier(const map_location &loc,
struct undo_action {
enum ACTION_TYPE { NONE, RECRUIT, RECALL, DISMISS };
undo_action(const unit& u, const std::vector<map_location>& rt,
const std::vector<map_location>& wp, int sm,
undo_action(const unit& u, const std::vector<map_location>& rt, int sm,
int timebonus=0, int orig=-1,
const map_location::DIRECTION dir=map_location::NDIRECTIONS) :
route(rt),
waypoints(wp),
starting_moves(sm),
original_village_owner(orig),
recall_loc(),
@ -368,7 +366,6 @@ struct undo_action {
undo_action(const unit& u, const map_location& loc,
const ACTION_TYPE action_type=NONE) :
route(),
waypoints(),
starting_moves(),
original_village_owner(),
recall_loc(loc),
@ -379,7 +376,6 @@ struct undo_action {
{}
std::vector<map_location> route;
std::vector<map_location> waypoints;
int starting_moves;
int original_village_owner;
map_location recall_loc;

View file

@ -596,11 +596,6 @@ void game_display::draw_movement_info(const map_location& loc)
image::get_image("misc/capture.png", image::SCALED_TO_HEX));
}
if (w->second.pass_here) {
drawing_buffer_add(LAYER_MOVE_INFO, loc, xpos, ypos,
image::get_image("misc/waypoint.png", image::SCALED_TO_HEX));
}
//we display turn info only if different from a simple last "1"
if (w->second.turns > 1 || (w->second.turns == 1 && loc != route_.steps.back())) {
std::stringstream turns_text;

View file

@ -55,7 +55,6 @@ const struct {
{ hotkey::HOTKEY_ANIMATE_MAP, "animatemap", N_("Animate Map"), false, hotkey::SCOPE_GENERAL },
{ hotkey::HOTKEY_CYCLE_UNITS, "cycle", N_("Next Unit"), false, hotkey::SCOPE_GAME },
{ hotkey::HOTKEY_CYCLE_BACK_UNITS, "cycleback", N_("Previous Unit"), false, hotkey::SCOPE_GAME },
{ hotkey::HOTKEY_ADD_WAYPOINT, "addwaypoint", N_("Add waypoint"), false, hotkey::SCOPE_GAME },
{ hotkey::HOTKEY_UNIT_HOLD_POSITION, "holdposition", N_("Hold Position"), false, hotkey::SCOPE_GAME },
{ hotkey::HOTKEY_END_UNIT_TURN, "endunitturn", N_("End Unit Turn"), false, hotkey::SCOPE_GAME },
{ hotkey::HOTKEY_LEADER, "leader", N_("Leader"), false, hotkey::SCOPE_GAME },
@ -951,9 +950,6 @@ bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
case HOTKEY_ENDTURN:
end_turn();
break;
case HOTKEY_ADD_WAYPOINT:
add_waypoint();
break;
case HOTKEY_UNIT_HOLD_POSITION:
unit_hold_position();
break;

View file

@ -39,7 +39,7 @@ enum scope {
enum HOTKEY_COMMAND {
HOTKEY_CYCLE_UNITS,HOTKEY_CYCLE_BACK_UNITS,
HOTKEY_ADD_WAYPOINT, HOTKEY_UNIT_HOLD_POSITION,
HOTKEY_UNIT_HOLD_POSITION,
HOTKEY_END_UNIT_TURN, HOTKEY_LEADER,
HOTKEY_UNDO, HOTKEY_REDO,
HOTKEY_ZOOM_IN, HOTKEY_ZOOM_OUT, HOTKEY_ZOOM_DEFAULT,
@ -285,7 +285,6 @@ public:
virtual void cycle_back_units() {}
virtual void end_turn() {}
virtual void goto_leader() {}
virtual void add_waypoint() {}
virtual void unit_hold_position() {}
virtual void end_unit_turn() {}
virtual void undo() {}

View file

@ -1148,7 +1148,6 @@ void menu_handler::undo(int side_num)
u = units_.find(route.back());
u->set_goto(map_location());
std::swap(u->waypoints(), action_copy.waypoints);
u->set_movement(starting_moves);
u->set_standing();
@ -1289,7 +1288,6 @@ void menu_handler::redo(int side_num)
unit::clear_status_caches();
u->set_goto(action_copy.affected_unit.get_goto());
std::swap(u->waypoints(), action_copy.waypoints);
u->set_movement(starting_moves);
u->set_standing();
@ -1694,7 +1692,7 @@ void menu_handler::move_unit_to_loc(const unit_map::iterator &ui,
{
assert(ui != units_.end());
pathfind::marked_route route = mousehandler.get_route(&*ui, target, ui->waypoints(), teams_[side_num - 1]);
pathfind::marked_route route = mousehandler.get_route(&*ui, target, teams_[side_num - 1]);
if(route.steps.empty())
return;
@ -1739,7 +1737,7 @@ void menu_handler::execute_gotos(mouse_handler &mousehandler, int side)
if(fully_moved.count(current_loc))
continue;
pathfind::marked_route route = mousehandler.get_route(&*ui, goto_loc, ui->waypoints(), teams_[side - 1]);
pathfind::marked_route route = mousehandler.get_route(&*ui, goto_loc, teams_[side - 1]);
if(route.steps.size() <= 1) { // invalid path
fully_moved.insert(current_loc);

View file

@ -66,7 +66,6 @@ mouse_handler::mouse_handler(game_display* gui, std::vector<team>& teams,
selected_hex_(),
next_unit_(),
current_route_(),
waypoints_(),
current_paths_(),
enemy_paths_(false),
path_turns_(0),
@ -239,7 +238,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update, m
{
if (selected_unit != units_.end() && !selected_unit->incapacitated()) {
// Show the route from selected unit to mouseover hex
current_route_ = get_route(&*selected_unit, dest, waypoints_, viewing_team());
current_route_ = get_route(&*selected_unit, dest, viewing_team());
{ wb::scoped_real_unit_map raii;
resources::whiteboard->create_temp_move();
@ -283,7 +282,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update, m
pathfind::marked_route route;
{ // start planned unit map scope
wb::scoped_planned_unit_map raii;
route = get_route(un, go_to, un->waypoints(), current_team());
route = get_route(un, go_to, current_team());
} // end planned unit map scope
gui().set_route(&route);
}
@ -386,21 +385,7 @@ map_location mouse_handler::current_unit_attacks_from(const map_location& loc)
return res;
}
void mouse_handler::add_waypoint(const map_location& loc) {
std::vector<map_location>::iterator w = std::find(waypoints_.begin(), waypoints_.end(), loc);
//toggle between add a new one and remove an old one
if(w != waypoints_.end()){
waypoints_.erase(w);
} else {
waypoints_.push_back(loc);
}
// we need to update the route, simulate a mouse move for the moment
// (browse is supposed false here, 0,0 are dummy values)
mouse_motion(0,0, false, true);
}
pathfind::marked_route mouse_handler::get_route(unit* un, map_location go_to, const std::vector<map_location>& waypoints, team &team)
pathfind::marked_route mouse_handler::get_route(unit* un, map_location go_to, team &team)
{
// The pathfinder will check unit visibility (fogged/stealthy).
const pathfind::shortest_path_calculator calc(*un, team, units_, teams_, map_);
@ -409,40 +394,9 @@ pathfind::marked_route mouse_handler::get_route(unit* un, map_location go_to, co
pathfind::plain_route route;
if (waypoints.empty()) {
// standard shortest path
route = pathfind::a_star_search(un->get_location(), go_to, 10000.0, &calc, map_.w(), map_.h(), &allowed_teleports);
} else {
// initialize the main route with the first step
route.steps.push_back(un->get_location());
route.move_cost = 0;
route = pathfind::a_star_search(un->get_location(), go_to, 10000.0, &calc, map_.w(), map_.h(), &allowed_teleports);
//copy waypoints and add first source and last destination
//TODO: don't copy but use vector index trick
std::vector<map_location> waypts;
waypts.push_back(un->get_location());
waypts.insert(waypts.end(), waypoints.begin(), waypoints.end());
waypts.push_back(go_to);
std::vector<map_location>::iterator src = waypts.begin(),
dst = ++waypts.begin();
for(; dst != waypts.end(); ++src,++dst){
if (*src == *dst) continue;
pathfind::plain_route inter_route = pathfind::a_star_search(*src, *dst, 10000.0, &calc, map_.w(), map_.h(), &allowed_teleports);
if(inter_route.steps.size()>=1) {
// add to the main route but skip the head (already in)
route.steps.insert(route.steps.end(),
inter_route.steps.begin()+1,inter_route.steps.end());
route.move_cost+=inter_route.move_cost;
} else {
// we can't reach dst, stop the route at the last src
// as the normal case do
break;
}
}
}
return mark_route(route, waypoints);
return mark_route(route);
}
void mouse_handler::mouse_press(const SDL_MouseButtonEvent& event, const bool browse)
@ -486,11 +440,9 @@ bool mouse_handler::left_click(int x, int y, const bool browse)
u = find_unit(selected_hex_);
//if the unit is selected and then itself clicked on,
//any goto command and waypoints are cancelled
//any goto command is cancelled
if (u != units_.end() && !browse && selected_hex_ == hex && u->side() == side_num_) {
u->set_goto(map_location());
u->waypoints().clear();
waypoints_.clear();
}
clicked_u = find_unit(hex);
@ -508,7 +460,6 @@ bool mouse_handler::left_click(int x, int y, const bool browse)
gui().select_hex(map_location());
gui().clear_attack_indicator();
gui().set_route(NULL);
waypoints_.clear();
show_partial_move_ = false;
gui().unhighlight_reach();
current_paths_ = pathfind::paths();
@ -555,9 +506,6 @@ bool mouse_handler::left_click(int x, int y, const bool browse)
return false;
}
//register the mouse-UI waypoints into the unit's waypoints
u->waypoints() = waypoints_;
// store side, since u may be invalidated later
int side = u->side();
//record visible enemies adjacent to destination
@ -599,7 +547,6 @@ bool mouse_handler::left_click(int x, int y, const bool browse)
gui().select_hex(map_location());
gui().clear_attack_indicator();
gui().set_route(NULL);
waypoints_.clear();
show_partial_move_ = false;
gui().unhighlight_reach();
current_paths_ = pathfind::paths();
@ -615,9 +562,6 @@ bool mouse_handler::left_click(int x, int y, const bool browse)
return false;
}
//register the mouse-UI waypoints into the unit's waypoints
u->waypoints() = waypoints_;
move_unit_along_current_route(current_team().auto_shroud_updates());
// during the move, we may have selected another unit
// (but without triggering a select event (command was disabled)
@ -641,7 +585,6 @@ void mouse_handler::select_hex(const map_location& hex, const bool browse) {
gui().select_hex(hex);
gui().clear_attack_indicator();
gui().set_route(NULL);
waypoints_.clear();
show_partial_move_ = false;
wb::scoped_planned_unit_map planned_unit_map; //lasts for whole method

View file

@ -55,9 +55,7 @@ public:
unit_map::iterator selected_unit();
void add_waypoint(const map_location& loc);
pathfind::marked_route get_route(unit* un, map_location go_to, const std::vector<map_location>& waypoints, team &team);
pathfind::marked_route get_route(unit* un, map_location go_to, team &team);
const pathfind::marked_route& get_current_route() { return current_route_; }
@ -128,7 +126,6 @@ private:
map_location selected_hex_;
map_location next_unit_;
pathfind::marked_route current_route_;
std::vector<map_location> waypoints_;
pathfind::paths current_paths_;
bool enemy_paths_;
int path_turns_;

View file

@ -368,8 +368,7 @@ pathfind::paths::paths(gamemap const &map, unit_map const &units,
see_all, ignore_units);
}
pathfind::marked_route pathfind::mark_route(const plain_route &rt,
const std::vector<map_location>& waypoints)
pathfind::marked_route pathfind::mark_route(const plain_route &rt)
{
marked_route res;
@ -385,8 +384,7 @@ pathfind::marked_route pathfind::mark_route(const plain_route &rt,
const team& unit_team = (*resources::teams)[u.side()-1];
bool zoc = false;
std::vector<map_location>::const_iterator i = rt.steps.begin(),
w = waypoints.begin();
std::vector<map_location>::const_iterator i = rt.steps.begin();
for (; i !=rt.steps.end(); ++i) {
bool last_step = (i+1 == rt.steps.end());
@ -394,23 +392,10 @@ pathfind::marked_route pathfind::mark_route(const plain_route &rt,
// move_cost of the next step is irrelevant for the last step
assert(last_step || resources::game_map->on_board(*(i+1)));
const int move_cost = last_step ? 0 : u.movement_cost((*resources::game_map)[*(i+1)]);
bool pass_here = false;
if (w != waypoints.end() && *i == *w) {
++w;
pass_here = true;
}
team const& viewing_team = (*resources::teams)[resources::screen->viewing_team()];
// check if there is a village that we could capture
// if it's an enemy unit and a fogged village, we assume it's free
// (if he already owns it, we can't know that)
// if it's not an enemy, we can always know if he owns the village
bool village = resources::game_map->is_village(*i) && ( !unit_team.owns_village(*i)
|| (viewing_team.is_enemy(u.side()) && viewing_team.fogged(*i)) );
// NOTE if there is a waypoint on a not owned village, then we will always stop there
if (last_step || zoc || move_cost > movement || (pass_here && village)) {
if (last_step || zoc || move_cost > movement) {
// check if we stop an a village and so maybe capture it
// if it's an enemy unit and a fogged village, we assume a capture
// (if he already owns it, we can't know that)
@ -422,7 +407,7 @@ pathfind::marked_route pathfind::mark_route(const plain_route &rt,
bool invisible = u.invisible(*i,false);
res.marks[*i] = marked_route::mark(turns, pass_here, zoc, capture, invisible);
res.marks[*i] = marked_route::mark(turns, zoc, capture, invisible);
if (last_step) break; // finished and we used dummy move_cost
@ -430,9 +415,6 @@ pathfind::marked_route pathfind::mark_route(const plain_route &rt,
if(move_cost > movement) {
return res; //we can't reach destination
}
} else if (pass_here) {
bool invisible = u.invisible(*i,false);
res.marks[*i] = marked_route::mark(0, pass_here, zoc, false, invisible);
}
zoc = enemy_zoc((*resources::teams), *(i + 1), viewing_team,u.side())

View file

@ -147,12 +147,11 @@ struct marked_route
struct mark
{
mark(int turns_number = 0, bool pass = false, bool in_zoc = false,
mark(int turns_number = 0, bool in_zoc = false,
bool do_capture = false, bool is_invisible = false)
: turns(turns_number), pass_here(pass), zoc(in_zoc),
: turns(turns_number), zoc(in_zoc),
capture(do_capture), invisible(is_invisible) {}
int turns;
bool pass_here;
bool zoc;
bool capture;
bool invisible;
@ -176,8 +175,7 @@ plain_route a_star_search(map_location const &src, map_location const &dst,
* Add marks on a route @a rt assuming that the unit located at the first hex of
* rt travels along it.
*/
marked_route mark_route(const plain_route &rt,
const std::vector<map_location>& waypoints);
marked_route mark_route(const plain_route &rt);
struct shortest_path_calculator : cost_calculator
{

View file

@ -184,11 +184,6 @@ void playsingle_controller::continue_move(){
menu_handler_.continue_move(mouse_handler_, player_number_);
}
void playsingle_controller::add_waypoint(){
if (!browse_)
mouse_handler_.add_waypoint(mouse_handler_.get_last_hex());
}
void playsingle_controller::unit_hold_position(){
if (!browse_)
menu_handler_.unit_hold_position(mouse_handler_, player_number_);
@ -1011,7 +1006,6 @@ bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command,
{
bool res = true;
switch (command){
case hotkey::HOTKEY_ADD_WAYPOINT:
case hotkey::HOTKEY_UNIT_HOLD_POSITION:
case hotkey::HOTKEY_END_UNIT_TURN:
return !browse_ && !linger_ && !events::commands_disabled;

View file

@ -46,7 +46,6 @@ public:
virtual void label_terrain(bool);
virtual void clear_labels();
virtual void continue_move();
virtual void add_waypoint();
virtual void unit_hold_position();
virtual void end_unit_turn();
virtual void user_command();

View file

@ -162,7 +162,6 @@ unit::unit(const unit& o):
unit_value_(o.unit_value_),
goto_(o.goto_),
interrupted_move_(o.interrupted_move_),
waypoints_(o.waypoints_),
flying_(o.flying_),
is_fearless_(o.is_fearless_),
is_healthy_(o.is_healthy_),
@ -240,7 +239,6 @@ unit::unit(const config &cfg, bool use_traits, game_state* state) :
unit_value_(),
goto_(),
interrupted_move_(),
waypoints_(),
flying_(false),
is_fearless_(false),
is_healthy_(false),
@ -437,15 +435,6 @@ unit::unit(const config &cfg, bool use_traits, game_state* state) :
goto_.x = cfg["goto_x"].to_int() - 1;
goto_.y = cfg["goto_y"].to_int() - 1;
if (const config &waypoints = cfg.child("waypoints")) {
read_locations(waypoints, waypoints_);
if(waypoints_.empty()==false){
if(waypoints_.back() != goto_)
waypoints_.clear(); //goto has changed, ignore waypoints
else
waypoints_.pop_back(); //last one was only for goto check
}
}
if (const config::attribute_value *v = cfg.get("moves")) {
movement_ = *v;
@ -587,7 +576,6 @@ unit::unit(const unit_type *t, int side, bool real_unit,
unit_value_(),
goto_(),
interrupted_move_(),
waypoints_(),
flying_(false),
is_fearless_(false),
is_healthy_(false),
@ -793,7 +781,7 @@ void unit::advance_to(const config &old_cfg, const unit_type *t,
}
}
//copy ínformation what this unit is able to recall
//copy <EFBFBD>nformation what this unit is able to recall
new_cfg.add_child("filter_recall", old_cfg.child_or_empty("filter_recall"));
if(t->movement_type().get_parent()) {
@ -1041,7 +1029,6 @@ void unit::new_scenario()
// Set the goto-command to be going to no-where
goto_ = map_location();
waypoints_.clear();
bool rebuild_from_type = false;
@ -1629,16 +1616,6 @@ void unit::write(config& cfg) const
cfg["goto_x"] = goto_.x + 1;
cfg["goto_y"] = goto_.y + 1;
cfg.clear_children("waypoints");
if(waypoints_.empty() == false && goto_.valid()) {
config& waypoints_cfg = cfg.add_child("waypoints");
// append the goto for consistency checking
// (if goto changes, we will ignore waypoints)
std::vector<map_location> waypoints(waypoints_);
waypoints.push_back(goto_);
write_locations(waypoints, waypoints_cfg);
}
cfg["moves"] = movement_;
cfg["max_moves"] = max_movement_;

View file

@ -220,8 +220,6 @@ public:
const map_location& get_goto() const { return goto_; }
void set_goto(const map_location& new_goto) { goto_ = new_goto; }
const std::vector<map_location>& waypoints() const { return waypoints_; }
std::vector<map_location>& waypoints() { return waypoints_; }
int upkeep() const;
bool loyal() const;
@ -423,7 +421,6 @@ private:
int unit_value_;
map_location goto_, interrupted_move_;
std::vector<map_location> waypoints_;
bool flying_, is_fearless_, is_healthy_;

View file

@ -111,7 +111,7 @@ move::move(config const& cfg, bool hidden)
}
foreach(config const& mark_cfg, route_cfg.child_range("mark")) {
route_->marks[map_location(mark_cfg["x"],mark_cfg["y"])]
= pathfind::marked_route::mark(mark_cfg["turns"],mark_cfg["pass_here"],mark_cfg["zoc"],mark_cfg["capture"],mark_cfg["invisible"]);
= pathfind::marked_route::mark(mark_cfg["turns"],mark_cfg["zoc"],mark_cfg["capture"],mark_cfg["invisible"]);
}
// Validate route_ some more
@ -359,7 +359,7 @@ bool move::calculate_new_route(const map_location& source_hex, const map_locatio
new_plain_route = pathfind::a_star_search(source_hex,
dest_hex, 10000, &path_calc, resources::game_map->w(), resources::game_map->h());
if (new_plain_route.move_cost >= path_calc.getNoPathValue()) return false;
route_.reset(new pathfind::marked_route(pathfind::mark_route(new_plain_route, std::vector<map_location>())));
route_.reset(new pathfind::marked_route(pathfind::mark_route(new_plain_route)));
calculate_move_cost();
return true;
}
@ -486,7 +486,6 @@ config move::to_config() const
mark_cfg["x"]=item.first.x;
mark_cfg["y"]=item.first.y;
mark_cfg["turns"]=item.second.turns;
mark_cfg["pass_here"]=item.second.pass_here;
mark_cfg["zoc"]=item.second.zoc;
mark_cfg["capture"]=item.second.capture;
mark_cfg["invisible"]=item.second.invisible;

View file

@ -98,16 +98,15 @@ validate_visitor::VALIDITY validate_visitor::evaluate_move_validity(move_ptr m_p
m.unit_ = &*unit_it;
//check that the path is good
if (m.get_source_hex() != m.get_dest_hex()) //allow for zero-hex, move, in which case we skip pathfinding
if (m.get_source_hex() != m.get_dest_hex()) //allow for zero-hex move, in which case we skip pathfinding
{
//verify that the destination hex is free
if (get_visible_unit(m.get_dest_hex(),resources::teams->at(viewer_team())) != NULL)
return OBSTRUCTED;
pathfind::marked_route new_route;
//@todo: use something else than empty vector for waypoints?
new_route = resources::controller->get_mouse_handler_base().get_route(m.get_unit(),m.get_dest_hex(),
std::vector<map_location>(), resources::teams->at(viewer_actions_.team_index()));
resources::teams->at(viewer_actions_.team_index()));
/**
* @todo Is the comparison with getNoPathValue really necessary? An empty route (with cost = 0) is returned