Routines to manage units. More...
#include "units/unit.hpp"
#include "ai/manager.hpp"
#include "color.hpp"
#include "deprecation.hpp"
#include "display.hpp"
#include "formatter.hpp"
#include "formula/string_utils.hpp"
#include "game_board.hpp"
#include "game_config.hpp"
#include "game_data.hpp"
#include "game_events/manager.hpp"
#include "game_version.hpp"
#include "lexical_cast.hpp"
#include "log.hpp"
#include "map/map.hpp"
#include "preferences/preferences.hpp"
#include "random.hpp"
#include "resources.hpp"
#include "scripting/game_lua_kernel.hpp"
#include "synced_context.hpp"
#include "team.hpp"
#include "units/abilities.hpp"
#include "units/animation_component.hpp"
#include "units/filter.hpp"
#include "units/formula_manager.hpp"
#include "units/id.hpp"
#include "units/map.hpp"
#include "units/types.hpp"
#include "utils/config_filters.hpp"
#include "variable.hpp"
#include <cassert>
#include <cstdlib>
#include <exception>
#include <iterator>
#include <string_view>
#include <utility>
Go to the source code of this file.
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) |
Functions | |
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 color_t | hp_color_impl (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... | |
static bool | resistance_filter_matches_base (const config &cfg, bool attacker) |
std::string | get_checksum (const unit &u, backwards_compatibility::unit_checksum_version version) |
Gets a checksum for a unit. More... | |
Variables | |
static lg::log_domain | log_unit ("unit") |
Routines to manage units.
Definition in file unit.cpp.
#define DBG_UT LOG_STREAM(debug, log_unit) |
#define ERR_UT LOG_STREAM(err, log_unit) |
#define LOG_UT LOG_STREAM(info, log_unit) |
#define WRN_UT LOG_STREAM(warn, log_unit) |
|
static |
Definition at line 226 of file unit.cpp.
References randomness::generator, and randomness::rng::get_random_int().
Referenced by generate_gender(), and unit::init().
|
static |
Definition at line 238 of file unit.cpp.
References generate_gender(), and string_gender().
std::string get_checksum | ( | const unit & | u, |
backwards_compatibility::unit_checksum_version | version = backwards_compatibility::unit_checksum_version::current |
||
) |
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 | this unit |
version | allows the checksum expected in older replays to be used |
Definition at line 2830 of file unit.cpp.
References config::add_child(), c, config::child_range(), DBG_UT, config::hash(), config::recursive_clear_value(), backwards_compatibility::version_1_16_or_older, 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 214 of file unit.cpp.
References unit_type::check_id(), unit_type_data::find(), i, and unit_types.
Referenced by unit::expire_modifications(), wfl::gamestate_function_symbol_table::gamestate_function_symbol_table(), and unit::init().
|
static |
Definition at line 1151 of file unit.cpp.
Referenced by unit::hp_color(), and unit::hp_color_max().
|
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 1272 of file unit.cpp.
Referenced by unit::expire_modifications().
|
static |
Definition at line 1772 of file unit.cpp.
References config::has_attribute().
Referenced by unit::resistance_against().
|
static |