mirror of
https://github.com/glest/glest-source.git
synced 2025-08-28 18:29:48 +02:00
- moved version checking into one common method in the util file. Now all network related checks use this common method to determine version compatibility
This commit is contained in:
@@ -180,6 +180,7 @@ int round(float f);
|
||||
|
||||
//misc
|
||||
bool fileExists(const string &path);
|
||||
bool checkVersionComptability(string clientVersionString, string serverVersionString);
|
||||
|
||||
template<typename T>
|
||||
void deleteValues(T beginIt, T endIt){
|
||||
|
@@ -542,4 +542,24 @@ bool fileExists(const string &path){
|
||||
return false;
|
||||
}
|
||||
|
||||
bool checkVersionComptability(string clientVersionString, string serverVersionString) {
|
||||
bool compatible = (clientVersionString == serverVersionString);
|
||||
if(compatible == false) {
|
||||
vector<string> tokens;
|
||||
vector<string> tokensServer;
|
||||
Tokenize(clientVersionString,tokens,".");
|
||||
Tokenize(serverVersionString,tokensServer,".");
|
||||
|
||||
// only check the first 3 sections with . to compare makor versions #'s
|
||||
compatible = (tokens.size() >= 3 && tokensServer.size() >= 3);
|
||||
for(int i = 0; compatible == true && i < 3; ++i) {
|
||||
if(tokens[i] != tokensServer[i]) {
|
||||
compatible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compatible;
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
Reference in New Issue
Block a user