mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 22:21:18 +02:00
- added code to merge duplicate sounds used in a techtree
This commit is contained in:
@@ -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);
|
||||
|
@@ -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
|
||||
// =====================================
|
||||
|
Reference in New Issue
Block a user