remove undo_stack parameter from move_unit

it was only there for the ai code to skip undo which it no longer does
This commit is contained in:
gfgtdf 2024-11-11 17:18:01 +01:00 committed by sevu
parent a6cd4441c9
commit d0050dac8e
6 changed files with 15 additions and 18 deletions

View file

@ -204,7 +204,7 @@ namespace { // Private helpers for move_unit()
/** Attempts to move the unit along the expected path. */
void try_actual_movement(bool show);
/** Does some bookkeeping and event firing, for use after movement. */
void post_move(undo_list *undo_stack);
void post_move();
/** Shows the various on-screen messages, for use after movement. */
void feedback() const;
/** Attempts to teleport the unit to a map_location. */
@ -1094,15 +1094,16 @@ namespace { // Private helpers for move_unit()
wml_undo_disabled_ |= wml_undo_blocked;
}
post_move(resources::undo_stack);
post_move();
}
/**
* Does some bookkeeping and event firing, for use after movement.
* This includes village capturing and the undo stack.
*/
void unit_mover::post_move(undo_list *undo_stack)
void unit_mover::post_move()
{
auto* undo_stack = resources::undo_stack;
const map_location & final_loc = final_hex();
int orig_village_owner = 0;
@ -1247,7 +1248,7 @@ namespace { // Private helpers for move_unit()
}//end anonymous namespace
static std::size_t move_unit_internal(undo_list* undo_stack,
static std::size_t move_unit_internal(
bool show_move, bool* interrupted, unit_mover& mover)
{
show_move = show_move && !resources::controller->is_skipping_actions();
@ -1277,7 +1278,7 @@ static std::size_t move_unit_internal(undo_list* undo_stack,
// Bookkeeping, etc.
// also fires the moveto event
mover.post_move(undo_stack);
mover.post_move();
if (show_move) {
mover.feedback();
}
@ -1347,7 +1348,7 @@ void teleport_unit_from_replay(const std::vector<map_location> &steps,
* than steps.size() ).
*/
std::size_t move_unit_and_record(const std::vector<map_location> &steps,
undo_list* undo_stack, bool continued_move, bool show_move,
bool continued_move, bool show_move,
bool* interrupted, move_unit_spectator* move_spectator)
{
@ -1377,7 +1378,7 @@ std::size_t move_unit_and_record(const std::vector<map_location> &steps,
*/
resources::recorder->add_synced_command("move",replay_helper::get_movement(steps, continued_move, skip_ally_sighted));
set_scontext_synced sync;
std::size_t r = move_unit_internal(undo_stack, show_move, interrupted, mover);
std::size_t r = move_unit_internal(show_move, interrupted, mover);
resources::controller->check_victory();
resources::controller->maybe_throw_return_to_play_side();
sync.do_final_checkup();
@ -1386,13 +1387,12 @@ std::size_t move_unit_and_record(const std::vector<map_location> &steps,
else
{
//we are already in synced mode and don't need to reenter it again.
return move_unit_internal(undo_stack, show_move, interrupted, mover);
return move_unit_internal(show_move, interrupted, mover);
}
}
std::size_t move_unit_from_replay(const std::vector<map_location> &steps,
undo_list* undo_stack, bool continued_move, bool skip_ally_sighted,
bool show_move)
bool continued_move, bool skip_ally_sighted, bool show_move)
{
// Evaluate this move.
unit_mover mover(steps, nullptr, continued_move,skip_ally_sighted);
@ -1402,7 +1402,7 @@ std::size_t move_unit_from_replay(const std::vector<map_location> &steps,
return 0;
}
return move_unit_internal(undo_stack, show_move, nullptr, mover);
return move_unit_internal(show_move, nullptr, mover);
}

View file

@ -122,7 +122,6 @@ void teleport_unit_from_replay(
*/
std::size_t move_unit_and_record(
const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move = false,
bool show_move = true,
bool* interrupted = nullptr,
@ -134,7 +133,6 @@ std::size_t move_unit_and_record(
*/
std::size_t move_unit_from_replay(
const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move,
bool skip_ally_sighted,
bool show_move = true);

View file

@ -467,7 +467,6 @@ void move_result::do_execute()
if (from_ != to_) {
std::size_t num_steps = ::actions::move_unit_and_record(
/*std::vector<map_location> steps*/ route_->steps,
/*::actions::undo_list* undo_stack*/ nullptr,
/*bool continue_move*/ true,
/*bool show_move*/ true,
/*bool* interrupted*/ nullptr,

View file

@ -884,7 +884,7 @@ void menu_handler::move_unit_to_loc(const unit_map::iterator& ui,
{
LOG_NG << "move_unit_to_loc " << route.steps.front() << " to " << route.steps.back();
actions::move_unit_and_record(route.steps, &pc_.get_undo_stack(), continue_move);
actions::move_unit_and_record(route.steps, continue_move);
}
mousehandler.deselect_hex();
@ -962,7 +962,7 @@ void menu_handler::execute_gotos(mouse_handler& mousehandler, int side)
{
LOG_NG << "execute goto from " << route.steps.front() << " to " << route.steps.back();
int moves = actions::move_unit_and_record(route.steps, &pc_.get_undo_stack());
int moves = actions::move_unit_and_record(route.steps);
change = moves > 0;
}

View file

@ -1264,7 +1264,7 @@ std::size_t mouse_handler::move_unit_along_route(const std::vector<map_location>
}
LOG_NG << "move unit along route from " << steps.front() << " to " << steps.back();
std::size_t moves = actions::move_unit_and_record(steps, &pc_.get_undo_stack(), false, true, &interrupted);
std::size_t moves = actions::move_unit_and_record(steps, false, true, &interrupted);
cursor::set(cursor::NORMAL);
gui().invalidate_game_status();

View file

@ -312,7 +312,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(move, child, spectator)
{
show_move = show_move && !prefs::get().skip_ai_moves();
}
actions::move_unit_from_replay(steps, resources::undo_stack, skip_sighted, skip_ally_sighted, show_move);
actions::move_unit_from_replay(steps, skip_sighted, skip_ally_sighted, show_move);
return true;
}