mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 05:57:00 -04:00
nicer error messags when aliases don't but should apply
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@242 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+15
-6
@@ -32,9 +32,9 @@ Reader::Reader(const String& filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Reader::addAlias(Version end_version, const Char* a, const Char* b) {
|
void Reader::addAlias(Version end_version, const Char* a, const Char* b) {
|
||||||
if (file_app_version < end_version) {
|
Alias& alias = aliasses[a];
|
||||||
aliasses[a] = b;
|
alias.new_key = b;
|
||||||
}
|
alias.end_version = end_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::handleAppVersion() {
|
void Reader::handleAppVersion() {
|
||||||
@@ -126,13 +126,22 @@ void Reader::readLine() {
|
|||||||
|
|
||||||
void Reader::unknownKey() {
|
void Reader::unknownKey() {
|
||||||
// aliasses?
|
// aliasses?
|
||||||
map<String,String>::const_iterator it = aliasses.find(key);
|
map<String,Alias>::const_iterator it = aliasses.find(key);
|
||||||
if (it != aliasses.end()) {
|
if (it != aliasses.end()) {
|
||||||
if (aliasses.find(it->second) != aliasses.end()) {
|
if (aliasses.find(it->second.new_key) != aliasses.end()) {
|
||||||
// alias points to another alias, don't follow it, there is the risk of infinite loops
|
// alias points to another alias, don't follow it, there is the risk of infinite loops
|
||||||
|
} else if (it->second.end_version <= file_version) {
|
||||||
|
// alias not used for this version, use in warning
|
||||||
|
if (indent == expected_indent) {
|
||||||
|
warning(_("Unexpected key: '") + key + _("' try '") + it->second.new_key + _("'"));
|
||||||
|
do {
|
||||||
|
moveNext();
|
||||||
|
} while (indent > expected_indent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// try this key instead
|
// try this key instead
|
||||||
key = it->second;
|
key = it->second.new_key;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,12 @@ class Reader {
|
|||||||
/// Did we just open a block (i.e. not read any more lines of it)?
|
/// Did we just open a block (i.e. not read any more lines of it)?
|
||||||
bool just_opened;
|
bool just_opened;
|
||||||
/// Aliasses for compatability
|
/// Aliasses for compatability
|
||||||
map<String, String> aliasses;
|
struct Alias {
|
||||||
|
String new_key;
|
||||||
|
Version end_version;
|
||||||
|
};
|
||||||
|
/// Aliasses for compatability
|
||||||
|
map<String, Alias> aliasses;
|
||||||
|
|
||||||
/// Filename for error messages
|
/// Filename for error messages
|
||||||
String filename;
|
String filename;
|
||||||
|
|||||||
Reference in New Issue
Block a user