From b50cb7770c194de2d7c0df6a3df1f6d76e6dc85a Mon Sep 17 00:00:00 2001 From: titiger Date: Sun, 21 Dec 2014 13:35:42 +0100 Subject: [PATCH] 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. --- source/shared_lib/sources/util/util.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 56c289044..06c1a70ea 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -819,9 +819,20 @@ int getMajor(string version){ int getMinor(string version){ vector 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; }