remove support for 1.2 map format and allow wildcards on some places,

the latter isn't finished yet
This commit is contained in:
Mark de Wever 2007-04-29 16:57:56 +00:00
parent 7651defcbb
commit 2506dc9e97
13 changed files with 51 additions and 428 deletions

View file

@ -3,6 +3,9 @@ Version 1.3.2+svn:
* updated translations: Chinese, Czech, Danish, French, Spanish
* WML engine
* removed deprecated special= support in [effect]
* removed deprecated 1.2 map format support
* Miscellaneous and bugfixes
* 1.2 savegames are no longer compatible and thus not loaded
Version 1.3.2:
* campaigns

View file

@ -3,7 +3,8 @@ may be omitted). For a complete list of changes, see the main changelog:
http://svn.gna.org/viewcvs/*checkout*/wesnoth/trunk/changelog
Version 1.3.2+svn:
* Miscellaneous and bugfixes
* 1.2 savegames are no longer compatible and thus not loaded
Version 1.3.2:
* Campaigns

View file

@ -1027,7 +1027,7 @@ void terrain_builder::build_terrains()
if(cons != rule->second.constraints.end()) {
adjacent_types[i] = cons->second.terrain_types_match.terrain;
} else {
adjacent_types[i] = t_translation::read_list("", -1, t_translation::T_FORMAT_STRING, t_translation::WILDCARD);
adjacent_types[i] = t_translation::read_list("", t_translation::WILDCARD);
}
}

View file

@ -29,8 +29,7 @@
namespace map_editor {
bool is_invalid_terrain(t_translation::t_letter c) {
return (c == t_translation::VOID_TERRAIN || c == t_translation::FOGGED ||
c == t_translation::OBSOLETE_KEEP);
return (c == t_translation::VOID_TERRAIN || c == t_translation::FOGGED);
}
terrain_group::terrain_group(const config& cfg, display& gui):

View file

@ -1304,10 +1304,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
std::string terrain_type = cfg["letter"];
wassert(state_of_game != NULL);
//At this point terrain_type contains the letter as known in WML
//convert to an internal number
t_translation::t_letter terrain =
t_translation::read_letter(terrain_type, t_translation::T_FORMAT_AUTO);
t_translation::t_letter terrain = t_translation::read_letter(terrain_type);
if(terrain != t_translation::NONE_TERRAIN) {
@ -1963,6 +1960,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
* - terrain: if present, filter the village types against this list of terrain types
*/
else if(cmd == "store_villages" ) {
//TODO - add wildcard support
log_scope("store_villages");
std::string side = cfg["side"];
std::string variable = cfg["variable"];
@ -1972,11 +1970,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
std::string wml_terrain = cfg["terrain"];
wassert(state_of_game != NULL);
const int side_index = lexical_cast_default<int>(side,1)-1;
//convertert the terrain to a internal vector
//FIXME: once the terrain backwards compability layer is gone we can load the string
// in a t_match structure and use the optimized match routine in the loop
const t_translation::t_list& terrain =
t_translation::read_list(wml_terrain, 0, t_translation::T_FORMAT_AUTO);
const t_translation::t_list& terrain = t_translation::read_list(wml_terrain);
state_of_game->clear_variable_cfg(variable);
@ -1997,6 +1991,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
}
else if(cmd == "store_locations" ) {
//TODO - add wildcard support
log_scope("store_locations");
std::string variable = cfg["variable"];
if (variable.empty()) {
@ -2007,11 +2002,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
std::string y = cfg["y"];
std::string radius_str = cfg["radius"];
wassert(state_of_game != NULL);
//convertert the terrain to a internal vector
//FIXME: once the terrain backwards compability layer is gone we can load the string
// in a t_match structure and use the optimized match routine in the loop
const t_translation::t_list& terrain =
t_translation::read_list(wml_terrain, 0, t_translation::T_FORMAT_AUTO);
const t_translation::t_list& terrain = t_translation::read_list(wml_terrain);
const vconfig unit_filter = cfg.child("filter");

View file

@ -369,31 +369,27 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, const int xpos,
static const std::string src_key = "old", src_not_key = "old_not",
dst_key = "new", dst_not_key = "new_not";
const config& cfg = **rule;
const t_translation::t_list& src =
t_translation::read_list(cfg[src_key], 0, t_translation::T_FORMAT_AUTO);
const t_translation::t_list& src = t_translation::read_list(cfg[src_key]);
if(!src.empty() && std::find(src.begin(),src.end(),current) == src.end()) {
if(!src.empty() && t_translation::terrain_matches(current, src) == false) {
continue;
}
const t_translation::t_list& src_not =
t_translation::read_list(cfg[src_not_key], 0, t_translation::T_FORMAT_AUTO);
const t_translation::t_list& src_not = t_translation::read_list(cfg[src_not_key]);
if(!src_not.empty() && std::find(src_not.begin(),src_not.end(),current) != src_not.end()) {
if(!src_not.empty() && t_translation::terrain_matches(current, src_not)) {
continue;
}
const t_translation::t_list& dst =
t_translation::read_list(cfg[dst_key], 0, t_translation::T_FORMAT_AUTO);
const t_translation::t_list& dst = t_translation::read_list(cfg[dst_key]);
if(!dst.empty() && std::find(dst.begin(),dst.end(),t) == dst.end()) {
if(!dst.empty() && t_translation::terrain_matches(current, dst) == false) {
continue;
}
const t_translation::t_list& dst_not =
t_translation::read_list(cfg[dst_not_key], 0, t_translation::T_FORMAT_AUTO);
const t_translation::t_list& dst_not = t_translation::read_list(cfg[dst_not_key]);
if(!dst_not.empty() && std::find(dst_not.begin(),dst_not.end(),t) != dst_not.end()) {
if(!dst_not.empty() && t_translation::terrain_matches(current, dst_not)) {
continue;
}
@ -403,8 +399,7 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, const int xpos,
if(rule != rules.end()) {
const config& cfg = **rule;
const t_translation::t_list& terrain =
t_translation::read_list(cfg["terrain"], 0, t_translation::T_FORMAT_AUTO);
const t_translation::t_list& terrain = t_translation::read_list(cfg["terrain"]);
if(!terrain.empty()) {
set_terrain(location(x2,y2),terrain[0]);
@ -600,55 +595,20 @@ bool gamemap::terrain_matches_filter(const gamemap::location& loc, const vconfig
bool gamemap::terrain_matches_internal(const gamemap::location& loc, const vconfig& cfg,
const gamestatus& game_status, const unit_map& units, const bool flat_tod) const
{
/* *
* The abilities use a comma separated list of terrains, this code has been
* used and also needs to be backwards compatible. This should happen
* independant of the map so added this hack. Obiously it needs to be removed
* as soon as possible.
*/
const int terrain_format = lexical_cast_default(cfg["terrain_format"], -1);
/* enable when the hack is no longer used
if(terrain_format != -1) {
std::cerr << "key terrain_format in filter_location is obsolete old format no longer supported";
lg::wml_error << "key terrain_format in filter_location is no longer used, this message will disappear in 1.3.5\n";
}
*/
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
if(terrain_format == 0 || terrain_format == -1 && !cfg["terrain"].empty()) {
lg::wml_error << "Warning deprecated terrain format in filter_location, support will be removed in version 1.3.3\n";
const t_string& t_terrain = cfg["terrain"];
const std::string& terrain = t_terrain;
// Any of these may be a CSV
std::string terrain_letter;
terrain_letter += t_translation::get_old_letter(get_terrain_info(loc).number());
if(!terrain.empty() && !terrain_letter.empty()) {
if(terrain != terrain_letter) {
if(std::find(terrain.begin(),terrain.end(),',') != terrain.end() &&
std::search(terrain.begin(),terrain.end(),
terrain_letter.begin(),terrain_letter.end()) != terrain.end()) {
const std::vector<std::string>& vals = utils::split(terrain);
if(std::find(vals.begin(),vals.end(),terrain_letter) == vals.end()) {
return false;
}
} else {
return false;
}
}
}
} else {
#endif
const t_translation::t_list& terrain =
t_translation::read_list(cfg["terrain"], -1, t_translation::T_FORMAT_STRING);
if(! terrain.empty()) {
const t_translation::t_letter letter = get_terrain_info(loc).number();
if(! t_translation::terrain_matches(letter, terrain)) {
return false;
}
const t_translation::t_list& terrain = t_translation::read_list(cfg["terrain"]);
if(! terrain.empty()) {
const t_translation::t_letter letter = get_terrain_info(loc).number();
if(! t_translation::terrain_matches(letter, terrain)) {
return false;
}
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
}
#endif
//Allow filtering on location ranges
if(!cfg["x"].empty() || !cfg["y"].empty()){

View file

@ -506,8 +506,7 @@ static gamemap::location place_village(const t_translation::t_map& map,
const t_translation::t_letter t = map[adj[n].x][adj[n].y];
const t_translation::t_list& adjacent_liked =
t_translation::read_list((*child)["adjacent_liked"],
0, t_translation::T_FORMAT_STRING);
t_translation::read_list((*child)["adjacent_liked"]);
rating += std::count(adjacent_liked.begin(),adjacent_liked.end(),t);
}
@ -580,7 +579,7 @@ terrain_height_mapper::terrain_height_mapper(const config& cfg) :
{
const std::string& terrain = cfg["terrain"];
if(terrain != "") {
to = t_translation::read_letter(terrain, t_translation::T_FORMAT_STRING);
to = t_translation::read_letter(terrain);
}
}
@ -610,7 +609,7 @@ private:
terrain_converter::terrain_converter(const config& cfg) : min_temp(-1),
max_temp(-1), min_height(-1), max_height(-1),
from(t_translation::read_list(cfg["from"],0 , t_translation::T_FORMAT_STRING)),
from(t_translation::read_list(cfg["from"])),
to(t_translation::NONE_TERRAIN)
{
min_temp = lexical_cast_default<int>(cfg["min_temperature"],-100000);
@ -620,7 +619,7 @@ terrain_converter::terrain_converter(const config& cfg) : min_temp(-1),
const std::string& to_str = cfg["to"];
if(to_str != "") {
to = t_translation::read_letter(to_str, t_translation::T_FORMAT_STRING);
to = t_translation::read_letter(to_str);
}
}
@ -657,8 +656,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
flatland = t_translation::write_letter(t_translation::GRASS_LAND);
}
const t_translation::t_letter grassland =
t_translation::read_letter(flatland, t_translation::T_FORMAT_STRING);
const t_translation::t_letter grassland = t_translation::read_letter(flatland);
//we want to generate a map that is 9 times bigger than the
//actual size desired. Only the middle part of the map will be
@ -853,8 +851,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
//castle configuration tag contains a 'valid_terrain' attribute which is a list of
//terrains that the castle may appear on.
const t_translation::t_list list =
t_translation::read_list((*castle_config)["valid_terrain"],
0, t_translation::T_FORMAT_STRING);
t_translation::read_list((*castle_config)["valid_terrain"]);
const is_valid_terrain terrain_tester(terrain, list);
@ -1018,8 +1015,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
if(direction != -1) {
const std::vector<std::string> items = utils::split(convert_to_bridge);
if(size_t(direction) < items.size() && items[direction].empty() == false) {
terrain[x][y] = t_translation::read_letter(items[direction],
t_translation::T_FORMAT_STRING);
terrain[x][y] = t_translation::read_letter(items[direction]);
}
continue;
@ -1032,7 +1028,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
const std::string& convert_to = (*child)["convert_to"];
if(convert_to.empty() == false) {
const t_translation::t_letter letter =
t_translation::read_letter(convert_to, t_translation::T_FORMAT_STRING);
t_translation::read_letter(convert_to);
if(labels != NULL && terrain[x][y] != letter && name_count++ == name_frequency && on_bridge == false) {
labels->insert(std::pair<gamemap::location,std::string>(gamemap::location(x-width/3,y-height/3),name));
name_count = 0;
@ -1128,8 +1124,7 @@ std::string default_generate_map(size_t width, size_t height, size_t island_size
if(child != NULL) {
const std::string& convert_to = (*child)["convert_to"];
if(convert_to != "") {
terrain[res.x][res.y] = t_translation::read_letter(convert_to,
t_translation::T_FORMAT_STRING);
terrain[res.x][res.y] = t_translation::read_letter(convert_to);
villages.insert(res);

View file

@ -129,17 +129,7 @@ void play_controller::init_managers(){
static int placing_score(const config& side, const gamemap& map, const gamemap::location& pos)
{
int positions = 0, liked = 0;
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
const std::string& terrain_liked = side["terrain_liked"];
t_translation::t_list terrain;
if(std::find(terrain_liked.begin(), terrain_liked.end(), ',') != terrain_liked.end()) {
terrain = t_translation::read_list(terrain_liked, -1, t_translation::T_FORMAT_STRING);
} else {
terrain = t_translation::read_list(terrain_liked, 0, t_translation::T_FORMAT_LETTER);
}
#else
const t_translation::t_list terrain = t_translation::read_list(side["terrain_liked"]);
#endif
for(int i = pos.x-8; i != pos.x+8; ++i) {
for(int j = pos.y-8; j != pos.y+8; ++j) {

View file

@ -81,7 +81,7 @@ manager::manager()
std::inserter(encountered_units_set, encountered_units_set.begin()));
const t_translation::t_list terrain =
t_translation::read_list(prefs["encountered_terrain_list"], -1, t_translation::T_FORMAT_STRING);
t_translation::read_list(prefs["encountered_terrain_list"]);
std::copy(terrain.begin(), terrain.end(),
std::inserter(encountered_terrains_set, encountered_terrains_set.begin()));
}

View file

@ -41,41 +41,22 @@ terrain_type::terrain_type(const config& cfg)
name_ = cfg["name"];
id_ = cfg["id"];
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
// load the old char and the new string part
std::string terrain_char = cfg["char"];
std::string terrain_string = cfg["string"];
wassert(terrain_string != "");
number_ = t_translation::read_letter(terrain_string, t_translation::T_FORMAT_STRING);
//if both a char and a string are defined load it in the translation
//table. This to maintain backwards compability
if(terrain_char != "") {
t_translation::add_translation(terrain_char, number_);
}
#else
number_ = t_translation::read_letter(terrain_string);
#endif
number_ = t_translation::read_letter(cfg["string"]);
mvt_type_.push_back(number_);
def_type_.push_back(number_);
const t_translation::t_list& alias =
t_translation::read_list(cfg["aliasof"], -1, t_translation::T_FORMAT_STRING);
const t_translation::t_list& alias = t_translation::read_list(cfg["aliasof"]);
if(!alias.empty()) {
mvt_type_ = alias;
def_type_ = alias;
}
const t_translation::t_list& mvt_alias =
t_translation::read_list(cfg["mvt_alias"], -1, t_translation::T_FORMAT_STRING);
const t_translation::t_list& mvt_alias = t_translation::read_list(cfg["mvt_alias"]);
if(!mvt_alias.empty()) {
mvt_type_ = mvt_alias;
}
const t_translation::t_list& def_alias =
t_translation::read_list(cfg["def_alias"], -1, t_translation::T_FORMAT_STRING);
const t_translation::t_list& def_alias = t_translation::read_list(cfg["def_alias"]);
if(!def_alias.empty()) {
def_type_ = def_alias;
}

View file

@ -27,46 +27,12 @@ namespace t_translation {
/***************************************************************************************/
// forward declaration of internal functions
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
// the former terrain letter
typedef char TERRAIN_LETTER;
// This function can convert EOL's and converts them to EOL
// which doesn't need to be and EOL char
// this will convert UNIX, Mac and Windows end of line types
// this due to the fact they all have a different idea of EOL
// Note this also eats all blank lines so the sequence "\n\n\n" will become just 1 EOL
static t_list string_to_vector_(const std::string& str, const bool convert_eol, const int separated);
// When the terrain is loaded it sends all letter, string combinations
// to add_translation. This way the translation table is build.
// This way it's possible to read old maps and convert them to
// the proper internal format
static std::map<TERRAIN_LETTER, t_letter> lookup_table_;
// This value contains the map format used, when reading the main
// map this format should be set, don't know how we're going to do
// it but we will. This format determines whether the WML
// map and letter are read old or new format.
// formats
// 0 = unknown
// 1 = old single letter format
// 2 = new multi letter format
static int map_format_ = 0;
//old low level converters
static t_letter letter_to_number_(const TERRAIN_LETTER terrain);
// reads old maps
static t_map read_game_map_old_(const std::string& map,std::map<int, coordinate>& starting_positions);
//this is used for error messages used in string_to_number_
//so we can't use this function to convert us. So we do the conversion here
//manually not the best solution but good enough for a tempory solution
const t_letter OBSOLETE_KEEP('_' << 24 | 'K' << 16, 0xFFFFFFFF);
#endif
// the low level convertors, these function are the ones which
// now about the internal format. All other functions are unaware
@ -203,7 +169,7 @@ t_match::t_match() :
{}
t_match::t_match(const std::string& str, const t_layer filler):
terrain(t_translation::read_list(str, -1, t_translation::T_FORMAT_STRING, filler))
terrain(t_translation::read_list(str, filler))
{
mask.resize(terrain.size());
masked_terrain.resize(terrain.size());
@ -230,23 +196,9 @@ t_match::t_match(const t_letter& letter):
}
}
t_letter read_letter(const std::string& str, const int t_format, const t_layer filler)
t_letter read_letter(const std::string& str, const t_layer filler)
{
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
if(t_format == T_FORMAT_STRING ||
(t_format == T_FORMAT_AUTO && map_format_ == 2)) {
return string_to_number_(str, filler);
} else if(t_format == T_FORMAT_LETTER ||
(t_format == T_FORMAT_AUTO && map_format_ == 1)) {
return letter_to_number_(str[0]);
} else {
throw error("Invalid case in read_letter");
}
#else
return string_to_number_(str, filler);
#endif
return string_to_number_(str, filler);
}
std::string write_letter(const t_letter& letter)
@ -254,23 +206,9 @@ std::string write_letter(const t_letter& letter)
return number_to_string_(letter);
}
t_list read_list(const std::string& str, const int separated, const int t_format, const t_layer filler)
t_list read_list(const std::string& str, const t_layer filler)
{
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
if(t_format == T_FORMAT_STRING ||
(t_format == T_FORMAT_AUTO && map_format_ == 2)) {
return string_to_vector_(str, filler);
} else if(t_format == T_FORMAT_LETTER ||
(t_format == T_FORMAT_AUTO && map_format_ == 1)) {
return string_to_vector_(str, false, separated);
} else {
throw error("Invalid case in read_list");
}
#else
return string_to_vector_(str, filler);
#endif
return string_to_vector_(str, filler);
}
std::string write_list(const t_list& list)
@ -293,27 +231,6 @@ t_map read_game_map(const std::string& str, std::map<int, coordinate>& starting_
{
t_map result;
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
// the test here is too avoid deprecated warning
if(str.empty()) {
return result;
}
// process the data, polls for the format. NOTE we test for a comma
// so an empty map or a map with 1 letter is doomed to be the old
// format. Shouldn't hurt
if(str.find(',') == std::string::npos) {
//old format
lg::wml_error << "Using the single letter map format is deprecated, support will be removed in version 1.3.3\n";
map_format_ = 1;
return read_game_map_old_(str, starting_positions);
}
// at this point we're the new format, we also dissapear in the future so
// inside the ifdef
map_format_ = 2;
#endif
size_t offset = 0;
size_t x = 0, y = 0, width = 0;
@ -709,172 +626,9 @@ t_map read_builder_map(const std::string& str)
return result;
}
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
void add_translation(const std::string& str, const t_letter& number)
{
lookup_table_[str[0]] = number;
}
std::string get_old_letter(const t_letter& number)
{
std::map<TERRAIN_LETTER, t_letter>::iterator itor = lookup_table_.begin();
for(; itor != lookup_table_.end(); ++itor) {
if(itor->second == number) return std::string(1, itor->first);
}
return "";
}
#endif
/***************************************************************************************/
//internal
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
static t_list string_to_vector_(const std::string& str, const bool convert_eol, const int separated)
{
// only used here so define here
const t_letter EOL(7, NO_LAYER);
bool last_eol = false;
t_list result;
std::string::const_iterator itor = str.begin();
for( ; itor != str.end(); ++itor) {
if(separated == 1 && *itor == ',') {
//ignore the character
last_eol = false;
} else if ((convert_eol) && (*itor == '\n' || *itor == '\r')) {
// end of line marker found
if(last_eol == false){
// last wasn't eol then add us
result.push_back(EOL);
}
last_eol = true;
} else {
// normal just add
last_eol = false;
result.push_back(letter_to_number_(*itor));
}
}
return result;
}
static t_letter letter_to_number_(const TERRAIN_LETTER terrain)
{
std::map<TERRAIN_LETTER, t_letter>::const_iterator itor = lookup_table_.find(terrain);
if(itor == lookup_table_.end()) {
ERR_G << "No translation found for old terrain letter " << terrain << "\n";
throw error("No translation found for old terrain letter");
}
return itor->second;
}
static t_map read_game_map_old_(const std::string& str, std::map<int, coordinate>& starting_positions)
{
size_t offset = 0;
size_t x = 0, y = 0, width = 0;
t_map result;
// skip the leading newlines
while(offset < str.length() && utils::isnewline(str[offset])) {
++offset;
}
// did we get an empty map?
if((offset + 1) >= str.length()) {
WRN_G << "Empty map found\n";
return result;
}
while(offset < str.length()) {
// handle newlines
if(utils::isnewline(str[offset])) {
// the first line we set the with the other lines we check the width
if(y == 0 ) {
// note x has been increased to the new value at the end of
// the loop so width = x and not x + 1
width = x;
} else {
if(x != width ) {
ERR_G << "Map not a rectangle error occured at line " << y << " position " << x << "\n";
throw error("Map not a rectangle.");
}
}
// prepare next itertration
++y;
x = 0;
++offset;
//skip the following newlines
while(offset < str.length() && utils::isnewline(str[offset])) {
++offset;
}
// stop if at end of file
if((offset + 1) >= str.length()) {
break;
}
}
// get a terrain chunk
TERRAIN_LETTER terrain = str[offset];
// process the chunk
int starting_position = lexical_cast_default<int>(std::string(1, terrain), -1);
// add to the resulting starting position
if(starting_position != -1) {
if(starting_positions.find(starting_position) != starting_positions.end()) {
// redefine existion position
WRN_G << "Starting position " << starting_position <<" redefined.\n";
starting_positions[starting_position].x = x;
starting_positions[starting_position].y = y;
} else {
// add new position
struct coordinate coord = {x, y};
starting_positions.insert(std::pair<int, coordinate>(starting_position, coord));
}
//the letter of the keep hardcoded, since this code is
//scheduled for removal the hardcoded letter is oke
terrain = 'K';
}
// make space for the new item
if(result.size() <= x) {
result.resize(x + 1);
}
if(result[x].size() <= y) {
result[x].resize(y + 1);
}
// add the resulting terrain number,
result[x][y] = letter_to_number_(terrain);
//set next value
++x;
++offset;
}
if(x != 0 && x != width) {
ERR_G << "Map not a rectangle error occured at the end\n";
throw error("Map not a rectangle.");
}
return result;
}
#endif
static t_list string_to_vector_(const std::string& str, const t_layer filler)
{
// handle an empty string
@ -1054,13 +808,10 @@ static t_letter string_to_number_(std::string str, int& start_position, const t_
}
#endif
#ifndef TERRAIN_TRANSLATION_COMPATIBLE
if(result == OBSOLETE_KEEP) {
lg::wml_error << "Using _K for a keep is deprecated, support will be removed in version 1.3.5\n";
result = HUMAN_KEEP;
}
#endif
return result;
}

View file

@ -14,25 +14,11 @@
#ifndef TERRAIN_TRANSLATION_H_INCLUDED
#define TERRAIN_TRANSLATION_H_INCLUDED
//NOTE due to backwards compability some items are done in a
// not so nice way. This will be corrected in version 1.3.3
// These items are marked with "FIXME: remove"
// Also the the next definition is used for the compatible
// mode. Disabling this define should make wesnoth run in
// non compatible mode. Using defines is not the most
// beautiful way to do things but this way both versions of
// the code can be made. The callers should be fixed after
// the undefing. The define is more a hint for me than
// to really use -- Mordante
#define TERRAIN_TRANSLATION_COMPATIBLE
#include <SDL_types.h> //used for Uint32 definition
#include <string>
#include <vector>
#include <map>
//#include "variable.hpp"
namespace t_translation {
typedef Uint32 t_layer;
@ -139,21 +125,8 @@ namespace t_translation {
extern const t_letter NOT; // !
extern const t_letter STAR; // *
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
//the terrain format lets the terrain functions know what to expect
// this is part of the backwards compability layer.
// T_FORMAT_LETTER the string is a terrain letter (single char)
// T_FORMAT_STRING the string is a terrain string (multiple chars)
// T_FORMAT_AUTO uses map_format_ to determine the type
enum { T_FORMAT_LETTER = 1, T_FORMAT_STRING = 2, T_FORMAT_AUTO = 3 };
extern const t_letter OBSOLETE_KEEP;
#endif
/**
* Reads a single terrain from a string
* FIXME: remove t_format
*
* @param str The string which should contain 1 letter the new format
* of a letter is 2 to 4 characters in the set
* [a-Z][A-Z]/|\_ The underscore is intended for internal
@ -163,12 +136,11 @@ namespace t_translation {
* be two groups separated by a caret, the first group
* is the base terrain, the second the overlay terrain.
*
* @param t_format The format to read
* @param filler if there's no layer this value will be used as the second layer
*
* @return A single terrain letter
*/
t_letter read_letter(const std::string& str, const int t_format, const t_layer filler = NO_LAYER);
t_letter read_letter(const std::string& str, const t_layer filler = NO_LAYER);
/**
* Writes a single letter to a string.
@ -184,22 +156,12 @@ namespace t_translation {
/**
* Reads a list of terrain from a string, when reading the
* old format the comma separator is optional the new format
* only reads with a separator and ignores
* FIXME: remove separated and t_format
*
* @param str A string with one or more terrain letters (see read_letter)
* @param separated The old terrain format is optional separated by a comma
* the new format is always separated by a comma and
* ignores this parameter. Possible values:
* 0 = no
* 1 = yes
* @param t_format The format to read.
* @param filler if there's no layer this value will be used as the second layer
*
* @returns A vector which contains the letters found in the string
*/
t_list read_list(const std::string& str, const int separated, const int t_format, const t_layer filler = NO_LAYER);
t_list read_list(const std::string& str, const t_layer filler = NO_LAYER);
/**
* Writes a list of terrains to a string, only writes the new format.
@ -349,14 +311,5 @@ namespace t_translation {
*/
t_map read_builder_map(const std::string& str);
/***************************************************************************************/
#ifdef TERRAIN_TRANSLATION_COMPATIBLE
// The terrain letter is an old letter and will be converted with get_letter
void add_translation(const std::string& letter, const t_letter& number);
std::string get_old_letter(const t_letter& number);
#endif
}
#endif

View file

@ -100,8 +100,7 @@ unit_animation::unit_animation(int start_time,const unit_frame & frame ):
}
unit_animation::unit_animation(const config& cfg,const std::string frame_string ) :
//this format hasn't been used yet, so force the new terrain format
terrain_types_(t_translation::read_list(cfg["terrain"], -1, t_translation::T_FORMAT_STRING))
terrain_types_(t_translation::read_list(cfg["terrain"]))
{
config::const_child_itors range = cfg.child_range(frame_string);
if(cfg["start_time"].empty() &&range.first != range.second) {