- added new commandline option to convert folders of g3d models to use specified texture format
- added new utility methods and changed code to use them (like adding trailing slash on paths)
This commit is contained in:
parent
f35e920d47
commit
39bf1b986e
|
@ -770,9 +770,7 @@ void MainWindow::saveScreenshot() {
|
|||
//string screenShotsPath = extractDirectoryPathFromFile(appPath) + string("screens/");
|
||||
string userData = Config::getInstance().getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
string screenShotsPath = userData + string("screens/");
|
||||
printf("screenShotsPath [%s]\n",screenShotsPath.c_str());
|
||||
|
|
|
@ -43,9 +43,7 @@ Logger::Logger() {
|
|||
else {
|
||||
string userData = Config::getInstance().getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
fileName= userData + "log.txt";
|
||||
}
|
||||
|
|
|
@ -231,7 +231,6 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,st
|
|||
vector<string> loadScreenList;
|
||||
findAll(scenarioDir + factionLogoFilter, loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
//string senarioLogo = scenarioDir + "/" + "loading_screen.jpg";
|
||||
string senarioLogo = scenarioDir + loadScreenList[0];
|
||||
if(fileExists(senarioLogo) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found scenario loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str());
|
||||
|
@ -291,15 +290,17 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,st
|
|||
else {
|
||||
vector<string> pathList=config.getPathListForType(ptTechs,scenarioDir);
|
||||
for(int idx = 0; idx < pathList.size(); idx++) {
|
||||
const string path = pathList[idx]+ "/" +techName+ "/"+ "factions"+ "/"+ settings->getFactionTypeName(i);
|
||||
string currentPath = pathList[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
string path = currentPath + techName + "/" + "factions" + "/" + settings->getFactionTypeName(i);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] possible loading screen dir '%s'\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||
if(isdir(path.c_str()) == true) {
|
||||
vector<string> loadScreenList;
|
||||
findAll(path + "/" + factionLogoFilter, loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
//string factionLogo = path + "/" + "loading_screen.jpg";
|
||||
string factionLogo = path + "/" + loadScreenList[0];
|
||||
endPathWithSlash(path);
|
||||
|
||||
vector<string> loadScreenList;
|
||||
findAll(path + factionLogoFilter, loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
string factionLogo = path + loadScreenList[0];
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
|
||||
|
||||
if(fileExists(factionLogo) == true) {
|
||||
|
@ -330,15 +331,17 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,st
|
|||
|
||||
vector<string> pathList=config.getPathListForType(ptTechs,scenarioDir);
|
||||
for(int idx = 0; idx < pathList.size(); idx++) {
|
||||
const string path = pathList[idx]+ "/" +techName;
|
||||
string currentPath = pathList[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
string path = currentPath + techName;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] possible loading screen dir '%s'\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||
if(isdir(path.c_str()) == true) {
|
||||
vector<string> loadScreenList;
|
||||
findAll(path + "/" + factionLogoFilter, loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
//string factionLogo = path + "/" + "loading_screen.jpg";
|
||||
string factionLogo = path + "/" + loadScreenList[0];
|
||||
endPathWithSlash(path);
|
||||
|
||||
vector<string> loadScreenList;
|
||||
findAll(path + factionLogoFilter, loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
string factionLogo = path + loadScreenList[0];
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
|
||||
|
||||
if(fileExists(factionLogo) == true) {
|
||||
|
|
|
@ -114,22 +114,37 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
|||
}
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
|
||||
|
||||
string userData = "";
|
||||
if(cfgType.first == cfgMainGame) {
|
||||
if( properties.first.getString("UserData_Root", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||
fileName.second = properties.first.getString("UserData_Root") + fileNameParameter.second;
|
||||
string userData = properties.first.getString("UserData_Root");
|
||||
if(userData != "") {
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
fileName.second = userData + fileNameParameter.second;
|
||||
}
|
||||
else if(properties.first.getString("UserOverrideFile", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||
fileName.second = properties.first.getString("UserOverrideFile") + fileNameParameter.second;
|
||||
string userData = properties.first.getString("UserOverrideFile");
|
||||
if(userData != "") {
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
fileName.second = userData + fileNameParameter.second;
|
||||
}
|
||||
}
|
||||
else if(cfgType.first == cfgMainKeys) {
|
||||
Config &mainCfg = Config::getInstance();
|
||||
if( mainCfg.getString("UserData_Root", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||
fileName.second = mainCfg.getString("UserData_Root") + fileNameParameter.second;
|
||||
string userData = mainCfg.getString("UserData_Root");
|
||||
if(userData != "") {
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
fileName.second = userData + fileNameParameter.second;
|
||||
}
|
||||
else if(mainCfg.getString("UserOverrideFile", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||
fileName.second = mainCfg.getString("UserOverrideFile") + fileNameParameter.second;
|
||||
string userData = mainCfg.getString("UserOverrideFile");
|
||||
if(userData != "") {
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
fileName.second = userData + fileNameParameter.second;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,9 @@ void Lang::loadStrings(const string &language){
|
|||
void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenarioName){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scenarioDir = [%s] scenarioName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioDir.c_str(),scenarioName.c_str());
|
||||
|
||||
string scenarioFolder = scenarioDir + "/" + scenarioName + "/";
|
||||
string currentPath = scenarioDir;
|
||||
endPathWithSlash(currentPath);
|
||||
string scenarioFolder = currentPath + scenarioName + "/";
|
||||
string path = scenarioFolder + scenarioName + "_" + language + ".lng";
|
||||
if(EndsWith(scenarioDir, ".xml") == true) {
|
||||
scenarioFolder = extractDirectoryPathFromFile(scenarioDir);
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
#include "config.h"
|
||||
#include "game_constants.h"
|
||||
#include "util.h"
|
||||
#include "platform_common.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Xml;
|
||||
using namespace Shared::Graphics;
|
||||
using namespace Shared::Util;
|
||||
using namespace Shared::PlatformCommon;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
|
@ -51,7 +53,9 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
|||
else{
|
||||
texture->getPixmap()->init(4);
|
||||
}
|
||||
texture->load(dir + "/" + textureNode->getAttribute("path")->getRestrictedValue());
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
texture->load(currentPath + textureNode->getAttribute("path")->getRestrictedValue());
|
||||
}
|
||||
else {
|
||||
texture= NULL;
|
||||
|
@ -65,7 +69,10 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
|||
string path= modelNode->getAttribute("path")->getRestrictedValue();
|
||||
model= renderer->newModel(rsGame);
|
||||
|
||||
model->load(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
model->load(currentPath + path);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "FileReader.h"
|
||||
#include "cache_manager.h"
|
||||
#include <iterator>
|
||||
#include "core_data.h"
|
||||
|
||||
// For gcc backtrace on crash!
|
||||
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||
|
@ -99,7 +100,8 @@ const char *GAME_ARGS[] = {
|
|||
"--ini-path",
|
||||
"--log-path",
|
||||
"--show-ini-settings",
|
||||
"--convert-model",
|
||||
"--convert-models",
|
||||
"--convert-textures",
|
||||
"--disable-backtrace",
|
||||
"--disable-vbo",
|
||||
"--verbose"
|
||||
|
@ -123,7 +125,8 @@ enum GAME_ARG_TYPE {
|
|||
GAME_ARG_INI_PATH,
|
||||
GAME_ARG_LOG_PATH,
|
||||
GAME_ARG_SHOW_INI_SETTINGS,
|
||||
GAME_ARG_CONVERT_MODEL,
|
||||
GAME_ARG_CONVERT_MODELS,
|
||||
GAME_ARG_CONVERT_TEXTURES,
|
||||
GAME_ARG_DISABLE_BACKTRACE,
|
||||
GAME_ARG_DISABLE_VBO,
|
||||
GAME_ARG_VERBOSE_MODE
|
||||
|
@ -697,9 +700,7 @@ void MainWindow::eventKeyDown(char key){
|
|||
else if(key == configKeys.getCharKey("Screenshot")) {
|
||||
string userData = Config::getInstance().getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
|
||||
string path = userData + GameConstants::folder_path_screenshots;
|
||||
|
@ -862,10 +863,15 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
|||
printf("\n \t\tWhere x is an optional property name to filter (default shows all).");
|
||||
printf("\n \t\texample: %s %s=DebugMode",argv0,GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]);
|
||||
|
||||
printf("\n%s=x=format\t\t\tconvert a model to current g3d format.",GAME_ARGS[GAME_ARG_CONVERT_MODEL]);
|
||||
printf("\n \t\tWhere x is the filename for the g3d model.");
|
||||
printf("\n \t\tWhere format is the optional texture format to convert to (default is png).");
|
||||
printf("\n \t\texample: %s %s=techs/megapack/factions/tech/units/castle/models/castle.g3d",argv0,GAME_ARGS[GAME_ARG_CONVERT_MODEL]);
|
||||
printf("\n%s=x=textureformat\t\t\tconvert a model file or folder to the current g3d version format.",GAME_ARGS[GAME_ARG_CONVERT_MODELS]);
|
||||
printf("\n \t\tWhere x is a filename or folder containing the g3d model(s).");
|
||||
printf("\n \t\tWhere textureformat is an optional supported texture format to convert to (tga,bmp,png).");
|
||||
printf("\n \t\texample: %s %s=techs/megapack/factions/tech/units/castle/models/castle.g3d=png",argv0,GAME_ARGS[GAME_ARG_CONVERT_MODELS]);
|
||||
|
||||
printf("\n%s=x=textureformat\t\t\tconvert a texture file or folder to the format textureformat.",GAME_ARGS[GAME_ARG_CONVERT_TEXTURES]);
|
||||
printf("\n \t\tWhere x is a filename or folder containing the texture(s).");
|
||||
printf("\n \t\tWhere textureformat is a supported texture format to convert to (tga,bmp,png).");
|
||||
printf("\n \t\texample: %s %s=data/core/misc_textures/fire_particle.tga=png",argv0,GAME_ARGS[GAME_ARG_CONVERT_TEXTURES]);
|
||||
|
||||
printf("\n%s\t\tdisables stack backtrace on errors.",GAME_ARGS[GAME_ARG_DISABLE_BACKTRACE]);
|
||||
printf("\n%s\t\tdisables trying to use Vertex Buffer Objects.",GAME_ARGS[GAME_ARG_DISABLE_VBO]);
|
||||
|
@ -964,9 +970,7 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
|
|||
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
|
||||
string debugLogFile = config.getString("DebugLogFile","");
|
||||
|
@ -1154,6 +1158,8 @@ void runTechValidationReport(int argc, char** argv) {
|
|||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
string &techPath = techPaths[idx];
|
||||
endPathWithSlash(techPath);
|
||||
|
||||
//printf("techPath [%s]\n",techPath.c_str());
|
||||
|
||||
for(int idx2 = 0; idx2 < techTreeFiles.size(); idx2++) {
|
||||
|
@ -1163,7 +1169,7 @@ void runTechValidationReport(int argc, char** argv) {
|
|||
std::find(filteredTechTreeList.begin(),filteredTechTreeList.end(),techName) != filteredTechTreeList.end()) {
|
||||
|
||||
vector<string> factionsList;
|
||||
findAll(techPath + "/" + techName + "/factions/*.", factionsList, false, false);
|
||||
findAll(techPath + techName + "/factions/*.", factionsList, false, false);
|
||||
|
||||
if(factionsList.size() > 0) {
|
||||
Checksum checksum;
|
||||
|
@ -1419,8 +1425,11 @@ void CheckForDuplicateData() {
|
|||
if(duplicateMapsToRename.size() > 0) {
|
||||
string errorMsg = "Warning duplicate maps were detected and renamed:\n";
|
||||
for(int i = 0; i < duplicateMapsToRename.size(); ++i) {
|
||||
string oldFile = mapPaths[1] + "/" + duplicateMapsToRename[i];
|
||||
string newFile = mapPaths[1] + "/" + duplicateMapsToRename[i];
|
||||
string currentPath = mapPaths[1];
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
string oldFile = currentPath + duplicateMapsToRename[i];
|
||||
string newFile = currentPath + duplicateMapsToRename[i];
|
||||
string ext = extractExtension(newFile);
|
||||
newFile = newFile.substr( 0, newFile.length()-ext.length()-1);
|
||||
newFile = newFile + "_custom." + ext;
|
||||
|
@ -1608,9 +1617,7 @@ int glestMain(int argc, char** argv) {
|
|||
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
|
||||
if(isdir(userData.c_str()) == false) {
|
||||
createDirectoryPaths(userData);
|
||||
|
@ -1786,6 +1793,108 @@ int glestMain(int argc, char** argv) {
|
|||
delete mainWindow;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_CONVERT_MODELS]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_CONVERT_MODELS]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_CONVERT_MODELS]),&foundParamIndIndex);
|
||||
}
|
||||
string paramValue = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(paramValue,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
string modelFile = paramPartTokens[1];
|
||||
printf("About to convert model(s) [%s]\n",modelFile.c_str());
|
||||
|
||||
string textureFormat = "";
|
||||
if(paramPartTokens.size() >= 3 && paramPartTokens[1].length() > 0) {
|
||||
textureFormat = paramPartTokens[2];
|
||||
printf("About to convert using texture format [%s]\n",textureFormat.c_str());
|
||||
}
|
||||
|
||||
showCursor(true);
|
||||
mainWindow->setUseDefaultCursorOnly(true);
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
renderer.clearBuffers();
|
||||
renderer.clearZBuffer();
|
||||
renderer.reset2d();
|
||||
renderer.renderText(
|
||||
"Please wait, converting models...",
|
||||
CoreData::getInstance().getMenuFontBig(),
|
||||
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
||||
(metrics.getScreenH() / 2), true);
|
||||
renderer.swapBuffers();
|
||||
|
||||
std::vector<string> models;
|
||||
if(isdir(modelFile.c_str()) == true) {
|
||||
models = getFolderTreeContentsListRecursively(modelFile, ".g3d");
|
||||
}
|
||||
else {
|
||||
models.push_back(modelFile);
|
||||
}
|
||||
|
||||
sleep(0);
|
||||
Window::handleEvent();
|
||||
SDL_PumpEvents();
|
||||
|
||||
char szTextBuf[1024]="";
|
||||
for(unsigned int i =0; i < models.size(); ++i) {
|
||||
string &file = models[i];
|
||||
bool modelLoadedOk = false;
|
||||
|
||||
renderer.clearBuffers();
|
||||
renderer.clearZBuffer();
|
||||
renderer.reset2d();
|
||||
sprintf(szTextBuf,"Please wait, converting models [%d of %lu] ...",i,(long int)models.size());
|
||||
renderer.renderText(
|
||||
szTextBuf,
|
||||
CoreData::getInstance().getMenuFontBig(),
|
||||
Vec3f(1.f, 1.f, 0.f), (metrics.getScreenW() / 2) - 400,
|
||||
(metrics.getScreenH() / 2), true);
|
||||
renderer.swapBuffers();
|
||||
|
||||
sleep(0);
|
||||
Window::handleEvent();
|
||||
SDL_PumpEvents();
|
||||
|
||||
Model *model = renderer.newModel(rsGlobal);
|
||||
try {
|
||||
printf("About to load model [%s]\n",file.c_str());
|
||||
model->load(file);
|
||||
modelLoadedOk = true;
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
printf("ERROR loading model [%s] message [%s]\n",file.c_str(),ex.what());
|
||||
}
|
||||
|
||||
if(modelLoadedOk == true) {
|
||||
printf("About to save converted model [%s]\n",file.c_str());
|
||||
model->save(file,textureFormat);
|
||||
}
|
||||
|
||||
Renderer::getInstance().endModel(rsGlobal, model);
|
||||
}
|
||||
|
||||
delete mainWindow;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
printf("\nInvalid model specified on commandline [%s] texture [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
printParameterHelp(argv[0],foundInvalidArgs);
|
||||
delete mainWindow;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_CONVERT_TEXTURES]) == true) {
|
||||
//!!!
|
||||
printf("\nComing soon (not yet implemented)\n\n");
|
||||
delete mainWindow;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]) == true ||
|
||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true) {
|
||||
|
||||
|
@ -1795,49 +1904,11 @@ int glestMain(int argc, char** argv) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_CONVERT_MODEL]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_CONVERT_MODEL]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_CONVERT_MODEL]),&foundParamIndIndex);
|
||||
}
|
||||
string paramValue = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(paramValue,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
string modelFile = paramPartTokens[1];
|
||||
string textureFormat = "png";
|
||||
if(paramPartTokens.size() >= 3) {
|
||||
textureFormat = paramPartTokens[2];
|
||||
}
|
||||
|
||||
printf("About to convert model [%s] using texture format [%s]\n",modelFile.c_str(),textureFormat.c_str());
|
||||
|
||||
Model *model = renderer.newModel(rsGlobal);
|
||||
model->load(modelFile);
|
||||
model->save(modelFile,textureFormat);
|
||||
|
||||
//!!!
|
||||
delete mainWindow;
|
||||
return -1;
|
||||
|
||||
}
|
||||
else {
|
||||
printf("\nInvalid model name specified on commandline [%s] model [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
printParameterHelp(argv[0],foundInvalidArgs);
|
||||
delete mainWindow;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
gameInitialized = true;
|
||||
|
||||
// Setup the screenshots folder
|
||||
//string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
|
||||
string screenShotsPath = userData + GameConstants::folder_path_screenshots;
|
||||
|
|
|
@ -495,9 +495,7 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
|||
else {
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
|
||||
logFile = userData + logFile;
|
||||
|
|
|
@ -1604,8 +1604,8 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
|
|||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
string &techPath = techPaths[idx];
|
||||
|
||||
findAll(techPath + "/" + gameSettings->getTech() + "/factions/*.", results, false, false);
|
||||
endPathWithSlash(techPath);
|
||||
findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false);
|
||||
if(results.size() > 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -444,7 +444,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
string &techPath = techPaths[idx];
|
||||
findAll(techPath + "/" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
|
||||
endPathWithSlash(techPath);
|
||||
findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
|
||||
|
||||
if(results.size() > 0) {
|
||||
break;
|
||||
|
@ -2238,15 +2239,10 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
|||
void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||
// fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
||||
//}
|
||||
Config &config = Config::getInstance();
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
fileName = userData + fileName;
|
||||
|
||||
|
@ -2306,15 +2302,10 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
|
||||
GameSettings gameSettings;
|
||||
|
||||
//if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||
// fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
||||
//}
|
||||
Config &config = Config::getInstance();
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
fileName = userData + fileName;
|
||||
|
||||
|
@ -2556,16 +2547,14 @@ void MenuStateCustomGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMa
|
|||
}
|
||||
|
||||
void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem) {
|
||||
|
||||
vector<string> results;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
string &techPath = techPaths[idx];
|
||||
|
||||
findAll(techPath + "/" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
|
||||
endPathWithSlash(techPath);
|
||||
findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
|
||||
if(results.size() > 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -54,15 +54,9 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
|||
networkManager.init(nrClient);
|
||||
|
||||
serversSavedFile = serverFileName;
|
||||
//if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||
// serversSavedFile = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + serversSavedFile;
|
||||
//}
|
||||
//Config &config = Config::getInstance();
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
serversSavedFile = userData + serversSavedFile;
|
||||
|
||||
|
|
|
@ -69,10 +69,11 @@ ServerLine::ServerLine(MasterServerInfo *mServerInfo, int lineIndex, int baseY,
|
|||
|
||||
Config &config= Config::getInstance();
|
||||
if(config.getString("CountryTexturePath", "") != ""){
|
||||
countryLogoPath= config.getString("CountryTexturePath", "");
|
||||
countryLogoPath = config.getString("CountryTexturePath", "");
|
||||
}
|
||||
endPathWithSlash(countryLogoPath);
|
||||
|
||||
string logoFile= countryLogoPath + "/" + toLower(masterServerInfo.getCountry()) + ".png";
|
||||
string logoFile= countryLogoPath + toLower(masterServerInfo.getCountry()) + ".png";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFile [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFile.c_str());
|
||||
|
||||
if(fileExists(logoFile) == true){
|
||||
|
|
|
@ -321,7 +321,6 @@ void ClientInterface::updateLobby() {
|
|||
}
|
||||
|
||||
// check the checksum's
|
||||
//int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_tilesets) + "/" + networkMessageSynchNetworkGameData.getTileset() + "/*", ".xml", NULL);
|
||||
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,scenarioDir), string("/") + networkMessageSynchNetworkGameData.getTileset() + string("/*"), ".xml", NULL);
|
||||
|
||||
this->setNetworkGameDataSynchCheckOkTile((tilesetCRC == networkMessageSynchNetworkGameData.getTilesetCRC()));
|
||||
|
@ -330,9 +329,7 @@ void ClientInterface::updateLobby() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetCRC info, local = %d, remote = %d, networkMessageSynchNetworkGameData.getTileset() = [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetCRC,networkMessageSynchNetworkGameData.getTilesetCRC(),networkMessageSynchNetworkGameData.getTileset().c_str());
|
||||
//}
|
||||
|
||||
|
||||
//tech, load before map because of resources
|
||||
//int32 techCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_techs) + "/" + networkMessageSynchNetworkGameData.getTech() + "/*", ".xml", NULL);
|
||||
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,scenarioDir), string("/") + networkMessageSynchNetworkGameData.getTech() + string("/*"), ".xml", NULL);
|
||||
|
||||
this->setNetworkGameDataSynchCheckOkTech((techCRC == networkMessageSynchNetworkGameData.getTechCRC()));
|
||||
|
|
|
@ -637,21 +637,17 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
|
||||
if(networkGameDataSynchCheckOkTile == false) {
|
||||
if(tilesetCRC == 0) {
|
||||
//vctFileList = getFolderTreeContentsCheckSumListRecursively(string(GameConstants::folder_path_tilesets) + "/" + serverInterface->getGameSettings()->getTileset() + "/*", "", &vctFileList);
|
||||
vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTilesets,scenarioDir), string("/") + serverInterface->getGameSettings()->getTileset() + string("/*"), "", &vctFileList);
|
||||
}
|
||||
else {
|
||||
//vctFileList = getFolderTreeContentsCheckSumListRecursively(string(GameConstants::folder_path_tilesets) + "/" + serverInterface->getGameSettings()->getTileset() + "/*", ".xml", &vctFileList);
|
||||
vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTilesets,scenarioDir), "/" + serverInterface->getGameSettings()->getTileset() + "/*", ".xml", &vctFileList);
|
||||
}
|
||||
}
|
||||
if(networkGameDataSynchCheckOkTech == false) {
|
||||
if(techCRC == 0) {
|
||||
//vctFileList = getFolderTreeContentsCheckSumListRecursively(string(GameConstants::folder_path_techs) + "/" + serverInterface->getGameSettings()->getTech() + "/*", "", &vctFileList);
|
||||
vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTechs,scenarioDir),"/" + serverInterface->getGameSettings()->getTech() + "/*", "", &vctFileList);
|
||||
}
|
||||
else {
|
||||
//vctFileList = getFolderTreeContentsCheckSumListRecursively(string(GameConstants::folder_path_techs) + "/" + serverInterface->getGameSettings()->getTech() + "/*", ".xml", &vctFileList);
|
||||
vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTechs,scenarioDir),"/" + serverInterface->getGameSettings()->getTech() + "/*", ".xml", &vctFileList);
|
||||
}
|
||||
|
||||
|
@ -670,14 +666,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
}
|
||||
else {
|
||||
if(networkGameDataSynchCheckOkTech == false) {
|
||||
//if(techCRC == 0) {
|
||||
//vctFileList = getFolderTreeContentsCheckSumListRecursively(string(GameConstants::folder_path_techs) + "/" + serverInterface->getGameSettings()->getTech() + "/*", "", &vctFileList);
|
||||
//vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTechs,scenarioDir),"/" + serverInterface->getGameSettings()->getTech() + "/*", "", &vctFileList);
|
||||
//}
|
||||
//else {
|
||||
//vctFileList = getFolderTreeContentsCheckSumListRecursively(string(GameConstants::folder_path_techs) + "/" + serverInterface->getGameSettings()->getTech() + "/*", ".xml", &vctFileList);
|
||||
vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTechs,scenarioDir),"/" + serverInterface->getGameSettings()->getTech() + "/*", ".xml", NULL);
|
||||
//}
|
||||
|
||||
string report = networkMessageSynchNetworkGameDataStatus.getTechCRCFileMismatchReport(serverInterface->getGameSettings()->getTech(),vctFileList);
|
||||
this->setNetworkGameDataSynchCheckTechMismatchReport(report);
|
||||
|
|
|
@ -51,7 +51,10 @@ void CommandType::load(int id, const XmlNode *n, const string &dir, const TechTr
|
|||
//image
|
||||
const XmlNode *imageNode= n->getChild("image");
|
||||
image= Renderer::getInstance().newTexture2D(rsGame);
|
||||
image->load(dir+"/"+imageNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
image->load(currentPath + imageNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
//unit requirements
|
||||
const XmlNode *unitRequirementsNode= n->getChild("unit-requirements");
|
||||
|
@ -378,7 +381,10 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir, const T
|
|||
const XmlNode *soundFileNode= startSoundNode->getChild("sound-file", i);
|
||||
string path= soundFileNode->getAttribute("path")->getRestrictedValue();
|
||||
StaticSound *sound= new StaticSound();
|
||||
sound->load(dir + "/" + path);
|
||||
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
sound->load(currentPath + path);
|
||||
startSounds[i]= sound;
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +397,10 @@ void BuildCommandType::load(int id, const XmlNode *n, const string &dir, const T
|
|||
const XmlNode *soundFileNode= builtSoundNode->getChild("sound-file", i);
|
||||
string path= soundFileNode->getAttribute("path")->getRestrictedValue();
|
||||
StaticSound *sound= new StaticSound();
|
||||
sound->load(dir + "/" + path);
|
||||
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
sound->load(currentPath + path);
|
||||
builtSounds[i]= sound;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,9 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
|||
}
|
||||
|
||||
//open xml file
|
||||
string path= dir+"/"+name+".xml";
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
string path= currentPath + name + ".xml";
|
||||
checksum->addFile(path);
|
||||
techtreeChecksum->addFile(path);
|
||||
|
||||
|
@ -143,7 +145,10 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
|||
bool value= musicNode->getAttribute("value")->getBoolValue();
|
||||
if(value){
|
||||
music= new StrSound();
|
||||
music->open(dir+"/"+musicNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
music->open(currentPath + musicNode->getAttribute("path")->getRestrictedValue());
|
||||
}
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -57,7 +57,9 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||
name= lastDir(dir);
|
||||
|
||||
Logger::getInstance().add("Resource type: "+ formatString(name), true);
|
||||
path= dir+"/"+name+".xml";
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
path= currentPath + name + ".xml";
|
||||
checksum->addFile(path);
|
||||
techtreeChecksum->addFile(path);
|
||||
|
||||
|
@ -69,7 +71,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||
//image
|
||||
const XmlNode *imageNode= resourceNode->getChild("image");
|
||||
image= renderer.newTexture2D(rsGame);
|
||||
image->load(dir+"/"+imageNode->getAttribute("path")->getRestrictedValue());
|
||||
image->load(currentPath + imageNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
//type
|
||||
const XmlNode *typeNode= resourceNode->getChild("type");
|
||||
|
@ -81,7 +83,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||
{
|
||||
//model
|
||||
const XmlNode *modelNode= typeNode->getChild("model");
|
||||
string path=dir+"/" + modelNode->getAttribute("path")->getRestrictedValue();
|
||||
string path= currentPath + modelNode->getAttribute("path")->getRestrictedValue();
|
||||
|
||||
model= renderer.newModel(rsGame);
|
||||
model->load(path);
|
||||
|
@ -95,7 +97,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
|
||||
|
||||
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
|
||||
objectParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||
objectParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance());
|
||||
particleTypes.push_back(objectParticleSystemType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,9 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, c
|
|||
//model
|
||||
string path= sn->getChild("animation")->getAttribute("path")->getRestrictedValue();
|
||||
animation= Renderer::getInstance().newModel(rsGame);
|
||||
animation->load(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
animation->load(currentPath + path);
|
||||
|
||||
//particles
|
||||
if(sn->hasChild("particles")){
|
||||
|
@ -74,7 +76,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, c
|
|||
const XmlNode *particleFileNode= particleNode->getChild("particle-file", i);
|
||||
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
|
||||
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();
|
||||
unitParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||
unitParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance());
|
||||
unitParticleSystemTypes.push_back(unitParticleSystemType);
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +95,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, c
|
|||
const XmlNode *soundFileNode= soundNode->getChild("sound-file", i);
|
||||
string path= soundFileNode->getAttribute("path")->getRestrictedValue();
|
||||
StaticSound *sound= new StaticSound();
|
||||
sound->load(dir + "/" + path);
|
||||
sound->load(currentPath + path);
|
||||
sounds[i]= sound;
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +191,9 @@ AttackSkillType::~AttackSkillType() {
|
|||
void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, const FactionType *ft) {
|
||||
SkillType::load(sn, dir, tt, ft);
|
||||
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
//misc
|
||||
attackStrength= sn->getChild("attack-strenght")->getAttribute("value")->getIntValue();
|
||||
attackVar= sn->getChild("attack-var")->getAttribute("value")->getIntValue();
|
||||
|
@ -239,7 +244,7 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree
|
|||
if(particleEnabled){
|
||||
string path= particleNode->getAttribute("path")->getRestrictedValue();
|
||||
projectileParticleSystemType= new ParticleSystemTypeProjectile();
|
||||
projectileParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||
projectileParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance());
|
||||
}
|
||||
|
||||
//proj sounds
|
||||
|
@ -251,7 +256,7 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree
|
|||
const XmlNode *soundFileNode= soundNode->getChild("sound-file", i);
|
||||
string path= soundFileNode->getAttribute("path")->getRestrictedValue();
|
||||
StaticSound *sound= new StaticSound();
|
||||
sound->load(dir + "/" + path);
|
||||
sound->load(currentPath + path);
|
||||
projSounds[i]= sound;
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +275,7 @@ void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree
|
|||
if(particleEnabled){
|
||||
string path= particleNode->getAttribute("path")->getRestrictedValue();
|
||||
splashParticleSystemType= new ParticleSystemTypeSplash();
|
||||
splashParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||
splashParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,10 @@ namespace Glest{ namespace Game{
|
|||
Checksum TechTree::loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum) {
|
||||
Checksum techtreeChecksum;
|
||||
for(int idx = 0; idx < pathList.size(); idx++) {
|
||||
string path = pathList[idx] + "/" + techName;
|
||||
string currentPath = pathList[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
string path = currentPath + techName;
|
||||
if(isdir(path.c_str()) == true) {
|
||||
load(path, factions, checksum, &techtreeChecksum);
|
||||
break;
|
||||
|
@ -85,7 +88,9 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||
//load tech tree xml info
|
||||
try{
|
||||
XmlTree xmlTree;
|
||||
string path= dir+"/"+lastDir(dir)+".xml";
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
string path = currentPath + lastDir(dir) + ".xml";
|
||||
|
||||
checksum->addFile(path);
|
||||
checksumValue.addFile(path);
|
||||
|
|
|
@ -121,7 +121,9 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
string path = dir + "/" + name + ".xml";
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
string path = currentPath + name + ".xml";
|
||||
|
||||
this->id= id;
|
||||
|
||||
|
@ -284,7 +286,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
|
|||
//Texture2D *newTexture = Renderer::getInstance().newTexture2D(rsGame);
|
||||
Texture2D *newTexture = NULL;
|
||||
|
||||
unitParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||
unitParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance());
|
||||
if(unitParticleSystemType->hasTexture() == false) {
|
||||
//Renderer::getInstance().endLastTexture(rsGame,true);
|
||||
}
|
||||
|
@ -353,19 +355,19 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
|
|||
//image
|
||||
const XmlNode *imageNode= parametersNode->getChild("image");
|
||||
image= Renderer::getInstance().newTexture2D(rsGame);
|
||||
image->load(dir+"/"+imageNode->getAttribute("path")->getRestrictedValue());
|
||||
image->load(currentPath + imageNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
//image cancel
|
||||
const XmlNode *imageCancelNode= parametersNode->getChild("image-cancel");
|
||||
cancelImage= Renderer::getInstance().newTexture2D(rsGame);
|
||||
cancelImage->load(dir+"/"+imageCancelNode->getAttribute("path")->getRestrictedValue());
|
||||
cancelImage->load(currentPath + imageCancelNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
//meeting point
|
||||
const XmlNode *meetingPointNode= parametersNode->getChild("meeting-point");
|
||||
meetingPoint= meetingPointNode->getAttribute("value")->getBoolValue();
|
||||
if(meetingPoint){
|
||||
meetingPointImage= Renderer::getInstance().newTexture2D(rsGame);
|
||||
meetingPointImage->load(dir+"/"+meetingPointNode->getAttribute("image-path")->getRestrictedValue());
|
||||
meetingPointImage->load(currentPath + meetingPointNode->getAttribute("image-path")->getRestrictedValue());
|
||||
}
|
||||
|
||||
//selection sounds
|
||||
|
@ -376,7 +378,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
|
|||
const XmlNode *soundNode= selectionSoundNode->getChild("sound", i);
|
||||
string path= soundNode->getAttribute("path")->getRestrictedValue();
|
||||
StaticSound *sound= new StaticSound();
|
||||
sound->load(dir + "/" + path);
|
||||
sound->load(currentPath + path);
|
||||
selectionSounds[i]= sound;
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +391,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
|
|||
const XmlNode *soundNode= commandSoundNode->getChild("sound", i);
|
||||
string path= soundNode->getAttribute("path")->getRestrictedValue();
|
||||
StaticSound *sound= new StaticSound();
|
||||
sound->load(dir + "/" + path);
|
||||
sound->load(currentPath + path);
|
||||
commandSounds[i]= sound;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,9 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const Factio
|
|||
|
||||
Logger::getInstance().add("Upgrade type: "+ formatString(name), true);
|
||||
|
||||
path = dir + "/" + name + ".xml";
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
path = currentPath + name + ".xml";
|
||||
|
||||
try{
|
||||
checksum->addFile(path);
|
||||
|
@ -67,12 +69,12 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const Factio
|
|||
//image
|
||||
const XmlNode *imageNode= upgradeNode->getChild("image");
|
||||
image= Renderer::getInstance().newTexture2D(rsGame);
|
||||
image->load(dir+"/"+imageNode->getAttribute("path")->getRestrictedValue());
|
||||
image->load(currentPath + imageNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
//image cancel
|
||||
const XmlNode *imageCancelNode= upgradeNode->getChild("image-cancel");
|
||||
cancelImage= Renderer::getInstance().newTexture2D(rsGame);
|
||||
cancelImage->load(dir+"/"+imageCancelNode->getAttribute("path")->getRestrictedValue());
|
||||
cancelImage->load(currentPath + imageCancelNode->getAttribute("path")->getRestrictedValue());
|
||||
|
||||
//upgrade time
|
||||
const XmlNode *upgradeTimeNode= upgradeNode->getChild("time");
|
||||
|
|
|
@ -1250,9 +1250,11 @@ string Map::getMapPath(const string &mapName, string scenarioDir, bool errorOnNo
|
|||
vector<string> pathList = config.getPathListForType(ptMaps,scenarioDir);
|
||||
|
||||
for(int idx = 0; idx < pathList.size(); idx++) {
|
||||
const string &map_path = pathList[idx];
|
||||
const string mega = map_path + "/" + mapName + ".mgm";
|
||||
const string glest = map_path + "/" + mapName + ".gbm";
|
||||
string map_path = pathList[idx];
|
||||
endPathWithSlash(map_path);
|
||||
|
||||
const string mega = map_path + mapName + ".mgm";
|
||||
const string glest = map_path + mapName + ".gbm";
|
||||
if (fileExists(mega)) {
|
||||
return mega;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
#include "xml_parser.h"
|
||||
#include "util.h"
|
||||
#include "game_util.h"
|
||||
#include "leak_dumper.h"
|
||||
#include <stdio.h>
|
||||
#include "platform_common.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Xml;
|
||||
using namespace Shared::Util;
|
||||
using namespace Shared::PlatformCommon;
|
||||
using namespace std;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
@ -67,7 +69,9 @@ Checksum Scenario::load(const string &path) {
|
|||
int Scenario::getScenarioPathIndex(const vector<string> dirList, const string &scenarioName) {
|
||||
int iIndex = 0;
|
||||
for(int idx = 0; idx < dirList.size(); idx++) {
|
||||
string scenarioFile = dirList[idx] + "/" + scenarioName + "/" + scenarioName + ".xml";
|
||||
string currentPath = dirList[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
string scenarioFile = currentPath + scenarioName + "/" + scenarioName + ".xml";
|
||||
if(fileExists(scenarioFile) == true) {
|
||||
iIndex = idx;
|
||||
break;
|
||||
|
@ -80,7 +84,9 @@ int Scenario::getScenarioPathIndex(const vector<string> dirList, const string &s
|
|||
string Scenario::getScenarioPath(const vector<string> dirList, const string &scenarioName, bool getMatchingRootScenarioPathOnly){
|
||||
string scenarioFile = "";
|
||||
for(int idx = 0; idx < dirList.size(); idx++) {
|
||||
scenarioFile = dirList[idx] + "/" + scenarioName + "/" + scenarioName + ".xml";
|
||||
string currentPath = dirList[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
scenarioFile = currentPath + scenarioName + "/" + scenarioName + ".xml";
|
||||
if(fileExists(scenarioFile) == true) {
|
||||
if(getMatchingRootScenarioPathOnly == true) {
|
||||
scenarioFile = dirList[idx];
|
||||
|
@ -96,9 +102,9 @@ string Scenario::getScenarioPath(const vector<string> dirList, const string &sce
|
|||
}
|
||||
|
||||
string Scenario::getScenarioPath(const string &dir, const string &scenarioName){
|
||||
string scenarioFile = dir + "/" + scenarioName + "/" + scenarioName + ".xml";
|
||||
//printf("dir [%s] scenarioName [%s] scenarioFile [%s]\n",dir.c_str(),scenarioName.c_str(),scenarioFile.c_str());
|
||||
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
string scenarioFile = currentPath + scenarioName + "/" + scenarioName + ".xml";
|
||||
return scenarioFile;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,9 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
|
|||
enabledDay= dayNode->getAttribute("enabled")->getBoolValue();
|
||||
if(enabledDay){
|
||||
path= dayNode->getAttribute("path")->getRestrictedValue();
|
||||
day.open(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
day.open(currentPath + path);
|
||||
alwaysPlayDay= dayNode->getAttribute("play-always")->getBoolValue();
|
||||
}
|
||||
|
||||
|
@ -48,7 +50,9 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
|
|||
enabledNight= nightNode->getAttribute("enabled")->getBoolValue();
|
||||
if(enabledNight){
|
||||
path= nightNode->getAttribute("path")->getRestrictedValue();
|
||||
night.open(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
night.open(currentPath + path);
|
||||
alwaysPlayNight= nightNode->getAttribute("play-always")->getBoolValue();
|
||||
}
|
||||
|
||||
|
@ -57,7 +61,9 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
|
|||
enabledRain= rainNode->getAttribute("enabled")->getBoolValue();
|
||||
if(enabledRain){
|
||||
path= rainNode->getAttribute("path")->getRestrictedValue();
|
||||
rain.open(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
rain.open(currentPath + path);
|
||||
}
|
||||
|
||||
//snow
|
||||
|
@ -65,7 +71,9 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
|
|||
enabledSnow= snowNode->getAttribute("enabled")->getBoolValue();
|
||||
if(enabledSnow){
|
||||
path= snowNode->getAttribute("path")->getRestrictedValue();
|
||||
snow.open(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
snow.open(currentPath + path);
|
||||
}
|
||||
|
||||
//dayStart
|
||||
|
@ -73,7 +81,9 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
|
|||
enabledDayStart= dayStartNode->getAttribute("enabled")->getBoolValue();
|
||||
if(enabledDayStart){
|
||||
path= dayStartNode->getAttribute("path")->getRestrictedValue();
|
||||
dayStart.load(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
dayStart.load(currentPath + path);
|
||||
}
|
||||
|
||||
//nightStart
|
||||
|
@ -81,9 +91,10 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
|
|||
enabledNightStart= nightStartNode->getAttribute("enabled")->getBoolValue();
|
||||
if(enabledNightStart){
|
||||
path= nightStartNode->getAttribute("path")->getRestrictedValue();
|
||||
nightStart.load(dir + "/" + path);
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
nightStart.load(currentPath + path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
|
@ -93,7 +104,9 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
|
|||
Checksum Tileset::loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum) {
|
||||
Checksum tilesetChecksum;
|
||||
for(int idx = 0; idx < pathList.size(); idx++) {
|
||||
const string path = pathList[idx] + "/" + tilesetName;
|
||||
string currentPath = pathList[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
string path = currentPath + tilesetName;
|
||||
if(isdir(path.c_str()) == true) {
|
||||
load(path, checksum, &tilesetChecksum);
|
||||
break;
|
||||
|
@ -111,7 +124,9 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
string name= lastDir(dir);
|
||||
string path= dir + "/" + name + ".xml";
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
string path= currentPath + name + ".xml";
|
||||
|
||||
checksum->addFile(path);
|
||||
tilesetChecksum->addFile(path);
|
||||
|
@ -152,7 +167,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
|
|||
for(int j=0; j<childCount; ++j){
|
||||
const XmlNode *textureNode= surfaceNode->getChild("texture", j);
|
||||
surfPixmaps[i][j].init(3);
|
||||
surfPixmaps[i][j].load(dir +"/"+textureNode->getAttribute("path")->getRestrictedValue());
|
||||
surfPixmaps[i][j].load(currentPath + textureNode->getAttribute("path")->getRestrictedValue());
|
||||
surfProbs[i][j]= textureNode->getAttribute("prob")->getFloatValue();
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +193,7 @@ 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(dir +"/"+ pathAttribute->getRestrictedValue());
|
||||
objectTypes[i].loadModel(currentPath + pathAttribute->getRestrictedValue());
|
||||
|
||||
if(modelNode->hasChild("particles")){
|
||||
const XmlNode *particleNode= modelNode->getChild("particles");
|
||||
|
@ -188,7 +203,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
|
|||
const XmlNode *particleFileNode= particleNode->getChild("particle-file", k);
|
||||
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
|
||||
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
|
||||
objectParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||
objectParticleSystemType->load(dir, currentPath + path, &Renderer::getInstance());
|
||||
objectTypes[i].addParticleSystem((objectParticleSystemType));
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +237,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
|
|||
waterTex->getPixmap()->init(waterFrameCount, 4);
|
||||
for(int i=0; i<waterFrameCount; ++i){
|
||||
const XmlNode *waterFrameNode= waterNode->getChild("texture", i);
|
||||
waterTex->getPixmap()->loadSlice(dir +"/"+ waterFrameNode->getAttribute("path")->getRestrictedValue(), i);
|
||||
waterTex->getPixmap()->loadSlice(currentPath + waterFrameNode->getAttribute("path")->getRestrictedValue(), i);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -1597,9 +1597,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
|
|||
else {
|
||||
string userData = Config::getInstance().getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
debugWorldLogFile = userData + debugWorldLogFile;
|
||||
}
|
||||
|
|
|
@ -131,20 +131,21 @@ public:
|
|||
void updateInterpolationData(float t, bool cycle);
|
||||
void updateInterpolationVertices(float t, bool cycle);
|
||||
|
||||
Texture2D *loadMeshTexture(TextureManager *textureManager, string textureFile,
|
||||
Texture2D *loadMeshTexture(int meshIndex, int textureIndex, TextureManager *textureManager, string textureFile,
|
||||
int textureChannelCount, bool &textureOwned,
|
||||
bool deletePixMapAfterLoad);
|
||||
|
||||
//load
|
||||
void loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
|
||||
void loadV3(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
|
||||
void load(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
|
||||
void save(const string &dir, FILE *f, TextureManager *textureManager,
|
||||
void loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
|
||||
void loadV3(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
|
||||
void load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
|
||||
void save(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
|
||||
string convertTextureToFormat, std::map<string,int> &textureDeleteList);
|
||||
|
||||
void deletePixels();
|
||||
|
||||
private:
|
||||
string findAlternateTexture(vector<string> conversionList, string textureFile);
|
||||
void computeTangents();
|
||||
};
|
||||
|
||||
|
|
|
@ -147,8 +147,11 @@ void restoreVideoMode(bool exitingApp=false);
|
|||
bool StartsWith(const std::string &str, const std::string &key);
|
||||
bool EndsWith(const string &str, const string& key);
|
||||
|
||||
void endPathWithSlash(string &path);
|
||||
|
||||
string replaceAll(string& context, const string& from, const string& to);
|
||||
bool removeFile(string file);
|
||||
bool renameFile(string oldFile, string newFile);
|
||||
void removeFolder(const string path);
|
||||
|
||||
int getScreenW();
|
||||
|
|
|
@ -189,19 +189,41 @@ void Mesh::ReleaseVBOs() {
|
|||
|
||||
// ==================== load ====================
|
||||
|
||||
void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
|
||||
string Mesh::findAlternateTexture(vector<string> conversionList, string textureFile) {
|
||||
string result = textureFile;
|
||||
string fileExt = extractExtension(textureFile);
|
||||
|
||||
for(int i = 0; i < conversionList.size(); ++i) {
|
||||
string convertTo = conversionList[i];
|
||||
if(fileExt != convertTo) {
|
||||
string alternateTexture = textureFile;
|
||||
replaceAll(alternateTexture, "." + fileExt, "." + convertTo);
|
||||
if(fileExists(alternateTexture) == true) {
|
||||
result = alternateTexture;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
|
||||
this->textureManager = textureManager;
|
||||
//read header
|
||||
MeshHeaderV2 meshHeader;
|
||||
size_t readBytes = fread(&meshHeader, sizeof(MeshHeaderV2), 1, f);
|
||||
|
||||
|
||||
if(meshHeader.normalFrameCount!=meshHeader.vertexFrameCount){
|
||||
throw runtime_error("Old model: vertex frame count different from normal frame count");
|
||||
if(meshHeader.normalFrameCount != meshHeader.vertexFrameCount) {
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"Old v2 model: vertex frame count different from normal frame count [v = %d, n = %d] meshIndex = %d",meshHeader.vertexFrameCount,meshHeader.normalFrameCount,meshIndex);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
if(meshHeader.texCoordFrameCount!=1){
|
||||
throw runtime_error("Old model: texture coord frame count is not 1");
|
||||
if(meshHeader.texCoordFrameCount != 1) {
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"Old v2 model: texture coord frame count is not 1 [t = %d] meshIndex = %d",meshHeader.texCoordFrameCount,meshIndex);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
//init
|
||||
|
@ -216,7 +238,7 @@ void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,boo
|
|||
twoSided= false;
|
||||
customColor= false;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v2, this = %p Found meshHeader.hasTexture = %d, texName [%s] mtDiffuse = %d\n",this,meshHeader.hasTexture,toLower(reinterpret_cast<char*>(meshHeader.texName)).c_str(),mtDiffuse);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v2, this = %p Found meshHeader.hasTexture = %d, texName [%s] mtDiffuse = %d meshIndex = %d\n",this,meshHeader.hasTexture,toLower(reinterpret_cast<char*>(meshHeader.texName)).c_str(),mtDiffuse,meshIndex);
|
||||
|
||||
textureFlags= 0;
|
||||
if(meshHeader.hasTexture == true) {
|
||||
|
@ -228,19 +250,31 @@ void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,boo
|
|||
texturePaths[mtDiffuse]= toLower(reinterpret_cast<char*>(meshHeader.texName));
|
||||
string texPath= dir;
|
||||
if(texPath != "") {
|
||||
texPath += "/";
|
||||
endPathWithSlash(texPath);
|
||||
}
|
||||
texPath += texturePaths[mtDiffuse];
|
||||
|
||||
textures[mtDiffuse]= static_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if(textures[mtDiffuse]==NULL){
|
||||
textures[mtDiffuse]= textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
texturesOwned[mtDiffuse]=true;
|
||||
// M.V. Test
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
textures[mtDiffuse]= dynamic_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if(textures[mtDiffuse] == NULL) {
|
||||
if(fileExists(texPath) == false) {
|
||||
vector<string> conversionList;
|
||||
conversionList.push_back("png");
|
||||
conversionList.push_back("jpg");
|
||||
conversionList.push_back("tga");
|
||||
conversionList.push_back("bmp");
|
||||
texPath = findAlternateTexture(conversionList, texPath);
|
||||
}
|
||||
if(fileExists(texPath) == true) {
|
||||
textures[mtDiffuse]= textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
texturesOwned[mtDiffuse]=true;
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
}
|
||||
}
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error v2 model is missing texture [%s] meshIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,texPath.c_str(),meshIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +291,7 @@ void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,boo
|
|||
readBytes = fread(indices, sizeof(uint32)*indexCount, 1, f);
|
||||
}
|
||||
|
||||
void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
|
||||
void Mesh::loadV3(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
|
||||
this->textureManager = textureManager;
|
||||
|
||||
//read header
|
||||
|
@ -265,8 +299,10 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager,boo
|
|||
size_t readBytes = fread(&meshHeader, sizeof(MeshHeaderV3), 1, f);
|
||||
|
||||
|
||||
if(meshHeader.normalFrameCount!=meshHeader.vertexFrameCount){
|
||||
throw runtime_error("Old model: vertex frame count different from normal frame count");
|
||||
if(meshHeader.normalFrameCount != meshHeader.vertexFrameCount) {
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"Old v3 model: vertex frame count different from normal frame count [v = %d, n = %d] meshIndex = %d",meshHeader.vertexFrameCount,meshHeader.normalFrameCount,meshIndex);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
//init
|
||||
|
@ -286,7 +322,7 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager,boo
|
|||
textureFlags= 1;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v3, this = %p Found meshHeader.properties = %d, textureFlags = %d, texName [%s] mtDiffuse = %d\n",this,meshHeader.properties,textureFlags,toLower(reinterpret_cast<char*>(meshHeader.texName)).c_str(),mtDiffuse);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v3, this = %p Found meshHeader.properties = %d, textureFlags = %d, texName [%s] mtDiffuse = %d meshIndex = %d\n",this,meshHeader.properties,textureFlags,toLower(reinterpret_cast<char*>(meshHeader.texName)).c_str(),mtDiffuse,meshIndex);
|
||||
|
||||
//texture
|
||||
if((meshHeader.properties & mp3NoTexture) != mp3NoTexture && textureManager!=NULL){
|
||||
|
@ -294,19 +330,32 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager,boo
|
|||
|
||||
string texPath= dir;
|
||||
if(texPath != "") {
|
||||
texPath += "/";
|
||||
endPathWithSlash(texPath);
|
||||
}
|
||||
texPath += texturePaths[mtDiffuse];
|
||||
|
||||
textures[mtDiffuse]= static_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if(textures[mtDiffuse]==NULL){
|
||||
textures[mtDiffuse]= textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
texturesOwned[mtDiffuse]=true;
|
||||
// M.V. Test
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
textures[mtDiffuse]= dynamic_cast<Texture2D*>(textureManager->getTexture(texPath));
|
||||
if(textures[mtDiffuse] == NULL) {
|
||||
if(fileExists(texPath) == false) {
|
||||
vector<string> conversionList;
|
||||
conversionList.push_back("png");
|
||||
conversionList.push_back("jpg");
|
||||
conversionList.push_back("tga");
|
||||
conversionList.push_back("bmp");
|
||||
texPath = findAlternateTexture(conversionList, texPath);
|
||||
}
|
||||
|
||||
if(fileExists(texPath) == true) {
|
||||
textures[mtDiffuse]= textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
texturesOwned[mtDiffuse]=true;
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
}
|
||||
}
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error v3 model is missing texture [%s] meshHeader.properties = %d meshIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,texPath.c_str(),meshHeader.properties,meshIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,26 +374,53 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager,boo
|
|||
readBytes = fread(indices, sizeof(uint32)*indexCount, 1, f);
|
||||
}
|
||||
|
||||
Texture2D* Mesh::loadMeshTexture(TextureManager *textureManager, string textureFile,
|
||||
Texture2D* Mesh::loadMeshTexture(int meshIndex, int textureIndex, TextureManager *textureManager, string textureFile,
|
||||
int textureChannelCount, bool &textureOwned, bool deletePixMapAfterLoad) {
|
||||
Texture2D* texture = static_cast<Texture2D*>(textureManager->getTexture(textureFile));
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] #1 load texture [%s]\n",__FUNCTION__,textureFile.c_str());
|
||||
|
||||
Texture2D* texture = dynamic_cast<Texture2D*>(textureManager->getTexture(textureFile));
|
||||
if(texture == NULL) {
|
||||
texture = textureManager->newTexture2D();
|
||||
if(textureChannelCount != -1) {
|
||||
texture->getPixmap()->init(textureChannelCount);
|
||||
if(fileExists(textureFile) == false) {
|
||||
vector<string> conversionList;
|
||||
conversionList.push_back("png");
|
||||
conversionList.push_back("jpg");
|
||||
conversionList.push_back("tga");
|
||||
conversionList.push_back("bmp");
|
||||
textureFile = findAlternateTexture(conversionList, textureFile);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] #2 load texture [%s]\n",__FUNCTION__,textureFile.c_str());
|
||||
}
|
||||
texture->load(textureFile);
|
||||
textureOwned = true;
|
||||
texture->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
texture->deletePixels();
|
||||
|
||||
if(fileExists(textureFile) == true) {
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] texture exists loading [%s]\n",__FUNCTION__,textureFile.c_str());
|
||||
|
||||
texture = textureManager->newTexture2D();
|
||||
if(textureChannelCount != -1) {
|
||||
texture->getPixmap()->init(textureChannelCount);
|
||||
}
|
||||
texture->load(textureFile);
|
||||
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] texture loaded [%s]\n",__FUNCTION__,textureFile.c_str());
|
||||
|
||||
textureOwned = true;
|
||||
texture->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
texture->deletePixels();
|
||||
}
|
||||
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] texture inited [%s]\n",__FUNCTION__,textureFile.c_str());
|
||||
}
|
||||
else {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] #3 cannot load texture [%s]\n",__FUNCTION__,textureFile.c_str());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error v4 model is missing texture [%s] textureFlags = %d meshIndex = %d textureIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,textureFile.c_str(),textureFlags,meshIndex,textureIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
void Mesh::load(const string &dir, FILE *f, TextureManager *textureManager,
|
||||
void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
|
||||
bool deletePixMapAfterLoad) {
|
||||
this->textureManager = textureManager;
|
||||
|
||||
|
@ -375,26 +451,28 @@ void Mesh::load(const string &dir, FILE *f, TextureManager *textureManager,
|
|||
|
||||
textureFlags= meshHeader.textures;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v4, this = %p Found meshHeader.textures = %d\n",this,meshHeader.textures);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v4, this = %p Found meshHeader.textures = %d meshIndex = %d\n",this,meshHeader.textures,meshIndex);
|
||||
|
||||
//maps
|
||||
uint32 flag= 1;
|
||||
for(int i=0; i<meshTextureCount; ++i){
|
||||
if((meshHeader.textures & flag) && textureManager!=NULL){
|
||||
for(int i = 0; i < meshTextureCount; ++i) {
|
||||
if((meshHeader.textures & flag) && textureManager != NULL) {
|
||||
uint8 cMapPath[mapPathSize];
|
||||
readBytes = fread(cMapPath, mapPathSize, 1, f);
|
||||
string mapPath= toLower(reinterpret_cast<char*>(cMapPath));
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("mapPath [%s] meshHeader.textures = %d flag = %d (meshHeader.textures & flag) = %d meshIndex = %d i = %d\n",mapPath.c_str(),meshHeader.textures,flag,(meshHeader.textures & flag),meshIndex,i);
|
||||
|
||||
string mapFullPath= dir;
|
||||
if(mapFullPath != "") {
|
||||
mapFullPath += "/";
|
||||
endPathWithSlash(mapFullPath);
|
||||
}
|
||||
mapFullPath += mapPath;
|
||||
|
||||
textures[i] = loadMeshTexture(textureManager, mapFullPath,
|
||||
textures[i] = loadMeshTexture(meshIndex, i, textureManager, mapFullPath,
|
||||
meshTextureChannelCount[i],texturesOwned[i],deletePixMapAfterLoad);
|
||||
}
|
||||
flag*= 2;
|
||||
flag *= 2;
|
||||
}
|
||||
|
||||
//read data
|
||||
|
@ -411,7 +489,7 @@ void Mesh::load(const string &dir, FILE *f, TextureManager *textureManager,
|
|||
}
|
||||
}
|
||||
|
||||
void Mesh::save(const string &dir, FILE *f, TextureManager *textureManager,
|
||||
void Mesh::save(int meshIndex, const string &dir, FILE *f, TextureManager *textureManager,
|
||||
string convertTextureToFormat, std::map<string,int> &textureDeleteList) {
|
||||
MeshHeader meshHeader;
|
||||
memset(&meshHeader, 0, sizeof(struct MeshHeader));
|
||||
|
@ -439,7 +517,7 @@ void Mesh::save(const string &dir, FILE *f, TextureManager *textureManager,
|
|||
meshHeader.textures = textureFlags;
|
||||
fwrite(&meshHeader, sizeof(MeshHeader), 1, f);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Save, this = %p, Found meshTextureCount = %d, meshHeader.textures = %d\n",this,meshTextureCount,meshHeader.textures);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Save, this = %p, Found meshTextureCount = %d, meshHeader.textures = %d meshIndex = %d\n",this,meshTextureCount,meshHeader.textures,meshIndex);
|
||||
|
||||
//maps
|
||||
uint32 flag= 1;
|
||||
|
@ -487,7 +565,9 @@ void Mesh::save(const string &dir, FILE *f, TextureManager *textureManager,
|
|||
}
|
||||
|
||||
//textureManager->endTexture(texture);
|
||||
texture = loadMeshTexture(textureManager,file,
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Save, load new texture [%s]\n",file.c_str());
|
||||
texture = loadMeshTexture(meshIndex, i, textureManager,file,
|
||||
meshTextureChannelCount[i],
|
||||
texturesOwned[i],
|
||||
false);
|
||||
|
@ -496,8 +576,16 @@ void Mesh::save(const string &dir, FILE *f, TextureManager *textureManager,
|
|||
|
||||
file = extractFileFromDirectoryPath(texture->getPath());
|
||||
|
||||
if(file.length() > mapPathSize) {
|
||||
throw runtime_error("file.length() > mapPathSize, file.length() = " + intToStr(file.length()));
|
||||
}
|
||||
else if(file.length() == 0) {
|
||||
throw runtime_error("file.length() == 0");
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Save, new texture file [%s]\n",file.c_str());
|
||||
|
||||
memset(&cMapPath[0],0,mapPathSize);
|
||||
memcpy(&cMapPath[0],file.c_str(),file.length());
|
||||
}
|
||||
|
||||
|
@ -690,32 +778,32 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad) {
|
|||
|
||||
//load meshes
|
||||
meshes= new Mesh[meshCount];
|
||||
for(uint32 i=0; i<meshCount; ++i){
|
||||
meshes[i].load(dir, f, textureManager,deletePixMapAfterLoad);
|
||||
for(uint32 i = 0; i < meshCount; ++i) {
|
||||
meshes[i].load(i, dir, f, textureManager,deletePixMapAfterLoad);
|
||||
meshes[i].buildInterpolationData();
|
||||
}
|
||||
}
|
||||
//version 3
|
||||
else if(fileHeader.version==3){
|
||||
else if(fileHeader.version == 3) {
|
||||
readBytes = fread(&meshCount, sizeof(meshCount), 1, f);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("meshCount = %d\n",meshCount);
|
||||
|
||||
meshes= new Mesh[meshCount];
|
||||
for(uint32 i=0; i<meshCount; ++i){
|
||||
meshes[i].loadV3(dir, f, textureManager,deletePixMapAfterLoad);
|
||||
for(uint32 i = 0; i < meshCount; ++i) {
|
||||
meshes[i].loadV3(i, dir, f, textureManager,deletePixMapAfterLoad);
|
||||
meshes[i].buildInterpolationData();
|
||||
}
|
||||
}
|
||||
//version 2
|
||||
else if(fileHeader.version==2) {
|
||||
else if(fileHeader.version == 2) {
|
||||
readBytes = fread(&meshCount, sizeof(meshCount), 1, f);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("meshCount = %d\n",meshCount);
|
||||
|
||||
meshes= new Mesh[meshCount];
|
||||
for(uint32 i=0; i<meshCount; ++i){
|
||||
meshes[i].loadV2(dir, f, textureManager,deletePixMapAfterLoad);
|
||||
for(uint32 i = 0; i < meshCount; ++i){
|
||||
meshes[i].loadV2(i,dir, f, textureManager,deletePixMapAfterLoad);
|
||||
meshes[i].buildInterpolationData();
|
||||
}
|
||||
}
|
||||
|
@ -733,9 +821,12 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad) {
|
|||
|
||||
//save a model to a g3d file
|
||||
void Model::saveG3d(const string &path, string convertTextureToFormat) {
|
||||
FILE *f= fopen(path.c_str(), "wb");
|
||||
|
||||
string tempModelFilename = path + "cvt";
|
||||
|
||||
FILE *f= fopen(tempModelFilename.c_str(), "wb");
|
||||
if(f == NULL) {
|
||||
throw runtime_error("Cant open file for writting: "+path);
|
||||
throw runtime_error("Cant open file for writting: [" + tempModelFilename + "]");
|
||||
}
|
||||
|
||||
convertTextureToFormat = toLower(convertTextureToFormat);
|
||||
|
@ -760,13 +851,17 @@ void Model::saveG3d(const string &path, string convertTextureToFormat) {
|
|||
|
||||
std::map<string,int> textureDeleteList;
|
||||
for(uint32 i = 0; i < meshCount; ++i) {
|
||||
meshes[i].save(path, f, textureManager,convertTextureToFormat,textureDeleteList);
|
||||
meshes[i].save(i,tempModelFilename, f, textureManager,
|
||||
convertTextureToFormat,textureDeleteList);
|
||||
}
|
||||
|
||||
// Now delete old textures since they were converted to a new format
|
||||
for(std::map<string,int>::iterator iterMap = textureDeleteList.begin();
|
||||
iterMap != textureDeleteList.end(); ++iterMap) {
|
||||
|
||||
removeFile(path);
|
||||
if(renameFile(tempModelFilename,path) == true) {
|
||||
// Now delete old textures since they were converted to a new format
|
||||
for(std::map<string,int>::iterator iterMap = textureDeleteList.begin();
|
||||
iterMap != textureDeleteList.end(); ++iterMap) {
|
||||
removeFile(iterMap->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -61,7 +61,7 @@ using namespace Shared::Platform;
|
|||
using namespace Shared::Util;
|
||||
using namespace std;
|
||||
|
||||
#define _DISABLE MEMORY_VAULT_CHECKS 1
|
||||
#define _DISABLE_MEMORY_VAULT_CHECKS 1
|
||||
|
||||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
|
@ -214,13 +214,15 @@ void findDirs(const vector<string> &paths, vector<string> &results, bool errorOn
|
|||
results.clear();
|
||||
size_t pathCount = paths.size();
|
||||
for(unsigned int idx = 0; idx < pathCount; idx++) {
|
||||
string path = paths[idx] + "/*.";
|
||||
string currentPath = paths[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
string path = currentPath + "*.";
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, false, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
const string current_folder = current_results[folder_index];
|
||||
const string current_folder_path = paths[idx] + "/" + current_folder;
|
||||
const string current_folder_path = currentPath + current_folder;
|
||||
|
||||
if(isdir(current_folder_path.c_str()) == true) {
|
||||
if(keepDuplicates == true || std::find(results.begin(),results.end(),current_folder) == results.end()) {
|
||||
|
@ -238,7 +240,10 @@ void findAll(const vector<string> &paths, const string &fileFilter, vector<strin
|
|||
results.clear();
|
||||
size_t pathCount = paths.size();
|
||||
for(unsigned int idx = 0; idx < pathCount; idx++) {
|
||||
string path = paths[idx] + "/" + fileFilter;
|
||||
string currentPath = paths[idx];
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
string path = currentPath + fileFilter;
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, cutExtension, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
|
@ -401,6 +406,12 @@ bool EndsWith(const string &str, const string& key)
|
|||
return result;
|
||||
}
|
||||
|
||||
void endPathWithSlash(string &path) {
|
||||
if(EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
|
||||
path += "/";
|
||||
}
|
||||
}
|
||||
|
||||
string getCRCCacheFilePath() {
|
||||
return crcCachePath;
|
||||
}
|
||||
|
@ -656,8 +667,12 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
|||
if( S_ISDIR(statStruct.st_mode) == 0)
|
||||
continue;
|
||||
#endif
|
||||
const char* p = globbuf.gl_pathv[i];
|
||||
getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum);
|
||||
const char *p = globbuf.gl_pathv[i];
|
||||
|
||||
string currentPath = p;
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
getFolderTreeContentsCheckSumRecursively(currentPath + "*", filterFileExt, &checksum);
|
||||
}
|
||||
|
||||
globfree(&globbuf);
|
||||
|
@ -829,7 +844,11 @@ vector<string> getFolderTreeContentsListRecursively(const string &path, const st
|
|||
if(includeFolders == true) {
|
||||
resultFiles.push_back(p);
|
||||
}
|
||||
resultFiles = getFolderTreeContentsListRecursively(string(p) + "/*", filterFileExt, includeFolders,&resultFiles);
|
||||
|
||||
string currentPath = p;
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
resultFiles = getFolderTreeContentsListRecursively(currentPath + "*", filterFileExt, includeFolders,&resultFiles);
|
||||
}
|
||||
|
||||
globfree(&globbuf);
|
||||
|
@ -953,8 +972,12 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
|
|||
if( S_ISDIR(statStruct.st_mode) == 0)
|
||||
continue;
|
||||
#endif
|
||||
const char* p = globbuf.gl_pathv[i];
|
||||
checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles);
|
||||
const char *p = globbuf.gl_pathv[i];
|
||||
|
||||
string currentPath = p;
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
checksumFiles = getFolderTreeContentsCheckSumListRecursively(currentPath + "*", filterFileExt, &checksumFiles);
|
||||
}
|
||||
|
||||
globfree(&globbuf);
|
||||
|
@ -972,7 +995,6 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
|
|||
|
||||
string extractFileFromDirectoryPath(string filename) {
|
||||
size_t lastDirectory = filename.find_last_of("/\\");
|
||||
//return filename.substr( 0, filename.rfind("/")+1 );
|
||||
if (lastDirectory == string::npos) {
|
||||
return filename;
|
||||
}
|
||||
|
@ -982,14 +1004,10 @@ string extractFileFromDirectoryPath(string filename) {
|
|||
|
||||
string extractDirectoryPathFromFile(string filename) {
|
||||
size_t lastDirectory = filename.find_last_of("/\\");
|
||||
//printf("In [%s::%s Line: %d] filename = [%s] lastDirectory= %u\n",__FILE__,__FUNCTION__,__LINE__,filename.c_str(),lastDirectory);
|
||||
|
||||
string path = "";
|
||||
//return filename.substr( 0, filename.rfind("/")+1 );
|
||||
if (lastDirectory != string::npos) {
|
||||
path = filename.substr( 0, lastDirectory + 1);
|
||||
}
|
||||
//printf("In [%s::%s Line: %d] filename = [%s] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filename.c_str(),path.c_str());
|
||||
|
||||
return path;
|
||||
}
|
||||
|
@ -1356,6 +1374,16 @@ bool removeFile(string file) {
|
|||
return (result == 0);
|
||||
}
|
||||
|
||||
bool renameFile(string oldFile, string newFile) {
|
||||
#ifdef WIN32
|
||||
int result = _rename(oldFile.c_str(),newFile.c_str());
|
||||
#else
|
||||
int result = rename(oldFile.c_str(),newFile.c_str());
|
||||
#endif
|
||||
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
// =====================================
|
||||
// ModeInfo
|
||||
// =====================================
|
||||
|
@ -1371,15 +1399,19 @@ string ModeInfo::getString() const{
|
|||
}
|
||||
|
||||
void ValueCheckerVault::addItemToVault(const void *ptr,int value) {
|
||||
#ifndef _DISABLE MEMORY_VAULT_CHECKS
|
||||
#ifndef _DISABLE_MEMORY_VAULT_CHECKS
|
||||
|
||||
Checksum checksum;
|
||||
vaultList[ptr] = checksum.addInt(value);
|
||||
|
||||
#endif
|
||||
|
||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] add vault key [%p] value [%s] [%d]\n",__FILE__,__FUNCTION__,__LINE__,ptr,intToStr(checksum.getSum()).c_str(),value);
|
||||
}
|
||||
|
||||
void ValueCheckerVault::checkItemInVault(const void *ptr,int value) const {
|
||||
#ifndef _DISABLE MEMORY_VAULT_CHECKS
|
||||
#ifndef _DISABLE_MEMORY_VAULT_CHECKS
|
||||
|
||||
map<const void *,int32>::const_iterator iterFind = vaultList.find(ptr);
|
||||
if(iterFind == vaultList.end()) {
|
||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) {
|
||||
|
@ -1402,7 +1434,9 @@ void ValueCheckerVault::checkItemInVault(const void *ptr,int value) const {
|
|||
// }
|
||||
throw std::runtime_error("memory value has been unexpectedly modified (changed)!");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -240,9 +240,7 @@ FTP_Client_ResultType FTPClientThread::getMapFromServer(string mapFileName, stri
|
|||
string destFileExt = "";
|
||||
string destFile = this->mapsPath.second;
|
||||
|
||||
if(EndsWith(destFile,"/") == false && EndsWith(destFile,"\\") == false) {
|
||||
destFile += "/";
|
||||
}
|
||||
endPathWithSlash(destFile);
|
||||
destFile += mapFileName;
|
||||
|
||||
if(EndsWith(destFile,".mgm") == false && EndsWith(destFile,".gbm") == false) {
|
||||
|
@ -388,34 +386,22 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName,
|
|||
string destRootFolder = "";
|
||||
if(tileSetNameSubfolder == "") {
|
||||
destRootFolder = this->tilesetsPath.second;
|
||||
if( EndsWith(destRootFolder,"/") == false &&
|
||||
EndsWith(destRootFolder,"\\") == false) {
|
||||
destRootFolder += "/";
|
||||
}
|
||||
endPathWithSlash(destRootFolder);
|
||||
|
||||
destRootArchiveFolder = destRootFolder;
|
||||
destRootFolder += tileSetName;
|
||||
if( EndsWith(destRootFolder,"/") == false &&
|
||||
EndsWith(destRootFolder,"\\") == false) {
|
||||
destRootFolder += "/";
|
||||
}
|
||||
endPathWithSlash(destRootFolder);
|
||||
|
||||
createDirectoryPaths(destRootFolder);
|
||||
}
|
||||
|
||||
if(EndsWith(destFile,"/") == false && EndsWith(destFile,"\\") == false) {
|
||||
destFile += "/";
|
||||
}
|
||||
endPathWithSlash(destFile);
|
||||
destFile += tileSetName;
|
||||
if(EndsWith(destFile,"/") == false && EndsWith(destFile,"\\") == false) {
|
||||
destFile += "/";
|
||||
}
|
||||
endPathWithSlash(destFile);
|
||||
|
||||
if(tileSetNameSubfolder != "") {
|
||||
destFile += tileSetNameSubfolder;
|
||||
|
||||
if(EndsWith(destFile,"/") == false && EndsWith(destFile,"\\") == false) {
|
||||
destFile += "/";
|
||||
}
|
||||
endPathWithSlash(destFile);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread about to try to RETR into [%s] findArchive = %d\n",destFile.c_str(),findArchive);
|
||||
|
@ -580,26 +566,16 @@ FTP_Client_ResultType FTPClientThread::getTechtreeFromServer(string techtreeName
|
|||
string destRootArchiveFolder = "";
|
||||
string destRootFolder = "";
|
||||
destRootFolder = this->techtreesPath.second;
|
||||
if( EndsWith(destRootFolder,"/") == false &&
|
||||
EndsWith(destRootFolder,"\\") == false) {
|
||||
destRootFolder += "/";
|
||||
}
|
||||
endPathWithSlash(destRootFolder);
|
||||
destRootArchiveFolder = destRootFolder;
|
||||
destRootFolder += techtreeName;
|
||||
if( EndsWith(destRootFolder,"/") == false &&
|
||||
EndsWith(destRootFolder,"\\") == false) {
|
||||
destRootFolder += "/";
|
||||
}
|
||||
endPathWithSlash(destRootFolder);
|
||||
|
||||
createDirectoryPaths(destRootFolder);
|
||||
|
||||
if(EndsWith(destFile,"/") == false && EndsWith(destFile,"\\") == false) {
|
||||
destFile += "/";
|
||||
}
|
||||
endPathWithSlash(destFile);
|
||||
destFile += techtreeName;
|
||||
if(EndsWith(destFile,"/") == false && EndsWith(destFile,"\\") == false) {
|
||||
destFile += "/";
|
||||
}
|
||||
endPathWithSlash(destFile);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread about to try to RETR into [%s]\n",destFile.c_str());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client thread about to try to RETR into [%s]\n",destFile.c_str());
|
||||
|
|
|
@ -79,9 +79,7 @@ Profiler::~Profiler(){
|
|||
else {
|
||||
string userData = config.getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||
userData += "/";
|
||||
}
|
||||
endPathWithSlash(userData);
|
||||
}
|
||||
profileLog = userData + profileLog;
|
||||
}
|
||||
|
|
|
@ -322,9 +322,10 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
|||
vsnprintf(szBuf,max_debug_buffer_size-1,fmt, argList);
|
||||
va_end(argList);
|
||||
|
||||
if(SystemFlags::ENABLE_THREADED_LOGGING &&
|
||||
threadLogger != NULL &&
|
||||
threadLogger->getRunningStatus() == true) {
|
||||
if( currentDebugLog.debugLogFileName != "" &&
|
||||
SystemFlags::ENABLE_THREADED_LOGGING &&
|
||||
threadLogger != NULL &&
|
||||
threadLogger->getRunningStatus() == true) {
|
||||
threadLogger->addLogEntry(type, szBuf);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue