Routines to manage units. More...
#include "units/unit.hpp"#include "global.hpp"#include "display_context.hpp"#include "formula/string_utils.hpp"#include "game_board.hpp"#include "game_data.hpp"#include "game_config.hpp"#include "game_errors.hpp"#include "game_events/manager.hpp"#include "game_preferences.hpp"#include "gettext.hpp"#include "log.hpp"#include "utils/make_enum.hpp"#include "map/map.hpp"#include "random_new.hpp"#include "resources.hpp"#include "scripting/game_lua_kernel.hpp"#include "synced_context.hpp"#include "side_filter.hpp"#include "team.hpp"#include "terrain/filter.hpp"#include "units/abilities.hpp"#include "units/animation.hpp"#include "units/animation_component.hpp"#include "units/filter.hpp"#include "units/formula_manager.hpp"#include "units/id.hpp"#include "units/map.hpp"#include "variable.hpp"#include "utils/functional.hpp"#include <boost/intrusive_ptr.hpp>#include <boost/function_output_iterator.hpp>#include <boost/range/begin.hpp>#include <boost/range/end.hpp>#include <boost/range/algorithm.hpp>#include <cassert>#include <cstdlib>#include <exception>#include <iterator>#include <new>#include <ostream>#include <SDL_video.h>
Go to the source code of this file.
Classes | |
| struct | ptr_vector_pushback |
Namespaces | |
| t_translation | |
Macros | |
| #define | DBG_UT LOG_STREAM(debug, log_unit) |
| #define | LOG_UT LOG_STREAM(info, log_unit) |
| #define | WRN_UT LOG_STREAM(warn, log_unit) |
| #define | ERR_UT LOG_STREAM(err, log_unit) |
| #define | ERR_NG LOG_STREAM(err, log_engine) |
| #define | WRN_CF LOG_STREAM(warn, log_config) |
| #define | ERR_CONFIG LOG_STREAM(err, log_config) |
| #define | LOG_RG LOG_STREAM(info, log_enginerefac) |
Functions | |
| void | intrusive_ptr_add_ref (const unit *u) |
| Intrusive Pointer interface. More... | |
| void | intrusive_ptr_release (const unit *u) |
| static const unit_type & | get_unit_type (const std::string &type_id) |
| Converts a string ID to a unit_type. More... | |
| static unit_race::GENDER | generate_gender (const unit_type &type, bool random_gender) |
| static unit_race::GENDER | generate_gender (const unit_type &u_type, const config &cfg) |
| static SDL_Color | hp_color_ (int hitpoints, int max_hitpoints) |
| bool | mod_duration_match (const std::string &mod_dur, const std::string &goal_dur) |
| Determines if mod_dur "matches" goal_dur. More... | |
| std::string | get_checksum (const unit &u) |
| Gets a checksum for a unit. More... | |
Variables | |
| static lg::log_domain | log_unit ("unit") |
| static lg::log_domain | log_engine ("engine") |
| static lg::log_domain | log_config ("config") |
| static lg::log_domain | log_enginerefac ("enginerefac") |
Routines to manage units.
Definition in file unit.cpp.
| #define DBG_UT LOG_STREAM(debug, log_unit) |
Definition at line 77 of file unit.cpp.
Referenced by get_checksum(), unit::invisible(), and unit_movement_resetter::~unit_movement_resetter().
| #define ERR_CONFIG LOG_STREAM(err, log_config) |
| #define ERR_NG LOG_STREAM(err, log_engine) |
| #define ERR_UT LOG_STREAM(err, log_unit) |
Definition at line 80 of file unit.cpp.
Referenced by unit::~unit().
| #define LOG_RG LOG_STREAM(info, log_enginerefac) |
| #define LOG_UT LOG_STREAM(info, log_unit) |
Definition at line 78 of file unit.cpp.
Referenced by unit::apply_builtin_effect(), unit::generate_traits(), intrusive_ptr_add_ref(), and intrusive_ptr_release().
| #define WRN_CF LOG_STREAM(warn, log_config) |
| #define WRN_UT LOG_STREAM(warn, log_unit) |
Definition at line 79 of file unit.cpp.
Referenced by unit::advances_to_translated(), unit::apply_builtin_effect(), unit::clone(), and unit::parse_upkeep().
|
static |
Definition at line 208 of file unit.cpp.
References unit_type::genders(), random_new::generator, and random_new::rng::get_random_int().
Referenced by generate_gender().
|
static |
Definition at line 225 of file unit.cpp.
References generate_gender(), and string_gender().
| std::string get_checksum | ( | const unit & | u | ) |
Gets a checksum for a unit.
In MP games the descriptions are locally generated and might differ, so it should be possible to discard them. Not sure whether replays suffer the same problem.
| u | the unit |
Definition at line 2511 of file unit.cpp.
References config::add_child(), config::child_range(), DBG_UT, config::hash(), i, config::recursive_clear_value(), and unit::write().
Referenced by replay::add_unit_checksum().
|
static |
Converts a string ID to a unit_type.
Throws a game_error exception if the string does not correspond to a type.
Definition at line 196 of file unit.cpp.
References unit_type::check_id(), error(), unit_type_data::find(), i, and unit_types.
Referenced by game_logic::ai_function_symbol_table::ai_function_symbol_table(), and unit::expire_modifications().
Definition at line 1028 of file unit.cpp.
Referenced by unit::hp_color().
Intrusive Pointer interface.
Definition at line 164 of file unit.cpp.
References unit::id(), LOG_UT, unit::ref_count(), unit::ref_count_, and unit::underlying_id().
Definition at line 180 of file unit.cpp.
References unit::id(), LOG_UT, unit::ref_count(), unit::ref_count_, and unit::underlying_id().
|
inline |
Determines if mod_dur "matches" goal_dur.
If goal_dur is not empty, they match if they are equal. If goal_dur is empty, they match if mod_dur is neither empty nor "forever". Helper function for expire_modifications().
Definition at line 1164 of file unit.cpp.
Referenced by unit::expire_modifications().
|
static |
|
static |
|
static |
|
static |
1.8.8