diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index a43a26b3c..6ad4dfda2 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -1113,7 +1113,7 @@ void MainWindow::loadParticle(string path) { // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; - std::map loadedFileList; + std::map > loadedFileList; UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType(); unitParticleSystemType->load(dir, dir + folderDelimiter + particlePath, renderer,loadedFileList); @@ -1210,7 +1210,7 @@ void MainWindow::loadProjectileParticle(string path) { // std::cout << "Loaded successfully, loading values..." << std::endl; - std::map loadedFileList; + std::map > loadedFileList; ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile(); projectileParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer, loadedFileList); @@ -1312,7 +1312,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp // std::cout << "Loaded successfully, loading values..." << std::endl; - std::map loadedFileList; + std::map > loadedFileList; ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash(); splashParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer, loadedFileList); // <---- only that must be splash... diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 5d8475142..ea92fa678 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -458,7 +458,7 @@ void Game::load() { } void Game::load(LoadGameItem loadTypes) { - std::map loadedFileList; + std::map > loadedFileList; originalDisplayMsgCallback = NetworkInterface::getDisplayMessageFunction(); NetworkInterface::setDisplayMessageFunction(ErrorDisplayMessage); diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index 6b821ef9e..4fb489e3f 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -41,7 +41,7 @@ ParticleSystemType::ParticleSystemType() { } void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *renderer, std::map &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList) { //texture const XmlNode *textureNode= particleSystemNode->getChild("texture"); bool textureEnabled= textureNode->getAttribute("value")->getBoolValue(); @@ -58,7 +58,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)]++; + loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); } else { texture= NULL; @@ -75,8 +75,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); - loadedFileList[path]++; + model->load(path, false, &loadedFileList, ¤tPath); + loadedFileList[path].push_back(currentPath); } } else { @@ -186,12 +186,12 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){ // =========================================================== void ParticleSystemTypeProjectile::load(const string &dir, const string &path, - RendererInterface *renderer, std::map &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList) { try{ XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(dir); const XmlNode *particleSystemNode= xmlTree.getRootNode(); @@ -247,12 +247,12 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() { // =========================================================== void ParticleSystemTypeSplash::load(const string &dir, const string &path, - RendererInterface *renderer, std::map &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList) { try{ XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(dir); const XmlNode *particleSystemNode= xmlTree.getRootNode(); diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index abaf486a6..29940b95c 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -68,7 +68,7 @@ protected: public: ParticleSystemType(); void load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *renderer, std::map &loadedFileList); + RendererInterface *renderer, std::map > &loadedFileList); void setValues(AttackParticleSystem *ats); bool hasTexture() const { return(texture != NULL); } bool hasModel() const { return(model != NULL); } @@ -90,7 +90,7 @@ private: public: void load(const string &dir, const string &path, - RendererInterface *renderer, std::map &loadedFileList); + RendererInterface *renderer, std::map > &loadedFileList); ProjectileParticleSystem *create(); }; @@ -102,7 +102,7 @@ public: class ParticleSystemTypeSplash: public ParticleSystemType { public: void load(const string &dir, const string &path, - RendererInterface *renderer, std::map &loadedFileList); + RendererInterface *renderer, std::map > &loadedFileList); SplashParticleSystem *create(); private: diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index 4d56c89d9..15736c098 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -30,7 +30,7 @@ namespace Glest{ namespace Game{ // ===================================================== void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *renderer, std::map &loadedFileList) { + RendererInterface *renderer, std::map > &loadedFileList) { ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList); //radius const XmlNode *radiusNode= particleSystemNode->getChild("radius"); @@ -136,12 +136,12 @@ 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) { try{ XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(dir); const XmlNode *particleSystemNode= xmlTree.getRootNode(); UnitParticleSystemType::load(particleSystemNode, dir, renderer, diff --git a/source/glest_game/graphics/unit_particle_type.h b/source/glest_game/graphics/unit_particle_type.h index 2315e4a34..c60129c28 100644 --- a/source/glest_game/graphics/unit_particle_type.h +++ b/source/glest_game/graphics/unit_particle_type.h @@ -57,9 +57,9 @@ protected: public: void load(const XmlNode *particleSystemNode, const string &dir, - RendererInterface *newTexture, std::map &loadedFileList); + RendererInterface *newTexture, std::map > &loadedFileList); void load(const string &dir, const string &path, RendererInterface *newTexture, - std::map &loadedFileList); + std::map > &loadedFileList); 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 2a80c74c9..bd4965d32 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1296,7 +1296,7 @@ void runTechValidationForPath(string techPath, string techName, if(factions.size() > 0) { bool techtree_errors = false; - std::map loadedFileList; + std::map > loadedFileList; //vector pathList = config.getPathListForType(ptTechs,""); vector pathList; pathList.push_back(techPath); @@ -1304,8 +1304,8 @@ void runTechValidationForPath(string techPath, string techName, // Fixup paths with .. { - std::map newLoadedFileList; - for( std::map::iterator iterMap = loadedFileList.begin(); + std::map > newLoadedFileList; + for( std::map >::iterator iterMap = loadedFileList.begin(); iterMap != loadedFileList.end(); ++iterMap) { string loadedFile = iterMap->first; @@ -1358,7 +1358,7 @@ void runTechValidationForPath(string techPath, string techName, } // Now check for unused files in the techtree - std::map foundFileList; + std::map > foundFileList; for(unsigned int i = 0; i < pathList.size(); ++i) { string path = pathList[i]; endPathWithSlash(path); @@ -1388,13 +1388,13 @@ void runTechValidationForPath(string techPath, string techName, replaceAll(file,"//","/"); replaceAll(file,"\\\\","\\"); - foundFileList[file]++; + foundFileList[file].push_back(path); } } printf("Found techtree filecount = %lu, used = %lu\n",(unsigned long)foundFileList.size(),(unsigned long)loadedFileList.size()); -// for( std::map::iterator iterMap = loadedFileList.begin(); +// for( std::map >::iterator iterMap = loadedFileList.begin(); // iterMap != loadedFileList.end(); ++iterMap) { // string foundFile = iterMap->first; // @@ -1405,7 +1405,7 @@ void runTechValidationForPath(string techPath, string techName, int purgeCount = 0; bool foundUnusedFile = false; - for( std::map::iterator iterMap = foundFileList.begin(); + for( std::map >::iterator iterMap = foundFileList.begin(); iterMap != foundFileList.end(); ++iterMap) { string foundFile = iterMap->first; @@ -1438,6 +1438,58 @@ void runTechValidationForPath(string techPath, string techName, printf("\nWarning, unused files were detected - END:\n"); } + std::map > mapDuplicateFiles; + // Now check for duplicate data content + for(std::map >::iterator iterMap = loadedFileList.begin(); + iterMap != loadedFileList.end(); iterMap++) { + string fileName = iterMap->first; + Checksum checksum; + checksum.addFile(fileName); + int32 crcValue = checksum.getSum(); + mapDuplicateFiles[crcValue].push_back(fileName); + } + double duplicateMegaBytes=0; + int duplicateCount=0; + bool foundDuplicates = false; + for(std::map >::iterator iterMap = mapDuplicateFiles.begin(); + iterMap != mapDuplicateFiles.end(); iterMap++) { + vector &fileList = iterMap->second; + if(fileList.size() > 1) { + if(foundDuplicates == false) { + foundDuplicates = true; + printf("\nWarning, duplicate files were detected - START:\n=====================\n"); + } + + for(unsigned int idx = 0; idx < fileList.size(); ++idx) { + string duplicateFile = fileList[idx]; + if(idx > 0) { + off_t fileSize = getFileSize(duplicateFile); + // convert to MB + duplicateMegaBytes += ((double)fileSize / 1048576.0); + duplicateCount++; + } + else { + printf("\n"); + } + + 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()); +// } +// } + } + } + } + if(foundDuplicates == true) { + printf("Duplicates %.2f MB (%d) in files\n",duplicateMegaBytes,duplicateCount); + printf("\nWarning, duplicate files were detected - END:\n"); + } + if(techtree_errors == false) { printf("\nValidation found NO ERRORS for techPath [%s] techName [%s] factions checked (count = %d):\n",techPath.c_str(), techName.c_str(),(int)factions.size()); for ( set::iterator it = factions.begin(); it != factions.end(); ++it ) { @@ -2005,6 +2057,12 @@ int glestMain(int argc, char** argv) { // printf("error %s opening resource\n", u_errorName(status)); // } + // TEST: + //string testfile = "/home/softcoder/Code/megaglest/trunk/mk/linux/techs/megapack/factions/egypt/units/desert_camp/../../upgrades/spear_weapons/images/piercing.bmp"; + //updatePathClimbingParts(testfile); + //return -1; + //CHANGED relative path from [/home/softcoder/Code/megaglest/trunk/mk/linux/techs/megapack/factions/egypt/units/desert_camp/../../upgrades/spear_weapons/images/piercing.bmp] to [/home/softcoder/Code/megaglest/trunk/mk/linux/techs/megapack/factions/egypt/units/desert_camp/upgrades/spear_weapons/images/piercing.bmp] + const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]); for(int idx = 1; idx < argc; ++idx) { if( hasCommandArgument(knownArgCount, (char **)&GAME_ARGS[0], argv[idx], NULL, 0, true) == false) { diff --git a/source/glest_game/types/command_type.cpp b/source/glest_game/types/command_type.cpp index 15fdafdc3..5149f67d4 100644 --- a/source/glest_game/types/command_type.cpp +++ b/source/glest_game/types/command_type.cpp @@ -44,7 +44,7 @@ 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) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); this->id= id; @@ -57,7 +57,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)]++; + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); //unit requirements const XmlNode *unitRequirementsNode= n->getChild("unit-requirements"); @@ -112,7 +112,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //stop @@ -137,7 +137,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //move @@ -186,7 +186,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //move @@ -278,7 +278,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //stop @@ -365,7 +365,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //move @@ -397,7 +397,7 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir, StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); startSounds[i]= sound; } } @@ -415,7 +415,7 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir, StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); builtSounds[i]= sound; } } @@ -460,7 +460,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //move @@ -541,7 +541,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //move @@ -614,7 +614,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //produce @@ -679,7 +679,7 @@ 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) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); @@ -736,7 +736,7 @@ 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) { + std::map > &loadedFileList) { CommandType::load(id, n, dir, tt, ft, ut, loadedFileList); //morph skill diff --git a/source/glest_game/types/command_type.h b/source/glest_game/types/command_type.h index c1199d486..44cbfc955 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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const= 0; virtual string toString() const= 0; virtual const ProducibleType *getProduced() const {return NULL;} @@ -117,7 +117,7 @@ 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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual Queueability isQueuable() const {return qNever;} @@ -140,7 +140,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -163,7 +163,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -187,7 +187,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -215,7 +215,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -248,7 +248,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual Queueability isQueuable() const {return qOnRequest;} @@ -282,7 +282,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; @@ -311,7 +311,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string getReqDesc() const; virtual string toString() const; @@ -339,7 +339,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual string getReqDesc() const; @@ -367,7 +367,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); virtual string getDesc(const TotalUpgrade *totalUpgrade) const; virtual string toString() const; virtual string getReqDesc() const; diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index 32a8b290e..e6e6c2739 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -37,7 +37,7 @@ FactionType::FactionType() { //load a faction, given a directory void FactionType::load(const string &dir, const TechTree *techTree, Checksum* checksum, - Checksum *techtreeChecksum, std::map &loadedFileList) { + Checksum *techtreeChecksum, std::map > &loadedFileList) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -119,7 +119,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); const XmlNode *factionNode= xmlTree.getRootNode(); @@ -153,7 +153,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch if(value) { music= new StrSound(); music->open(musicNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[musicNode->getAttribute("path")->getRestrictedValue(currentPath)]++; + loadedFileList[musicNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); } } 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/types/faction_type.h b/source/glest_game/types/faction_type.h index b94db1c6c..72e9cd9be 100644 --- a/source/glest_game/types/faction_type.h +++ b/source/glest_game/types/faction_type.h @@ -48,7 +48,7 @@ public: //init FactionType(); void load(const string &dir, const TechTree *techTree, Checksum* checksum, - Checksum *techtreeChecksum, std::map &loadedFileList); + Checksum *techtreeChecksum, std::map > &loadedFileList); ~FactionType(); //get diff --git a/source/glest_game/types/object_type.cpp b/source/glest_game/types/object_type.cpp index ee9969ebf..fd2793c66 100644 --- a/source/glest_game/types/object_type.cpp +++ b/source/glest_game/types/object_type.cpp @@ -38,9 +38,10 @@ ObjectType::~ObjectType(){ //Logger::getInstance().add("ObjectType", true); } -void ObjectType::loadModel(const string &path, std::map *loadedFileList) { +void ObjectType::loadModel(const string &path, std::map > *loadedFileList, + string parentLoader) { Model *model= Renderer::getInstance().newModel(rsGame); - model->load(path, false, loadedFileList); + model->load(path, false, loadedFileList, &parentLoader); color= Vec3f(0.f); if(model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) { const Pixmap2D *p= model->getMesh(0)->getTexture(0)->getPixmapConst(); diff --git a/source/glest_game/types/object_type.h b/source/glest_game/types/object_type.h index 9583e6b56..41ca44703 100644 --- a/source/glest_game/types/object_type.h +++ b/source/glest_game/types/object_type.h @@ -56,7 +56,8 @@ public: ~ObjectType(); void init(int modelCount, int objectClass, bool walkable, int height); - void loadModel(const string &path, std::map *loadedFileList=NULL); + void loadModel(const string &path, std::map > *loadedFileList=NULL, + string parentLoader=""); void addParticleSystem(ObjectParticleSystemType *particleSystem); Model *getModel(int i) {return models[i];} diff --git a/source/glest_game/types/resource_type.cpp b/source/glest_game/types/resource_type.cpp index e62853c35..1e92f9f05 100644 --- a/source/glest_game/types/resource_type.cpp +++ b/source/glest_game/types/resource_type.cpp @@ -46,7 +46,7 @@ ResourceType::~ResourceType(){ } void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum, - std::map &loadedFileList) { + std::map > &loadedFileList) { string path, str; Renderer &renderer= Renderer::getInstance(); @@ -67,7 +67,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre //tree XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); const XmlNode *resourceNode= xmlTree.getRootNode(); @@ -75,7 +75,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)]++; + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); //type const XmlNode *typeNode= resourceNode->getChild("type"); @@ -90,8 +90,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); - loadedFileList[modelPath]++; + model->load(modelPath, false, &loadedFileList, ¤tPath); + loadedFileList[modelPath].push_back(currentPath); if(modelNode->hasChild("particles")){ const XmlNode *particleNode= modelNode->getChild("particles"); @@ -104,7 +104,7 @@ 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]++; + loadedFileList[currentPath + particlePath].push_back(currentPath); particleTypes.push_back(objectParticleSystemType); } diff --git a/source/glest_game/types/resource_type.h b/source/glest_game/types/resource_type.h index 505ab7b3d..5ebe6530c 100644 --- a/source/glest_game/types/resource_type.h +++ b/source/glest_game/types/resource_type.h @@ -54,7 +54,7 @@ public: ResourceType(); ~ResourceType(); void load(const string &dir, Checksum* checksum,Checksum *techtreeChecksum, - std::map &loadedFileList); + std::map > &loadedFileList); //get int getClass() const {return resourceClass;} diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 188c942ca..303410b4f 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -42,7 +42,7 @@ 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) { //name name= sn->getChild("name")->getAttribute("value")->getRestrictedValue(); @@ -67,8 +67,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); - loadedFileList[path]++; + animation->load(path, false, &loadedFileList, ¤tPath); + loadedFileList[path].push_back(currentPath); //particles if(sn->hasChild("particles")) { @@ -81,7 +81,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType(); unitParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance(), loadedFileList); - loadedFileList[currentPath + path]++; + loadedFileList[currentPath + path].push_back(currentPath); unitParticleSystemTypes.push_back(unitParticleSystemType); } } @@ -98,7 +98,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); sounds[i]= sound; } } @@ -192,7 +192,7 @@ AttackSkillType::~AttackSkillType() { } void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map &loadedFileList) { + const FactionType *ft, std::map > &loadedFileList) { SkillType::load(sn, dir, tt, ft, loadedFileList); string currentPath = dir; @@ -263,7 +263,7 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); projSounds[i]= sound; } } @@ -406,7 +406,7 @@ DieSkillType::DieSkillType(){ } void DieSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, - const FactionType *ft, std::map &loadedFileList) { + const FactionType *ft, std::map > &loadedFileList) { SkillType::load(sn, dir, tt, ft, loadedFileList); 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 4472dff8f..0289166ea 100644 --- a/source/glest_game/types/skill_type.h +++ b/source/glest_game/types/skill_type.h @@ -92,7 +92,7 @@ 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); //get const string &getName() const {return name;} @@ -162,7 +162,7 @@ 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); virtual string toString() const; //get @@ -282,7 +282,7 @@ 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); virtual string toString() const; }; diff --git a/source/glest_game/types/tech_tree.cpp b/source/glest_game/types/tech_tree.cpp index 0f1bb9b36..a899efdc1 100644 --- a/source/glest_game/types/tech_tree.cpp +++ b/source/glest_game/types/tech_tree.cpp @@ -33,7 +33,7 @@ namespace Glest{ namespace Game{ // ===================================================== Checksum TechTree::loadTech(const vector pathList, const string &techName, - set &factions, Checksum* checksum, std::map &loadedFileList) { + set &factions, Checksum* checksum, std::map > &loadedFileList) { Checksum techtreeChecksum; for(int idx = 0; idx < pathList.size(); idx++) { string currentPath = pathList[idx]; @@ -49,7 +49,7 @@ Checksum TechTree::loadTech(const vector pathList, const string &techNam } void TechTree::load(const string &dir, set &factions, Checksum* checksum, - Checksum *techtreeChecksum, std::map &loadedFileList) { + Checksum *techtreeChecksum, std::map > &loadedFileList) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); string currentPath = dir; @@ -100,7 +100,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum checksumValue.addFile(path); xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); const XmlNode *techTreeNode= xmlTree.getRootNode(); diff --git a/source/glest_game/types/tech_tree.h b/source/glest_game/types/tech_tree.h index 685746284..0046104d6 100644 --- a/source/glest_game/types/tech_tree.h +++ b/source/glest_game/types/tech_tree.h @@ -46,9 +46,9 @@ private: public: Checksum loadTech(const vector pathList, const string &techName, - set &factions, Checksum* checksum, std::map &loadedFileList); + set &factions, Checksum* checksum, std::map > &loadedFileList); void load(const string &dir, set &factions, Checksum* checksum, - Checksum *techtreeChecksum, std::map &loadedFileList); + Checksum *techtreeChecksum, std::map > &loadedFileList); ~TechTree(); Checksum * getChecksumValue() { return &checksumValue; } diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 672051f08..843a0d57d 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -119,7 +119,7 @@ void UnitType::preLoad(const string &dir) { void UnitType::load(int id,const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum, - Checksum* techtreeChecksum, std::map &loadedFileList) { + Checksum* techtreeChecksum, std::map > &loadedFileList) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -139,7 +139,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(dir); const XmlNode *unitNode= xmlTree.getRootNode(); @@ -295,7 +295,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, unitParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance(),loadedFileList); - loadedFileList[currentPath + path]++; + loadedFileList[currentPath + path].push_back(dir); //if(unitParticleSystemType->hasTexture() == false) { //Renderer::getInstance().endLastTexture(rsGame,true); @@ -399,21 +399,21 @@ 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)]++; + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); //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)]++; + loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); //meeting point const XmlNode *meetingPointNode= parametersNode->getChild("meeting-point"); meetingPoint= meetingPointNode->getAttribute("value")->getBoolValue(); - if(meetingPoint){ + if(meetingPoint) { meetingPointImage= Renderer::getInstance().newTexture2D(rsGame); meetingPointImage->load(meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)); - loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)]++; + loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)].push_back(currentPath); } //selection sounds @@ -425,7 +425,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, string path= soundNode->getAttribute("path")->getRestrictedValue(currentPath); StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); selectionSounds[i]= sound; } } @@ -439,7 +439,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, string path= soundNode->getAttribute("path")->getRestrictedValue(currentPath); StaticSound *sound= new StaticSound(); sound->load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); commandSounds[i]= sound; } } diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index a1bf3a245..bc382f9a2 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -138,7 +138,7 @@ public: void preLoad(const string &dir); void load(int id, const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum, - Checksum* techtreeChecksum, std::map &loadedFileList); + Checksum* techtreeChecksum, std::map > &loadedFileList); //get int getId() const {return id;} diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index dc1086ed8..f0dadc0dd 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -49,7 +49,7 @@ void UpgradeType::preLoad(const string &dir){ void UpgradeType::load(const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum, - Checksum* techtreeChecksum, std::map &loadedFileList) { + Checksum* techtreeChecksum, std::map > &loadedFileList) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); Logger::getInstance().add("Upgrade type: "+ formatString(name), true); @@ -64,20 +64,28 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); const XmlNode *upgradeNode= xmlTree.getRootNode(); //image const XmlNode *imageNode= upgradeNode->getChild("image"); image= Renderer::getInstance().newTexture2D(rsGame); - image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)]++; + image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)); + loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(currentPath); + + //if(fileExists(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) { + // printf("\n***ERROR MISSING FILE [%s]\n",imageNode->getAttribute("path")->getRestrictedValue(currentPath,true).c_str()); + //} //image cancel const XmlNode *imageCancelNode= upgradeNode->getChild("image-cancel"); cancelImage= Renderer::getInstance().newTexture2D(rsGame); - cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)); - loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)]++; + cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)); + loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(currentPath); + + //if(fileExists(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) { + // printf("\n***ERROR MISSING FILE [%s]\n",imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true).c_str()); + //} //upgrade time const XmlNode *upgradeTimeNode= upgradeNode->getChild("time"); diff --git a/source/glest_game/types/upgrade_type.h b/source/glest_game/types/upgrade_type.h index af631596f..4ed340190 100644 --- a/source/glest_game/types/upgrade_type.h +++ b/source/glest_game/types/upgrade_type.h @@ -79,7 +79,7 @@ public: void preLoad(const string &dir); void load(const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum, - Checksum* techtreeChecksum, std::map &loadedFileList); + Checksum* techtreeChecksum, std::map > &loadedFileList); //get all int getEffectCount() const {return effects.size();} diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index 4717bbeb0..45f48a70a 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -32,7 +32,7 @@ namespace Glest{ namespace Game{ // ===================================================== void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, - std::map &loadedFileList) { + std::map > &loadedFileList) { string path; //day @@ -44,7 +44,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, path= dayNode->getAttribute("path")->getRestrictedValue(currentPath); day.open(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); 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]++; + loadedFileList[path].push_back(currentPath); 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]++; + loadedFileList[path].push_back(currentPath); } //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]++; + loadedFileList[path].push_back(currentPath); } //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]++; + loadedFileList[path].push_back(currentPath); } //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]++; + loadedFileList[path].push_back(currentPath); } } @@ -117,7 +117,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, // ===================================================== Checksum Tileset::loadTileset(const vector pathList, const string &tilesetName, - Checksum* checksum, std::map &loadedFileList) { + Checksum* checksum, std::map > &loadedFileList) { Checksum tilesetChecksum; for(int idx = 0; idx < pathList.size(); idx++) { string currentPath = pathList[idx]; @@ -133,7 +133,7 @@ Checksum Tileset::loadTileset(const vector pathList, const string &tiles void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum, - std::map &loadedFileList) { + std::map > &loadedFileList) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); random.init(time(NULL)); @@ -158,7 +158,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck //parse xml XmlTree xmlTree; xmlTree.load(path); - loadedFileList[path]++; + loadedFileList[path].push_back(currentPath); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -186,7 +186,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)]++; + loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); surfProbs[i][j]= textureNode->getAttribute("prob")->getFloatValue(); } @@ -213,8 +213,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); - loadedFileList[pathAttribute->getRestrictedValue(currentPath)]++; + objectTypes[i].loadModel(pathAttribute->getRestrictedValue(currentPath),&loadedFileList, currentPath); + loadedFileList[pathAttribute->getRestrictedValue(currentPath)].push_back(currentPath); if(modelNode->hasChild("particles")){ const XmlNode *particleNode= modelNode->getChild("particles"); @@ -226,7 +226,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType(); objectParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance(), loadedFileList); - loadedFileList[currentPath + path]++; + loadedFileList[currentPath + path].push_back(currentPath); objectTypes[i].addParticleSystem((objectParticleSystemType)); } @@ -262,7 +262,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)]++; + loadedFileList[waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(currentPath); } 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 d13b53333..c77c25e7c 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); }; // ===================================================== @@ -133,9 +133,9 @@ private: public: ~Tileset(); Checksum loadTileset(const vector pathList, const string &tilesetName, - Checksum* checksum, std::map &loadedFileList); + Checksum* checksum, std::map > &loadedFileList); void load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum, - std::map &loadedFileList); + std::map > &loadedFileList); Checksum * getChecksumValue() { return &checksumValue; } //get diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index f2f99d2c7..e23743ef4 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -199,7 +199,7 @@ void World::init(Game *game, bool createUnits){ //load tileset Checksum World::loadTileset(const vector pathList, const string &tilesetName, - Checksum* checksum, std::map &loadedFileList) { + Checksum* checksum, std::map > &loadedFileList) { Checksum tilsetChecksum; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -212,7 +212,7 @@ Checksum World::loadTileset(const vector pathList, const string &tileset return tilsetChecksum; } -Checksum World::loadTileset(const string &dir, Checksum *checksum, std::map &loadedFileList) { +Checksum World::loadTileset(const string &dir, Checksum *checksum, std::map > &loadedFileList) { Checksum tilesetChecksum; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -226,7 +226,7 @@ Checksum World::loadTileset(const string &dir, Checksum *checksum, std::map pathList, const string &techName, - set &factions, Checksum *checksum, std::map &loadedFileList) { + set &factions, Checksum *checksum, std::map > &loadedFileList) { Checksum techtreeChecksum; 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/world.h b/source/glest_game/world/world.h index 8d4474f59..feb2dff05 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -174,11 +174,11 @@ public: //init & load void init(Game *game, bool createUnits); Checksum loadTileset(const vector pathList, const string &tilesetName, - Checksum* checksum, std::map &loadedFileList); + Checksum* checksum, std::map > &loadedFileList); Checksum loadTileset(const string &dir, Checksum* checksum, - std::map &loadedFileList); + std::map > &loadedFileList); Checksum loadTech(const vector pathList, const string &techName, - set &factions, Checksum* checksum,std::map &loadedFileList); + set &factions, Checksum* checksum,std::map > &loadedFileList); Checksum loadMap(const string &path, Checksum* checksum); Checksum loadScenario(const string &path, Checksum* checksum); diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index 1ed6d2f02..c3c769413 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -133,14 +133,15 @@ public: Texture2D *loadMeshTexture(int meshIndex, int textureIndex, TextureManager *textureManager, string textureFile, int textureChannelCount, bool &textureOwned, - bool deletePixMapAfterLoad, std::map *loadedFileList=NULL); + bool deletePixMapAfterLoad, std::map > *loadedFileList=NULL, + string sourceLoader=""); //load void loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager, - bool deletePixMapAfterLoad,std::map *loadedFileList=NULL); + bool deletePixMapAfterLoad,std::map > *loadedFileList=NULL,string sourceLoader=""); void loadV3(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager, - bool deletePixMapAfterLoad,std::map *loadedFileList=NULL); - void load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad,std::map *loadedFileList=NULL); + bool deletePixMapAfterLoad,std::map > *loadedFileList=NULL,string sourceLoader=""); + void load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad,std::map > *loadedFileList=NULL,string sourceLoader=""); void save(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager, string convertTextureToFormat, std::map &textureDeleteList, bool keepsmallest); @@ -173,6 +174,7 @@ private: bool lastCycleVertex; string fileName; + string sourceLoader; public: //constructor & destructor @@ -196,9 +198,9 @@ public: uint32 getVertexCount() const; //io - void load(const string &path,bool deletePixMapAfterLoad=false,std::map *loadedFileList=NULL); + void load(const string &path,bool deletePixMapAfterLoad=false,std::map > *loadedFileList=NULL, string *sourceLoader=NULL); void save(const string &path, string convertTextureToFormat,bool keepsmallest); - void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map *loadedFileList=NULL); + void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map > *loadedFileList=NULL, string sourceLoader=""); void saveG3d(const string &path, string convertTextureToFormat,bool keepsmallest); void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;} diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index cf1301277..8e9d9c5e7 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -208,7 +208,8 @@ string Mesh::findAlternateTexture(vector conversionList, string textureF } void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager, - bool deletePixMapAfterLoad, std::map *loadedFileList) { + bool deletePixMapAfterLoad, std::map > *loadedFileList, + string sourceLoader) { this->textureManager = textureManager; //read header MeshHeaderV2 meshHeader; @@ -269,7 +270,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex textures[mtDiffuse]= textureManager->newTexture2D(); textures[mtDiffuse]->load(texPath); if(loadedFileList) { - (*loadedFileList)[texPath]++; + (*loadedFileList)[texPath].push_back(sourceLoader); } texturesOwned[mtDiffuse]=true; textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy()); @@ -297,7 +298,8 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex void Mesh::loadV3(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad, - std::map *loadedFileList) { + std::map > *loadedFileList, + string sourceLoader) { this->textureManager = textureManager; //read header @@ -355,7 +357,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f, textures[mtDiffuse]= textureManager->newTexture2D(); textures[mtDiffuse]->load(texPath); if(loadedFileList) { - (*loadedFileList)[texPath]++; + (*loadedFileList)[texPath].push_back(sourceLoader); } texturesOwned[mtDiffuse]=true; @@ -387,7 +389,8 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f, Texture2D* Mesh::loadMeshTexture(int meshIndex, int textureIndex, TextureManager *textureManager, string textureFile, int textureChannelCount, bool &textureOwned, bool deletePixMapAfterLoad, - std::map *loadedFileList) { + std::map > *loadedFileList, + string sourceLoader) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] #1 load texture [%s]\n",__FUNCTION__,textureFile.c_str()); @@ -413,7 +416,7 @@ Texture2D* Mesh::loadMeshTexture(int meshIndex, int textureIndex, } texture->load(textureFile); if(loadedFileList) { - (*loadedFileList)[textureFile]++; + (*loadedFileList)[textureFile].push_back(sourceLoader); } //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] texture loaded [%s]\n",__FUNCTION__,textureFile.c_str()); @@ -436,7 +439,8 @@ Texture2D* Mesh::loadMeshTexture(int meshIndex, int textureIndex, } void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager, - bool deletePixMapAfterLoad,std::map *loadedFileList) { + bool deletePixMapAfterLoad,std::map > *loadedFileList, + string sourceLoader) { this->textureManager = textureManager; //read header @@ -486,7 +490,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu textures[i] = loadMeshTexture(meshIndex, i, textureManager, mapFullPath, meshTextureChannelCount[i],texturesOwned[i], - deletePixMapAfterLoad, loadedFileList); + deletePixMapAfterLoad, loadedFileList, sourceLoader); } flag *= 2; } @@ -766,16 +770,18 @@ uint32 Model::getVertexCount() const { // ==================== io ==================== void Model::load(const string &path, bool deletePixMapAfterLoad, - std::map *loadedFileList) { - string extension= path.substr(path.find_last_of('.')+1); - if(extension=="g3d" || extension=="G3D"){ - loadG3d(path,deletePixMapAfterLoad,loadedFileList); + std::map > *loadedFileList, string *sourceLoader) { + + this->sourceLoader = (sourceLoader != NULL ? *sourceLoader : ""); + this->fileName = path; + + string extension= path.substr(path.find_last_of('.') + 1); + if(extension=="g3d" || extension=="G3D") { + loadG3d(path,deletePixMapAfterLoad,loadedFileList, this->sourceLoader); } - else{ + else { throw runtime_error("Unknown model format: " + extension); } - - this->fileName = path; } void Model::save(const string &path, string convertTextureToFormat, @@ -791,7 +797,8 @@ void Model::save(const string &path, string convertTextureToFormat, //load a model from a g3d file void Model::loadG3d(const string &path, bool deletePixMapAfterLoad, - std::map *loadedFileList) { + std::map > *loadedFileList, + string sourceLoader) { try{ FILE *f=fopen(path.c_str(),"rb"); @@ -801,7 +808,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad, } if(loadedFileList) { - (*loadedFileList)[path]++; + (*loadedFileList)[path].push_back(sourceLoader); } string dir= extractDirectoryPathFromFile(path); @@ -834,7 +841,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad, meshes= new Mesh[meshCount]; for(uint32 i = 0; i < meshCount; ++i) { meshes[i].load(i, dir, f, textureManager,deletePixMapAfterLoad, - loadedFileList); + loadedFileList,sourceLoader); meshes[i].buildInterpolationData(); } } @@ -847,7 +854,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad, meshes= new Mesh[meshCount]; for(uint32 i = 0; i < meshCount; ++i) { meshes[i].loadV3(i, dir, f, textureManager,deletePixMapAfterLoad, - loadedFileList); + loadedFileList,sourceLoader); meshes[i].buildInterpolationData(); } } @@ -860,7 +867,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad, meshes= new Mesh[meshCount]; for(uint32 i = 0; i < meshCount; ++i){ meshes[i].loadV2(i,dir, f, textureManager,deletePixMapAfterLoad, - loadedFileList); + loadedFileList,sourceLoader); meshes[i].buildInterpolationData(); } } diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 09d02898a..463e90dc1 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -474,6 +474,33 @@ void trimPathWithStartingSlash(string &path) { void updatePathClimbingParts(string &path) { // Update paths with .. + string::size_type pos = path.find(".."); + if(pos != string::npos && pos != 0) { + string orig = path; + path.erase(pos,2); + pos--; + if(path[pos] == '/' || path[pos] == '\\') { + path.erase(pos,1); + } + + for(int x = pos; x >= 0; --x) { + //printf("x [%d][%c] pos [%ld][%c] [%s]\n",x,path[x],(long int)pos,path[pos],path.substr(0,x+1).c_str()); + + if((path[x] == '/' || path[x] == '\\') && x != pos) { + path.erase(x,pos-x); + break; + } + } + pos = path.find(".."); + if(pos != string::npos && pos != 0) { + updatePathClimbingParts(path); + } + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("CHANGED relative path from [%s] to [%s]\n",orig.c_str(),path.c_str()); + } + + +/* string::size_type pos = path.rfind(".."); if(pos != string::npos && pos != 0) { string orig = path; @@ -492,8 +519,9 @@ void updatePathClimbingParts(string &path) { } } - //printf("CHANGED relative path from [%s] to [%s]\n",orig.c_str(),path.c_str()); + printf("CHANGED relative path from [%s] to [%s]\n",orig.c_str(),path.c_str()); } +*/ } string getCRCCacheFilePath() {