Comparison of version numbers allows non integer characters too

This is used to check compatibility of saved games typically.
Only the leading digits are used as minor version now.
This commit is contained in:
titiger
2014-12-21 13:35:42 +01:00
parent 1a8c28cc93
commit b50cb7770c

View File

@@ -819,9 +819,20 @@ int getMajor(string version){
int getMinor(string version){
vector<string> parts=split(version.substr(1),".");
if(parts.size()>2 && parts[1] != "" && IsNumeric(parts[1].c_str(),false))
return strToInt(parts[1]);
if(parts.size()>2 && parts[1] != ""){
string resultStr="";
for (int i = 0; i < (int)parts[1].length(); ++i) {
// just add leading numbers
if(IsNumeric((resultStr+parts[1][i]).c_str(),false) )
resultStr += parts[1][i];
else
break;
}
if(resultStr=="")
return 0;
else
return strToInt(resultStr);
}
else
return 0;
}