Fixed an assertion failure in delayed fog-of-war update code
(apply_shroud_changes(...)). Specifically, the code had an implicit dependency on a unit only being moved once per turn. This has been fixed.
This commit is contained in:
parent
7e1e93a82c
commit
d06c918024
3 changed files with 9 additions and 9 deletions
|
@ -1558,7 +1558,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
|
|||
apply_shroud_changes(*undo_stack,disp,status,map,gamedata,units,teams,team_num);
|
||||
undo_stack->clear();
|
||||
} else {
|
||||
undo_stack->push_back(undo_action(steps,starting_moves,orig_village_owner));
|
||||
undo_stack->push_back(undo_action(u,steps,starting_moves,orig_village_owner));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1692,12 +1692,10 @@ void apply_shroud_changes(undo_list& undos, display* disp, const gamestatus& sta
|
|||
*/
|
||||
for(undo_list::const_iterator un = undos.begin(); un != undos.end(); ++un) {
|
||||
if(un->is_recall()) continue;
|
||||
unit_map::const_iterator ui = units.find(un->route.back());
|
||||
unit_map um;
|
||||
assert(ui != units.end());
|
||||
std::vector<gamemap::location>::const_iterator step;
|
||||
for(step = un->route.begin(); step != un->route.end(); ++step) {
|
||||
um.insert(std::pair<gamemap::location,unit>(*step,ui->second));
|
||||
um.insert(std::pair<gamemap::location,unit>(*step,un->affected_unit));
|
||||
clear_shroud_unit(map,status,gamedata,um,*step,teams,team,NULL,NULL);
|
||||
um.erase(*step);
|
||||
}
|
||||
|
|
|
@ -161,14 +161,16 @@ int combat_modifier(const gamestatus& status,
|
|||
|
||||
//structure which records information to be able to undo a movement
|
||||
struct undo_action {
|
||||
undo_action(const std::vector<gamemap::location>& rt,int sm,int orig=-1)
|
||||
: route(rt), starting_moves(sm), original_village_owner(orig), recall_pos(-1) {}
|
||||
undo_action(const gamemap::location& loc, int pos) : recall_loc(loc), recall_pos(pos) {}
|
||||
undo_action(unit u,const std::vector<gamemap::location>& rt,int sm,int orig=-1)
|
||||
: affected_unit(u), route(rt), starting_moves(sm), original_village_owner(orig), recall_pos(-1) {}
|
||||
undo_action(unit u,const gamemap::location& loc, int pos)
|
||||
: affected_unit(u), recall_loc(loc), recall_pos(pos) {}
|
||||
std::vector<gamemap::location> route;
|
||||
int starting_moves;
|
||||
int original_village_owner;
|
||||
gamemap::location recall_loc;
|
||||
int recall_pos;
|
||||
unit affected_unit;
|
||||
bool is_recall() const { return recall_pos >= 0; }
|
||||
};
|
||||
|
||||
|
|
|
@ -1109,7 +1109,7 @@ void turn_info::end_unit_turn()
|
|||
un->second.movement_left() >= 0) {
|
||||
std::vector<gamemap::location> steps;
|
||||
steps.push_back(selected_hex_);
|
||||
undo_stack_.push_back(undo_action(steps,un->second.movement_left(),-1));
|
||||
undo_stack_.push_back(undo_action(un->second,steps,un->second.movement_left(),-1));
|
||||
redo_stack_.clear();
|
||||
un->second.end_unit_turn();
|
||||
gui_.draw_tile(selected_hex_.x,selected_hex_.y);
|
||||
|
@ -1722,7 +1722,7 @@ void turn_info::recall()
|
|||
current_team.spend_gold(game_config::recall_cost);
|
||||
recorder.add_recall(res,loc);
|
||||
|
||||
undo_stack_.push_back(undo_action(loc,res));
|
||||
undo_stack_.push_back(undo_action(un,loc,res));
|
||||
redo_stack_.clear();
|
||||
|
||||
recall_list.erase(recall_list.begin()+res);
|
||||
|
|
Loading…
Add table
Reference in a new issue