Classes | |
| struct | t_terrain |
| A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separated by a caret and each group consists of 2 to 4 characters if no second layer is defined it is stored as 0xFFFFFFFF, if the second layer is empty (needed for matching) the layer has the value 0. More... | |
| struct | t_match |
| This structure can be used for matching terrain strings. More... | |
| struct | coordinate |
| Contains an x and y coordinate used for starting positions in maps. More... | |
| struct | error |
Typedefs | |
| typedef Uint32 | t_layer |
| typedef std::vector< t_terrain > | t_list |
| typedef std::vector < std::vector< t_terrain > > | t_map |
Functions | |
| size_t | max_map_size () |
| Return the maximum allowed map size (in either dimension), the maximum map area is, therefore, this value squared. | |
| static t_layer | get_layer_mask_ (t_layer terrain) |
| Get the mask for a single layer. | |
| static t_terrain | get_mask_ (const t_terrain &terrain) |
| Gets a mask for a terrain, this mask is used for wildcard matching. | |
| static t_layer | string_to_layer_ (const std::string &str) |
| Converts a string to a layer. | |
| static t_terrain | string_to_number_ (std::string str, int &start_position, const t_layer filler) |
| Converts a terrain string to a number. | |
| static t_terrain | string_to_number_ (const std::string &str, const t_layer filler=NO_LAYER) |
| static std::string | number_to_string_ (t_terrain terrain, const int start_position=-1) |
| Converts a terrain number to a string. | |
| static t_terrain | string_to_builder_number_ (std::string str) |
| Converts a terrain string to a number for the builder. | |
| const t_match | ALL_FORESTS ("F*,*^F*") |
| t_terrain | read_terrain_code (const std::string &str, const t_layer filler=NO_LAYER) |
| Reads a single terrain from a string. | |
| std::string | write_terrain_code (const t_terrain &tcode) |
| Writes a single terrain code to a string. | |
| t_list | read_list (const std::string &str, const t_layer filler=NO_LAYER) |
| Reads a list of terrains from a string, when reading the. | |
| std::string | write_list (const t_list &list) |
| Writes a list of terrains to a string, only writes the new format. | |
| t_map | read_game_map (const std::string &str, std::map< int, coordinate > &starting_positions) |
| Reads a gamemap string into a 2D vector. | |
| std::string | write_game_map (const t_map &map, std::map< int, coordinate > starting_positions=std::map< int, coordinate >()) |
| Write a gamemap in to a vector string. | |
| bool | terrain_matches (const t_terrain &src, const t_terrain &dest) |
| Tests whether a specific terrain matches an expression, for matching rules see above. | |
| bool | terrain_matches (const t_terrain &src, const t_list &dest) |
| Tests whether a specific terrain matches a list of expressions. | |
| bool | terrain_matches (const t_terrain &src, const t_match &dest) |
| Tests whether a certain terrain matches a list of expressions, for matching rules see above. | |
| bool | has_wildcard (const t_terrain &tcode) |
| Tests whether a terrain code contains a wildcard. | |
| bool | has_wildcard (const t_list &list) |
| Tests whether a terrain-code list contains at least one item with a wildcard. | |
| t_map | read_builder_map (const std::string &str) |
| Reads a builder map. | |
| bool | operator< (const t_terrain &a, const t_terrain &b) |
| bool | operator== (const t_terrain &a, const t_terrain &b) |
| bool | operator!= (const t_terrain &a, const t_terrain &b) |
| t_terrain | operator& (const t_terrain &a, const t_terrain &b) |
| t_terrain | operator| (const t_terrain &a, const t_terrain &b) |
| std::ostream & | operator<< (std::ostream &s, const t_terrain &a) |
Variables | |
| const t_terrain | OFF_MAP_USER = string_to_number_("_off^_usr") |
| const t_terrain | VOID_TERRAIN = string_to_number_("_s") |
| const t_terrain | FOGGED = string_to_number_("_f") |
| const t_terrain | HUMAN_CASTLE = string_to_number_("Ch") |
| const t_terrain | HUMAN_KEEP = string_to_number_("Kh") |
| const t_terrain | SHALLOW_WATER = string_to_number_("Ww") |
| const t_terrain | DEEP_WATER = string_to_number_("Wo") |
| const t_terrain | GRASS_LAND = string_to_number_("Gg") |
| const t_terrain | FOREST = string_to_number_("Gg^Ff") |
| const t_terrain | MOUNTAIN = string_to_number_("Mm") |
| const t_terrain | HILL = string_to_number_("Hh") |
| const t_terrain | CAVE_WALL = string_to_number_("Xu") |
| const t_terrain | CAVE = string_to_number_("Uu") |
| const t_terrain | UNDERGROUND_VILLAGE = string_to_number_("Uu^Vu") |
| const t_terrain | DWARVEN_CASTLE = string_to_number_("Cud") |
| const t_terrain | DWARVEN_KEEP = string_to_number_("Kud") |
| const t_terrain | PLUS = string_to_number_("+") |
| const t_terrain | MINUS = string_to_number_("-") |
| const t_terrain | NOT = string_to_number_("!") |
| const t_terrain | STAR = string_to_number_("*") |
| const t_terrain | BASE = string_to_number_("_bas") |
| const t_match | ALL_HILLS ("!,*^V*,!,H*") |
| const t_match | ALL_MOUNTAINS ("!,*^V*,!,M*") |
| const t_match | ALL_SWAMPS ("!,*^V*,*^B*,!,S*") |
| const t_layer | WILDCARD = 0x2A000000 |
| const t_layer | NO_LAYER = 0xFFFFFFFF |
| const t_terrain | NONE_TERRAIN = t_terrain() |
| const t_match | ALL_FORESTS |
| const t_layer | TB_STAR = '*' << 24 |
| const t_layer | TB_DOT = '.' << 24 |
| typedef Uint32 t_translation::t_layer |
Definition at line 35 of file terrain_translation.hpp.
| typedef std::vector<t_terrain> t_translation::t_list |
Definition at line 74 of file terrain_translation.hpp.
| typedef std::vector<std::vector<t_terrain> > t_translation::t_map |
Definition at line 75 of file terrain_translation.hpp.
| const t_match t_translation::ALL_FORESTS | ( | "F* | , | |
| *^F *" | ||||
| ) |
| t_layer t_translation::get_layer_mask_ | ( | t_layer | terrain | ) | [inline, static] |
Get the mask for a single layer.
| terrain | 1 layer of a terrain, might have a wildcard. |
Definition at line 673 of file terrain_translation.cpp.
Referenced by get_mask_().

| static t_terrain t_translation::get_mask_ | ( | const t_terrain & | terrain | ) | [static] |
Gets a mask for a terrain, this mask is used for wildcard matching.
| terrain | The terrain which might have a wildcard. |
Definition at line 698 of file terrain_translation.cpp.
References t_translation::t_terrain::base, get_layer_mask_(), NO_LAYER, and t_translation::t_terrain::overlay.
Referenced by t_translation::t_match::t_match().


| bool t_translation::has_wildcard | ( | const t_terrain & | tcode | ) |
Tests whether a terrain code contains a wildcard.
| tcode | the terrain code to test for a wildcard |
| bool t_translation::has_wildcard | ( | const t_list & | list | ) |
Tests whether a terrain-code list contains at least one item with a wildcard.
| list | the list to test for a wildcard |
| size_t t_translation::max_map_size | ( | ) |
Return the maximum allowed map size (in either dimension), the maximum map area is, therefore, this value squared.
| static std::string t_translation::number_to_string_ | ( | t_terrain | terrain, | |
| const int | start_position = -1 | |||
| ) | [static] |
Converts a terrain number to a string.
| terrain | The terrain number to convert. | |
| start_position | The starting position, if smaller than 0 it's ignored else it's written. | |
| min_size | Padds the results with spaces if required, until the result has a length of min_size. |
Definition at line 783 of file terrain_translation.cpp.
References t_translation::t_terrain::base, NO_LAYER, t_translation::t_terrain::overlay, and str_cast().

| bool t_translation::operator!= | ( | const t_terrain & | a, | |
| const t_terrain & | b | |||
| ) | [inline] |
Definition at line 63 of file terrain_translation.hpp.
References t_translation::t_terrain::base, and t_translation::t_terrain::overlay.
| t_terrain t_translation::operator& | ( | const t_terrain & | a, | |
| const t_terrain & | b | |||
| ) | [inline] |
Definition at line 66 of file terrain_translation.hpp.
References t_translation::t_terrain::base, and t_translation::t_terrain::overlay.
| bool t_translation::operator< | ( | const t_terrain & | a, | |
| const t_terrain & | b | |||
| ) | [inline] |
Definition at line 57 of file terrain_translation.hpp.
References t_translation::t_terrain::base, and t_translation::t_terrain::overlay.
| std::ostream& t_translation::operator<< | ( | std::ostream & | s, | |
| const t_terrain & | a | |||
| ) | [inline] |
Definition at line 177 of file terrain_translation.hpp.
References write_terrain_code().

| bool t_translation::operator== | ( | const t_terrain & | a, | |
| const t_terrain & | b | |||
| ) | [inline] |
Definition at line 60 of file terrain_translation.hpp.
References t_translation::t_terrain::base, and t_translation::t_terrain::overlay.
| t_terrain t_translation::operator| | ( | const t_terrain & | a, | |
| const t_terrain & | b | |||
| ) | [inline] |
Definition at line 69 of file terrain_translation.hpp.
References t_translation::t_terrain::base, and t_translation::t_terrain::overlay.
| t_map t_translation::read_builder_map | ( | const std::string & | str | ) |
Reads a builder map.
A builder map differs a great deal from a normal map, hence the different functions.
| str | The map data, a terrain letter is either a * or a . or a number as anchor. The star or dot are stored in the base part of the terrain and the anchor in the overlay part. If more letters are allowed as special case they will be stored in the base part. Anchor 0 is no anchor. |
Referenced by terrain_builder::parse_mapstring().

| t_map t_translation::read_game_map | ( | const std::string & | str, | |
| std::map< int, coordinate > & | starting_positions | |||
| ) |
Reads a gamemap string into a 2D vector.
| str | A string containing the gamemap, the following rules are stated for a gamemap: * The map is square * The map can be prefixed with one or more empty lines, these lines are ignored * The map can be postfixed with one or more empty lines, these lines are ignored * Every end of line can be followed by one or more empty lines, these lines are ignored. |
| starting_positions | This parameter will be filled with the starting locations found. Starting locations can only occur once if multiple definitions occur of the same position only the last is stored. The returned value is a map: * first the starting locations * second a coordinate structure where the location was found |
Referenced by gamemap::read().

| t_list t_translation::read_list | ( | const std::string & | str, | |
| const t_layer | filler = NO_LAYER | |||
| ) |
Reads a list of terrains from a string, when reading the.
| str | A string with one or more terrain codes (see read_terrain_code) | |
| filler | If there's no layer, this value will be used as the second layer |
Referenced by default_generate_map(), preferences::manager::manager(), gamemap::overlay(), place_village(), placing_score(), and terrain_type::terrain_type().

| t_terrain t_translation::read_terrain_code | ( | const std::string & | str, | |
| const t_layer | filler = NO_LAYER | |||
| ) |
Reads a single terrain from a string.
| str | The string which should contain 1 terrain code; the new format of a terrain code is 2 to 4 characters in the set
* [a-Z][A-Z]/|\_ * The underscore is intended for internal use. Other letters and characters are not validated but users of these letters can get nasty surprices. The * is used as wildcard in some cases. The terrain code can be two groups separated by a caret, the first group is the base terrain, the second the overlay terrain. | |
| filler | if there's no layer this value will be used as the second layer |
Referenced by default_generate_map(), intf_get_terrain_info(), intf_set_terrain(), intf_unit_defense(), and intf_unit_movement_cost().

| static t_terrain t_translation::string_to_builder_number_ | ( | std::string | str | ) | [static] |
Converts a terrain string to a number for the builder.
The translation rules differ from the normal conversion rules
| str | The terrain string. |
Definition at line 829 of file terrain_translation.cpp.
References lexical_cast_default(), and schema_validation::number.

| static t_layer t_translation::string_to_layer_ | ( | const std::string & | str | ) | [static] |
Converts a string to a layer.
| str | The terrain string to convert, but needs to be sanitized so no spaces and only the terrain to convert. |
Definition at line 707 of file terrain_translation.cpp.
| static t_terrain t_translation::string_to_number_ | ( | const std::string & | str, | |
| const t_layer | filler = NO_LAYER | |||
| ) | [static] |
Definition at line 736 of file terrain_translation.cpp.
References string_to_number_().

| static t_terrain t_translation::string_to_number_ | ( | std::string | str, | |
| int & | start_position, | |||
| const t_layer | filler | |||
| ) | [static] |
Converts a terrain string to a number.
| str | The terrain string with an optional number. | |
| start_position | Returns the start_position, the caller should set it on -1 and it's only changed it there is a starting position found. | |
| filler | If the terrain has only 1 layer then the filler will be used as the second layer. |
Definition at line 741 of file terrain_translation.cpp.
References t_translation::t_terrain::base, lexical_cast(), NO_LAYER, NOT, t_translation::t_terrain::overlay, STAR, VOID_TERRAIN, and WILDCARD.
Referenced by string_to_number_().


| bool t_translation::terrain_matches | ( | const t_terrain & | src, | |
| const t_list & | dest | |||
| ) |
Tests whether a specific terrain matches a list of expressions.
The list can use wildcard matching with *. It also has an inversion function. When a ! is found the result of the match is inverted. The matching stops at the first match (regardless of the ! found) the data is match from start to end.
Example: Ww, W* does match and returns true Ww, {!, W*} does match and returns false (due to the !) WW, Ww doesn't match and return false
Multilayer rules: If a terrain has multiple layers, each layer will be matched separately, returning true only if both layers match.
Example: A*^* matches Abcd but also Abcd^Abcd A*^ matches Abcd but *not* Abcd^Abcd A*^Abcd does not match Abcd but matches Abcd^Abcd
Note: If an expression doesn't specify a second layer (i.e. it contains no caret) the second layer will be filled in with a default value (See read_terrain_code and read_list).
In the terrain building code, the second layer will default to the wildcard, so both A* and A*^* will match Abcd^Abcd
| src | the value to match (may not contain wildcards) | |
| dest | the list of expressions to match against |
| bool t_translation::terrain_matches | ( | const t_terrain & | src, | |
| const t_terrain & | dest | |||
| ) |
Tests whether a specific terrain matches an expression, for matching rules see above.
| src | the value to match (may not contain wildcards) | |
| dest | the expression to match against |
Referenced by default_generate_map(), flood_name(), terrain_filter::match_internal(), unit_animation::matches(), and gamemap::overlay().

| bool t_translation::terrain_matches | ( | const t_terrain & | src, | |
| const t_match & | dest | |||
| ) |
Tests whether a certain terrain matches a list of expressions, for matching rules see above.
The matching requires some bit mask which impose a certain overhead. This version uses a cache to cache the masks so if a list needs to be matched often this version is preferred.
| src | the value to match (may not contain wildcards) | |
| dest | the cached list of expressions to match against |
| std::string t_translation::write_game_map | ( | const t_map & | map, | |
| std::map< int, coordinate > | starting_positions = std::map< int, coordinate >() | |||
| ) |
Write a gamemap in to a vector string.
| map | A terrain vector, as returned from read_game_map | |
| starting_positions | A starting positions map, as returned from read_game_map |
Referenced by cave_map_generator::create_scenario(), output_map(), and gamemap::write().

| std::string t_translation::write_list | ( | const t_list & | list | ) |
Writes a list of terrains to a string, only writes the new format.
| list | A vector with one or more terrain codes |
Referenced by terrain_builder::parse_config(), and preferences::manager::~manager().

| std::string t_translation::write_terrain_code | ( | const t_terrain & | tcode | ) |
Writes a single terrain code to a string.
The writers only support the new format.
| tcode | The terrain code to convert to a string |
Referenced by terrain_builder::add_off_map_rule(), default_generate_map(), defense_range_modifier_internal(), intf_get_terrain(), movement_cost_internal(), operator<<(), terrain_builder::parse_mapstring(), place_village(), gamemap::read(), terrain_type::terrain_type(), and gamemap::write_terrain().

Referenced by default_generate_map().
Definition at line 141 of file terrain_translation.hpp.
Definition at line 142 of file terrain_translation.hpp.
Referenced by default_generate_map().
Definition at line 143 of file terrain_translation.hpp.
Referenced by default_generate_map().
| const t_terrain t_translation::BASE = string_to_number_("_bas") |
Definition at line 142 of file terrain_translation.cpp.
Referenced by merge_alias_lists().
| const t_terrain t_translation::CAVE = string_to_number_("Uu") |
Definition at line 133 of file terrain_translation.cpp.
| const t_terrain t_translation::CAVE_WALL = string_to_number_("Xu") |
Definition at line 132 of file terrain_translation.cpp.
| const t_terrain t_translation::DEEP_WATER = string_to_number_("Wo") |
Definition at line 126 of file terrain_translation.cpp.
Referenced by generate_river_internal().
| const t_terrain t_translation::DWARVEN_CASTLE = string_to_number_("Cud") |
Definition at line 135 of file terrain_translation.cpp.
| const t_terrain t_translation::DWARVEN_KEEP = string_to_number_("Kud") |
Definition at line 136 of file terrain_translation.cpp.
| const t_terrain t_translation::FOGGED = string_to_number_("_f") |
Definition at line 121 of file terrain_translation.cpp.
Referenced by editor::is_valid_terrain(), editor::editor_map::mask_to(), help::unit_topic_generator::operator()(), and gamemap::overlay().
| const t_terrain t_translation::FOREST = string_to_number_("Gg^Ff") |
Definition at line 128 of file terrain_translation.cpp.
Referenced by default_generate_map().
| const t_terrain t_translation::GRASS_LAND = string_to_number_("Gg") |
Definition at line 127 of file terrain_translation.cpp.
Referenced by editor::context_manager::create_default_context(), default_generate_map(), and editor::context_manager::new_map_dialog().
| const t_terrain t_translation::HILL = string_to_number_("Hh") |
Definition at line 130 of file terrain_translation.cpp.
Referenced by default_generate_map().
| const t_terrain t_translation::HUMAN_CASTLE = string_to_number_("Ch") |
Definition at line 123 of file terrain_translation.cpp.
Referenced by default_generate_map().
| const t_terrain t_translation::HUMAN_KEEP = string_to_number_("Kh") |
Definition at line 124 of file terrain_translation.cpp.
Referenced by default_generate_map().
| const t_terrain t_translation::MINUS = string_to_number_("-") |
Definition at line 139 of file terrain_translation.cpp.
Referenced by defense_range_modifier_internal(), merge_alias_lists(), movement_cost_internal(), terrain_type::terrain_type(), and unit_defense().
| const t_terrain t_translation::MOUNTAIN = string_to_number_("Mm") |
Definition at line 129 of file terrain_translation.cpp.
Referenced by default_generate_map().
| const t_layer t_translation::NO_LAYER = 0xFFFFFFFF |
Definition at line 37 of file terrain_translation.hpp.
Referenced by editor::map_context::draw_terrain_actual(), get_mask_(), gamemap::merge_terrains(), number_to_string_(), string_to_layer_(), string_to_number_(), and gamemap::try_merge_terrains().
| const t_terrain t_translation::NONE_TERRAIN = t_terrain() |
Definition at line 55 of file terrain_translation.hpp.
Referenced by change_terrain(), editor::editor_map::clone_column(), editor::terrain_palette::draw_item(), editor::editor_map::expand_bottom(), editor::editor_map::expand_top(), gamemap::get_terrain(), intf_get_terrain_info(), intf_set_terrain(), terrain_type::is_nonnull(), gamemap::merge_terrains(), terrain_builder::parse_mapstring(), editor::context_manager::resize_map_dialog(), gamemap::set_terrain(), terrain_type::terrain_type(), and terrain_type::terrain_with_default_base().
| const t_terrain t_translation::NOT = string_to_number_("!") |
Definition at line 140 of file terrain_translation.cpp.
Referenced by string_to_number_().
| const t_terrain t_translation::OFF_MAP_USER = string_to_number_("_off^_usr") |
Definition at line 118 of file terrain_translation.cpp.
Referenced by terrain_builder::add_off_map_rule(), display::draw_hex(), help::unit_topic_generator::operator()(), and REPORT_GENERATOR().
| const t_terrain t_translation::PLUS = string_to_number_("+") |
Definition at line 138 of file terrain_translation.cpp.
Referenced by defense_range_modifier_internal(), merge_alias_lists(), movement_cost_internal(), terrain_type::terrain_type(), and unit_defense().
| const t_terrain t_translation::SHALLOW_WATER = string_to_number_("Ww") |
Definition at line 125 of file terrain_translation.cpp.
Referenced by generate_lake(), and generate_river_internal().
| const t_terrain t_translation::STAR = string_to_number_("*") |
Definition at line 141 of file terrain_translation.cpp.
Referenced by terrain_builder::parse_mapstring(), and string_to_number_().
| const t_layer t_translation::TB_DOT = '.' << 24 |
Definition at line 328 of file terrain_translation.hpp.
Referenced by terrain_builder::parse_mapstring().
| const t_layer t_translation::TB_STAR = '*' << 24 |
Definition at line 327 of file terrain_translation.hpp.
Referenced by terrain_builder::parse_mapstring().
| const t_terrain t_translation::UNDERGROUND_VILLAGE = string_to_number_("Uu^Vu") |
Definition at line 134 of file terrain_translation.cpp.
| const t_terrain t_translation::VOID_TERRAIN = string_to_number_("_s") |
Definition at line 120 of file terrain_translation.cpp.
Referenced by terrain_type::is_nonnull(), editor::is_valid_terrain(), help::unit_topic_generator::operator()(), gamemap::overlay(), and string_to_number_().
| const t_layer t_translation::WILDCARD = 0x2A000000 |
Definition at line 36 of file terrain_translation.hpp.
Referenced by terrain_builder::add_constraints(), and string_to_number_().
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:25:39 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |