mirror of
https://github.com/glest/glest-source.git
synced 2025-08-12 03:14:00 +02:00
- bugfix for shared team resources
- added some new internal feature code to test auto updates for a future release
This commit is contained in:
@@ -845,6 +845,8 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getFileInternalFromServer(p
|
||||
pair<FTP_Client_ResultType,string> result = getFileFromServer(ftp_cct_File,
|
||||
fileName,remotePath, destFileSaveAs, "", "");
|
||||
|
||||
//printf("Got file [%s] result.first = %d\n",destFileSaveAs.c_str(),result.first);
|
||||
|
||||
// Extract the archive
|
||||
if(result.first == ftp_crt_SUCCESS) {
|
||||
string ext = extractExtension(destFileSaveAs);
|
||||
@@ -897,10 +899,18 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getTempFileInternalFromServ
|
||||
destFileSaveAs += fileName.first;
|
||||
|
||||
string remotePath = fileName.second;
|
||||
fileName.second = "";
|
||||
|
||||
pair<FTP_Client_ResultType,string> result = getFileFromServer(ftp_cct_TempFile,
|
||||
fileName,remotePath, destFileSaveAs, FTP_TEMPFILES_USERNAME, FTP_COMMON_PASSWORD);
|
||||
//printf("First [%s] Second [%s]\n",fileName.first.c_str(),fileName.second.c_str());
|
||||
pair<FTP_Client_ResultType,string> result;
|
||||
if(StartsWith(remotePath,"http://")) {
|
||||
result = getFileFromServer(ftp_cct_TempFile, fileName,remotePath, destFileSaveAs, "", "");
|
||||
}
|
||||
else {
|
||||
fileName.second = "";
|
||||
result = getFileFromServer(ftp_cct_TempFile,fileName,remotePath, destFileSaveAs, FTP_TEMPFILES_USERNAME, FTP_COMMON_PASSWORD);
|
||||
}
|
||||
|
||||
//printf("Got temp file [%s] result.first = %d\n",destFileSaveAs.c_str(),result.first);
|
||||
|
||||
// Extract the archive
|
||||
if(result.first == ftp_crt_SUCCESS) {
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "conversion.h"
|
||||
#include "util.h"
|
||||
@@ -31,7 +33,6 @@
|
||||
#include "utf8.h"
|
||||
#include "font.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -56,8 +57,6 @@ string Properties::tutorialPath = "";
|
||||
void Properties::load(const string &path, bool clearCurrentProperties) {
|
||||
|
||||
char lineBuffer[maxLine]="";
|
||||
string line, key, value, original_value;
|
||||
size_t pos=0;
|
||||
this->path= path;
|
||||
|
||||
bool is_utf8_language = valid_utf8_file(path.c_str());
|
||||
@@ -88,80 +87,7 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
|
||||
fileStream.getline(lineBuffer, maxLine);
|
||||
lineBuffer[maxLine-1]='\0';
|
||||
|
||||
//printf("\n[%ls]\n",lineBuffer);
|
||||
//printf("\n[%s]\n",&lineBuffer[0]);
|
||||
|
||||
if(lineBuffer[0] != '\0') {
|
||||
// If the file is NOT in UTF-8 format convert each line
|
||||
if(is_utf8_language == false && Font::forceLegacyFonts == false) {
|
||||
char *utfStr = ConvertToUTF8(&lineBuffer[0]);
|
||||
|
||||
//printf("\nBefore [%s] After [%s]\n",&lineBuffer[0],utfStr);
|
||||
|
||||
memset(&lineBuffer[0],0,maxLine);
|
||||
memcpy(&lineBuffer[0],&utfStr[0],strlen(utfStr));
|
||||
|
||||
delete [] utfStr;
|
||||
}
|
||||
else if(is_utf8_language == true && Font::forceLegacyFonts == true) {
|
||||
char *asciiStr = ConvertFromUTF8(&lineBuffer[0]);
|
||||
|
||||
//printf("\nBefore [%s] After [%s]\n",&lineBuffer[0],utfStr);
|
||||
|
||||
memset(&lineBuffer[0],0,maxLine);
|
||||
memcpy(&lineBuffer[0],&asciiStr[0],strlen(asciiStr));
|
||||
|
||||
delete [] asciiStr;
|
||||
}
|
||||
}
|
||||
|
||||
//process line if it it not a comment
|
||||
if(lineBuffer[0] != ';' && lineBuffer[0] != '#') {
|
||||
//wstring wstr = lineBuffer;
|
||||
//line.assign(wstr.begin(),wstr.end());
|
||||
|
||||
// gracefully handle win32 \r\n line endings
|
||||
size_t len= strlen(lineBuffer);
|
||||
if(len > 0 && lineBuffer[len-1] == '\r') {
|
||||
lineBuffer[len-1]= 0;
|
||||
}
|
||||
|
||||
line= lineBuffer;
|
||||
pos= line.find('=');
|
||||
|
||||
if(pos != string::npos){
|
||||
key= line.substr(0, pos);
|
||||
value= line.substr(pos+1);
|
||||
original_value = value;
|
||||
|
||||
if(applyTagsToValue(value) == true) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Property key [%s] now has value [%s] original_value [%s]\n",key.c_str(),value.c_str(),original_value.c_str());
|
||||
}
|
||||
|
||||
bool replaceExisting = false;
|
||||
if(propertyMap.find(key) != propertyMap.end()) {
|
||||
replaceExisting = true;
|
||||
}
|
||||
propertyMap[key] = original_value;
|
||||
propertyMapTmp[key] = value;
|
||||
|
||||
if(replaceExisting == false) {
|
||||
propertyVector.push_back(PropertyPair(key, original_value));
|
||||
propertyVectorTmp.push_back(PropertyPair(key, value));
|
||||
}
|
||||
else {
|
||||
for(unsigned int i = 0; i < propertyVector.size(); ++i) {
|
||||
PropertyPair ¤tPair = propertyVector[i];
|
||||
if(currentPair.first == key) {
|
||||
currentPair.second = original_value;
|
||||
|
||||
propertyVectorTmp[i].second = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
processTextLine(is_utf8_language,lineBuffer);
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
@@ -172,6 +98,108 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void Properties::loadFromText(const string &text) {
|
||||
bool is_utf8_language = false;
|
||||
|
||||
char lineBuffer[maxLine]="";
|
||||
|
||||
std::istringstream textStream(text);
|
||||
while(textStream.eof() == false) {
|
||||
//lineBuffer[0]='\0';
|
||||
std::string lineText;
|
||||
getline(textStream, lineText);
|
||||
if(lineText.length() > 0) {
|
||||
memset(&lineBuffer[0],0,maxLine);
|
||||
memcpy(&lineBuffer[0],&lineText[0],lineText.length());
|
||||
|
||||
//fileStream.getline(lineBuffer, maxLine);
|
||||
//lineBuffer[maxLine-1]='\0';
|
||||
|
||||
processTextLine(is_utf8_language,&lineBuffer[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Properties::processTextLine(bool is_utf8_language, char *lineBuffer) {
|
||||
//printf("\n[%ls]\n",lineBuffer);
|
||||
//printf("\n[%s]\n",&lineBuffer[0]);
|
||||
|
||||
string line, key, value, original_value;
|
||||
size_t pos=0;
|
||||
|
||||
if(lineBuffer != NULL && lineBuffer[0] != '\0') {
|
||||
// If the file is NOT in UTF-8 format convert each line
|
||||
if(is_utf8_language == false && Font::forceLegacyFonts == false) {
|
||||
char *utfStr = ConvertToUTF8(&lineBuffer[0]);
|
||||
|
||||
//printf("\nBefore [%s] After [%s]\n",&lineBuffer[0],utfStr);
|
||||
|
||||
memset(&lineBuffer[0],0,maxLine);
|
||||
memcpy(&lineBuffer[0],&utfStr[0],strlen(utfStr));
|
||||
|
||||
delete [] utfStr;
|
||||
}
|
||||
else if(is_utf8_language == true && Font::forceLegacyFonts == true) {
|
||||
char *asciiStr = ConvertFromUTF8(&lineBuffer[0]);
|
||||
|
||||
//printf("\nBefore [%s] After [%s]\n",&lineBuffer[0],utfStr);
|
||||
|
||||
memset(&lineBuffer[0],0,maxLine);
|
||||
memcpy(&lineBuffer[0],&asciiStr[0],strlen(asciiStr));
|
||||
|
||||
delete [] asciiStr;
|
||||
}
|
||||
}
|
||||
|
||||
//process line if it it not a comment
|
||||
if(lineBuffer != NULL && lineBuffer[0] != ';' && lineBuffer[0] != '#') {
|
||||
//wstring wstr = lineBuffer;
|
||||
//line.assign(wstr.begin(),wstr.end());
|
||||
|
||||
// gracefully handle win32 \r\n line endings
|
||||
size_t len= strlen(lineBuffer);
|
||||
if(len > 0 && lineBuffer[len-1] == '\r') {
|
||||
lineBuffer[len-1]= 0;
|
||||
}
|
||||
|
||||
line= lineBuffer;
|
||||
pos= line.find('=');
|
||||
|
||||
if(pos != string::npos){
|
||||
key= line.substr(0, pos);
|
||||
value= line.substr(pos+1);
|
||||
original_value = value;
|
||||
|
||||
if(applyTagsToValue(value) == true) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Property key [%s] now has value [%s] original_value [%s]\n",key.c_str(),value.c_str(),original_value.c_str());
|
||||
}
|
||||
|
||||
bool replaceExisting = false;
|
||||
if(propertyMap.find(key) != propertyMap.end()) {
|
||||
replaceExisting = true;
|
||||
}
|
||||
propertyMap[key] = original_value;
|
||||
propertyMapTmp[key] = value;
|
||||
|
||||
if(replaceExisting == false) {
|
||||
propertyVector.push_back(PropertyPair(key, original_value));
|
||||
propertyVectorTmp.push_back(PropertyPair(key, value));
|
||||
}
|
||||
else {
|
||||
for(unsigned int i = 0; i < propertyVector.size(); ++i) {
|
||||
PropertyPair ¤tPair = propertyVector[i];
|
||||
if(currentPair.first == key) {
|
||||
currentPair.second = original_value;
|
||||
|
||||
propertyVectorTmp[i].second = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::map<string,string> Properties::getTagReplacementValues(std::map<string,string> *mapExtraTagReplacementValues) {
|
||||
std::map<string,string> mapTagReplacementValues;
|
||||
|
||||
|
@@ -787,54 +787,70 @@ int round(float f){
|
||||
}
|
||||
|
||||
// ==================== misc ====================
|
||||
int compareMajorMinorVersion(string versionA,string versionB){
|
||||
int majorA=getMajor(versionA);
|
||||
int minorA=getMinor(versionA);
|
||||
int majorB=getMajor(versionB);
|
||||
int minorB=getMinor(versionB);
|
||||
int compareMajorMinorVersion(string versionA,string versionB, bool checkForNewVersionUpdates) {
|
||||
int majorA = getMajor(versionA);
|
||||
int minorA = getMinor(versionA);
|
||||
int majorB = getMajor(versionB);
|
||||
int minorB = getMinor(versionB);
|
||||
|
||||
if(majorA<majorB) return -1;
|
||||
else if(majorA==majorB){
|
||||
if(minorA<minorB) return -1;
|
||||
else if(minorA==minorB){
|
||||
if(majorA < majorB) {
|
||||
return -1;
|
||||
}
|
||||
else if(majorA == majorB) {
|
||||
if(minorA < minorB) {
|
||||
return -1;
|
||||
}
|
||||
else if(minorA == minorB) {
|
||||
if(checkForNewVersionUpdates) {
|
||||
if(versionA != versionB) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int getMajor(string version){
|
||||
vector<string> parts=split(version.substr(1),".");
|
||||
int getMajor(string version) {
|
||||
vector<string> parts = split(version.substr(1),".");
|
||||
|
||||
if(parts.size()>2 && parts[0] != "" && IsNumeric(parts[0].c_str(),false))
|
||||
if(parts.size() > 2 && parts[0] != "" && IsNumeric(parts[0].c_str(),false)) {
|
||||
return strToInt(parts[0]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int getMinor(string version){
|
||||
vector<string> parts=split(version.substr(1),".");
|
||||
if(parts.size()>2 && parts[1] != ""){
|
||||
int getMinor(string version) {
|
||||
vector<string> parts = split(version.substr(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) )
|
||||
if(IsNumeric((resultStr + parts[1][i]).c_str(),false) ) {
|
||||
resultStr += parts[1][i];
|
||||
else
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(resultStr=="")
|
||||
if(resultStr == "") {
|
||||
return 0;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return strToInt(resultStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool checkVersionComptability(string clientVersionString, string serverVersionString) {
|
||||
|
Reference in New Issue
Block a user