unit.cpp File Reference

Routines to manage units. More...

#include "global.hpp"
#include "game_config.hpp"
#include "game_errors.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "pathfind.hpp"
#include "random.hpp"
#include "unit.hpp"
#include "unit_types.hpp"
#include "unit_abilities.hpp"
#include "util.hpp"
#include "serialization/string_utils.hpp"
#include "halo.hpp"
#include "game_display.hpp"
#include "gamestatus.hpp"
#include "actions.hpp"
#include "game_events.hpp"
#include "sound.hpp"
#include "sdl_utils.hpp"
#include "terrain_filter.hpp"
#include "variable.hpp"
#include "callable_objects.hpp"
#include "formula.hpp"
#include <cassert>
#include <climits>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iterator>

Include dependency graph for unit.cpp:

Go to the source code of this file.

Defines

#define DBG_UT   LOG_STREAM(debug, engine)
#define LOG_UT   LOG_STREAM(info, engine)
#define ERR_UT   LOG_STREAM(err, engine)
#define ERR_CONFIG   LOG_STREAM(err, config)

Functions

static bool compare_unit_values (unit const &a, unit const &b)
void sort_units (std::vector< unit > &units)
static void mod_mdr_merge (config &dst, const config &mod, bool delta)
 Helper function for add_modifications.
int team_units (const unit_map &units, unsigned int side)
 Returns the number of units of the given side (team).
int team_upkeep (const unit_map &units, unsigned int side)
unit_map::const_iterator team_leader (unsigned int side, const unit_map &units)
unit_map::iterator find_visible_unit (unit_map &units, const gamemap::location loc, const gamemap &map, const std::vector< team > &teams, const team &current_team, bool see_all)
unit_map::const_iterator find_visible_unit (const unit_map &units, const gamemap::location loc, const gamemap &map, const std::vector< team > &teams, const team &current_team, bool see_all)
team_data calculate_team_data (const team &tm, int side, const unit_map &units)
std::string get_checksum (const unit &u)
 advanceto alignment cost experience gender hitpoints level max_attacks max_experience max_hitpoints max_moves movement movement_type race random_traits resting undead_variation upkeep value zoc [attack] name type range damage number [specials] * [/special] [/attack] anything in: [abilities], [advance_from], [defense], [movement_cost], [resistance], [trait] remove description, description_inactive, name, name_inactive from all tags under [abilities] remove description from all tags under [specials] remove description, male_name, female_name, name from [trait]

Variables

const std::string ModificationTypes [] = { "advance", "trait", "object" }
const size_t NumModificationTypes
static std::vector< const unit * > units_with_cache
 Pointers to units which have data in their internal caches.


Detailed Description

Routines to manage units.

Definition in file unit.cpp.


Define Documentation

#define DBG_UT   LOG_STREAM(debug, engine)

#define ERR_CONFIG   LOG_STREAM(err, config)

Definition at line 58 of file unit.cpp.

#define ERR_UT   LOG_STREAM(err, engine)

Definition at line 57 of file unit.cpp.

#define LOG_UT   LOG_STREAM(info, engine)

Definition at line 56 of file unit.cpp.

Referenced by unit::add_modification(), and unit::generate_traits().


Function Documentation

team_data calculate_team_data ( const team tm,
int  side,
const unit_map units 
)

static bool compare_unit_values ( unit const &  a,
unit const &  b 
) [static]

Definition at line 73 of file unit.cpp.

References unit::experience(), unit::level(), and unit::max_experience().

Referenced by sort_units().

unit_map::const_iterator find_visible_unit ( const unit_map units,
const gamemap::location  loc,
const gamemap map,
const std::vector< team > &  teams,
const team current_team,
bool  see_all 
)

unit_map::iterator find_visible_unit ( unit_map units,
const gamemap::location  loc,
const gamemap map,
const std::vector< team > &  teams,
const team current_team,
bool  see_all 
)

std::string get_checksum ( const unit u  ) 

advanceto alignment cost experience gender hitpoints level max_attacks max_experience max_hitpoints max_moves movement movement_type race random_traits resting undead_variation upkeep value zoc [attack] name type range damage number [specials] * [/special] [/attack] anything in: [abilities], [advance_from], [defense], [movement_cost], [resistance], [trait] remove description, description_inactive, name, name_inactive from all tags under [abilities] remove description from all tags under [specials] remove description, male_name, female_name, name from [trait]

Gets a checksum for a unit.

Definition at line 2990 of file unit.cpp.

References config::add_child(), unit::attacks(), config::clear_children(), DBG_UT, config::get_children(), config::hash(), config::recursive_clear_value(), and unit::write().

Referenced by replay::add_unit_checksum(), check_checksums(), and recruit_unit().

static void mod_mdr_merge ( config dst,
const config mod,
bool  delta 
) [static]

Helper function for add_modifications.

Definition at line 2311 of file unit.cpp.

References boost::foreach_detail_::end(), and config::values.

Referenced by unit::add_modification().

void sort_units ( std::vector< unit > &  units  ) 

Definition at line 84 of file unit.cpp.

References compare_unit_values().

Referenced by do_replay_handle(), and events::menu_handler::recall().

unit_map::const_iterator team_leader ( unsigned int  side,
const unit_map units 
)

int team_units ( const unit_map units,
unsigned int  team_num 
)

Returns the number of units of the given side (team).

Definition at line 2831 of file unit.cpp.

References unit_map::begin(), and unit_map::end().

Referenced by calculate_team_data(), reports::generate_report(), and playsingle_controller::play_turn().

int team_upkeep ( const unit_map units,
unsigned int  side 
)

Definition at line 2843 of file unit.cpp.

References unit_map::begin(), and unit_map::end().

Referenced by calculate_team_data(), and play_controller::init_side().


Variable Documentation

const std::string ModificationTypes[] = { "advance", "trait", "object" } [static]

Definition at line 61 of file unit.cpp.

Referenced by unit::apply_modifications(), and unit::remove_temporary_modifications().

const size_t NumModificationTypes [static]

Initial value:

Definition at line 62 of file unit.cpp.

Referenced by unit::apply_modifications(), and unit::remove_temporary_modifications().

std::vector<const unit *> units_with_cache [static]

Pointers to units which have data in their internal caches.

The destructor of an unit removes itself from the cache, so the pointers are always valid.

Definition at line 70 of file unit.cpp.

Referenced by unit::clear_status_caches(), unit::invisible(), and unit::~unit().


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs