- updates to commondata handling. From now on commondata tag specified the commondata folder under a techtree making it easier to share data and portable since you just need to copy the techtree and its contents, this means no sharing data between techtrees (which is good since we don't want such dependencies)

This commit is contained in:
Mark Vejvoda 2011-05-06 22:12:16 +00:00
parent 9c992ed353
commit 449e3f25c8
28 changed files with 324 additions and 119 deletions

View File

@ -32,7 +32,6 @@ find glest.ini \( -name "*" \) -exec cp -p "{}" $RELEASEDIR/glest_linux.ini ';'
find glestkeys.ini \( -name "*" \) -exec cp -p --parents "{}" $RELEASEDIR ';'
find configuration.xml \( -name "*" \) -exec cp -p --parents "{}" $RELEASEDIR ';'
find commondata/ \( -name "*" \) -not \( -name .svn -prune \) -not \( -name "*~" -prune \) -not \( -name "*.bak" -prune \) -exec cp -p --parents "{}" $RELEASEDIR ';'
find data/ \( -name "*" \) -not \( -name .svn -prune \) -not \( -name "*~" -prune \) -not \( -name "*.bak" -prune \) -exec cp -p --parents "{}" $RELEASEDIR ';'
find docs/ \( -name "*" \) -not \( -name .svn -prune \) -not \( -name "*~" -prune \) -not \( -name "*.bak" -prune \) -exec cp -p --parents "{}" $RELEASEDIR ';'
find maps/ \( -name "*" \) -not \( -name .svn -prune \) -not \( -name "*~" -prune \) -not \( -name "*.bak" -prune \) -exec cp -p --parents "{}" $RELEASEDIR ';'

View File

@ -201,7 +201,6 @@ Section "${APNAME} (required)"
File "..\..\..\source\tools\glexemel\g3d_logo.png"
SetOutPath $INSTDIR
File /r /x .svn /x mydata "..\..\..\data\glest_game\commondata"
File /r /x .svn /x mydata "..\..\..\data\glest_game\data"
File /r /x .svn /x mydata "..\..\..\data\glest_game\docs"
File /r /x .svn /x mydata "..\..\..\data\glest_game\maps"
@ -279,7 +278,6 @@ Section "Uninstall"
Delete $INSTDIR\xerces-c_3_0.dll
Delete $INSTDIR\*.log
Delete $INSTDIR\commondata\*.*
Delete $INSTDIR\data\*.*
Delete $INSTDIR\docs\*.*
Delete $INSTDIR\maps\*.*
@ -289,7 +287,6 @@ Section "Uninstall"
Delete $INSTDIR\tilesets\*.*
Delete $INSTDIR\tutorials\*.*
RMDir /r $INSTDIR\commondata
RMDir /r $INSTDIR\data
RMDir /r $INSTDIR\docs
RMDir /r $INSTDIR\maps

View File

@ -43,7 +43,7 @@ void Configuration::load(const string &path){
void Configuration::loadStructure(const string &path){
XmlTree xmlTree;
xmlTree.load(path);
xmlTree.load(path,Properties::getTagReplacementValues());
const XmlNode *configurationNode= xmlTree.getRootNode();

View File

@ -931,7 +931,7 @@ void MainWindow::loadUnit(string path, string skillName) {
if(fileExists(unitXML) == true) {
XmlTree xmlTree;
xmlTree.load(unitXML);
xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode();
bool foundSkillName = false;
@ -1102,7 +1102,7 @@ void MainWindow::loadParticle(string path) {
if(fileExists(unitXML) == true) {
XmlTree xmlTree;
xmlTree.load(unitXML);
xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode();
const XmlNode *parametersNode= unitNode->getChild("parameters");
//size
@ -1116,7 +1116,7 @@ void MainWindow::loadParticle(string path) {
std::map<string,vector<pair<string, string> > > loadedFileList;
UnitParticleSystemType *unitParticleSystemType = new UnitParticleSystemType();
unitParticleSystemType->load(dir, dir + folderDelimiter + particlePath,
renderer,loadedFileList,"g3dviewer");
renderer,loadedFileList,"g3dviewer","");
unitParticleSystemTypes.push_back(unitParticleSystemType);
for(std::vector<UnitParticleSystemType *>::const_iterator it= unitParticleSystemTypes.begin(); it != unitParticleSystemTypes.end(); ++it) {
@ -1193,7 +1193,7 @@ void MainWindow::loadProjectileParticle(string path) {
if(fileExists(unitXML) == true) {
XmlTree xmlTree;
xmlTree.load(unitXML);
xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode();
const XmlNode *parametersNode= unitNode->getChild("parameters");
//size
@ -1205,7 +1205,7 @@ void MainWindow::loadProjectileParticle(string path) {
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath);
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl;
@ -1214,7 +1214,7 @@ void MainWindow::loadProjectileParticle(string path) {
ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile();
projectileParticleSystemType->load(dir,
dir + folderDelimiter + particlePath,renderer, loadedFileList,
"g3dviewer");
"g3dviewer","");
// std::cout << "Values loaded, about to read..." << std::endl;
@ -1296,7 +1296,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
if(fileExists(unitXML) == true) {
XmlTree xmlTree;
xmlTree.load(unitXML);
xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode();
const XmlNode *parametersNode= unitNode->getChild("parameters");
//size
@ -1308,7 +1308,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath);
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl;
@ -1316,7 +1316,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash();
splashParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer,
loadedFileList,"g3dviewer"); // <---- only that must be splash...
loadedFileList,"g3dviewer",""); // <---- only that must be splash...
// std::cout << "Values loaded, about to read..." << std::endl;

View File

@ -42,7 +42,7 @@ ParticleSystemType::ParticleSystemType() {
void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
string parentLoader, string techtreePath) {
//texture
const XmlNode *textureNode= particleSystemNode->getChild("texture");
bool textureEnabled= textureNode->getAttribute("value")->getBoolValue();
@ -188,16 +188,19 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
void ParticleSystemTypeProjectile::load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
string parentLoader, string techtreePath) {
try{
XmlTree xmlTree;
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techtreePath + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
const XmlNode *particleSystemNode= xmlTree.getRootNode();
ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList,parentLoader);
ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList,parentLoader, techtreePath);
//trajectory values
const XmlNode *tajectoryNode= particleSystemNode->getChild("trajectory");
@ -250,16 +253,19 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() {
void ParticleSystemTypeSplash::load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
string parentLoader, string techtreePath) {
try{
XmlTree xmlTree;
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techtreePath + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
const XmlNode *particleSystemNode= xmlTree.getRootNode();
ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList, parentLoader);
ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList, parentLoader, techtreePath);
//emission rate fade
const XmlNode *emissionRateFadeNode= particleSystemNode->getChild("emission-rate-fade");

View File

@ -69,7 +69,7 @@ public:
ParticleSystemType();
void load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
string parentLoader, string techtreePath);
void setValues(AttackParticleSystem *ats);
bool hasTexture() const { return(texture != NULL); }
bool hasModel() const { return(model != NULL); }
@ -92,7 +92,7 @@ private:
public:
void load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
string parentLoader, string techtreePath);
ProjectileParticleSystem *create();
};
@ -105,7 +105,7 @@ class ParticleSystemTypeSplash: public ParticleSystemType {
public:
void load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
string parentLoader, string techtreePath);
SplashParticleSystem *create();
private:

View File

@ -31,8 +31,9 @@ namespace Glest{ namespace Game{
void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList, parentLoader);
string parentLoader, string techtreePath) {
ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList,
parentLoader,techtreePath);
//radius
const XmlNode *radiusNode= particleSystemNode->getChild("radius");
radius= radiusNode->getAttribute("value")->getFloatValue();
@ -138,16 +139,19 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
void UnitParticleSystemType::load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
string parentLoader, string techtreePath) {
try{
XmlTree xmlTree;
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techtreePath + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
const XmlNode *particleSystemNode= xmlTree.getRootNode();
UnitParticleSystemType::load(particleSystemNode, dir, renderer,
loadedFileList, parentLoader);
loadedFileList, parentLoader, techtreePath);
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());

View File

@ -58,9 +58,10 @@ protected:
public:
void load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *newTexture, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
string parentLoader, string techtreePath);
void load(const string &dir, const string &path, RendererInterface *newTexture,
std::map<string,vector<pair<string, string> > > &loadedFileList,string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList,string parentLoader,
string techtreePath);
const void setValues (UnitParticleSystem *uts);
bool hasTexture() const { return(texture != NULL); }
};

View File

@ -969,11 +969,13 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n%s\t\t\tdisplays your SDL version information.",GAME_ARGS[GAME_ARG_SDL_INFO]);
printf("\n%s\t\t\tdisplays your LUA version information.",GAME_ARGS[GAME_ARG_LUA_INFO]);
printf("\n%s\t\t\tdisplays your CURL version information.",GAME_ARGS[GAME_ARG_CURL_INFO]);
printf("\n%s=x=purgeunused=purgeduplicates\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n%s=x=purgeunused=purgeduplicates=svndelete\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n \t\tto your selected techtrees game data.");
printf("\n \t\tWhere x is a comma-delimited list of techtrees to validate.");
printf("\n \t\tWhere purgeunused is an optional parameter telling the validation to delete extra files in the techtree that are not used.");
printf("\n \t\tWhere purgeduplicates is an optional parameter telling the validation to merge duplicate files in the techtree.");
printf("\n \t\tWhere svndelete is an optional parameter telling the validation to call svn delete on duplicate / unused files in the techtree.");
printf("\n \t\t*NOTE: This only applies when files are purged due to the above flags being set.");
printf("\n \t\texample: %s %s=megapack,vbros_pack_5",argv0,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n%s=x=purgeunused=purgeduplicates\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
printf("\n \t\tto your selected factions game data.");
@ -984,7 +986,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n \t\t%s",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n \t\texample: %s %s=tech,egypt",argv0,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
printf("\n%s=x=purgeunused\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]);
printf("\n%s=x=purgeunused=svndelete\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]);
printf("\n \t\tto your selected scenario game data.");
printf("\n \t\tWhere x is a single scenario to validate.");
printf("\n \t\tWhere purgeunused is an optional parameter telling the validation to delete extra files in the scenario that are not used.");
@ -1271,7 +1273,8 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
void runTechValidationForPath(string techPath, string techName,
const std::vector<string> filteredFactionList, World &world,
bool purgeUnusedFiles,bool purgeDuplicateFiles, double &purgedMegaBytes) {
bool purgeUnusedFiles,bool purgeDuplicateFiles, bool svnPurgeFiles,
double &purgedMegaBytes) {
Config &config = Config::getInstance();
vector<string> factionsList;
findDirs(techPath + techName + "/factions/", factionsList, false, false);
@ -1437,7 +1440,17 @@ void runTechValidationForPath(string techPath, string techName,
purgedMegaBytes += ((double)fileSize / 1048576.0);
purgeCount++;
removeFile(foundFile);
if(svnPurgeFiles == true) {
char szBuf[4096]="";
sprintf(szBuf,"svn delete \"%s\"",foundFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
}
}
else {
removeFile(foundFile);
}
}
}
}
@ -1525,22 +1538,51 @@ void runTechValidationForPath(string techPath, string techName,
newCommonFileName = "$COMMONDATAPATH/sounds/" + extractFileFromDirectoryPath(duplicateFile);
string expandedNewCommonFileName = newCommonFileName;
Properties::applyTagsToValue(expandedNewCommonFileName);
//int result = 0;
int result = rename(duplicateFile.c_str(),expandedNewCommonFileName.c_str());
if(result != 0) {
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techPath + techName + "/commondata/";
mapExtraTagReplacementValues = Properties::getTagReplacementValues(&mapExtraTagReplacementValues);
Properties::applyTagsToValue(expandedNewCommonFileName,&mapExtraTagReplacementValues);
createDirectoryPaths(extractDirectoryPathFromFile(expandedNewCommonFileName));
if(svnPurgeFiles == true) {
copyFileTo(duplicateFile, expandedNewCommonFileName);
char szBuf[4096]="";
char *errmsg = strerror(errno);
sprintf(szBuf,"!!! Error [%s] Could not rename [%s] to [%s]!",errmsg,duplicateFile.c_str(),expandedNewCommonFileName.c_str());
throw runtime_error(szBuf);
sprintf(szBuf,"svn delete \"%s\"",duplicateFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
}
printf("*** Duplicate file:\n[%s]\nwas svn deleted and copied to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
}
else {
printf("*** Duplicate file:\n[%s]\nwas renamed to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
//int result = 0;
int result = rename(duplicateFile.c_str(),expandedNewCommonFileName.c_str());
if(result != 0) {
char szBuf[4096]="";
char *errmsg = strerror(errno);
sprintf(szBuf,"!!! Error [%s] Could not rename [%s] to [%s]!",errmsg,duplicateFile.c_str(),expandedNewCommonFileName.c_str());
throw runtime_error(szBuf);
}
else {
printf("*** Duplicate file:\n[%s]\nwas renamed to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
}
}
}
else {
removeFile(duplicateFile);
if(svnPurgeFiles == true) {
char szBuf[4096]="";
sprintf(szBuf,"svn delete \"%s\"",duplicateFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
}
printf("*** Duplicate file:\n[%s]\nwas svn deleted\n",duplicateFile.c_str());
}
else {
removeFile(duplicateFile);
}
printf("*** Duplicate file:\n[%s]\nwas removed\n",duplicateFile.c_str());
// convert to MB
@ -1640,6 +1682,8 @@ void runTechValidationReport(int argc, char** argv) {
bool purgeDuplicateFiles = false;
bool purgeUnusedFiles = false;
bool svnPurgeFiles = false;
double purgedMegaBytes=0;
Config &config = Config::getInstance();
@ -1691,7 +1735,7 @@ void runTechValidationReport(int argc, char** argv) {
string file = scenarioPath + scenarioName + "/" + scenarioName + ".xml";
XmlTree xmlTree;
xmlTree.load(file);
xmlTree.load(file,Properties::getTagReplacementValues());
const XmlNode *scenarioNode= xmlTree.getRootNode();
string techName = scenarioNode->getChild("tech-tree")->getAttribute("value")->getValue();
@ -1702,7 +1746,7 @@ void runTechValidationReport(int argc, char** argv) {
printf("Found Scenario [%s] with custom techtree [%s] validating...\n",scenarioName.c_str(),techName.c_str());
runTechValidationForPath(techPath, techName, filteredFactionList,
world, purgeUnusedFiles, false, purgedMegaBytes);
world, purgeUnusedFiles, false, false, purgedMegaBytes);
}
//
//
@ -1785,6 +1829,10 @@ void runTechValidationReport(int argc, char** argv) {
purgeDuplicateFiles = true;
printf("*NOTE All duplicate techtree files will be merged!\n");
}
else if(paramPartTokens[2] == "svndelete") {
svnPurgeFiles = true;
printf("*NOTE All unused / duplicate techtree files will be removed from svn!\n");
}
}
if(paramPartTokens.size() >= 4) {
if(paramPartTokens[3] == "purgeunused") {
@ -1795,12 +1843,29 @@ void runTechValidationReport(int argc, char** argv) {
purgeDuplicateFiles = true;
printf("*NOTE All duplicate techtree files will be merged!\n");
}
else if(paramPartTokens[3] == "svndelete") {
svnPurgeFiles = true;
printf("*NOTE All unused / duplicate techtree files will be removed from svn!\n");
}
}
if(paramPartTokens.size() >= 5) {
if(paramPartTokens[4] == "purgeunused") {
purgeUnusedFiles = true;
printf("*NOTE All unused techtree files will be deleted!\n");
}
else if(paramPartTokens[4] == "purgeduplicates") {
purgeDuplicateFiles = true;
printf("*NOTE All duplicate techtree files will be merged!\n");
}
else if(paramPartTokens[4] == "svndelete") {
svnPurgeFiles = true;
printf("*NOTE All unused / duplicate techtree files will be removed from svn!\n");
}
}
}
}
{
printf("\n---------------- Loading factions inside world ----------------");
World world;
@ -1819,7 +1884,7 @@ void runTechValidationReport(int argc, char** argv) {
std::find(filteredTechTreeList.begin(),filteredTechTreeList.end(),techName) != filteredTechTreeList.end()) {
runTechValidationForPath(techPath, techName, filteredFactionList,
world, purgeUnusedFiles,purgeDuplicateFiles,purgedMegaBytes);
world, purgeUnusedFiles,purgeDuplicateFiles,svnPurgeFiles,purgedMegaBytes);
}
}
}

View File

@ -221,7 +221,7 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
//camera
XmlTree xmlTree;
xmlTree.load(data_path + "data/core/menu/menu.xml");
xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues());
const XmlNode *menuNode= xmlTree.getRootNode();
const XmlNode *cameraNode= menuNode->getChild("camera");

View File

@ -1,7 +1,7 @@
// ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Martiño Figueroa
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -40,7 +40,7 @@ MenuBackground::MenuBackground(){
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
XmlTree xmlTree;
xmlTree.load(data_path + "data/core/menu/menu.xml");
xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues());
const XmlNode *menuNode= xmlTree.getRootNode();
//water

View File

@ -245,7 +245,7 @@ void MenuStateScenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo
Lang &lang= Lang::getInstance();
XmlTree xmlTree;
xmlTree.load(file);
xmlTree.load(file,Properties::getTagReplacementValues());
const XmlNode *scenarioNode= xmlTree.getRootNode();
const XmlNode *difficultyNode= scenarioNode->getChild("difficulty");

View File

@ -118,7 +118,9 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
techtreeChecksum->addFile(path);
XmlTree xmlTree;
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techTree->getPath() + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
const XmlNode *factionNode= xmlTree.getRootNode();

View File

@ -17,6 +17,7 @@
#include "renderer.h"
#include "xml_parser.h"
#include "game_util.h"
#include "properties.h"
#include "leak_dumper.h"
using namespace Shared::Util;
@ -46,7 +47,7 @@ ResourceType::~ResourceType(){
}
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum,
std::map<string,vector<pair<string, string> > > &loadedFileList) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string techtreePath) {
string path, str;
Renderer &renderer= Renderer::getInstance();
@ -67,7 +68,9 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
//tree
XmlTree xmlTree;
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techtreePath + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
const XmlNode *resourceNode= xmlTree.getRootNode();
@ -104,7 +107,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
objectParticleSystemType->load(dir, currentPath + particlePath,
&Renderer::getInstance(), loadedFileList, sourceXMLFile);
&Renderer::getInstance(), loadedFileList, sourceXMLFile, techtreePath);
loadedFileList[currentPath + particlePath].push_back(make_pair(sourceXMLFile,particleFileNode->getAttribute("path")->getRestrictedValue()));
particleTypes.push_back(objectParticleSystemType);

View File

@ -54,7 +54,8 @@ public:
ResourceType();
~ResourceType();
void load(const string &dir, Checksum* checksum,Checksum *techtreeChecksum,
std::map<string,vector<pair<string, string> > > &loadedFileList);
std::map<string,vector<pair<string, string> > > &loadedFileList,
string techtreePath);
//get
int getClass() const {return resourceClass;}

View File

@ -81,7 +81,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();
unitParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance(),
loadedFileList,parentLoader);
loadedFileList,parentLoader,tt->getPath());
loadedFileList[currentPath + path].push_back(make_pair(parentLoader,particleFileNode->getAttribute("path")->getRestrictedValue()));
unitParticleSystemTypes.push_back(unitParticleSystemType);
}
@ -251,7 +251,8 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree
string path= particleNode->getAttribute("path")->getRestrictedValue();
projectileParticleSystemType= new ParticleSystemTypeProjectile();
projectileParticleSystemType->load(dir, currentPath + path,
&Renderer::getInstance(), loadedFileList, parentLoader);
&Renderer::getInstance(), loadedFileList, parentLoader,
tt->getPath());
}
//proj sounds
@ -286,7 +287,8 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree
string path= particleNode->getAttribute("path")->getRestrictedValue();
splashParticleSystemType= new ParticleSystemTypeSplash();
splashParticleSystemType->load(dir, currentPath + path,
&Renderer::getInstance(),loadedFileList, parentLoader);
&Renderer::getInstance(),loadedFileList, parentLoader,
tt->getPath());
}
}
}

View File

@ -34,6 +34,7 @@ namespace Glest{ namespace Game{
Checksum TechTree::loadTech(const vector<string> pathList, const string &techName,
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
name = "";
Checksum techtreeChecksum;
for(int idx = 0; idx < pathList.size(); idx++) {
string currentPath = pathList[idx];
@ -54,10 +55,10 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
string currentPath = dir;
endPathWithSlash(currentPath);
treePath = currentPath;
name= lastDir(currentPath);
vector<string> filenames;
string name= lastDir(currentPath);
Logger::getInstance().add("TechTree: "+ formatString(name), true);
//load resources
@ -69,7 +70,8 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
for(int i=0; i<filenames.size(); ++i){
str= currentPath + "resources/" + filenames[i];
resourceTypes[i].load(str, checksum, &checksumValue, loadedFileList);
resourceTypes[i].load(str, checksum, &checksumValue, loadedFileList,
treePath);
Window::handleEvent();
SDL_PumpEvents();
}
@ -99,7 +101,9 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
checksum->addFile(path);
checksumValue.addFile(path);
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = currentPath + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
const XmlNode *techTreeNode= xmlTree.getRootNode();

View File

@ -36,7 +36,11 @@ private:
typedef vector<AttackType> AttackTypes;
private:
string desc;
string name;
//string desc;
string treePath;
ResourceTypes resourceTypes;
FactionTypes factionTypes;
ArmorTypes armorTypes;
@ -57,7 +61,11 @@ public:
int getTypeCount() const {return factionTypes.size();}
const FactionType *getType(int i) const {return &factionTypes[i];}
const ResourceType *getResourceType(int i) const {return &resourceTypes[i];}
const string &getDesc() const {return desc;}
const string getName() const {return name;}
//const string &getDesc() const {return desc;}
const string getPath() const {return treePath;}
const FactionType *getType(const string &name) const;
FactionType *getTypeByName(const string &name);
const ResourceType *getResourceType(const string &name) const;

View File

@ -130,8 +130,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
this->id= id;
try{
try {
Logger::getInstance().add("Unit type: " + formatString(name), true);
//file load
@ -139,7 +138,9 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
techtreeChecksum->addFile(path);
XmlTree xmlTree;
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techTree->getPath() + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(dir,dir));
const XmlNode *unitNode= xmlTree.getRootNode();
@ -295,7 +296,8 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
Texture2D *newTexture = NULL;
unitParticleSystemType->load(dir, currentPath + path,
&Renderer::getInstance(),loadedFileList, sourceXMLFile);
&Renderer::getInstance(),loadedFileList, sourceXMLFile,
techTree->getPath());
loadedFileList[currentPath + path].push_back(make_pair(sourceXMLFile,particleFileNode->getAttribute("path")->getRestrictedValue()));
//if(unitParticleSystemType->hasTexture() == false) {

View File

@ -59,12 +59,14 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
string path = currentPath + name + ".xml";
string sourceXMLFile = path;
try{
try {
checksum->addFile(path);
techtreeChecksum->addFile(path);
XmlTree xmlTree;
xmlTree.load(path);
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techTree->getPath() + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
const XmlNode *upgradeNode= xmlTree.getRootNode();

View File

@ -19,6 +19,7 @@
#include "game_util.h"
#include <stdio.h>
#include "platform_common.h"
#include "properties.h"
#include "leak_dumper.h"
using namespace Shared::Xml;
@ -47,7 +48,7 @@ Checksum Scenario::load(const string &path) {
//parse xml
XmlTree xmlTree;
xmlTree.load(path);
xmlTree.load(path,Properties::getTagReplacementValues());
const XmlNode *scenarioNode= xmlTree.getRootNode();
const XmlNode *scriptsNode= scenarioNode->getChild("scripts");

View File

@ -19,6 +19,7 @@
#include "renderer.h"
#include "game_util.h"
#include "leak_dumper.h"
#include "properties.h"
#include "platform_util.h"
using namespace Shared::Util;
@ -158,7 +159,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
//parse xml
XmlTree xmlTree;
xmlTree.load(path);
xmlTree.load(path,Properties::getTagReplacementValues());
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -226,7 +227,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
objectParticleSystemType->load(dir, currentPath + path,
&Renderer::getInstance(), loadedFileList, sourceXMLFile);
&Renderer::getInstance(), loadedFileList, sourceXMLFile,"");
loadedFileList[currentPath + path].push_back(make_pair(sourceXMLFile,particleFileNode->getAttribute("path")->getRestrictedValue()));
objectTypes[i].addParticleSystem((objectParticleSystemType));

View File

@ -175,6 +175,7 @@ bool renameFile(string oldFile, string newFile);
void removeFolder(const string path);
off_t getFileSize(string filename);
bool searchAndReplaceTextInFile(string fileName, string findText, string replaceText, bool simulateOnly);
void copyFileTo(string fromFileName, string toFileName);
int getScreenW();
int getScreenH();

View File

@ -75,7 +75,8 @@ public:
void setFloat(const string &key, float value);
void setString(const string &key, const string &value);
static bool applyTagsToValue(string &value);
static bool applyTagsToValue(string &value, std::map<string,string> *mapTagReplacementValues=NULL);
static std::map<string,string> getTagReplacementValues(std::map<string,string> *mapExtraTagReplacementValues=NULL);
string getpath() const { return path;}

View File

@ -15,10 +15,10 @@
#include <string>
#include <vector>
#include <xercesc/util/XercesDefs.hpp>
#include <map>
#include "leak_dumper.h"
using std::string;
using std::vector;
using namespace std;
namespace XERCES_CPP_NAMESPACE{
class DOMImplementation;
@ -29,7 +29,7 @@ namespace XERCES_CPP_NAMESPACE{
namespace Shared{ namespace Xml{
const int strSize= 256;
const int strSize= 4096;
class XmlIo;
class XmlTree;
@ -53,7 +53,7 @@ private:
public:
static XmlIo &getInstance();
~XmlIo();
XmlNode *load(const string &path);
XmlNode *load(const string &path, std::map<string,string> mapTagReplacementValues);
void save(const string &path, const XmlNode *node);
};
@ -74,7 +74,7 @@ public:
~XmlTree();
void init(const string &name);
void load(const string &path);
void load(const string &path, std::map<string,string> mapTagReplacementValues);
void save(const string &path);
XmlNode *getRootNode() const {return rootNode;}
@ -84,7 +84,7 @@ public:
// class XmlNode
// =====================================================
class XmlNode{
class XmlNode {
private:
string name;
string text;
@ -96,7 +96,7 @@ private:
void operator =(XmlNode&);
public:
XmlNode(XERCES_CPP_NAMESPACE::DOMNode *node);
XmlNode(XERCES_CPP_NAMESPACE::DOMNode *node, std::map<string,string> mapTagReplacementValues);
XmlNode(const string &name);
~XmlNode();
@ -115,7 +115,7 @@ public:
XmlNode *addChild(const string &name);
XmlAttribute *addAttribute(const string &name, const string &value);
XmlAttribute *addAttribute(const string &name, const string &value, std::map<string,string> mapTagReplacementValues);
XERCES_CPP_NAMESPACE::DOMElement *buildElement(XERCES_CPP_NAMESPACE::DOMDocument *document) const;
@ -133,14 +133,15 @@ private:
string name;
bool skipRestrictionCheck;
bool usesCommondata;
std::map<string,string> mapTagReplacementValues;
private:
XmlAttribute(XmlAttribute&);
void operator =(XmlAttribute&);
public:
XmlAttribute(XERCES_CPP_NAMESPACE::DOMNode *attribute);
XmlAttribute(const string &name, const string &value);
XmlAttribute(XERCES_CPP_NAMESPACE::DOMNode *attribute, std::map<string,string> mapTagReplacementValues);
XmlAttribute(const string &name, const string &value, std::map<string,string> mapTagReplacementValues);
public:
const string getName() const {return name;}

View File

@ -1807,16 +1807,18 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) {
buff_ptr = buffer;
while ((find_ptr = strstr(buff_ptr,findText.c_str()))) {
//printf("Replacing text [%s] with [%s] in file [%s]\n",findText.c_str(),replaceText.c_str(),fileName.c_str());
if(findText != "") {
while ((find_ptr = strstr(buff_ptr,findText.c_str()))) {
//printf("Replacing text [%s] with [%s] in file [%s]\n",findText.c_str(),replaceText.c_str(),fileName.c_str());
while(buff_ptr < find_ptr) {
fputc((int)*buff_ptr++,fp2);
while(buff_ptr < find_ptr) {
fputc((int)*buff_ptr++,fp2);
}
fputs(replaceText.c_str(),fp2);
buff_ptr += find_len;
replacedText = true;
}
fputs(replaceText.c_str(),fp2);
buff_ptr += find_len;
replacedText = true;
}
fputs(buff_ptr,fp2);
}
@ -1835,6 +1837,24 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
return replacedText;
}
void copyFileTo(string fromFileName, string toFileName) {
const int MAX_LEN_SINGLE_LINE = 4096;
char buffer[MAX_LEN_SINGLE_LINE+2];
char *buff_ptr, *find_ptr;
FILE *fp1, *fp2;
fp1 = fopen(fromFileName.c_str(),"r");
fp2 = fopen(toFileName.c_str(),"w");
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) {
buff_ptr = buffer;
fputs(buff_ptr,fp2);
}
fclose(fp2);
fclose(fp1);
}
// =====================================
// ModeInfo
// =====================================

View File

@ -104,8 +104,87 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
fileStream.close();
}
bool Properties::applyTagsToValue(string &value) {
std::map<string,string> Properties::getTagReplacementValues(std::map<string,string> *mapExtraTagReplacementValues) {
std::map<string,string> mapTagReplacementValues;
//
// #1
// First add the standard tags
//
char *homeDir = NULL;
#ifdef WIN32
homeDir = getenv("USERPROFILE");
#else
homeDir = getenv("HOME");
#endif
mapTagReplacementValues["~/"] = (homeDir != NULL ? homeDir : "");
mapTagReplacementValues["$HOME"] = (homeDir != NULL ? homeDir : "");
mapTagReplacementValues["%%HOME%%"] = (homeDir != NULL ? homeDir : "");
mapTagReplacementValues["%%USERPROFILE%%"] = (homeDir != NULL ? homeDir : "");
mapTagReplacementValues["%%HOMEPATH%%"] = (homeDir != NULL ? homeDir : "");
// For win32 we allow use of the appdata variable since that is the recommended
// place for application data in windows platform
#ifdef WIN32
TCHAR szPath[MAX_PATH]="";
// Get path for each computer, non-user specific and non-roaming data.
if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_APPDATA,
NULL, 0, szPath))) {
string appPath = szPath;
mapTagReplacementValues["$APPDATA"] = appPath;
mapTagReplacementValues["%%APPDATA%%"] = appPath;
}
#endif
char *username = NULL;
username = getenv("USERNAME");
mapTagReplacementValues["$USERNAME"] = (username != NULL ? username : "");
mapTagReplacementValues["%%USERNAME%%"] = (username != NULL ? username : "");
mapTagReplacementValues["$APPLICATIONPATH"] = Properties::applicationPath;
mapTagReplacementValues["%%APPLICATIONPATH%%"] = Properties::applicationPath;
#if defined(CUSTOM_DATA_INSTALL_PATH)
mapTagReplacementValues["$APPLICATIONDATAPATH"] = CUSTOM_DATA_INSTALL_PATH;
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = CUSTOM_DATA_INSTALL_PATH;
//mapTagReplacementValues["$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//mapTagReplacementValues["%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
#else
mapTagReplacementValues["$APPLICATIONDATAPATH"] = Properties::applicationPath;
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = Properties::applicationPath;
//mapTagReplacementValues["$COMMONDATAPATH", Properties::applicationPath + "/commondata/");
//mapTagReplacementValues["%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/");
#endif
//
// #2
// Next add the extra tags if passed in
//
if(mapExtraTagReplacementValues != NULL) {
for(std::map<string,string>::iterator iterMap = mapExtraTagReplacementValues->begin();
iterMap != mapExtraTagReplacementValues->end(); ++iterMap) {
mapTagReplacementValues[iterMap->first] = iterMap->second;
}
}
return mapTagReplacementValues;
}
bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTagReplacementValues) {
string originalValue = value;
if(mapTagReplacementValues != NULL) {
for(std::map<string,string>::iterator iterMap = mapTagReplacementValues->begin();
iterMap != mapTagReplacementValues->end(); ++iterMap) {
replaceAll(value, iterMap->first, iterMap->second);
}
}
else {
char *homeDir = NULL;
#ifdef WIN32
homeDir = getenv("USERPROFILE");
@ -144,17 +223,19 @@ bool Properties::applyTagsToValue(string &value) {
replaceAll(value, "$APPLICATIONDATAPATH", CUSTOM_DATA_INSTALL_PATH);
replaceAll(value, "%%APPLICATIONDATAPATH%%", CUSTOM_DATA_INSTALL_PATH);
replaceAll(value, "$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
replaceAll(value, "%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//replaceAll(value, "$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//replaceAll(value, "%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
#else
replaceAll(value, "$APPLICATIONDATAPATH", Properties::applicationPath);
replaceAll(value, "%%APPLICATIONDATAPATH%%", Properties::applicationPath);
replaceAll(value, "$COMMONDATAPATH", Properties::applicationPath + "/commondata/");
replaceAll(value, "%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/");
//replaceAll(value, "$COMMONDATAPATH", Properties::applicationPath + "/commondata/");
//replaceAll(value, "%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/");
#endif
}
//printf("\nBEFORE SUBSTITUTE [%s] AFTER [%s]\n",originalValue.c_str(),value.c_str());
return (originalValue != value);
}

View File

@ -88,7 +88,7 @@ XmlIo::~XmlIo(){
XMLPlatformUtils::Terminate();
}
XmlNode *XmlIo::load(const string &path){
XmlNode *XmlIo::load(const string &path, std::map<string,string> mapTagReplacementValues) {
try{
ErrorHandler errorHandler;
@ -111,7 +111,7 @@ XmlNode *XmlIo::load(const string &path){
throw runtime_error("Can not parse URL: " + path);
}
XmlNode *rootNode= new XmlNode(document->getDocumentElement());
XmlNode *rootNode= new XmlNode(document->getDocumentElement(),mapTagReplacementValues);
parser->release();
return rootNode;
}
@ -167,8 +167,8 @@ void XmlTree::init(const string &name){
this->rootNode= new XmlNode(name);
}
void XmlTree::load(const string &path){
this->rootNode= XmlIo::getInstance().load(path);
void XmlTree::load(const string &path, std::map<string,string> mapTagReplacementValues) {
this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues);
}
void XmlTree::save(const string &path){
@ -183,7 +183,7 @@ XmlTree::~XmlTree(){
// class XmlNode
// =====================================================
XmlNode::XmlNode(DOMNode *node) {
XmlNode::XmlNode(DOMNode *node, std::map<string,string> mapTagReplacementValues) {
if(node == NULL || node->getNodeName() == NULL) {
throw runtime_error("XML structure seems to be corrupt!");
}
@ -203,7 +203,7 @@ XmlNode::XmlNode(DOMNode *node) {
for(unsigned int i = 0; i < node->getChildNodes()->getLength(); ++i) {
DOMNode *currentNode= node->getChildNodes()->item(i);
if(currentNode != NULL && currentNode->getNodeType()==DOMNode::ELEMENT_NODE){
XmlNode *xmlNode= new XmlNode(currentNode);
XmlNode *xmlNode= new XmlNode(currentNode, mapTagReplacementValues);
children.push_back(xmlNode);
}
}
@ -215,7 +215,7 @@ XmlNode::XmlNode(DOMNode *node) {
for(unsigned int i = 0; i < domAttributes->getLength(); ++i) {
DOMNode *currentNode= domAttributes->item(i);
if(currentNode->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
XmlAttribute *xmlAttribute= new XmlAttribute(domAttributes->item(i));
XmlAttribute *xmlAttribute= new XmlAttribute(domAttributes->item(i), mapTagReplacementValues);
attributes.push_back(xmlAttribute);
}
}
@ -321,8 +321,8 @@ XmlNode *XmlNode::addChild(const string &name){
return node;
}
XmlAttribute *XmlNode::addAttribute(const string &name, const string &value) {
XmlAttribute *attr= new XmlAttribute(name, value);
XmlAttribute *XmlNode::addAttribute(const string &name, const string &value, std::map<string,string> mapTagReplacementValues) {
XmlAttribute *attr= new XmlAttribute(name, value, mapTagReplacementValues);
attributes.push_back(attr);
return attr;
}
@ -371,27 +371,30 @@ string XmlNode::getTreeString() const {
// class XmlAttribute
// =====================================================
XmlAttribute::XmlAttribute(DOMNode *attribute) {
skipRestrictionCheck = false;
usesCommondata = false;
char str[strSize]="";
XmlAttribute::XmlAttribute(DOMNode *attribute, std::map<string,string> mapTagReplacementValues) {
skipRestrictionCheck = false;
usesCommondata = false;
this->mapTagReplacementValues = mapTagReplacementValues;
char str[strSize] = "";
XMLString::transcode(attribute->getNodeValue(), str, strSize-1);
value= str;
usesCommondata = ((value.find("$COMMONDATAPATH") != string::npos) || (value.find("%%COMMONDATAPATH%%") != string::npos));
skipRestrictionCheck = Properties::applyTagsToValue(this->value);
skipRestrictionCheck = Properties::applyTagsToValue(this->value,&this->mapTagReplacementValues);
XMLString::transcode(attribute->getNodeName(), str, strSize-1);
name= str;
}
XmlAttribute::XmlAttribute(const string &name, const string &value) {
skipRestrictionCheck = false;
usesCommondata = false;
this->name= name;
this->value= value;
XmlAttribute::XmlAttribute(const string &name, const string &value, std::map<string,string> mapTagReplacementValues) {
skipRestrictionCheck = false;
usesCommondata = false;
this->mapTagReplacementValues = mapTagReplacementValues;
this->name = name;
this->value = value;
usesCommondata = ((value.find("$COMMONDATAPATH") != string::npos) || (value.find("%%COMMONDATAPATH%%") != string::npos));
skipRestrictionCheck = Properties::applyTagsToValue(this->value);
skipRestrictionCheck = Properties::applyTagsToValue(this->value,&this->mapTagReplacementValues);
}
bool XmlAttribute::getBoolValue() const {