The Battle for Wesnoth  1.19.5+dev
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
unit_type_data Class Reference

#include <types.hpp>

Public Types

typedef std::map< std::string, unit_typeunit_type_map
 

Public Member Functions

 unit_type_data (const unit_type_data &)=delete
 
unit_type_dataoperator= (const unit_type_data &)=delete
 
 unit_type_data ()
 
const unit_type_maptypes () const
 
const race_mapraces () const
 
const movement_type_mapmovement_types () const
 
config_array_view traits () const
 
void set_config (const game_config_view &cfg)
 Resets all data based on the provided config. More...
 
const unit_typefind (const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
 Finds a unit_type by its id() and makes sure it is built to the specified level. More...
 
void check_types (const std::vector< std::string > &types) const
 
const unit_racefind_race (const std::string &) const
 
void build_all (unit_type::BUILD_STATUS status)
 Makes sure the all unit_types are built to the specified level. More...
 
void build_unit_type (const unit_type &ut, unit_type::BUILD_STATUS status) const
 Makes sure the provided unit_type is built to the specified level. More...
 
bool hide_help (const std::string &type_id, const std::string &race_id) const
 Checks if the [hide_help] tag contains these IDs. More...
 
void apply_scenario_fix (const config &cfg)
 
void remove_scenario_fixes ()
 

Private Member Functions

void read_hide_help (const config &cfg)
 Parses the [hide_help] tag. More...
 
void clear ()
 
void apply_base_unit (unit_type &type, std::vector< std::string > &base_tree)
 Modifies the provided config by merging all base units into it. More...
 
const game_config_viewunits_cfg () const
 

Private Attributes

unit_type_map types_
 
movement_type_map movement_types_
 
race_map races_
 
bool hide_help_all_
 True if [hide_help] contains a 'all=yes' at its root. More...
 
std::vector< std::set< std::string > > hide_help_type_
 
std::vector< std::set< std::string > > hide_help_race_
 
game_config_view units_cfg_
 
unit_type::BUILD_STATUS build_status_
 

Detailed Description

Definition at line 386 of file types.hpp.

Member Typedef Documentation

◆ unit_type_map

typedef std::map<std::string,unit_type> unit_type_data::unit_type_map

Definition at line 394 of file types.hpp.

Constructor & Destructor Documentation

◆ unit_type_data() [1/2]

unit_type_data::unit_type_data ( const unit_type_data )
delete

◆ unit_type_data() [2/2]

unit_type_data::unit_type_data ( )

Definition at line 876 of file types.cpp.

Member Function Documentation

◆ apply_base_unit()

void unit_type_data::apply_base_unit ( unit_type type,
std::vector< std::string > &  base_tree 
)
private

Modifies the provided config by merging all base units into it.

The base_tree parameter is used for detecting and reporting cycles of base units and in particular to prevent infinite loops.

Definition at line 995 of file types.cpp.

References ERR_CF, unit_type::get_cfg(), and types_.

Referenced by set_config().

◆ apply_scenario_fix()

void unit_type_data::apply_scenario_fix ( const config cfg)

Definition at line 1432 of file types.cpp.

References types_.

Referenced by play_controller::play_controller().

◆ build_all()

void unit_type_data::build_all ( unit_type::BUILD_STATUS  status)

Makes sure the all unit_types are built to the specified level.

Definition at line 1307 of file types.cpp.

References build_status_, build_unit_type(), gui2::dialogs::loading_screen::progress(), and types_.

Referenced by unit_type::advances_from(), ai::formula_ai::get_value(), help::init_help(), and set_config().

◆ build_unit_type()

void unit_type_data::build_unit_type ( const unit_type ut,
unit_type::BUILD_STATUS  status 
) const

◆ check_types()

void unit_type_data::check_types ( const std::vector< std::string > &  types) const

Definition at line 1286 of file types.cpp.

References find(), and types().

Referenced by unit::set_advances_to(), and unit::set_recruits().

◆ clear()

void unit_type_data::clear ( )
private

◆ find()

const unit_type * unit_type_data::find ( const std::string &  key,
unit_type::BUILD_STATUS  status = unit_type::FULL 
) const

Finds a unit_type by its id() and makes sure it is built to the specified level.

Definition at line 1265 of file types.cpp.

References build_unit_type(), DBG_CF, and types_.

Referenced by advancement_tree_internal(), unit::advances_to_translated(), unit::apply_builtin_effect(), events::menu_handler::can_recruit(), check_types(), ai::default_recruitment::recruitment::compare_unit_types(), actions::undo_list::create_action(), wb::recruit::create_corresponding_unit(), wfl::gamestate::DEFINE_WFL_FUNCTION(), ai::default_recruitment::recruitment::do_combat_analysis(), events::console_handler::do_create(), ai::recruit_result::do_execute(), ai::default_recruitment::recruitment::do_similarity_penalty(), ai::default_recruitment::recruitment::execute(), unit_filter_impl::unit_filter_compound::fill(), ng::flg_manager::flg_manager(), help::generate_faction_topics(), gui2::dialogs::mp_join_game::generate_side_list(), get_advanced_unit(), ai::default_recruitment::recruitment::get_average_defense(), ai::default_recruitment::recruitment::get_cheapest_unit_cost_for_leader(), ai::default_recruitment::recruitment::get_cost_map_of_side(), get_unit_type(), ai::recruit_result::get_unit_type_known(), ai::formula_ai::get_value(), ai::helper_advance_unit(), impl_unit_type_lookup(), intf_add_known_unit(), game_lua_kernel::intf_find_cost_map(), intf_transform_unit(), gui2::dialogs::editor_edit_unit::load_unit_type(), help::make_unit_link(), team::minimum_recruit_price(), gui2::dialogs::faction_select::on_faction_select(), gui2::dialogs::faction_select::on_leader_select(), gui2::dialogs::statistics_dialog::on_primary_list_select(), help::unit_topic_generator::operator()(), gui2::dialogs::faction_select::profile_button_callback(), ai::default_recruitment::recruitment::recall_unit_value(), wb::recruit::recruit(), events::menu_handler::recruit(), ai::default_recruitment::recruitment::recruit_matches_type(), ng::flg_manager::resolve_random(), help::show_unit_description(), statistics_t::sum_cost_str_int_map(), SYNCED_COMMAND_HANDLER_FUNCTION(), editor::mouse_action_unit::up_left(), ng::flg_manager::update_available_genders(), ai::default_recruitment::recruitment::update_average_local_cost(), gui2::dialogs::mp_staging::update_leader_display(), and gui2::dialogs::faction_select::update_leader_image().

◆ find_race()

const unit_race * unit_type_data::find_race ( const std::string &  key) const

◆ hide_help()

bool unit_type_data::hide_help ( const std::string &  type_id,
const std::string &  race_id 
) const

Checks if the [hide_help] tag contains these IDs.

Definition at line 1352 of file types.cpp.

References hide_help_all_, hide_help_race_, and hide_help_type_.

Referenced by unit_type::hide_help(), and set_config().

◆ movement_types()

const movement_type_map& unit_type_data::movement_types ( ) const
inline

Definition at line 398 of file types.hpp.

References movement_types_.

Referenced by gui2::dialogs::editor_edit_unit::pre_show().

◆ operator=()

unit_type_data& unit_type_data::operator= ( const unit_type_data )
delete

◆ races()

const race_map& unit_type_data::races ( ) const
inline

◆ read_hide_help()

void unit_type_data::read_hide_help ( const config cfg)
private

Parses the [hide_help] tag.

Definition at line 1323 of file types.cpp.

References hide_help_race_, hide_help_type_, config::optional_child(), races(), utils::split(), types(), and types_.

Referenced by set_config().

◆ remove_scenario_fixes()

void unit_type_data::remove_scenario_fixes ( )

Definition at line 1467 of file types.cpp.

References types_.

Referenced by play_controller::~play_controller().

◆ set_config()

void unit_type_data::set_config ( const game_config_view cfg)

Resets all data based on the provided config.

This includes some processing of the config, such as expanding base units. A pointer to the config is stored, so the config must be persistent.

The data to read from is in [terrain_defaults][subtag], and corresponds to [movetype][subtag]

Deprecated names used in 1.14.0's [terrain_defaults]. For [defense] the name didn't change.

Definition at line 1103 of file types.cpp.

References apply_base_unit(), build_all(), game_config_view::child_range(), clear(), unit_type::CREATED, DBG_CF, DBG_UT, ERR_CF, hide_help(), hide_help_all_, unit_race::id(), lg::info(), LOG_CONFIG, LOG_UT, movement_types_, game_config_view::optional_child(), gui2::dialogs::loading_screen::progress(), races_, read_hide_help(), types_, units_cfg_, and movetype::UNREACHABLE.

Referenced by test_utils::game_config_manager::game_config_manager(), and game_config_manager::set_unit_data().

◆ traits()

config_array_view unit_type_data::traits ( ) const
inline

Definition at line 399 of file types.hpp.

References game_config_view::child_range(), and units_cfg().

Referenced by help::generate_trait_topics(), and impl_race_get().

◆ types()

const unit_type_map& unit_type_data::types ( ) const
inline

◆ units_cfg()

const game_config_view& unit_type_data::units_cfg ( ) const
inlineprivate

Definition at line 435 of file types.hpp.

References units_cfg_.

Referenced by build_unit_type(), and traits().

Member Data Documentation

◆ build_status_

unit_type::BUILD_STATUS unit_type_data::build_status_
private

Definition at line 437 of file types.hpp.

Referenced by build_all(), and clear().

◆ hide_help_all_

bool unit_type_data::hide_help_all_
private

True if [hide_help] contains a 'all=yes' at its root.

Definition at line 430 of file types.hpp.

Referenced by clear(), hide_help(), and set_config().

◆ hide_help_race_

std::vector< std::set<std::string> > unit_type_data::hide_help_race_
private

Definition at line 433 of file types.hpp.

Referenced by clear(), hide_help(), and read_hide_help().

◆ hide_help_type_

std::vector< std::set<std::string> > unit_type_data::hide_help_type_
private

Definition at line 432 of file types.hpp.

Referenced by clear(), hide_help(), and read_hide_help().

◆ movement_types_

movement_type_map unit_type_data::movement_types_
private

Definition at line 426 of file types.hpp.

Referenced by build_unit_type(), clear(), movement_types(), and set_config().

◆ races_

race_map unit_type_data::races_
private

Definition at line 427 of file types.hpp.

Referenced by build_unit_type(), clear(), find_race(), races(), and set_config().

◆ types_

unit_type_map unit_type_data::types_
mutableprivate

◆ units_cfg_

game_config_view unit_type_data::units_cfg_
private

Definition at line 436 of file types.hpp.

Referenced by set_config(), and units_cfg().


The documentation for this class was generated from the following files: