wesnoth/src/race.hpp
Thonsew 3a41db7acd Updated unit_types to use t_token...
...in place of std::string and to replace std::map with
boost::unordered_map in the t_move_cost_cache, both to increase speed.
2011-09-08 19:17:31 +00:00

73 lines
2.0 KiB
C++

/* $Id$ */
/*
Copyright (C) 2003 - 2011 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef RACE_HPP_INCLUDED
#define RACE_HPP_INCLUDED
#include "config.hpp"
#include "serialization/string_utils.hpp"
namespace rand_rng {
class simple_rng;
} // namespace rand_rng
typedef std::map<wide_string, std::vector<wchar_t> > markov_prefix_map;
class unit_race
{
public:
enum GENDER { MALE, FEMALE, NUM_GENDERS };
unit_race();
unit_race(const config& cfg);
const config& get_cfg() const { return cfg_; };
const config::t_token& id() const { return id_; };
const t_string& name(GENDER gender=MALE) const { return name_[gender]; };
const t_string& plural_name() const { return plural_name_; };
const t_string& description() const { return description_; };
config::t_token generate_name(GENDER gender, rand_rng::simple_rng* rng = 0) const;
bool uses_global_traits() const;
const config::const_child_itors &additional_traits() const;
const config::const_child_itors &additional_topics() const;
unsigned int num_traits() const;
private:
const config cfg_;
config::t_token id_;
t_string name_[NUM_GENDERS];
t_string plural_name_;
t_string description_;
unsigned int ntraits_;
markov_prefix_map next_[NUM_GENDERS];
int chain_size_;
config::const_child_itors traits_;
config::const_child_itors topics_;
bool global_traits_;
};
unit_race::GENDER string_gender(const config::t_token& str,unit_race::GENDER def=unit_race::MALE);
config::t_token const& gender_string(unit_race::GENDER gender);
typedef boost::unordered_map<config::t_token,unit_race> race_map;
#endif