wip on ai aspect modification via [modify_side],
...plus fix of one of the assertion failures after recruitment on choose-your-recruits era
This commit is contained in:
parent
73c08f9a18
commit
5efa22b029
4 changed files with 34 additions and 4 deletions
|
@ -697,15 +697,18 @@ void recruit_result::do_check_after()
|
|||
const gamemap& map = info.map;
|
||||
if (!map.on_board(recruit_location_)){
|
||||
set_error(AI_ACTION_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
const unit_map& units = info.units;
|
||||
unit_map::const_iterator unit = units.find(recruit_location_);
|
||||
if (unit==units.end()){
|
||||
set_error(AI_ACTION_FAILURE);
|
||||
return;
|
||||
}
|
||||
if (unit->second.side()!=get_side()){
|
||||
set_error(AI_ACTION_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -115,6 +115,15 @@ interface& holder::get_ai_ref()
|
|||
}
|
||||
|
||||
|
||||
void holder::modify_ai_config_old( const config::const_child_itors &ai_parameters )
|
||||
{
|
||||
// only handle aspects
|
||||
// transform ai_parameters to new-style config
|
||||
// if not initialized, append that config to the bottom of base cfg, return
|
||||
// else run 'add_facet' command on aspect
|
||||
|
||||
}
|
||||
|
||||
config holder::to_config() const
|
||||
{
|
||||
if (!this->ai_) {
|
||||
|
@ -643,6 +652,12 @@ void manager::clear_ais()
|
|||
// =======================================================================
|
||||
// Work with active AI parameters
|
||||
// =======================================================================
|
||||
|
||||
void manager::modify_active_ai_config_old_for_side ( side_number side, const config::const_child_itors &ai_parameters )
|
||||
{
|
||||
get_active_ai_holder_for_side(side).modify_ai_config_old(ai_parameters);
|
||||
}
|
||||
|
||||
std::string manager::get_active_ai_identifier_for_side( side_number side )
|
||||
{
|
||||
return get_active_ai_holder_for_side(side).get_ai_identifier();
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
|
||||
const std::string describe_ai();
|
||||
|
||||
void modify_ai_config_old( const config::const_child_itors &ai_parameters );
|
||||
|
||||
config to_config() const;
|
||||
|
||||
const std::string get_ai_identifier() const;
|
||||
|
@ -487,6 +489,16 @@ public:
|
|||
// SET active AI parameters
|
||||
// =======================================================================
|
||||
|
||||
|
||||
/**
|
||||
* Modifies AI parameters for active AI of the given @a side.
|
||||
* This function is provided for backward-compatability with [modify_side][ai]...[/ai][/modify_side]
|
||||
* It can only add new facets to aspects
|
||||
* @param side side_number (1-based, as in game_info).
|
||||
* @param ai_parameters AI paramters to be modified.
|
||||
*/
|
||||
static void modify_active_ai_config_old_for_side ( side_number side, const config::const_child_itors &ai_parameters );
|
||||
|
||||
/**
|
||||
* Sets AI parameters for active AI of the given @a side.
|
||||
* @note Running this command may invalidate references previously returned
|
||||
|
|
|
@ -897,14 +897,14 @@ WML_HANDLER_FUNCTION(modify_side, /*event_info*/, cfg)
|
|||
if (!village_gold.empty()) {
|
||||
teams[team_index].set_village_gold(lexical_cast_default<int>(village_gold));
|
||||
}
|
||||
// Override AI parameters
|
||||
if (ai.first != ai.second) {
|
||||
//@todo 1.7: allow to change ai parameters in-flight
|
||||
}
|
||||
// Redeploy ai from location (this ignores current AI parameters)
|
||||
if (!switch_ai.empty()) {
|
||||
ai::manager::add_ai_for_side_from_file(side_num,switch_ai,true);
|
||||
}
|
||||
// Override AI parameters
|
||||
if (ai.first != ai.second) {
|
||||
ai::manager::modify_active_ai_config_old_for_side(side_num,ai);
|
||||
}
|
||||
// Add shared view to current team
|
||||
if (!share_view.empty()){
|
||||
teams[team_index].set_share_view(utils::string_bool(share_view, true));
|
||||
|
|
Loading…
Add table
Reference in a new issue