- added initial validation code to warn about duplicate data used in factions

This commit is contained in:
Mark Vejvoda
2011-05-05 19:21:50 +00:00
parent c3d1d6fca0
commit 6492832c35
30 changed files with 255 additions and 150 deletions

View File

@@ -1113,7 +1113,7 @@ void MainWindow::loadParticle(string path) {
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
std::map<string,int> loadedFileList;
std::map<string,vector<string> > 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<string,int> loadedFileList;
std::map<string,vector<string> > 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<string,int> loadedFileList;
std::map<string,vector<string> > loadedFileList;
ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash();
splashParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer,
loadedFileList); // <---- only that must be splash...

View File

@@ -458,7 +458,7 @@ void Game::load() {
}
void Game::load(LoadGameItem loadTypes) {
std::map<string,int> loadedFileList;
std::map<string,vector<string> > loadedFileList;
originalDisplayMsgCallback = NetworkInterface::getDisplayMessageFunction();
NetworkInterface::setDisplayMessageFunction(ErrorDisplayMessage);

View File

@@ -41,7 +41,7 @@ ParticleSystemType::ParticleSystemType() {
}
void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,int> &loadedFileList) {
RendererInterface *renderer, std::map<string,vector<string> > &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, &currentPath);
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<string,int> &loadedFileList) {
RendererInterface *renderer, std::map<string,vector<string> > &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<string,int> &loadedFileList) {
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList) {
try{
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path]++;
loadedFileList[path].push_back(dir);
const XmlNode *particleSystemNode= xmlTree.getRootNode();

View File

@@ -68,7 +68,7 @@ protected:
public:
ParticleSystemType();
void load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,int> &loadedFileList);
RendererInterface *renderer, std::map<string,vector<string> > &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<string,int> &loadedFileList);
RendererInterface *renderer, std::map<string,vector<string> > &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<string,int> &loadedFileList);
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList);
SplashParticleSystem *create();
private:

View File

@@ -30,7 +30,7 @@ namespace Glest{ namespace Game{
// =====================================================
void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,int> &loadedFileList) {
RendererInterface *renderer, std::map<string,vector<string> > &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<string,int> &loadedFileList) {
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList) {
try{
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path]++;
loadedFileList[path].push_back(dir);
const XmlNode *particleSystemNode= xmlTree.getRootNode();
UnitParticleSystemType::load(particleSystemNode, dir, renderer,

View File

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

View File

@@ -1296,7 +1296,7 @@ void runTechValidationForPath(string techPath, string techName,
if(factions.size() > 0) {
bool techtree_errors = false;
std::map<string,int> loadedFileList;
std::map<string,vector<string> > loadedFileList;
//vector<string> pathList = config.getPathListForType(ptTechs,"");
vector<string> pathList;
pathList.push_back(techPath);
@@ -1304,8 +1304,8 @@ void runTechValidationForPath(string techPath, string techName,
// Fixup paths with ..
{
std::map<string,int> newLoadedFileList;
for( std::map<string,int>::iterator iterMap = loadedFileList.begin();
std::map<string,vector<string> > newLoadedFileList;
for( std::map<string,vector<string> >::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<string,int> foundFileList;
std::map<string,vector<string> > 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<string,int>::iterator iterMap = loadedFileList.begin();
// for( std::map<string,vector<string> >::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<string,int>::iterator iterMap = foundFileList.begin();
for( std::map<string,vector<string> >::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<int32,vector<string> > mapDuplicateFiles;
// Now check for duplicate data content
for(std::map<string,vector<string> >::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<int32,vector<string> >::iterator iterMap = mapDuplicateFiles.begin();
iterMap != mapDuplicateFiles.end(); iterMap++) {
vector<string> &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<string,vector<string> >::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<string>::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) {

View File

@@ -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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string,int> &loadedFileList) {
std::map<string,vector<string> > &loadedFileList) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList);
//morph skill

View File

@@ -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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
const FactionType *ft, const UnitType &ut, std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &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<string,int> &loadedFileList);
std::map<string,vector<string> > &loadedFileList);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
virtual string getReqDesc() const;

View File

@@ -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<string,int> &loadedFileList) {
Checksum *techtreeChecksum, std::map<string,vector<string> > &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__);

View File

@@ -48,7 +48,7 @@ public:
//init
FactionType();
void load(const string &dir, const TechTree *techTree, Checksum* checksum,
Checksum *techtreeChecksum, std::map<string,int> &loadedFileList);
Checksum *techtreeChecksum, std::map<string,vector<string> > &loadedFileList);
~FactionType();
//get

View File

@@ -38,9 +38,10 @@ ObjectType::~ObjectType(){
//Logger::getInstance().add("ObjectType", true);
}
void ObjectType::loadModel(const string &path, std::map<string,int> *loadedFileList) {
void ObjectType::loadModel(const string &path, std::map<string,vector<string> > *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();

View File

@@ -56,7 +56,8 @@ public:
~ObjectType();
void init(int modelCount, int objectClass, bool walkable, int height);
void loadModel(const string &path, std::map<string,int> *loadedFileList=NULL);
void loadModel(const string &path, std::map<string,vector<string> > *loadedFileList=NULL,
string parentLoader="");
void addParticleSystem(ObjectParticleSystemType *particleSystem);
Model *getModel(int i) {return models[i];}

View File

@@ -46,7 +46,7 @@ ResourceType::~ResourceType(){
}
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum,
std::map<string,int> &loadedFileList) {
std::map<string,vector<string> > &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, &currentPath);
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);
}

View File

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

View File

@@ -42,7 +42,7 @@ SkillType::~SkillType() {
}
void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,int> &loadedFileList) {
const FactionType *ft, std::map<string,vector<string> > &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, &currentPath);
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<string,int> &loadedFileList) {
const FactionType *ft, std::map<string,vector<string> > &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<string,int> &loadedFileList) {
const FactionType *ft, std::map<string,vector<string> > &loadedFileList) {
SkillType::load(sn, dir, tt, ft, loadedFileList);
fade= sn->getChild("fade")->getAttribute("value")->getBoolValue();

View File

@@ -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<string,int> &loadedFileList);
const FactionType *ft, std::map<string,vector<string> > &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<string,int> &loadedFileList);
const FactionType *ft, std::map<string,vector<string> > &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<string,int> &loadedFileList);
const FactionType *ft, std::map<string,vector<string> > &loadedFileList);
virtual string toString() const;
};

View File

@@ -33,7 +33,7 @@ namespace Glest{ namespace Game{
// =====================================================
Checksum TechTree::loadTech(const vector<string> pathList, const string &techName,
set<string> &factions, Checksum* checksum, std::map<string,int> &loadedFileList) {
set<string> &factions, Checksum* checksum, std::map<string,vector<string> > &loadedFileList) {
Checksum techtreeChecksum;
for(int idx = 0; idx < pathList.size(); idx++) {
string currentPath = pathList[idx];
@@ -49,7 +49,7 @@ Checksum TechTree::loadTech(const vector<string> pathList, const string &techNam
}
void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum,
Checksum *techtreeChecksum, std::map<string,int> &loadedFileList) {
Checksum *techtreeChecksum, std::map<string,vector<string> > &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<string> &factions, Checksum* checksum
checksumValue.addFile(path);
xmlTree.load(path);
loadedFileList[path]++;
loadedFileList[path].push_back(currentPath);
const XmlNode *techTreeNode= xmlTree.getRootNode();

View File

@@ -46,9 +46,9 @@ private:
public:
Checksum loadTech(const vector<string> pathList, const string &techName,
set<string> &factions, Checksum* checksum, std::map<string,int> &loadedFileList);
set<string> &factions, Checksum* checksum, std::map<string,vector<string> > &loadedFileList);
void load(const string &dir, set<string> &factions, Checksum* checksum,
Checksum *techtreeChecksum, std::map<string,int> &loadedFileList);
Checksum *techtreeChecksum, std::map<string,vector<string> > &loadedFileList);
~TechTree();
Checksum * getChecksumValue() { return &checksumValue; }

View File

@@ -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<string,int> &loadedFileList) {
Checksum* techtreeChecksum, std::map<string,vector<string> > &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;
}
}

View File

@@ -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<string,int> &loadedFileList);
Checksum* techtreeChecksum, std::map<string,vector<string> > &loadedFileList);
//get
int getId() const {return id;}

View File

@@ -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<string,int> &loadedFileList) {
Checksum* techtreeChecksum, std::map<string,vector<string> > &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");

View File

@@ -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<string,int> &loadedFileList);
Checksum* techtreeChecksum, std::map<string,vector<string> > &loadedFileList);
//get all
int getEffectCount() const {return effects.size();}

View File

@@ -32,7 +32,7 @@ namespace Glest{ namespace Game{
// =====================================================
void AmbientSounds::load(const string &dir, const XmlNode *xmlNode,
std::map<string,int> &loadedFileList) {
std::map<string,vector<string> > &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<string> pathList, const string &tilesetName,
Checksum* checksum, std::map<string,int> &loadedFileList) {
Checksum* checksum, std::map<string,vector<string> > &loadedFileList) {
Checksum tilesetChecksum;
for(int idx = 0; idx < pathList.size(); idx++) {
string currentPath = pathList[idx];
@@ -133,7 +133,7 @@ Checksum Tileset::loadTileset(const vector<string> pathList, const string &tiles
void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum,
std::map<string,int> &loadedFileList) {
std::map<string,vector<string> > &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; j<childCount; ++j) {
const XmlNode *modelNode= objectNode->getChild("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; i<waterFrameCount; ++i){
const XmlNode *waterFrameNode= waterNode->getChild("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__);

View File

@@ -89,7 +89,7 @@ public:
StaticSound *getNightStart() {return &nightStart;}
void load(const string &dir, const XmlNode *xmlNode,
std::map<string,int> &loadedFileList);
std::map<string,vector<string> > &loadedFileList);
};
// =====================================================
@@ -133,9 +133,9 @@ private:
public:
~Tileset();
Checksum loadTileset(const vector<string> pathList, const string &tilesetName,
Checksum* checksum, std::map<string,int> &loadedFileList);
Checksum* checksum, std::map<string,vector<string> > &loadedFileList);
void load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum,
std::map<string,int> &loadedFileList);
std::map<string,vector<string> > &loadedFileList);
Checksum * getChecksumValue() { return &checksumValue; }
//get

View File

@@ -199,7 +199,7 @@ void World::init(Game *game, bool createUnits){
//load tileset
Checksum World::loadTileset(const vector<string> pathList, const string &tilesetName,
Checksum* checksum, std::map<string,int> &loadedFileList) {
Checksum* checksum, std::map<string,vector<string> > &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<string> pathList, const string &tileset
return tilsetChecksum;
}
Checksum World::loadTileset(const string &dir, Checksum *checksum, std::map<string,int> &loadedFileList) {
Checksum World::loadTileset(const string &dir, Checksum *checksum, std::map<string,vector<string> > &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<stri
//load tech
Checksum World::loadTech(const vector<string> pathList, const string &techName,
set<string> &factions, Checksum *checksum, std::map<string,int> &loadedFileList) {
set<string> &factions, Checksum *checksum, std::map<string,vector<string> > &loadedFileList) {
Checksum techtreeChecksum;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@@ -174,11 +174,11 @@ public:
//init & load
void init(Game *game, bool createUnits);
Checksum loadTileset(const vector<string> pathList, const string &tilesetName,
Checksum* checksum, std::map<string,int> &loadedFileList);
Checksum* checksum, std::map<string,vector<string> > &loadedFileList);
Checksum loadTileset(const string &dir, Checksum* checksum,
std::map<string,int> &loadedFileList);
std::map<string,vector<string> > &loadedFileList);
Checksum loadTech(const vector<string> pathList, const string &techName,
set<string> &factions, Checksum* checksum,std::map<string,int> &loadedFileList);
set<string> &factions, Checksum* checksum,std::map<string,vector<string> > &loadedFileList);
Checksum loadMap(const string &path, Checksum* checksum);
Checksum loadScenario(const string &path, Checksum* checksum);

View File

@@ -133,14 +133,15 @@ public:
Texture2D *loadMeshTexture(int meshIndex, int textureIndex, TextureManager *textureManager, string textureFile,
int textureChannelCount, bool &textureOwned,
bool deletePixMapAfterLoad, std::map<string,int> *loadedFileList=NULL);
bool deletePixMapAfterLoad, std::map<string,vector<string> > *loadedFileList=NULL,
string sourceLoader="");
//load
void loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
bool deletePixMapAfterLoad,std::map<string,int> *loadedFileList=NULL);
bool deletePixMapAfterLoad,std::map<string,vector<string> > *loadedFileList=NULL,string sourceLoader="");
void loadV3(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
bool deletePixMapAfterLoad,std::map<string,int> *loadedFileList=NULL);
void load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad,std::map<string,int> *loadedFileList=NULL);
bool deletePixMapAfterLoad,std::map<string,vector<string> > *loadedFileList=NULL,string sourceLoader="");
void load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad,std::map<string,vector<string> > *loadedFileList=NULL,string sourceLoader="");
void save(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
string convertTextureToFormat, std::map<string,int> &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<string,int> *loadedFileList=NULL);
void load(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<string> > *loadedFileList=NULL, string *sourceLoader=NULL);
void save(const string &path, string convertTextureToFormat,bool keepsmallest);
void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map<string,int> *loadedFileList=NULL);
void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<string> > *loadedFileList=NULL, string sourceLoader="");
void saveG3d(const string &path, string convertTextureToFormat,bool keepsmallest);
void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;}

View File

@@ -208,7 +208,8 @@ string Mesh::findAlternateTexture(vector<string> conversionList, string textureF
}
void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
bool deletePixMapAfterLoad, std::map<string,int> *loadedFileList) {
bool deletePixMapAfterLoad, std::map<string,vector<string> > *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<string,int> *loadedFileList) {
std::map<string,vector<string> > *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<string,int> *loadedFileList) {
std::map<string,vector<string> > *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<string,int> *loadedFileList) {
bool deletePixMapAfterLoad,std::map<string,vector<string> > *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<string,int> *loadedFileList) {
string extension= path.substr(path.find_last_of('.')+1);
if(extension=="g3d" || extension=="G3D"){
loadG3d(path,deletePixMapAfterLoad,loadedFileList);
std::map<string,vector<string> > *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<string,int> *loadedFileList) {
std::map<string,vector<string> > *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();
}
}

View File

@@ -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() {