fixup a20f221e83
and improve advance_unit() interface
This commit is contained in:
parent
a20f221e83
commit
16d5221934
3 changed files with 11 additions and 13 deletions
|
@ -133,7 +133,7 @@ namespace
|
|||
}
|
||||
else {
|
||||
const config &mod_option = mod_options[choice - options.size()];
|
||||
::advance_unit(loc, "", fire_event, &mod_option);
|
||||
::advance_unit(loc, &mod_option, fire_event);
|
||||
}
|
||||
|
||||
u = resources::units->find(loc);
|
||||
|
@ -314,8 +314,7 @@ unit_ptr get_amla_unit(const unit &u, const config &mod_option)
|
|||
}
|
||||
|
||||
|
||||
void advance_unit(map_location loc, const std::string &advance_to,
|
||||
const bool &fire_event, const config * mod_option)
|
||||
void advance_unit(map_location loc, const tadvancement_option &advance_to, bool fire_event)
|
||||
{
|
||||
unit_map::unit_iterator u = resources::units->find(loc);
|
||||
if(!u.valid()) {
|
||||
|
@ -346,9 +345,9 @@ void advance_unit(map_location loc, const std::string &advance_to,
|
|||
std::vector<int> not_seeing = actions::get_sides_not_seeing(*u);
|
||||
|
||||
// Create the advanced unit.
|
||||
bool use_amla = mod_option != nullptr;
|
||||
unit_ptr new_unit = use_amla ? get_amla_unit(*u, *mod_option) :
|
||||
get_advanced_unit(*u, advance_to);
|
||||
bool use_amla = boost::get<std::string>(&advance_to) == nullptr;
|
||||
unit_ptr new_unit = use_amla ? get_amla_unit(*u, *boost::get<const config*>(advance_to)) :
|
||||
get_advanced_unit(*u, boost::get<std::string>(advance_to));
|
||||
if ( !use_amla )
|
||||
{
|
||||
statistics::advance_unit(*new_unit);
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Various functions that implement attacks and attack calculations.
|
||||
* Unit advancements are also included, as they usually occur as a
|
||||
* result of combat.
|
||||
* Various functions that implement advancements of units.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -65,12 +63,14 @@ unit_ptr get_advanced_unit(const unit &u, const std::string &advance_to);
|
|||
*/
|
||||
unit_ptr get_amla_unit(const unit &u, const config &mod_option);
|
||||
|
||||
using tadvancement_option = boost::variant<std::string /*change type*/, const config* /*apply amla*/>;
|
||||
|
||||
/**
|
||||
* Function which will advance the unit at @a loc to 'advance_to'.
|
||||
* (Unless mod_option is supplied, in which case an AMLA is performed.)
|
||||
* which is eigher a type to advance to or a config containing the
|
||||
* [advancement] to perform an amla.
|
||||
* Note that 'loc' is not a reference, because if it were a reference,
|
||||
* we couldn't safely pass in a reference to the item in the map
|
||||
* that we're going to delete, since deletion would invalidate the reference.
|
||||
*/
|
||||
void advance_unit(map_location loc, const std::string &advance_to,
|
||||
const bool &fire_event = true, const config * mod_option = nullptr);
|
||||
void advance_unit(map_location loc, const tadvancement_option &advance_to, bool fire_event = true);
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include "addon/manager.hpp" // for get_installed_addons
|
||||
#include "config_assign.hpp"
|
||||
#include "dialogs.hpp"
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "generators/map_create.hpp"
|
||||
|
|
Loading…
Add table
Reference in a new issue