diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 6ad4dfda2..71468c895 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -1116,7 +1116,7 @@ void MainWindow::loadParticle(string path) { std::map > loadedFileList; UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType(); unitParticleSystemType->load(dir, dir + folderDelimiter + particlePath, - renderer,loadedFileList); + renderer,loadedFileList,"g3dviewer"); unitParticleSystemTypes.push_back(unitParticleSystemType); for(std::vector::const_iterator it= unitParticleSystemTypes.begin(); it != unitParticleSystemTypes.end(); ++it) { @@ -1213,7 +1213,8 @@ void MainWindow::loadProjectileParticle(string path) { std::map > loadedFileList; ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile(); projectileParticleSystemType->load(dir, - dir + folderDelimiter + particlePath,renderer, loadedFileList); + dir + folderDelimiter + particlePath,renderer, loadedFileList, + "g3dviewer"); // std::cout << "Values loaded, about to read..." << std::endl; @@ -1315,7 +1316,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp std::map > loadedFileList; ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash(); splashParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer, - loadedFileList); // <---- only that must be splash... + loadedFileList,"g3dviewer"); // <---- only that must be splash... // std::cout << "Values loaded, about to read..." << std::endl; diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index 4fb489e3f..a80883ad1 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -41,7 +41,8 @@ ParticleSystemType::ParticleSystemType() { } void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *renderer, std::map > &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader) { //texture const XmlNode *textureNode= particleSystemNode->getChild("texture"); bool textureEnabled= textureNode->getAttribute("value")->getBoolValue(); @@ -58,7 +59,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d string currentPath = dir; endPathWithSlash(currentPath); texture->load(textureNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(parentLoader); } else { texture= NULL; @@ -75,8 +76,8 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d string path= modelNode->getAttribute("path")->getRestrictedValue(currentPath); model= renderer->newModel(rsGame); - model->load(path, false, &loadedFileList, ¤tPath); - loadedFileList[path].push_back(currentPath); + model->load(path, false, &loadedFileList, &parentLoader); + loadedFileList[path].push_back(parentLoader); } } else { @@ -186,16 +187,17 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){ // =========================================================== void ParticleSystemTypeProjectile::load(const string &dir, const string &path, - RendererInterface *renderer, std::map > &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader) { try{ XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path].push_back(dir); + loadedFileList[path].push_back(parentLoader); const XmlNode *particleSystemNode= xmlTree.getRootNode(); - ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList); + ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList,parentLoader); //trajectory values const XmlNode *tajectoryNode= particleSystemNode->getChild("trajectory"); @@ -247,16 +249,17 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() { // =========================================================== void ParticleSystemTypeSplash::load(const string &dir, const string &path, - RendererInterface *renderer, std::map > &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader) { try{ XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path].push_back(dir); + loadedFileList[path].push_back(parentLoader); const XmlNode *particleSystemNode= xmlTree.getRootNode(); - ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList); + ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList, parentLoader); //emission rate fade const XmlNode *emissionRateFadeNode= particleSystemNode->getChild("emission-rate-fade"); diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index 29940b95c..dfce24550 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -68,7 +68,8 @@ protected: public: ParticleSystemType(); void load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *renderer, std::map > &loadedFileList); + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader); void setValues(AttackParticleSystem *ats); bool hasTexture() const { return(texture != NULL); } bool hasModel() const { return(model != NULL); } @@ -90,7 +91,8 @@ private: public: void load(const string &dir, const string &path, - RendererInterface *renderer, std::map > &loadedFileList); + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader); ProjectileParticleSystem *create(); }; @@ -102,7 +104,8 @@ public: class ParticleSystemTypeSplash: public ParticleSystemType { public: void load(const string &dir, const string &path, - RendererInterface *renderer, std::map > &loadedFileList); + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader); SplashParticleSystem *create(); private: diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index 15736c098..b83306d8c 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -30,8 +30,9 @@ namespace Glest{ namespace Game{ // ===================================================== void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *renderer, std::map > &loadedFileList) { - ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList); + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader) { + ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList, parentLoader); //radius const XmlNode *radiusNode= particleSystemNode->getChild("radius"); radius= radiusNode->getAttribute("value")->getFloatValue(); @@ -136,16 +137,17 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){ } void UnitParticleSystemType::load(const string &dir, const string &path, - RendererInterface *renderer, std::map > &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList, + string parentLoader) { try{ XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path].push_back(dir); + loadedFileList[path].push_back(parentLoader); const XmlNode *particleSystemNode= xmlTree.getRootNode(); UnitParticleSystemType::load(particleSystemNode, dir, renderer, - loadedFileList); + loadedFileList, parentLoader); } catch(const exception &e){ SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); @@ -153,5 +155,4 @@ void UnitParticleSystemType::load(const string &dir, const string &path, } } - }}//end mamespace diff --git a/source/glest_game/graphics/unit_particle_type.h b/source/glest_game/graphics/unit_particle_type.h index c60129c28..6a4070321 100644 --- a/source/glest_game/graphics/unit_particle_type.h +++ b/source/glest_game/graphics/unit_particle_type.h @@ -57,9 +57,10 @@ protected: public: void load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *newTexture, std::map > &loadedFileList); + RendererInterface *newTexture, std::map > &loadedFileList, + string parentLoader); void load(const string &dir, const string &path, RendererInterface *newTexture, - std::map > &loadedFileList); + std::map > &loadedFileList,string parentLoader); const void setValues (UnitParticleSystem *uts); bool hasTexture() const { return(texture != NULL); } }; diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index bd4965d32..be1ecc2a3 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1460,6 +1460,7 @@ void runTechValidationForPath(string techPath, string techName, printf("\nWarning, duplicate files were detected - START:\n=====================\n"); } + map parentList; for(unsigned int idx = 0; idx < fileList.size(); ++idx) { string duplicateFile = fileList[idx]; if(idx > 0) { @@ -1473,15 +1474,21 @@ void runTechValidationForPath(string techPath, string techName, } printf("[%s]\n",duplicateFile.c_str()); -// std::map >::iterator iterFind = loadedFileList.find(duplicateFile); -// if(iterFind != loadedFileList.end()) { -// for(unsigned int jdx = 0; jdx < iterFind->second.size(); jdx++) { -// if(jdx == 0) { -// printf("\tParents:\n"); -// } -// printf("\t[%s]\n",iterFind->second[jdx].c_str()); -// } -// } + std::map >::iterator iterFind = loadedFileList.find(duplicateFile); + if(iterFind != loadedFileList.end()) { + for(unsigned int jdx = 0; jdx < iterFind->second.size(); jdx++) { + parentList[iterFind->second[jdx]]++; + } + } + } + + for(map::iterator iterMap = parentList.begin(); + iterMap != parentList.end(); iterMap++) { + + if(iterMap == parentList.begin()) { + printf("\tParents:\n"); + } + printf("\t[%s]\n",iterMap->first.c_str()); } } } diff --git a/source/glest_game/types/command_type.cpp b/source/glest_game/types/command_type.cpp index 5149f67d4..f0151d8ac 100644 --- a/source/glest_game/types/command_type.cpp +++ b/source/glest_game/types/command_type.cpp @@ -44,7 +44,8 @@ CommandClass CommandType::getClass() const{ void CommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { + std::map > &loadedFileList, + string parentLoader) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); this->id= id; @@ -57,7 +58,7 @@ void CommandType::load(int id, const XmlNode *n, const string &dir, string currentPath = dir; endPathWithSlash(currentPath); image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(parentLoader); //unit requirements const XmlNode *unitRequirementsNode= n->getChild("unit-requirements"); @@ -112,8 +113,8 @@ string StopCommandType::toString() const{ void StopCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList,string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader); //stop string skillName= n->getChild("stop-skill")->getAttribute("value")->getRestrictedValue(); @@ -137,8 +138,9 @@ void MoveCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameInde void MoveCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList, + string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader); //move string skillName= n->getChild("move-skill")->getAttribute("value")->getRestrictedValue(); @@ -186,8 +188,9 @@ void AttackCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIn void AttackCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList, + string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader); //move string skillName= n->getChild("move-skill")->getAttribute("value")->getRestrictedValue(); @@ -278,8 +281,8 @@ void AttackStoppedCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int void AttackStoppedCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList,string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader); //stop string skillName= n->getChild("stop-skill")->getAttribute("value")->getRestrictedValue(); @@ -365,8 +368,8 @@ void BuildCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameInd void BuildCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList, string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader); //move string skillName= n->getChild("move-skill")->getAttribute("value")->getRestrictedValue(); @@ -397,7 +400,7 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir, StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); startSounds[i]= sound; } } @@ -415,7 +418,7 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir, StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); builtSounds[i]= sound; } } @@ -460,8 +463,8 @@ void HarvestCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameI void HarvestCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList, string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader); //move string skillName= n->getChild("move-skill")->getAttribute("value")->getRestrictedValue(); @@ -541,8 +544,8 @@ void RepairCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIn void RepairCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList, string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader); //move string skillName= n->getChild("move-skill")->getAttribute("value")->getRestrictedValue(); @@ -614,8 +617,8 @@ void ProduceCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameI void ProduceCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList, string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader); //produce string skillName= n->getChild("produce-skill")->getAttribute("value")->getRestrictedValue(); @@ -679,9 +682,9 @@ void UpgradeCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameI void UpgradeCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { + std::map > &loadedFileList, string parentLoader) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader); //upgrade string skillName= n->getChild("upgrade-skill")->getAttribute("value")->getRestrictedValue(); @@ -736,8 +739,8 @@ void MorphCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameInd void MorphCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList) { - CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); + std::map > &loadedFileList, string parentLoader) { + CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader); //morph skill string skillName= n->getChild("morph-skill")->getAttribute("value")->getRestrictedValue(); diff --git a/source/glest_game/types/command_type.h b/source/glest_game/types/command_type.h index 44cbfc955..dcf805a52 100644 --- a/source/glest_game/types/command_type.h +++ b/source/glest_game/types/command_type.h @@ -83,7 +83,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const= 0; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const= 0; virtual string toString() const= 0; virtual const ProducibleType *getProduced() const {return NULL;} @@ -117,7 +117,8 @@ public: StopCommandType(); virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, - const FactionType *ft, const UnitType &ut, std::map > &loadedFileList); + const FactionType *ft, const UnitType &ut, std::map > &loadedFileList, + string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual Queueability isQueuable() const {return qNever;} @@ -140,7 +141,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -163,7 +164,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -187,7 +188,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -215,7 +216,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -248,7 +249,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual Queueability isQueuable() const {return qOnRequest;} @@ -282,7 +283,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -311,7 +312,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string getReqDesc() const; virtual string toString() const; @@ -339,7 +340,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual string getReqDesc() const; @@ -367,7 +368,7 @@ public: virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const; virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut, - std::map > &loadedFileList); + std::map > &loadedFileList, string parentLoader); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual string getReqDesc() const; diff --git a/source/glest_game/types/resource_type.cpp b/source/glest_game/types/resource_type.cpp index 1e92f9f05..d2564edea 100644 --- a/source/glest_game/types/resource_type.cpp +++ b/source/glest_game/types/resource_type.cpp @@ -61,6 +61,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre string currentPath = dir; endPathWithSlash(currentPath); path= currentPath + name + ".xml"; + string sourceXMLFile = path; checksum->addFile(path); techtreeChecksum->addFile(path); @@ -75,7 +76,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre const XmlNode *imageNode= resourceNode->getChild("image"); image= renderer.newTexture2D(rsGame); image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile); //type const XmlNode *typeNode= resourceNode->getChild("type"); @@ -90,8 +91,8 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre string modelPath= modelNode->getAttribute("path")->getRestrictedValue(currentPath); model= renderer.newModel(rsGame); - model->load(modelPath, false, &loadedFileList, ¤tPath); - loadedFileList[modelPath].push_back(currentPath); + model->load(modelPath, false, &loadedFileList, &sourceXMLFile); + loadedFileList[modelPath].push_back(sourceXMLFile); if(modelNode->hasChild("particles")){ const XmlNode *particleNode= modelNode->getChild("particles"); @@ -103,8 +104,8 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType(); objectParticleSystemType->load(dir, currentPath + particlePath, - &Renderer::getInstance(), loadedFileList); - loadedFileList[currentPath + particlePath].push_back(currentPath); + &Renderer::getInstance(), loadedFileList, sourceXMLFile); + loadedFileList[currentPath + particlePath].push_back(sourceXMLFile); particleTypes.push_back(objectParticleSystemType); } diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 303410b4f..ff7f05583 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -42,7 +42,8 @@ SkillType::~SkillType() { } void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map > &loadedFileList) { + const FactionType *ft, std::map > &loadedFileList, + string parentLoader) { //name name= sn->getChild("name")->getAttribute("value")->getRestrictedValue(); @@ -67,8 +68,8 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, string path= sn->getChild("animation")->getAttribute("path")->getRestrictedValue(currentPath); animation= Renderer::getInstance().newModel(rsGame); - animation->load(path, false, &loadedFileList, ¤tPath); - loadedFileList[path].push_back(currentPath); + animation->load(path, false, &loadedFileList, &parentLoader); + loadedFileList[path].push_back(parentLoader); //particles if(sn->hasChild("particles")) { @@ -80,8 +81,8 @@ 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); - loadedFileList[currentPath + path].push_back(currentPath); + loadedFileList,parentLoader); + loadedFileList[currentPath + path].push_back(parentLoader); unitParticleSystemTypes.push_back(unitParticleSystemType); } } @@ -98,7 +99,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); sounds[i]= sound; } } @@ -192,8 +193,9 @@ AttackSkillType::~AttackSkillType() { } void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map > &loadedFileList) { - SkillType::load(sn, dir, tt, ft, loadedFileList); + const FactionType *ft, std::map > &loadedFileList, + string parentLoader) { + SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader); string currentPath = dir; endPathWithSlash(currentPath); @@ -249,7 +251,7 @@ 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); + &Renderer::getInstance(), loadedFileList, parentLoader); } //proj sounds @@ -263,7 +265,7 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); projSounds[i]= sound; } } @@ -283,7 +285,7 @@ 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); + &Renderer::getInstance(),loadedFileList, parentLoader); } } } @@ -406,8 +408,9 @@ DieSkillType::DieSkillType(){ } void DieSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map > &loadedFileList) { - SkillType::load(sn, dir, tt, ft, loadedFileList); + const FactionType *ft, std::map > &loadedFileList, + string parentLoader) { + SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader); fade= sn->getChild("fade")->getAttribute("value")->getBoolValue(); } diff --git a/source/glest_game/types/skill_type.h b/source/glest_game/types/skill_type.h index 0289166ea..0841cc141 100644 --- a/source/glest_game/types/skill_type.h +++ b/source/glest_game/types/skill_type.h @@ -92,7 +92,8 @@ public: //varios virtual ~SkillType(); virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map > &loadedFileList); + const FactionType *ft, std::map > &loadedFileList, + string parentLoader); //get const string &getName() const {return name;} @@ -162,7 +163,8 @@ public: AttackSkillType(); ~AttackSkillType(); virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map > &loadedFileList); + const FactionType *ft, std::map > &loadedFileList, + string parentLoader); virtual string toString() const; //get @@ -282,7 +284,8 @@ public: bool getFade() const {return fade;} virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map > &loadedFileList); + const FactionType *ft, std::map > &loadedFileList, + string parentLoader); virtual string toString() const; }; diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 843a0d57d..286feea7b 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -126,6 +126,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, string currentPath = dir; endPathWithSlash(currentPath); string path = currentPath + name + ".xml"; + string sourceXMLFile = path; this->id= id; @@ -294,8 +295,8 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, Texture2D *newTexture = NULL; unitParticleSystemType->load(dir, currentPath + path, - &Renderer::getInstance(),loadedFileList); - loadedFileList[currentPath + path].push_back(dir); + &Renderer::getInstance(),loadedFileList, sourceXMLFile); + loadedFileList[currentPath + path].push_back(sourceXMLFile); //if(unitParticleSystemType->hasTexture() == false) { //Renderer::getInstance().endLastTexture(rsGame,true); @@ -399,13 +400,13 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const XmlNode *imageNode= parametersNode->getChild("image"); image= Renderer::getInstance().newTexture2D(rsGame); image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile); //image cancel const XmlNode *imageCancelNode= parametersNode->getChild("image-cancel"); cancelImage= Renderer::getInstance().newTexture2D(rsGame); cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile); //meeting point const XmlNode *meetingPointNode= parametersNode->getChild("meeting-point"); @@ -413,33 +414,33 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, if(meetingPoint) { meetingPointImage= Renderer::getInstance().newTexture2D(rsGame); meetingPointImage->load(meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)); - loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile); } //selection sounds const XmlNode *selectionSoundNode= parametersNode->getChild("selection-sounds"); if(selectionSoundNode->getAttribute("enabled")->getBoolValue()){ selectionSounds.resize(selectionSoundNode->getChildCount()); - for(int i=0; igetChild("sound", i); string path= soundNode->getAttribute("path")->getRestrictedValue(currentPath); StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(sourceXMLFile); selectionSounds[i]= sound; } } //command sounds const XmlNode *commandSoundNode= parametersNode->getChild("command-sounds"); - if(commandSoundNode->getAttribute("enabled")->getBoolValue()){ + if(commandSoundNode->getAttribute("enabled")->getBoolValue()) { commandSounds.resize(commandSoundNode->getChildCount()); - for(int i=0; igetChildCount(); ++i){ + for(int i = 0; i < commandSoundNode->getChildCount(); ++i) { const XmlNode *soundNode= commandSoundNode->getChild("sound", i); string path= soundNode->getAttribute("path")->getRestrictedValue(currentPath); StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(sourceXMLFile); commandSounds[i]= sound; } } @@ -452,7 +453,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const XmlNode *typeNode= sn->getChild("type"); string classId= typeNode->getAttribute("value")->getRestrictedValue(); SkillType *skillType= SkillTypeFactory::getInstance().newInstance(classId); - skillType->load(sn, dir, techTree, factionType, loadedFileList); + skillType->load(sn, dir, techTree, factionType, loadedFileList,sourceXMLFile); skillTypes[i]= skillType; } @@ -465,7 +466,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, string classId= typeNode->getAttribute("value")->getRestrictedValue(); CommandType *commandType= CommandTypeFactory::getInstance().newInstance(classId); commandType->load(i, commandNode, dir, techTree, factionType, *this, - loadedFileList); + loadedFileList,sourceXMLFile); commandTypes[i]= commandType; } diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index f0dadc0dd..ba4cda85e 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -57,6 +57,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, string currentPath = dir; endPathWithSlash(currentPath); string path = currentPath + name + ".xml"; + string sourceXMLFile = path; try{ checksum->addFile(path); @@ -71,7 +72,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const XmlNode *imageNode= upgradeNode->getChild("image"); image= Renderer::getInstance().newTexture2D(rsGame); image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)); - loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(currentPath); + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(sourceXMLFile); //if(fileExists(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) { // printf("\n***ERROR MISSING FILE [%s]\n",imageNode->getAttribute("path")->getRestrictedValue(currentPath,true).c_str()); @@ -81,7 +82,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const XmlNode *imageCancelNode= upgradeNode->getChild("image-cancel"); cancelImage= Renderer::getInstance().newTexture2D(rsGame); cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)); - loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(currentPath); + loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(sourceXMLFile); //if(fileExists(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) { // printf("\n***ERROR MISSING FILE [%s]\n",imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true).c_str()); diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index 45f48a70a..62968d903 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -32,8 +32,8 @@ namespace Glest{ namespace Game{ // ===================================================== void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, - std::map > &loadedFileList) { - string path; + std::map > &loadedFileList, string parentLoader) { + string path=""; //day const XmlNode *dayNode= xmlNode->getChild("day-sound"); @@ -44,7 +44,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, path= dayNode->getAttribute("path")->getRestrictedValue(currentPath); day.open(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); alwaysPlayDay= dayNode->getAttribute("play-always")->getBoolValue(); } @@ -58,7 +58,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, path= nightNode->getAttribute("path")->getRestrictedValue(currentPath); night.open(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); alwaysPlayNight= nightNode->getAttribute("play-always")->getBoolValue(); } @@ -72,7 +72,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, path= rainNode->getAttribute("path")->getRestrictedValue(currentPath); rain.open(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); } //snow @@ -84,7 +84,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, path= snowNode->getAttribute("path")->getRestrictedValue(currentPath); snow.open(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); } //dayStart @@ -96,7 +96,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, path= dayStartNode->getAttribute("path")->getRestrictedValue(currentPath); dayStart.load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); } //nightStart @@ -108,7 +108,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, path= nightStartNode->getAttribute("path")->getRestrictedValue(currentPath); nightStart.load(path); - loadedFileList[path].push_back(currentPath); + loadedFileList[path].push_back(parentLoader); } } @@ -144,6 +144,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck string currentPath = dir; endPathWithSlash(currentPath); string path= currentPath + name + ".xml"; + string sourceXMLFile = path; checksum->addFile(path); tilesetChecksum->addFile(path); @@ -186,7 +187,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck const XmlNode *textureNode= surfaceNode->getChild("texture", j); surfPixmaps[i][j].init(3); surfPixmaps[i][j].load(textureNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile); surfProbs[i][j]= textureNode->getAttribute("prob")->getFloatValue(); } @@ -213,8 +214,8 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck for(int j=0; jgetChild("model", j); const XmlAttribute *pathAttribute= modelNode->getAttribute("path"); - objectTypes[i].loadModel(pathAttribute->getRestrictedValue(currentPath),&loadedFileList, currentPath); - loadedFileList[pathAttribute->getRestrictedValue(currentPath)].push_back(currentPath); + objectTypes[i].loadModel(pathAttribute->getRestrictedValue(currentPath),&loadedFileList, sourceXMLFile); + loadedFileList[pathAttribute->getRestrictedValue(currentPath)].push_back(sourceXMLFile); if(modelNode->hasChild("particles")){ const XmlNode *particleNode= modelNode->getChild("particles"); @@ -225,8 +226,8 @@ 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); - loadedFileList[currentPath + path].push_back(currentPath); + &Renderer::getInstance(), loadedFileList, sourceXMLFile); + loadedFileList[currentPath + path].push_back(sourceXMLFile); objectTypes[i].addParticleSystem((objectParticleSystemType)); } @@ -243,7 +244,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //ambient sounds - ambientSounds.load(dir, tilesetNode->getChild("ambient-sounds"), loadedFileList); + ambientSounds.load(dir, tilesetNode->getChild("ambient-sounds"), loadedFileList, sourceXMLFile); //parameters const XmlNode *parametersNode= tilesetNode->getChild("parameters"); @@ -262,7 +263,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck for(int i=0; igetChild("texture", i); waterTex->getPixmap()->loadSlice(waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath), i); - loadedFileList[waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); + loadedFileList[waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile); } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/world/tileset.h b/source/glest_game/world/tileset.h index c77c25e7c..353348a80 100644 --- a/source/glest_game/world/tileset.h +++ b/source/glest_game/world/tileset.h @@ -89,7 +89,7 @@ public: StaticSound *getNightStart() {return &nightStart;} void load(const string &dir, const XmlNode *xmlNode, - std::map > &loadedFileList); + std::map > &loadedFileList,string parentLoader); }; // =====================================================