- added code to merge duplicate sounds used in a techtree

This commit is contained in:
Mark Vejvoda 2011-05-06 07:47:31 +00:00
parent c258dc0822
commit e34e70a0c8
31 changed files with 330 additions and 144 deletions

View File

@ -1113,8 +1113,8 @@ void MainWindow::loadParticle(string path) {
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
std::map<string,vector<string> > loadedFileList;
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();
std::map<string,vector<pair<string, string> > > loadedFileList;
UnitParticleSystemType *unitParticleSystemType = new UnitParticleSystemType();
unitParticleSystemType->load(dir, dir + folderDelimiter + particlePath,
renderer,loadedFileList,"g3dviewer");
unitParticleSystemTypes.push_back(unitParticleSystemType);
@ -1210,7 +1210,7 @@ void MainWindow::loadProjectileParticle(string path) {
// std::cout << "Loaded successfully, loading values..." << std::endl;
std::map<string,vector<string> > loadedFileList;
std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile();
projectileParticleSystemType->load(dir,
dir + folderDelimiter + particlePath,renderer, loadedFileList,
@ -1313,7 +1313,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
// std::cout << "Loaded successfully, loading values..." << std::endl;
std::map<string,vector<string> > loadedFileList;
std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash();
splashParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer,
loadedFileList,"g3dviewer"); // <---- only that must be splash...

View File

@ -458,7 +458,7 @@ void Game::load() {
}
void Game::load(LoadGameItem loadTypes) {
std::map<string,vector<string> > loadedFileList;
std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
//texture
const XmlNode *textureNode= particleSystemNode->getChild("texture");
@ -59,7 +59,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
string currentPath = dir;
endPathWithSlash(currentPath);
texture->load(textureNode->getAttribute("path")->getRestrictedValue(currentPath));
loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(parentLoader);
loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(parentLoader,textureNode->getAttribute("path")->getRestrictedValue()));
}
else {
texture= NULL;
@ -77,7 +77,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
model= renderer->newModel(rsGame);
model->load(path, false, &loadedFileList, &parentLoader);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,modelNode->getAttribute("path")->getRestrictedValue()));
}
}
else {
@ -187,13 +187,13 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
// ===========================================================
void ParticleSystemTypeProjectile::load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
try{
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
const XmlNode *particleSystemNode= xmlTree.getRootNode();
@ -249,13 +249,13 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() {
// ===========================================================
void ParticleSystemTypeSplash::load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
try{
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
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,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
void setValues(AttackParticleSystem *ats);
bool hasTexture() const { return(texture != NULL); }
@ -91,7 +91,7 @@ private:
public:
void load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
ProjectileParticleSystem *create();
@ -104,7 +104,7 @@ public:
class ParticleSystemTypeSplash: public ParticleSystemType {
public:
void load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
SplashParticleSystem *create();

View File

@ -30,7 +30,7 @@ namespace Glest{ namespace Game{
// =====================================================
void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
ParticleSystemType::load(particleSystemNode, dir, renderer, loadedFileList, parentLoader);
//radius
@ -137,13 +137,13 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
}
void UnitParticleSystemType::load(const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<string> > &loadedFileList,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
try{
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
const XmlNode *particleSystemNode= xmlTree.getRootNode();
UnitParticleSystemType::load(particleSystemNode, dir, renderer,

View File

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

View File

@ -969,15 +969,17 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n%s\t\t\tdisplays your SDL version information.",GAME_ARGS[GAME_ARG_SDL_INFO]);
printf("\n%s\t\t\tdisplays your LUA version information.",GAME_ARGS[GAME_ARG_LUA_INFO]);
printf("\n%s\t\t\tdisplays your CURL version information.",GAME_ARGS[GAME_ARG_CURL_INFO]);
printf("\n%s=x=purgeunused\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n%s=x=purgeunused=purgeduplicates\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n \t\tto your selected techtrees game data.");
printf("\n \t\tWhere x is a comma-delimited list of techtrees to validate.");
printf("\n \t\tWhere purgeunused is an optional parameter telling the validation to delete extra files in the techtree that are not used.");
printf("\n \t\tWhere purgeduplicates is an optional parameter telling the validation to merge duplicate files in the techtree.");
printf("\n \t\texample: %s %s=megapack,vbros_pack_5",argv0,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n%s=x=purgeunused\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
printf("\n%s=x=purgeunused=purgeduplicates\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
printf("\n \t\tto your selected factions game data.");
printf("\n \t\tWhere x is a comma-delimited list of factions to validate.");
printf("\n \t\tWhere purgeunused is an optional parameter telling the validation to delete extra files in the faction that are not used.");
printf("\n \t\tWhere purgeduplicates is an optional parameter telling the validation to merge duplicate files in the faction.");
printf("\n \t\t*NOTE: leaving the list empty is the same as running");
printf("\n \t\t%s",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n \t\texample: %s %s=tech,egypt",argv0,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
@ -1269,7 +1271,7 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
void runTechValidationForPath(string techPath, string techName,
const std::vector<string> filteredFactionList, World &world,
bool purgeUnusedFiles,double &purgedMegaBytes) {
bool purgeUnusedFiles,bool purgeDuplicateFiles, double &purgedMegaBytes) {
Config &config = Config::getInstance();
vector<string> factionsList;
findDirs(techPath + techName + "/factions/", factionsList, false, false);
@ -1296,7 +1298,7 @@ void runTechValidationForPath(string techPath, string techName,
if(factions.size() > 0) {
bool techtree_errors = false;
std::map<string,vector<string> > loadedFileList;
std::map<string,vector<pair<string, string> > > loadedFileList;
//vector<string> pathList = config.getPathListForType(ptTechs,"");
vector<string> pathList;
pathList.push_back(techPath);
@ -1304,15 +1306,23 @@ void runTechValidationForPath(string techPath, string techName,
// Fixup paths with ..
{
std::map<string,vector<string> > newLoadedFileList;
for( std::map<string,vector<string> >::iterator iterMap = loadedFileList.begin();
std::map<string,vector<pair<string, string> > > newLoadedFileList;
for( std::map<string,vector<pair<string, string> > >::iterator iterMap = loadedFileList.begin();
iterMap != loadedFileList.end(); ++iterMap) {
string loadedFile = iterMap->first;
replaceAll(loadedFile,"//","/");
replaceAll(loadedFile,"\\\\","\\");
updatePathClimbingParts(loadedFile);
newLoadedFileList[loadedFile] = iterMap->second;
if(newLoadedFileList.find(loadedFile) != newLoadedFileList.end()) {
for(unsigned int xx1 = 0; xx1 < iterMap->second.size(); ++xx1) {
newLoadedFileList[loadedFile].push_back(iterMap->second[xx1]);
}
}
else {
newLoadedFileList[loadedFile] = iterMap->second;
}
}
loadedFileList = newLoadedFileList;
}
@ -1358,7 +1368,7 @@ void runTechValidationForPath(string techPath, string techName,
}
// Now check for unused files in the techtree
std::map<string,vector<string> > foundFileList;
std::map<string,vector<pair<string, string> > > foundFileList;
for(unsigned int i = 0; i < pathList.size(); ++i) {
string path = pathList[i];
endPathWithSlash(path);
@ -1388,7 +1398,7 @@ void runTechValidationForPath(string techPath, string techName,
replaceAll(file,"//","/");
replaceAll(file,"\\\\","\\");
foundFileList[file].push_back(path);
foundFileList[file].push_back(make_pair(path,path));
}
}
@ -1405,7 +1415,7 @@ void runTechValidationForPath(string techPath, string techName,
int purgeCount = 0;
bool foundUnusedFile = false;
for( std::map<string,vector<string> >::iterator iterMap = foundFileList.begin();
for( std::map<string,vector<pair<string, string> > >::iterator iterMap = foundFileList.begin();
iterMap != foundFileList.end(); ++iterMap) {
string foundFile = iterMap->first;
@ -1440,16 +1450,29 @@ void runTechValidationForPath(string techPath, string techName,
std::map<int32,vector<string> > mapDuplicateFiles;
// Now check for duplicate data content
for(std::map<string,vector<string> >::iterator iterMap = loadedFileList.begin();
for(std::map<string,vector<pair<string, string> > >::iterator iterMap = loadedFileList.begin();
iterMap != loadedFileList.end(); iterMap++) {
string fileName = iterMap->first;
Checksum checksum;
checksum.addFile(fileName);
int32 crcValue = checksum.getSum();
// if(crcValue == 0) {
// char szBuf[4096]="";
// sprintf(szBuf,"Error calculating CRC for file [%s]",fileName.c_str());
// throw runtime_error(szBuf);
// }
// else {
// printf("** CRC for file [%s] is [%d] and has %d parents\n",fileName.c_str(),crcValue,(int)iterMap->second.size());
// }
mapDuplicateFiles[crcValue].push_back(fileName);
}
double duplicateMegaBytesPurged=0;
int duplicateCountPurged=0;
double duplicateMegaBytes=0;
int duplicateCount=0;
bool foundDuplicates = false;
for(std::map<int32,vector<string> >::iterator iterMap = mapDuplicateFiles.begin();
iterMap != mapDuplicateFiles.end(); iterMap++) {
@ -1474,26 +1497,129 @@ void runTechValidationForPath(string techPath, string techName,
}
printf("[%s]\n",duplicateFile.c_str());
std::map<string,vector<string> >::iterator iterFind = loadedFileList.find(duplicateFile);
std::map<string,vector<pair<string, string> > >::iterator iterFind = loadedFileList.find(duplicateFile);
if(iterFind != loadedFileList.end()) {
for(unsigned int jdx = 0; jdx < iterFind->second.size(); jdx++) {
parentList[iterFind->second[jdx]]++;
parentList[iterFind->second[jdx].first]++;
}
}
}
for(map<string,int>::iterator iterMap = parentList.begin();
iterMap != parentList.end(); iterMap++) {
for(map<string,int>::iterator iterMap1 = parentList.begin();
iterMap1 != parentList.end(); iterMap1++) {
if(iterMap == parentList.begin()) {
if(iterMap1 == parentList.begin()) {
printf("\tParents:\n");
}
printf("\t[%s]\n",iterMap->first.c_str());
printf("\t[%s]\n",iterMap1->first.c_str());
}
if(purgeDuplicateFiles == true) {
string newCommonFileName = "";
for(unsigned int idx = 0; idx < fileList.size(); ++idx) {
string duplicateFile = fileList[idx];
string fileExt = extractExtension(duplicateFile);
if(fileExt == "wav" || fileExt == "ogg") {
off_t fileSize = getFileSize(duplicateFile);
if(idx == 0) {
newCommonFileName = "$COMMONDATAPATH/sounds/" + extractFileFromDirectoryPath(duplicateFile);
string expandedNewCommonFileName = newCommonFileName;
Properties::applyTagsToValue(expandedNewCommonFileName);
//int result = 0;
int result = rename(duplicateFile.c_str(),expandedNewCommonFileName.c_str());
if(result != 0) {
char szBuf[4096]="";
char *errmsg = strerror(errno);
sprintf(szBuf,"!!! Error [%s] Could not rename [%s] to [%s]!",errmsg,duplicateFile.c_str(),expandedNewCommonFileName.c_str());
throw runtime_error(szBuf);
}
else {
printf("*** Duplicate file:\n[%s]\nwas renamed to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
}
}
else {
removeFile(duplicateFile);
printf("*** Duplicate file:\n[%s]\nwas removed\n",duplicateFile.c_str());
// convert to MB
duplicateMegaBytesPurged += ((double)fileSize / 1048576.0);
duplicateCountPurged++;
}
}
}
std::map<string,int> mapUniqueParentList;
for(unsigned int idx = 0; idx < fileList.size(); ++idx) {
string duplicateFile = fileList[idx];
string fileExt = extractExtension(duplicateFile);
if(fileExt == "wav" || fileExt == "ogg") {
std::map<string,vector<pair<string, string> > >::iterator iterFind2 = loadedFileList.find(duplicateFile);
if(iterFind2 != loadedFileList.end()) {
for(unsigned int jdx1 = 0; jdx1 < iterFind2->second.size(); jdx1++) {
string parentFile = iterFind2->second[jdx1].first;
string searchText = iterFind2->second[jdx1].second;
if(mapUniqueParentList.find(parentFile) == mapUniqueParentList.end()) {
printf("*** Searching parent file:\n[%s]\nfor duplicate file reference:\n[%s]\nto replace with newname:\n[%s]\n",parentFile.c_str(),searchText.c_str(),newCommonFileName.c_str());
bool foundText = searchAndReplaceTextInFile(parentFile, searchText, newCommonFileName, false);
printf("foundText = %d\n",foundText);
if(foundText == false) {
char szBuf[4096]="";
sprintf(szBuf,"Error finding text [%s] in file [%s]",searchText.c_str(),parentFile.c_str());
throw runtime_error(szBuf);
}
mapUniqueParentList[parentFile]++;
}
}
}
}
}
}
else {
string newCommonFileName = "";
for(unsigned int idx = 0; idx < fileList.size(); ++idx) {
string duplicateFile = fileList[idx];
string fileExt = extractExtension(duplicateFile);
if(fileExt == "wav" || fileExt == "ogg") {
off_t fileSize = getFileSize(duplicateFile);
if(idx == 0) {
newCommonFileName = "$COMMONDATAPATH/sounds/" + extractFileFromDirectoryPath(duplicateFile);
break;
}
}
}
for(unsigned int idx = 0; idx < fileList.size(); ++idx) {
string duplicateFile = fileList[idx];
string fileExt = extractExtension(duplicateFile);
if(fileExt == "wav" || fileExt == "ogg") {
std::map<string,vector<pair<string, string> > >::iterator iterFind4 = loadedFileList.find(duplicateFile);
if(iterFind4 != loadedFileList.end()) {
for(unsigned int jdx = 0; jdx < iterFind4->second.size(); jdx++) {
string parentFile = iterFind4->second[jdx].first;
string searchText = iterFind4->second[jdx].second;
//printf("*** Searching parent file:\n[%s]\nfor duplicate file reference:\n[%s]\nto replace with newname:\n[%s]\n",parentFile.c_str(),searchText.c_str(),newCommonFileName.c_str());
bool foundText = searchAndReplaceTextInFile(parentFile, searchText, newCommonFileName, true);
//printf("foundText = %d\n",foundText);
if(foundText == false) {
char szBuf[4096]="";
sprintf(szBuf,"Error finding text [%s] in file [%s]",searchText.c_str(),parentFile.c_str());
throw runtime_error(szBuf);
}
}
}
}
}
}
}
}
if(foundDuplicates == true) {
printf("Duplicates %.2f MB (%d) in files\n",duplicateMegaBytes,duplicateCount);
printf("Duplicates purged %.2f MB (%d) in files\n",duplicateMegaBytesPurged,duplicateCountPurged);
printf("\nWarning, duplicate files were detected - END:\n");
}
@ -1512,6 +1638,7 @@ void runTechValidationReport(int argc, char** argv) {
//disableBacktrace=true;
printf("====== Started Validation ======\n");
bool purgeDuplicateFiles = false;
bool purgeUnusedFiles = false;
double purgedMegaBytes=0;
Config &config = Config::getInstance();
@ -1575,7 +1702,7 @@ void runTechValidationReport(int argc, char** argv) {
printf("Found Scenario [%s] with custom techtree [%s] validating...\n",scenarioName.c_str(),techName.c_str());
runTechValidationForPath(techPath, techName, filteredFactionList,
world, purgeUnusedFiles,purgedMegaBytes);
world, purgeUnusedFiles, false, purgedMegaBytes);
}
//
//
@ -1654,7 +1781,22 @@ void runTechValidationReport(int argc, char** argv) {
purgeUnusedFiles = true;
printf("*NOTE All unused techtree files will be deleted!\n");
}
else if(paramPartTokens[2] == "purgeduplicates") {
purgeDuplicateFiles = true;
printf("*NOTE All duplicate techtree files will be merged!\n");
}
}
if(paramPartTokens.size() >= 4) {
if(paramPartTokens[3] == "purgeunused") {
purgeUnusedFiles = true;
printf("*NOTE All unused techtree files will be deleted!\n");
}
else if(paramPartTokens[3] == "purgeduplicates") {
purgeDuplicateFiles = true;
printf("*NOTE All duplicate techtree files will be merged!\n");
}
}
}
}
@ -1677,7 +1819,7 @@ void runTechValidationReport(int argc, char** argv) {
std::find(filteredTechTreeList.begin(),filteredTechTreeList.end(),techName) != filteredTechTreeList.end()) {
runTechValidationForPath(techPath, techName, filteredFactionList,
world, purgeUnusedFiles,purgedMegaBytes);
world, purgeUnusedFiles,purgeDuplicateFiles,purgedMegaBytes);
}
}
}

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,vector<string> > &loadedFileList,
std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -58,7 +58,7 @@ void CommandType::load(int id, const XmlNode *n, const string &dir,
string currentPath = dir;
endPathWithSlash(currentPath);
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(parentLoader);
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(parentLoader,imageNode->getAttribute("path")->getRestrictedValue()));
//unit requirements
const XmlNode *unitRequirementsNode= n->getChild("unit-requirements");
@ -113,7 +113,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,vector<string> > &loadedFileList,string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList,string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader);
//stop
@ -138,7 +138,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,vector<string> > &loadedFileList,
std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader);
@ -188,7 +188,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,vector<string> > &loadedFileList,
std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader);
@ -281,7 +281,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,vector<string> > &loadedFileList,string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList,string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList,parentLoader);
//stop
@ -368,7 +368,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,vector<string> > &loadedFileList, string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
//move
@ -400,7 +400,7 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir,
StaticSound *sound= new StaticSound();
sound->load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,soundFileNode->getAttribute("path")->getRestrictedValue()));
startSounds[i]= sound;
}
}
@ -418,7 +418,7 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir,
StaticSound *sound= new StaticSound();
sound->load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,soundFileNode->getAttribute("path")->getRestrictedValue()));
builtSounds[i]= sound;
}
}
@ -463,7 +463,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,vector<string> > &loadedFileList, string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
//move
@ -544,7 +544,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,vector<string> > &loadedFileList, string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
//move
@ -617,7 +617,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,vector<string> > &loadedFileList, string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
//produce
@ -682,7 +682,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,vector<string> > &loadedFileList, string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
@ -739,7 +739,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,vector<string> > &loadedFileList, string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader) {
CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
//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,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const= 0;
virtual string toString() const= 0;
virtual const ProducibleType *getProduced() const {return NULL;}
@ -117,7 +117,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,vector<string> > &loadedFileList,
const FactionType *ft, const UnitType &ut, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
@ -141,7 +141,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
@ -164,7 +164,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
@ -188,7 +188,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
@ -216,7 +216,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
@ -249,7 +249,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
virtual Queueability isQueuable() const {return qOnRequest;}
@ -283,7 +283,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
@ -312,7 +312,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string getReqDesc() const;
virtual string toString() const;
@ -340,7 +340,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
virtual string getReqDesc() const;
@ -368,7 +368,7 @@ public:
virtual void update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const;
virtual void load(int id, const XmlNode *n, const string &dir,
const TechTree *tt, const FactionType *ft, const UnitType &ut,
std::map<string,vector<string> > &loadedFileList, string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader);
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,vector<string> > &loadedFileList) {
Checksum *techtreeChecksum, std::map<string,vector<pair<string, 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].push_back(currentPath);
loadedFileList[path].push_back(make_pair(currentPath,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)].push_back(currentPath);
loadedFileList[musicNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(path,musicNode->getAttribute("path")->getRestrictedValue()));
}
}
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,vector<string> > &loadedFileList);
Checksum *techtreeChecksum, std::map<string,vector<pair<string, string> > > &loadedFileList);
~FactionType();
//get

View File

@ -38,7 +38,7 @@ ObjectType::~ObjectType(){
//Logger::getInstance().add("ObjectType", true);
}
void ObjectType::loadModel(const string &path, std::map<string,vector<string> > *loadedFileList,
void ObjectType::loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList,
string parentLoader) {
Model *model= Renderer::getInstance().newModel(rsGame);
model->load(path, false, loadedFileList, &parentLoader);

View File

@ -56,7 +56,7 @@ public:
~ObjectType();
void init(int modelCount, int objectClass, bool walkable, int height);
void loadModel(const string &path, std::map<string,vector<string> > *loadedFileList=NULL,
void loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList=NULL,
string parentLoader="");
void addParticleSystem(ObjectParticleSystemType *particleSystem);

View File

@ -46,7 +46,7 @@ ResourceType::~ResourceType(){
}
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum,
std::map<string,vector<string> > &loadedFileList) {
std::map<string,vector<pair<string, string> > > &loadedFileList) {
string path, str;
Renderer &renderer= Renderer::getInstance();
@ -68,7 +68,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
//tree
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path].push_back(currentPath);
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
const XmlNode *resourceNode= xmlTree.getRootNode();
@ -76,7 +76,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
const XmlNode *imageNode= resourceNode->getChild("image");
image= renderer.newTexture2D(rsGame);
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile);
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,imageNode->getAttribute("path")->getRestrictedValue()));
//type
const XmlNode *typeNode= resourceNode->getChild("type");
@ -92,7 +92,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
model= renderer.newModel(rsGame);
model->load(modelPath, false, &loadedFileList, &sourceXMLFile);
loadedFileList[modelPath].push_back(sourceXMLFile);
loadedFileList[modelPath].push_back(make_pair(sourceXMLFile,modelNode->getAttribute("path")->getRestrictedValue()));
if(modelNode->hasChild("particles")){
const XmlNode *particleNode= modelNode->getChild("particles");
@ -105,7 +105,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
objectParticleSystemType->load(dir, currentPath + particlePath,
&Renderer::getInstance(), loadedFileList, sourceXMLFile);
loadedFileList[currentPath + particlePath].push_back(sourceXMLFile);
loadedFileList[currentPath + particlePath].push_back(make_pair(sourceXMLFile,particleFileNode->getAttribute("path")->getRestrictedValue()));
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,vector<string> > &loadedFileList);
std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
//name
name= sn->getChild("name")->getAttribute("value")->getRestrictedValue();
@ -69,7 +69,7 @@ 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, &parentLoader);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,sn->getChild("animation")->getAttribute("path")->getRestrictedValue()));
//particles
if(sn->hasChild("particles")) {
@ -82,7 +82,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,parentLoader);
loadedFileList[currentPath + path].push_back(parentLoader);
loadedFileList[currentPath + path].push_back(make_pair(parentLoader,particleFileNode->getAttribute("path")->getRestrictedValue()));
unitParticleSystemTypes.push_back(unitParticleSystemType);
}
}
@ -99,7 +99,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
StaticSound *sound= new StaticSound();
sound->load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,soundFileNode->getAttribute("path")->getRestrictedValue()));
sounds[i]= sound;
}
}
@ -193,7 +193,7 @@ AttackSkillType::~AttackSkillType() {
}
void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<string> > &loadedFileList,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader);
@ -262,10 +262,11 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree
for(int i=0; i<soundNode->getChildCount(); ++i){
const XmlNode *soundFileNode= soundNode->getChild("sound-file", i);
string path= soundFileNode->getAttribute("path")->getRestrictedValue(currentPath, true);
//printf("\n\n\n\n!@#$ ---> parentLoader [%s] path [%s] nodeValue [%s] i = %d",parentLoader.c_str(),path.c_str(),soundFileNode->getAttribute("path")->getRestrictedValue().c_str(),i);
StaticSound *sound= new StaticSound();
sound->load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,soundFileNode->getAttribute("path")->getRestrictedValue()));
projSounds[i]= sound;
}
}
@ -408,7 +409,7 @@ DieSkillType::DieSkillType(){
}
void DieSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<string> > &loadedFileList,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader);

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,vector<string> > &loadedFileList,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
//get
@ -163,7 +163,7 @@ public:
AttackSkillType();
~AttackSkillType();
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<string> > &loadedFileList,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string toString() const;
@ -284,7 +284,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,vector<string> > &loadedFileList,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
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,vector<string> > &loadedFileList) {
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList) {
Checksum *techtreeChecksum, std::map<string,vector<pair<string, 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].push_back(currentPath);
loadedFileList[path].push_back(make_pair(currentPath,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,vector<string> > &loadedFileList);
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList);
void load(const string &dir, set<string> &factions, Checksum* checksum,
Checksum *techtreeChecksum, std::map<string,vector<string> > &loadedFileList);
Checksum *techtreeChecksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList) {
Checksum* techtreeChecksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -140,7 +140,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path].push_back(dir);
loadedFileList[path].push_back(make_pair(dir,dir));
const XmlNode *unitNode= xmlTree.getRootNode();
@ -296,7 +296,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
unitParticleSystemType->load(dir, currentPath + path,
&Renderer::getInstance(),loadedFileList, sourceXMLFile);
loadedFileList[currentPath + path].push_back(sourceXMLFile);
loadedFileList[currentPath + path].push_back(make_pair(sourceXMLFile,particleFileNode->getAttribute("path")->getRestrictedValue()));
//if(unitParticleSystemType->hasTexture() == false) {
//Renderer::getInstance().endLastTexture(rsGame,true);
@ -400,13 +400,13 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
const XmlNode *imageNode= parametersNode->getChild("image");
image= Renderer::getInstance().newTexture2D(rsGame);
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile);
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,imageNode->getAttribute("path")->getRestrictedValue()));
//image cancel
const XmlNode *imageCancelNode= parametersNode->getChild("image-cancel");
cancelImage= Renderer::getInstance().newTexture2D(rsGame);
cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath));
loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile);
loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,imageCancelNode->getAttribute("path")->getRestrictedValue()));
//meeting point
const XmlNode *meetingPointNode= parametersNode->getChild("meeting-point");
@ -414,7 +414,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
if(meetingPoint) {
meetingPointImage= Renderer::getInstance().newTexture2D(rsGame);
meetingPointImage->load(meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath));
loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile);
loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,meetingPointNode->getAttribute("image-path")->getRestrictedValue()));
}
//selection sounds
@ -426,7 +426,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].push_back(sourceXMLFile);
loadedFileList[path].push_back(make_pair(sourceXMLFile,soundNode->getAttribute("path")->getRestrictedValue()));
selectionSounds[i]= sound;
}
}
@ -440,7 +440,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].push_back(sourceXMLFile);
loadedFileList[path].push_back(make_pair(sourceXMLFile,soundNode->getAttribute("path")->getRestrictedValue()));
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,vector<string> > &loadedFileList);
Checksum* techtreeChecksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList) {
Checksum* techtreeChecksum, std::map<string,vector<pair<string, 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);
@ -65,14 +65,14 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path].push_back(currentPath);
loadedFileList[path].push_back(make_pair(currentPath,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,true));
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(sourceXMLFile);
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(make_pair(sourceXMLFile,imageNode->getAttribute("path")->getRestrictedValue()));
//if(fileExists(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) {
// printf("\n***ERROR MISSING FILE [%s]\n",imageNode->getAttribute("path")->getRestrictedValue(currentPath,true).c_str());
@ -82,7 +82,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
const XmlNode *imageCancelNode= upgradeNode->getChild("image-cancel");
cancelImage= Renderer::getInstance().newTexture2D(rsGame);
cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true));
loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(sourceXMLFile);
loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(make_pair(sourceXMLFile,imageCancelNode->getAttribute("path")->getRestrictedValue()));
//if(fileExists(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) {
// printf("\n***ERROR MISSING FILE [%s]\n",imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true).c_str());

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,vector<string> > &loadedFileList);
Checksum* techtreeChecksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList, string parentLoader) {
std::map<string,vector<pair<string, string> > > &loadedFileList, string parentLoader) {
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].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,dayNode->getAttribute("path")->getRestrictedValue()));
alwaysPlayDay= dayNode->getAttribute("play-always")->getBoolValue();
}
@ -58,7 +58,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode,
path= nightNode->getAttribute("path")->getRestrictedValue(currentPath);
night.open(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,nightNode->getAttribute("path")->getRestrictedValue()));
alwaysPlayNight= nightNode->getAttribute("play-always")->getBoolValue();
}
@ -72,7 +72,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode,
path= rainNode->getAttribute("path")->getRestrictedValue(currentPath);
rain.open(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,rainNode->getAttribute("path")->getRestrictedValue()));
}
//snow
@ -84,7 +84,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode,
path= snowNode->getAttribute("path")->getRestrictedValue(currentPath);
snow.open(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,snowNode->getAttribute("path")->getRestrictedValue()));
}
//dayStart
@ -96,7 +96,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode,
path= dayStartNode->getAttribute("path")->getRestrictedValue(currentPath);
dayStart.load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,dayStartNode->getAttribute("path")->getRestrictedValue()));
}
//nightStart
@ -108,7 +108,7 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode,
path= nightStartNode->getAttribute("path")->getRestrictedValue(currentPath);
nightStart.load(path);
loadedFileList[path].push_back(parentLoader);
loadedFileList[path].push_back(make_pair(parentLoader,nightStartNode->getAttribute("path")->getRestrictedValue()));
}
}
@ -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,vector<string> > &loadedFileList) {
Checksum* checksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList) {
std::map<string,vector<pair<string, 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));
@ -159,7 +159,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
//parse xml
XmlTree xmlTree;
xmlTree.load(path);
loadedFileList[path].push_back(currentPath);
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -187,7 +187,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
const XmlNode *textureNode= surfaceNode->getChild("texture", j);
surfPixmaps[i][j].init(3);
surfPixmaps[i][j].load(textureNode->getAttribute("path")->getRestrictedValue(currentPath));
loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(sourceXMLFile);
loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,textureNode->getAttribute("path")->getRestrictedValue()));
surfProbs[i][j]= textureNode->getAttribute("prob")->getFloatValue();
}
@ -215,7 +215,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
const XmlNode *modelNode= objectNode->getChild("model", j);
const XmlAttribute *pathAttribute= modelNode->getAttribute("path");
objectTypes[i].loadModel(pathAttribute->getRestrictedValue(currentPath),&loadedFileList, sourceXMLFile);
loadedFileList[pathAttribute->getRestrictedValue(currentPath)].push_back(sourceXMLFile);
loadedFileList[pathAttribute->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,pathAttribute->getRestrictedValue()));
if(modelNode->hasChild("particles")){
const XmlNode *particleNode= modelNode->getChild("particles");
@ -227,7 +227,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
objectParticleSystemType->load(dir, currentPath + path,
&Renderer::getInstance(), loadedFileList, sourceXMLFile);
loadedFileList[currentPath + path].push_back(sourceXMLFile);
loadedFileList[currentPath + path].push_back(make_pair(sourceXMLFile,particleFileNode->getAttribute("path")->getRestrictedValue()));
objectTypes[i].addParticleSystem((objectParticleSystemType));
}
@ -263,7 +263,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)].push_back(sourceXMLFile);
loadedFileList[waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,waterFrameNode->getAttribute("path")->getRestrictedValue()));
}
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,vector<string> > &loadedFileList,string parentLoader);
std::map<string,vector<pair<string, string> > > &loadedFileList,string parentLoader);
};
// =====================================================
@ -133,9 +133,9 @@ private:
public:
~Tileset();
Checksum loadTileset(const vector<string> pathList, const string &tilesetName,
Checksum* checksum, std::map<string,vector<string> > &loadedFileList);
Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList);
void load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum,
std::map<string,vector<string> > &loadedFileList);
std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList) {
Checksum* checksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList) {
Checksum World::loadTileset(const string &dir, Checksum *checksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList) {
set<string> &factions, Checksum *checksum, std::map<string,vector<pair<string, 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,vector<string> > &loadedFileList);
Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList);
Checksum loadTileset(const string &dir, Checksum* checksum,
std::map<string,vector<string> > &loadedFileList);
std::map<string,vector<pair<string, string> > > &loadedFileList);
Checksum loadTech(const vector<string> pathList, const string &techName,
set<string> &factions, Checksum* checksum,std::map<string,vector<string> > &loadedFileList);
set<string> &factions, Checksum* checksum,std::map<string,vector<pair<string, string> > > &loadedFileList);
Checksum loadMap(const string &path, Checksum* checksum);
Checksum loadScenario(const string &path, Checksum* checksum);

View File

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

View File

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

View File

@ -208,7 +208,7 @@ 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,vector<string> > *loadedFileList,
bool deletePixMapAfterLoad, std::map<string,vector<pair<string, string> > > *loadedFileList,
string sourceLoader) {
this->textureManager = textureManager;
//read header
@ -270,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].push_back(sourceLoader);
(*loadedFileList)[texPath].push_back(make_pair(sourceLoader,sourceLoader));
}
texturesOwned[mtDiffuse]=true;
textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
@ -298,7 +298,7 @@ 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,vector<string> > *loadedFileList,
std::map<string,vector<pair<string, string> > > *loadedFileList,
string sourceLoader) {
this->textureManager = textureManager;
@ -357,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].push_back(sourceLoader);
(*loadedFileList)[texPath].push_back(make_pair(sourceLoader,sourceLoader));
}
texturesOwned[mtDiffuse]=true;
@ -389,7 +389,7 @@ 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,vector<string> > *loadedFileList,
std::map<string,vector<pair<string, string> > > *loadedFileList,
string sourceLoader) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] #1 load texture [%s]\n",__FUNCTION__,textureFile.c_str());
@ -416,7 +416,7 @@ Texture2D* Mesh::loadMeshTexture(int meshIndex, int textureIndex,
}
texture->load(textureFile);
if(loadedFileList) {
(*loadedFileList)[textureFile].push_back(sourceLoader);
(*loadedFileList)[textureFile].push_back(make_pair(sourceLoader,sourceLoader));
}
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] texture loaded [%s]\n",__FUNCTION__,textureFile.c_str());
@ -439,7 +439,7 @@ Texture2D* Mesh::loadMeshTexture(int meshIndex, int textureIndex,
}
void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
bool deletePixMapAfterLoad,std::map<string,vector<string> > *loadedFileList,
bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList,
string sourceLoader) {
this->textureManager = textureManager;
@ -770,7 +770,7 @@ uint32 Model::getVertexCount() const {
// ==================== io ====================
void Model::load(const string &path, bool deletePixMapAfterLoad,
std::map<string,vector<string> > *loadedFileList, string *sourceLoader) {
std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) {
this->sourceLoader = (sourceLoader != NULL ? *sourceLoader : "");
this->fileName = path;
@ -797,7 +797,7 @@ 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,vector<string> > *loadedFileList,
std::map<string,vector<pair<string, string> > > *loadedFileList,
string sourceLoader) {
try{
@ -808,7 +808,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
}
if(loadedFileList) {
(*loadedFileList)[path].push_back(sourceLoader);
(*loadedFileList)[path].push_back(make_pair(sourceLoader,sourceLoader));
}
string dir= extractDirectoryPathFromFile(path);

View File

@ -1793,6 +1793,48 @@ string executable_path(string exeName, bool includeExeNameInPath) {
return value;
}
bool searchAndReplaceTextInFile(string fileName, string findText, string replaceText, bool simulateOnly) {
bool replacedText = false;
const int MAX_LEN_SINGLE_LINE = 4096;
char buffer[MAX_LEN_SINGLE_LINE+2];
char *buff_ptr, *find_ptr;
FILE *fp1, *fp2;
size_t find_len = findText.length();
string tempfileName = fileName + "_tmp";
fp1 = fopen(fileName.c_str(),"r");
fp2 = fopen(tempfileName.c_str(),"w");
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) {
buff_ptr = buffer;
while ((find_ptr = strstr(buff_ptr,findText.c_str()))) {
//printf("Replacing text [%s] with [%s] in file [%s]\n",findText.c_str(),replaceText.c_str(),fileName.c_str());
while(buff_ptr < find_ptr) {
fputc((int)*buff_ptr++,fp2);
}
fputs(replaceText.c_str(),fp2);
buff_ptr += find_len;
replacedText = true;
}
fputs(buff_ptr,fp2);
}
fclose(fp2);
fclose(fp1);
if(replacedText == true && simulateOnly == false) {
removeFile(fileName);
renameFile(tempfileName,fileName);
}
else {
removeFile(tempfileName);
}
//removeFile(tempfileName);
return replacedText;
}
// =====================================
// ModeInfo
// =====================================