In the spirit of realease early a quick fix for the terrain system.
This might fix bug #8942 but still needs some cleanups
This commit is contained in:
parent
5a15150536
commit
bf74c11bc3
2 changed files with 36 additions and 13 deletions
|
@ -42,6 +42,23 @@ static const int UNITPOS = 36 + 18;
|
|||
*/
|
||||
static const int BASE_Y_INTERVAL = 100000;
|
||||
|
||||
static t_translation::t_letter builder_letter(const t_translation::t_letter& letter)
|
||||
{
|
||||
t_translation::t_letter result(letter);
|
||||
|
||||
if(result == t_translation::STAR || result == t_translation::NOT) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if(result.overlay == t_translation::NO_LAYER &&
|
||||
result.base != t_translation::WILDCARD) {
|
||||
|
||||
result.overlay = t_translation::WILDCARD;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
terrain_builder::rule_image::rule_image(int layer, int x, int y, bool global_image) :
|
||||
layer(layer), basex(x), basey(y), global_image(global_image)
|
||||
{}
|
||||
|
@ -543,7 +560,9 @@ void terrain_builder::add_constraints(
|
|||
add_images_from_config(constraints[loc].images, global_images, true, x, y);
|
||||
}
|
||||
|
||||
void terrain_builder::add_constraints(terrain_builder::constraint_set &constraints, const gamemap::location& loc, const config& cfg, const config& global_images)
|
||||
void terrain_builder::add_constraints(terrain_builder::constraint_set &constraints,
|
||||
const gamemap::location& loc, const config& cfg, const config& global_images)
|
||||
|
||||
{
|
||||
add_constraints(constraints, loc, t_translation::t_match(cfg["type"], t_translation::WILDCARD), global_images);
|
||||
|
||||
|
@ -592,7 +611,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
|
|||
} else if (terrain.overlay != 0 ) {
|
||||
anchors.insert(std::pair<int, gamemap::location>(terrain.overlay, gamemap::location(x, y)));
|
||||
} else if (terrain.base == t_translation::TB_STAR) {
|
||||
add_constraints(br.constraints, gamemap::location(x, y), t_translation::STAR, global_images);
|
||||
add_constraints(br.constraints, gamemap::location(x, y), builder_letter(t_translation::STAR), global_images);
|
||||
} else {
|
||||
ERR_NG << "Invalid terrain (" << t_translation::write_letter(terrain) << ") in builder map\n";
|
||||
wassert(false);
|
||||
|
@ -760,7 +779,6 @@ bool terrain_builder::rule_matches(const terrain_builder::building_rule &rule,
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(check_loc) {
|
||||
for(constraint_set::const_iterator cons = rule.constraints.begin();
|
||||
cons != rule.constraints.end(); ++cons) {
|
||||
|
@ -772,7 +790,7 @@ bool terrain_builder::rule_matches(const terrain_builder::building_rule &rule,
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!terrain_matches(map_.get_terrain(tloc), cons->second.terrain_types_match)) {
|
||||
if(!terrain_matches(builder_letter(map_.get_terrain(tloc)), cons->second.terrain_types_match)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -875,10 +893,10 @@ int terrain_builder::get_constraint_size(const building_rule& rule, const terrai
|
|||
if(types.empty()) {
|
||||
return INT_MAX;
|
||||
}
|
||||
if(types.front() == t_translation::NOT) {
|
||||
if(types.front() == builder_letter(t_translation::NOT)) {
|
||||
return INT_MAX;
|
||||
}
|
||||
if(std::find(types.begin(), types.end(), t_translation::STAR) != types.end()) {
|
||||
if(std::find(types.begin(), types.end(), builder_letter(t_translation::STAR)) != types.end()) {
|
||||
return INT_MAX;
|
||||
}
|
||||
// as soon as the list has 1 wildcard we bail out
|
||||
|
@ -902,7 +920,7 @@ int terrain_builder::get_constraint_size(const building_rule& rule, const terrai
|
|||
|
||||
t_translation::t_list::const_iterator itor = types.begin();
|
||||
for(; itor != types.end(); ++itor) {
|
||||
if(!terrain_matches(*itor, atypes)) {
|
||||
if(!terrain_matches(*itor, atypes)) {
|
||||
border = true;
|
||||
break;
|
||||
}
|
||||
|
@ -936,7 +954,7 @@ void terrain_builder::build_terrains()
|
|||
for(int x = -1; x <= map_.x(); ++x) {
|
||||
for(int y = -1; y <= map_.y(); ++y) {
|
||||
const gamemap::location loc(x,y);
|
||||
const t_translation::t_letter t = map_.get_terrain(loc);
|
||||
const t_translation::t_letter t = builder_letter(map_.get_terrain(loc));
|
||||
|
||||
terrain_by_type_[t].push_back(loc);
|
||||
gamemap::location adj[6];
|
||||
|
@ -948,10 +966,10 @@ void terrain_builder::build_terrains()
|
|||
tile_map_[loc].adjacents[0] = t;
|
||||
for(i = 0; i < 6; ++i) {
|
||||
//updates the list of adjacents for this tile
|
||||
tile_map_[loc].adjacents[i+1] = map_.get_terrain(adj[i]);
|
||||
tile_map_[loc].adjacents[i+1] = builder_letter(map_.get_terrain(adj[i]));
|
||||
|
||||
//determines if this tile is a border tile
|
||||
if(map_.get_terrain(adj[i]) != t) {
|
||||
if(builder_letter(map_.get_terrain(adj[i])) != t) {
|
||||
border = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace t_translation {
|
|||
*
|
||||
* @return the letter found in the string
|
||||
*/
|
||||
static t_letter string_to_number_(const std::string& str, const t_layer filler = WILDCARD);
|
||||
static t_letter string_to_number_(const std::string& str, const t_layer filler = NO_LAYER);
|
||||
static t_letter string_to_number_(std::string str, int& start_position, const t_layer filler);
|
||||
|
||||
/**
|
||||
|
@ -547,9 +547,9 @@ bool terrain_matches(const t_letter& src, const t_match& dest)
|
|||
for(t_list::const_iterator terrain_itor = dest.terrain.begin();
|
||||
terrain_itor != end;
|
||||
++i, ++terrain_itor) {
|
||||
|
||||
|
||||
// match wildcard
|
||||
if(*terrain_itor == STAR) {
|
||||
if(*terrain_itor == STAR) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -989,6 +989,11 @@ static t_letter string_to_number_(std::string str, int& start_position, const t_
|
|||
result = t_letter(base_str, overlay_str);
|
||||
} else {
|
||||
result = t_letter(str, filler);
|
||||
|
||||
//ugly hack
|
||||
if(filler == WILDCARD && (result.base == NOT.base || result.base == STAR.base)) {
|
||||
result.overlay = NO_LAYER;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TERRAIN_TRANSLATION_COMPATIBLE
|
||||
|
|
Loading…
Add table
Reference in a new issue