mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-18 05:39:48 +00:00

Only used in one place anymore which already included unit.hpp anyway, so there's no benefit here.
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
/*
|
|
Copyright (C) 2017 - 2024
|
|
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY.
|
|
|
|
See the COPYING file for more details.
|
|
*/
|
|
|
|
#include "actions/undo_dismiss_action.hpp"
|
|
#include "game_board.hpp"
|
|
#include "resources.hpp"
|
|
#include "team.hpp"
|
|
#include "units/unit.hpp"
|
|
|
|
namespace actions
|
|
{
|
|
namespace undo
|
|
{
|
|
dismiss_action::dismiss_action(const unit_const_ptr dismissed)
|
|
: undo_action()
|
|
, dismissed_unit(dismissed->clone())
|
|
{
|
|
}
|
|
|
|
dismiss_action::dismiss_action(const config& cfg, const config& unit_cfg)
|
|
: undo_action(cfg)
|
|
, dismissed_unit(unit::create(unit_cfg))
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Writes this into the provided config.
|
|
*/
|
|
void dismiss_action::write(config & cfg) const
|
|
{
|
|
undo_action::write(cfg);
|
|
dismissed_unit->write(cfg.add_child("unit"));
|
|
}
|
|
|
|
/**
|
|
* Undoes this action.
|
|
* @return true on success; false on an error.
|
|
*/
|
|
bool dismiss_action::undo(int side)
|
|
{
|
|
team ¤t_team = resources::gameboard->get_team(side);
|
|
|
|
current_team.recall_list().add(dismissed_unit);
|
|
execute_undo_umc_wml();
|
|
return true;
|
|
}
|
|
|
|
}
|
|
}
|