68 static const int UNITPOS = 36 + 18;
70 static const unsigned int DUMMY_HASH = 0;
75 typedef std::vector<animated<image::locator>>
imagelist;
111 void change_map(
const gamemap* m);
154 void rebuild_cache_all();
158 draw_border_ = do_draw;
169 rule_image_variant(
const std::string& image_string,
const std::string& variations,
int random_start = -1)
170 : image_string(image_string)
171 , variations(variations)
175 , random_start(random_start)
181 const std::string& variations,
182 const std::string& tod,
183 const std::string& has_flag,
184 int random_start = -1);
214 std::vector<animated<image::locator>>
images;
238 bool global_image =
false,
241 bool is_water =
false);
245 return layer < 0 || (layer == 0 && basey < UNITPOS);
283 , terrain_types_match()
294 , terrain_types_match()
327 typedef std::pair<const rule_image_rand*, const rule_image_variant*>
log_details;
328 typedef std::vector<log_details>
logs;
336 void rebuild_cache(
const std::string& tod, logs* log =
nullptr);
360 return std::tie(ri->layer, ri->basey) < std::tie(o.
ri->
layer, o.
ri->
basey);
411 , location_constraints()
412 , modulo_constraints()
461 unsigned int get_hash()
const;
477 : tiles_((x + 4) * (y + 4))
516 void reload(
int x,
int y);
582 void replace_rotate_tokens(std::string&
s,
int angle,
const std::vector<std::string>& replacement);
592 void replace_rotate_tokens(
rule_image&
image,
int angle,
const std::vector<std::string>& replacement);
605 replace_rotate_tokens(variant.
image_string, angle, replacement);
617 void replace_rotate_tokens(rule_imagelist& list,
int angle,
const std::vector<std::string>& replacement);
630 void replace_rotate_tokens(
building_rule& rule,
int angle,
const std::vector<std::string>& replacement);
668 void rotate_rule(
building_rule& rule,
int angle,
const std::vector<std::string>& angle_name);
686 void add_images_from_config(rule_imagelist& images,
const config& cfg,
bool global,
int dx = 0,
int dy = 0);
701 const config& global_images);
714 void add_constraints(
730 void parse_mapstring(
731 const std::string& mapstring,
struct building_rule& br, anchormap& anchors,
const config& global_images);
751 void add_rotated_rules(building_ruleset& rules,
building_rule& tpl,
const std::string& rotations);
774 void add_off_map_rule(
const std::string&
image);
776 void flush_local_rules();
835 void build_terrains();
863 static inline building_ruleset building_rules_{};
std::vector< tile > tiles_
The map.
std::pair< const rule_image_rand *, const rule_image_variant * > log_details
int layer
The layer of the image for horizontal layering.
rule_image_rand(const rule_image *r_i, unsigned int rnd)
section parse_config(const config *cfg)
Parse a help config, return the top level section.
The in-memory representation of a [terrain_graphics] WML rule.
terrain_by_type_map terrain_by_type_
A map representing all locations whose terrain is of a given type.
int y_
The y dimension of the map.
map_location modulo_constraints
Used to constrain locations to ones with coordinates that are multiples of the "mod_x" and "mod_y" pa...
bool operator<(const building_rule &that) const
The in-memory representation of a [tile] WML rule inside of a [terrain_graphics] WML rule...
const rule_image * operator->() const
bool no_draw
Whether to actually draw the images onto this hex or not.
bool terrain_matches(const terrain_code &src, const terrain_code &dest)
Tests whether a specific terrain matches an expression, for matching rules see above.
std::map< t_translation::terrain_code, std::vector< map_location > > terrain_by_type_map
Shorthand typedef for a map associating a list of locations to a terrain type.
void set_draw_border(bool do_draw)
std::vector< terrain_constraint > constraint_set
The list of constraints attached to a terrain_graphics WML rule.
Represent a rule_image applied with a random seed.
imagelist images_background
The list of images which are behind the unit sprites, attached to this tile.
int precedence
Ordering relation between the rules.
std::multimap< int, map_location > anchormap
void clear(const std::string &key)
The class terrain_builder is constructed from a config object, and a gamemap object.
bool is_background() const
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
const int tilewidth_
The tile width used when using basex and basey.
t_translation::ter_match terrain_types_match
terrain_constraint(map_location loc)
bool operator<(const rule_image_rand &o) const
sort by layer first then by basey
int random_start
Specify the allowed amount of random shift (in milliseconds) applied to the animation start time...
void replace_rotate_tokens(rule_image_variant &variant, int angle, const std::vector< std::string > &replacement)
Replaces, in a given rule_variant_image, rotation tokens with their values.
tilemap(int x, int y)
Constructs a tilemap of dimensions x * y.
int probability
The probability of this rule to match, when all conditions are met.
Represents a tile of the game map, with all associated builder-specific parameters: flags...
rule_image_variant(const std::string &image_string, const std::string &variations, int random_start=-1)
Constructor for the normal default case.
const gamemap * map_
A pointer to the gamemap class used in the current level.
tilemap tile_map_
The tile_map_ for the current level, which is filled by the build_terrains_ method to contain "tiles"...
Encapsulates the map of the game.
std::set< std::string > tods
The Time of Day associated to this variant (if any)
TERRAIN_TYPE
Used as a parameter for the get_terrain_at function.
std::vector< rule_image_variant > variants
A list of variants for this image.
std::vector< rule_image_rand > images
The list of rule_images and random seeds associated to this tile.
std::vector< log_details > logs
The map of "tile" structures corresponding to the level map.
bool local
Indicate if the rule is only for this scenario.
bool terrain_matches(const t_translation::terrain_code &tcode, const t_translation::ter_list &terrains) const
Checks whether a terrain code matches a given list of terrain codes.
Encapsulates the map of the game.
bool global_image
Set to true if the image was defined as a child of the [terrain_graphics] tag, set to false if it was...
std::string last_tod
The time-of-day to which the image caches correspond.
std::vector< std::string > set_flag
static map_location::DIRECTION s
std::set< std::string > flags
The list of flags present in this tile.
std::vector< rule_image > rule_imagelist
A shorthand notation for a vector of rule_images.
std::vector< std::string > has_flag
bool terrain_matches(const t_translation::terrain_code &tcode, const t_translation::ter_match &terrain) const
Checks whether a terrain code matches a given list of terrain tcodes.
Each terrain_graphics rule is associated a set of images, which are applied on the terrain if the rul...
std::vector< std::string > has_flag
std::vector< animated< image::locator > > imagelist
A shorthand typedef for a list of animated image locators, the base data type returned by the get_ter...
std::multiset< building_rule > building_ruleset
A set of building rules.
int x_
The x dimension of the map.
constraint_set constraints
The set of [tile] constraints of this rule.
void parse_global_config(const game_config_view &cfg)
bool sorted_images
Indicates if 'images' is sorted.
const gamemap & map() const
map_location location_constraints
The location on which this map may match.
std::vector< animated< image::locator > > images
An animated image locator built according to the image string.
Functions to load and save images from/to disk.
std::vector< terrain_code > ter_list
std::string image_string
A string representing either the filename for an image, or a list of images, with an optional timing ...
std::string variations
A semi-solon separated list of string used to replace.
imagelist images_foreground
The list of images which are in front of the unit sprites, attached to this tile. ...
A config object defines a single node in a WML file, with access to child nodes.
This structure can be used for matching terrain strings.
bool draw_border_
Whether the map border should be drawn.
std::vector< std::string > no_flag