- added new commandline options to tell the game where to look for data, ini's and where to write logs

This commit is contained in:
Mark Vejvoda
2010-12-09 20:41:11 +00:00
parent f4ed98ce27
commit 045c2f95e8
19 changed files with 477 additions and 133 deletions

View File

@@ -18,6 +18,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "platform_util.h" #include "platform_util.h"
#include "conversion.h" #include "conversion.h"
#include "cache_manager.h"
#include "leak_dumper.h" #include "leak_dumper.h"
using namespace Shared::Util; using namespace Shared::Util;
@@ -191,9 +192,24 @@ string formatString(const string &str){
return outStr; return outStr;
} }
string getGameReadWritePath() { string getGameReadWritePath(string lookupKey) {
string path = ""; string path = "";
if(getenv("GLESTHOME") != NULL) {
if(lookupKey != "") {
std::map<string,string> &pathCache = CacheManager::getCachedItem< std::map<string,string> >(GameConstants::pathCacheLookupKey);
std::map<string,string>::const_iterator iterFind = pathCache.find(lookupKey);
if(iterFind != pathCache.end()) {
path = iterFind->second;
if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
path += "/";
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path to be used for [%s] files [%s]\n",__FILE__,__FUNCTION__,__LINE__,lookupKey.c_str(),path.c_str());
}
}
if(path == "" && getenv("GLESTHOME") != NULL) {
path = getenv("GLESTHOME"); path = getenv("GLESTHOME");
if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) { if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
path += "/"; path += "/";

View File

@@ -41,7 +41,7 @@ string getCompileDateTime();
string formatString(const string &str); string formatString(const string &str);
string getGameReadWritePath(); string getGameReadWritePath(string lookupKey="");
}}//end namespace }}//end namespace

View File

@@ -3,9 +3,9 @@
// //
// Copyright (C) 2001-2008 Marti<74>o Figueroa // Copyright (C) 2001-2008 Marti<74>o Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the // by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version // License, or (at your option) any later version
// ============================================================== // ==============================================================
@@ -17,7 +17,8 @@
#include "metrics.h" #include "metrics.h"
#include "lang.h" #include "lang.h"
#include "graphics_interface.h" #include "graphics_interface.h"
#include "game_constants.h"
#include "game_util.h"
#include "leak_dumper.h" #include "leak_dumper.h"
using namespace std; using namespace std;
@@ -32,10 +33,12 @@ namespace Glest{ namespace Game{
const int Logger::logLineCount= 15; const int Logger::logLineCount= 15;
// ===================== PUBLIC ======================== // ===================== PUBLIC ========================
Logger::Logger(){ Logger::Logger(){
fileName= "log.txt"; string logs_path = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey);
fileName= logs_path + "log.txt";
loadingTexture=NULL; loadingTexture=NULL;
} }
@@ -87,7 +90,7 @@ void Logger::clear(){
if(f==NULL){ if(f==NULL){
throw runtime_error("Error opening log file"+ fileName); throw runtime_error("Error opening log file"+ fileName);
} }
fprintf(f, "%s", s.c_str()); fprintf(f, "%s", s.c_str());
fprintf(f, "\n"); fprintf(f, "\n");
@@ -96,14 +99,14 @@ void Logger::clear(){
void Logger::loadLoadingScreen(string filepath){ void Logger::loadLoadingScreen(string filepath){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
cleanupLoadingTexture(); cleanupLoadingTexture();
if(filepath=="") if(filepath=="")
{ {
loadingTexture=NULL; loadingTexture=NULL;
} }
else else
{ {
@@ -124,7 +127,7 @@ void Logger::loadLoadingScreen(string filepath){
} }
} }
// ==================== PRIVATE ==================== // ==================== PRIVATE ====================
void Logger::renderLoadingScreen(){ void Logger::renderLoadingScreen(){
@@ -139,16 +142,16 @@ void Logger::renderLoadingScreen(){
} }
else{ else{
renderer.renderBackground(loadingTexture); renderer.renderBackground(loadingTexture);
} }
renderer.renderText( renderer.renderText(
state, coreData.getMenuFontBig(), Vec3f(1.f), state, coreData.getMenuFontBig(), Vec3f(1.f),
metrics.getVirtualW()/4, 65*metrics.getVirtualH()/100, false); metrics.getVirtualW()/4, 65*metrics.getVirtualH()/100, false);
renderer.renderText( renderer.renderText(
current, coreData.getMenuFontNormal(), 1.0f, current, coreData.getMenuFontNormal(), 1.0f,
metrics.getVirtualW()/4, metrics.getVirtualW()/4,
62*metrics.getVirtualH()/100, false); 62*metrics.getVirtualH()/100, false);
renderer.swapBuffers(); renderer.swapBuffers();
} }

View File

@@ -103,7 +103,7 @@ Game::~Game() {
Logger &logger= Logger::getInstance(); Logger &logger= Logger::getInstance();
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
logger.loadLoadingScreen(""); logger.loadLoadingScreen("");
logger.setState(Lang::getInstance().get("Deleting")); logger.setState(Lang::getInstance().get("Deleting"));
logger.add("Game", true); logger.add("Game", true);
@@ -235,7 +235,8 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,st
//printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,settings->getFactionTypeName(i).c_str()); //printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,settings->getFactionTypeName(i).c_str());
if(settings->getFactionTypeName(i) == formatString(GameConstants::OBSERVER_SLOTNAME)) { if(settings->getFactionTypeName(i) == formatString(GameConstants::OBSERVER_SLOTNAME)) {
const string factionLogo = "data/core/misc_textures/observer.jpg"; string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
const string factionLogo = data_path + "data/core/misc_textures/observer.jpg";
//printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str()); //printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
if(fileExists(factionLogo) == true) { if(fileExists(factionLogo) == true) {
@@ -249,7 +250,8 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,st
} }
} }
else if(settings->getFactionTypeName(i) == formatString(GameConstants::RANDOMFACTION_SLOTNAME)) { else if(settings->getFactionTypeName(i) == formatString(GameConstants::RANDOMFACTION_SLOTNAME)) {
const string factionLogo = "data/core/misc_textures/random.jpg"; string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
const string factionLogo = data_path + "data/core/misc_textures/random.jpg";
//printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str()); //printf("In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
if(fileExists(factionLogo) == true) { if(fileExists(factionLogo) == true) {
@@ -1560,7 +1562,7 @@ void Game::render2d(){
string str=""; string str="";
std::map<int,string> factionDebugInfo; std::map<int,string> factionDebugInfo;
if( renderer.getShowDebugUI() == true || if( renderer.getShowDebugUI() == true ||
(perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1)) { (perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1)) {
str+= "MouseXY: " + intToStr(mouseX) + "," + intToStr(mouseY)+"\n"; str+= "MouseXY: " + intToStr(mouseX) + "," + intToStr(mouseY)+"\n";
str+= "PosObjWord: " + intToStr(gui.getPosObjWorld().x) + "," + intToStr(gui.getPosObjWorld().y)+"\n"; str+= "PosObjWord: " + intToStr(gui.getPosObjWorld().x) + "," + intToStr(gui.getPosObjWorld().y)+"\n";
@@ -1711,7 +1713,7 @@ void Game::render2d(){
if(perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1) { if(perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1) {
lastRenderLog2d = time(NULL); lastRenderLog2d = time(NULL);
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] Statistics: %s\n",__FILE__,__FUNCTION__,__LINE__,str.c_str()); SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] Statistics: %s\n",__FILE__,__FUNCTION__,__LINE__,str.c_str());
//SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"In [%s::%s Line: %d] Statistics: %s\n",__FILE__,__FUNCTION__,__LINE__,str.c_str()); //SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"In [%s::%s Line: %d] Statistics: %s\n",__FILE__,__FUNCTION__,__LINE__,str.c_str());
} }

View File

@@ -107,6 +107,10 @@ public:
static const char *RANDOMFACTION_SLOTNAME; static const char *RANDOMFACTION_SLOTNAME;
static const char *playerTextureCacheLookupKey; static const char *playerTextureCacheLookupKey;
static const char *pathCacheLookupKey;
static const char *path_data_CacheLookupKey;
static const char *path_ini_CacheLookupKey;
static const char *path_logs_CacheLookupKey;
static const char *application_name; static const char *application_name;
}; };

View File

@@ -48,6 +48,15 @@ const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache"; const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache";
const char *GameConstants::application_name = "MegaGlest"; const char *GameConstants::application_name = "MegaGlest";
const char *GameConstants::pathCacheLookupKey = "pathCache_";
const char *GameConstants::path_data_CacheLookupKey = "data";
const char *GameConstants::path_ini_CacheLookupKey = "ini";
const char *GameConstants::path_logs_CacheLookupKey = "logs";
const char *Config::glest_ini_filename = "glest.ini";
const char *Config::glestuser_ini_filename = "glestuser.ini";
// ===================================================== // =====================================================
// class Config // class Config
// ===================================================== // =====================================================
@@ -73,9 +82,9 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
cfgType = type; cfgType = type;
fileName = file; fileName = file;
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
fileName.first = getGameReadWritePath() + fileName.first; fileName.first = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.first;
fileName.second = getGameReadWritePath() + fileName.second; fileName.second = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.second;
} }
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
@@ -148,7 +157,7 @@ void Config::reload() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame); std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame);
Config newconfig(type, std::make_pair("glest.ini","glestuser.ini"), std::make_pair(true,false)); Config newconfig(type, std::make_pair(glest_ini_filename,glestuser_ini_filename), std::make_pair(true,false));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -382,46 +391,51 @@ string Config::toString(){
vector<string> Config::getPathListForType(PathType type, string scenarioDir) { vector<string> Config::getPathListForType(PathType type, string scenarioDir) {
vector<string> pathList; vector<string> pathList;
//#include "game_constants.h"
//#include "game_util.h"
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
string userData = getString("UserData_Root",""); string userData = getString("UserData_Root","");
if(userData != "") { if(userData != "") {
if(userData[userData.size()-1] != '/' && userData[userData.size()-1] != '\\') { if(userData[userData.size()-1] != '/' && userData[userData.size()-1] != '\\') {
userData += '/'; userData += '/';
} }
userData=data_path+userData;
if(isdir(userData.c_str()) == false) { if(isdir(userData.c_str()) == false) {
createDirectoryPaths(userData); createDirectoryPaths(userData);
} }
} }
if(scenarioDir != "") { if(scenarioDir != "") {
pathList.push_back(scenarioDir); pathList.push_back(data_path+scenarioDir);
} }
switch(type) { switch(type) {
case ptMaps: case ptMaps:
pathList.push_back(GameConstants::folder_path_maps); pathList.push_back(data_path+GameConstants::folder_path_maps);
if(userData != "") { if(userData != "") {
pathList.push_back(userData + string(GameConstants::folder_path_maps)); pathList.push_back(userData + string(GameConstants::folder_path_maps));
} }
break; break;
case ptScenarios: case ptScenarios:
pathList.push_back(GameConstants::folder_path_scenarios); pathList.push_back(data_path+GameConstants::folder_path_scenarios);
if(userData != "") { if(userData != "") {
pathList.push_back(userData + string(GameConstants::folder_path_scenarios)); pathList.push_back(userData + string(GameConstants::folder_path_scenarios));
} }
break; break;
case ptTechs: case ptTechs:
pathList.push_back(GameConstants::folder_path_techs); pathList.push_back(data_path+GameConstants::folder_path_techs);
if(userData != "") { if(userData != "") {
pathList.push_back(userData + string(GameConstants::folder_path_techs)); pathList.push_back(userData + string(GameConstants::folder_path_techs));
} }
break; break;
case ptTilesets: case ptTilesets:
pathList.push_back(GameConstants::folder_path_tilesets); pathList.push_back(data_path+GameConstants::folder_path_tilesets);
if(userData != "") { if(userData != "") {
pathList.push_back(userData + string(GameConstants::folder_path_tilesets)); pathList.push_back(userData + string(GameConstants::folder_path_tilesets));
} }
break; break;
case ptTutorials: case ptTutorials:
pathList.push_back(GameConstants::folder_path_tutorials); pathList.push_back(data_path+GameConstants::folder_path_tutorials);
if(userData != "") { if(userData != "") {
pathList.push_back(userData + string(GameConstants::folder_path_tutorials)); pathList.push_back(userData + string(GameConstants::folder_path_tutorials));
} }

View File

@@ -34,7 +34,6 @@ enum ConfigType {
cfgUserKeys cfgUserKeys
}; };
class Config { class Config {
private: private:
std::pair<Properties,Properties> properties; std::pair<Properties,Properties> properties;
@@ -44,6 +43,9 @@ private:
static map<ConfigType,Config> configList; static map<ConfigType,Config> configList;
static const char *glest_ini_filename;
static const char *glestuser_ini_filename;
protected: protected:
Config(); Config();
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist); Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist);
@@ -54,7 +56,7 @@ protected:
public: public:
static Config &getInstance(std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame) , static Config &getInstance(std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame) ,
std::pair<string,string> file = std::make_pair("glest.ini","glestuser.ini") , std::pair<string,string> file = std::make_pair(glest_ini_filename,glestuser_ini_filename) ,
std::pair<bool,bool> fileMustExist = std::make_pair(true,false) ); std::pair<bool,bool> fileMustExist = std::make_pair(true,false) );
void save(const string &path=""); void save(const string &path="");
void reload(); void reload();

View File

@@ -3,9 +3,9 @@
// //
// Copyright (C) 2001-2008 Marti<74>o Figueroa // Copyright (C) 2001-2008 Marti<74>o Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the // by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version // License, or (at your option) any later version
// ============================================================== // ==============================================================
@@ -17,6 +17,8 @@
#include "config.h" #include "config.h"
#include "util.h" #include "util.h"
#include "platform_util.h" #include "platform_util.h"
#include "game_constants.h"
#include "game_util.h"
#include "leak_dumper.h" #include "leak_dumper.h"
using namespace Shared::Sound; using namespace Shared::Sound;
@@ -31,17 +33,19 @@ namespace Glest{ namespace Game{
// ===================== PUBLIC ======================== // ===================== PUBLIC ========================
CoreData &CoreData::getInstance(){ CoreData &CoreData::getInstance() {
static CoreData coreData; static CoreData coreData;
return coreData; return coreData;
} }
CoreData::~CoreData(){ CoreData::~CoreData() {
deleteValues(waterSounds.getSounds().begin(), waterSounds.getSounds().end()); deleteValues(waterSounds.getSounds().begin(), waterSounds.getSounds().end());
} }
void CoreData::load(){ void CoreData::load() {
const string dir="data/core"; string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
const string dir = data_path + "data/core";
Logger::getInstance().add("Core data"); Logger::getInstance().add("Core data");
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
@@ -49,7 +53,7 @@ void CoreData::load(){
//textures //textures
backgroundTexture= renderer.newTexture2D(rsGlobal); backgroundTexture= renderer.newTexture2D(rsGlobal);
backgroundTexture->setMipmap(false); backgroundTexture->setMipmap(false);
backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga"); backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga");
fireTexture= renderer.newTexture2D(rsGlobal); fireTexture= renderer.newTexture2D(rsGlobal);
fireTexture->setFormat(Texture::fAlpha); fireTexture->setFormat(Texture::fAlpha);
@@ -61,9 +65,9 @@ void CoreData::load(){
snowTexture->setFormat(Texture::fAlpha); snowTexture->setFormat(Texture::fAlpha);
snowTexture->getPixmap()->init(1); snowTexture->getPixmap()->init(1);
snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga"); snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga");
customTexture= renderer.newTexture2D(rsGlobal); customTexture= renderer.newTexture2D(rsGlobal);
customTexture->getPixmap()->load("data/core/menu/textures/custom_texture.tga"); customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga");
logoTexture= renderer.newTexture2D(rsGlobal); logoTexture= renderer.newTexture2D(rsGlobal);
logoTexture->setMipmap(false); logoTexture->setMipmap(false);
@@ -95,7 +99,7 @@ void CoreData::load(){
buttonBigTexture= renderer.newTexture2D(rsGlobal); buttonBigTexture= renderer.newTexture2D(rsGlobal);
buttonBigTexture->setForceCompressionDisabled(true); buttonBigTexture->setForceCompressionDisabled(true);
buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga"); buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga");
//display font //display font
Config &config= Config::getInstance(); Config &config= Config::getInstance();
string displayFontNamePrefix=config.getString("FontDisplayPrefix"); string displayFontNamePrefix=config.getString("FontDisplayPrefix");
@@ -116,9 +120,9 @@ void CoreData::load(){
displayFontSmall= renderer.newFont(rsGlobal); displayFontSmall= renderer.newFont(rsGlobal);
displayFontSmall->setType(displayFontNameSmall); displayFontSmall->setType(displayFontNameSmall);
displayFontSmall->setSize(displayFontNameSmallSize); displayFontSmall->setSize(displayFontNameSmallSize);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize);
string menuFontNameNormalPrefix= config.getString("FontMenuNormalPrefix"); string menuFontNameNormalPrefix= config.getString("FontMenuNormalPrefix");
string menuFontNameNormalPostfix= config.getString("FontMenuNormalPostfix"); string menuFontNameNormalPostfix= config.getString("FontMenuNormalPostfix");
int menuFontNameNormalSize=computeFontSize(config.getInt("FontMenuNormalBaseSize")); int menuFontNameNormalSize=computeFontSize(config.getInt("FontMenuNormalBaseSize"));

View File

@@ -16,6 +16,8 @@
#include "logger.h" #include "logger.h"
#include "util.h" #include "util.h"
#include "platform_util.h" #include "platform_util.h"
#include "game_constants.h"
#include "game_util.h"
#include "leak_dumper.h" #include "leak_dumper.h"
using namespace std; using namespace std;
@@ -36,7 +38,8 @@ Lang &Lang::getInstance(){
void Lang::loadStrings(const string &language){ void Lang::loadStrings(const string &language){
this->language= language; this->language= language;
strings.clear(); strings.clear();
strings.load("data/lang/"+language+".lng"); string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
strings.load(data_path + "data/lang/"+language+".lng");
} }
void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenarioName){ void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenarioName){

View File

@@ -82,7 +82,10 @@ const char *GAME_ARGS[] = {
"--sdl-info", "--sdl-info",
"--lua-info", "--lua-info",
"--validate-techtrees", "--validate-techtrees",
"--validate-factions" "--validate-factions",
"--data-path",
"--ini-path",
"--log-path"
}; };
@@ -97,7 +100,10 @@ enum GAME_ARG_TYPE {
GAME_ARG_SDL_INFO, GAME_ARG_SDL_INFO,
GAME_ARG_LUA_INFO, GAME_ARG_LUA_INFO,
GAME_ARG_VALIDATE_TECHTREES, GAME_ARG_VALIDATE_TECHTREES,
GAME_ARG_VALIDATE_FACTIONS GAME_ARG_VALIDATE_FACTIONS,
GAME_ARG_DATA_PATH,
GAME_ARG_INI_PATH,
GAME_ARG_LOG_PATH
}; };
string runtimeErrorMsg = ""; string runtimeErrorMsg = "";
@@ -602,7 +608,13 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n \t\tWhere x is a comma-delimited list of factions to validate."); printf("\n \t\tWhere x is a comma-delimited list of factions to validate.");
printf("\n \t\t*NOTE: leaving the list empty is the same as running"); printf("\n \t\t*NOTE: leaving the list empty is the same as running");
printf("\n \t\t%s",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]); printf("\n \t\t%s",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]);
printf("\n \t\texample: %s %s=tech,egypt",argv0,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]); printf("\n \t\texample: %s %s=tech,egypt",argv0,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]);
printf("\n%s=x\t\t\tSets the game data path to x",GAME_ARGS[GAME_ARG_DATA_PATH]);
printf("\n \t\texample: %s %s=/usr/local/game_data/",argv0,GAME_ARGS[GAME_ARG_DATA_PATH]);
printf("\n%s=x\t\t\tSets the game ini path to x",GAME_ARGS[GAME_ARG_INI_PATH]);
printf("\n \t\texample: %s %s=~/game_config/",argv0,GAME_ARGS[GAME_ARG_INI_PATH]);
printf("\n%s=x\t\t\tSets the game logs path to x",GAME_ARGS[GAME_ARG_LOG_PATH]);
printf("\n \t\texample: %s %s=~/game_logs/",argv0,GAME_ARGS[GAME_ARG_LOG_PATH]);
printf("\n\n"); printf("\n\n");
} }
@@ -682,7 +694,80 @@ int glestMain(int argc, char** argv) {
ExceptionHandler exceptionHandler; ExceptionHandler exceptionHandler;
exceptionHandler.install( getCrashDumpFileName() ); exceptionHandler.install( getCrashDumpFileName() );
try { try {
// Setup path cache for files and folders used in the game
std::map<string,string> &pathCache = CacheManager::getCachedItem< std::map<string,string> >(GameConstants::pathCacheLookupKey);
//GAME_ARG_DATA_PATH
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_DATA_PATH]) == true) {
int foundParamIndIndex = -1;
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_DATA_PATH]) + string("="),&foundParamIndIndex);
if(foundParamIndIndex < 0) {
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_DATA_PATH]),&foundParamIndIndex);
}
string customPath = argv[foundParamIndIndex];
vector<string> paramPartTokens;
Tokenize(customPath,paramPartTokens,"=");
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
string customPathValue = paramPartTokens[1];
pathCache[GameConstants::path_data_CacheLookupKey]=customPathValue;
printf("Using custom data path [%s]\n",customPathValue.c_str());
}
else {
printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
printParameterHelp(argv[0],foundInvalidArgs);
return -1;
}
}
//GAME_ARG_INI_PATH
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_INI_PATH]) == true) {
int foundParamIndIndex = -1;
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_INI_PATH]) + string("="),&foundParamIndIndex);
if(foundParamIndIndex < 0) {
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_INI_PATH]),&foundParamIndIndex);
}
string customPath = argv[foundParamIndIndex];
vector<string> paramPartTokens;
Tokenize(customPath,paramPartTokens,"=");
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
string customPathValue = paramPartTokens[1];
pathCache[GameConstants::path_ini_CacheLookupKey]=customPathValue;
printf("Using custom ini path [%s]\n",customPathValue.c_str());
}
else {
printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
printParameterHelp(argv[0],foundInvalidArgs);
return -1;
}
}
//GAME_ARG_LOG_PATH
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LOG_PATH]) == true) {
int foundParamIndIndex = -1;
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_LOG_PATH]) + string("="),&foundParamIndIndex);
if(foundParamIndIndex < 0) {
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_LOG_PATH]),&foundParamIndIndex);
}
string customPath = argv[foundParamIndIndex];
vector<string> paramPartTokens;
Tokenize(customPath,paramPartTokens,"=");
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
string customPathValue = paramPartTokens[1];
pathCache[GameConstants::path_logs_CacheLookupKey]=customPathValue;
printf("Using custom logs path [%s]\n",customPathValue.c_str());
}
else {
printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
printParameterHelp(argv[0],foundInvalidArgs);
return -1;
}
}
std::auto_ptr<FileCRCPreCacheThread> preCacheThread; std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
Config &config = Config::getInstance(); Config &config = Config::getInstance();
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str())); FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
@@ -699,33 +784,57 @@ int glestMain(int argc, char** argv) {
SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = config.getBool("DebugError","true"); SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = config.getBool("DebugError","true");
string debugLogFile = config.getString("DebugLogFile",""); string debugLogFile = config.getString("DebugLogFile","");
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
debugLogFile = getGameReadWritePath() + debugLogFile; debugLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugLogFile;
} }
string debugWorldSynchLogFile = config.getString("DebugLogFileWorldSynch",""); string debugWorldSynchLogFile = config.getString("DebugLogFileWorldSynch","");
if(debugWorldSynchLogFile == "") { if(debugWorldSynchLogFile == "") {
debugWorldSynchLogFile = debugLogFile; debugWorldSynchLogFile = debugLogFile;
} }
else {
debugWorldSynchLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugWorldSynchLogFile;
}
string debugPerformanceLogFile = config.getString("DebugLogFilePerformance",""); string debugPerformanceLogFile = config.getString("DebugLogFilePerformance","");
if(debugPerformanceLogFile == "") { if(debugPerformanceLogFile == "") {
debugPerformanceLogFile = debugLogFile; debugPerformanceLogFile = debugLogFile;
}
else {
debugPerformanceLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugPerformanceLogFile;
} }
string debugNetworkLogFile = config.getString("DebugLogFileNetwork",""); string debugNetworkLogFile = config.getString("DebugLogFileNetwork","");
if(debugNetworkLogFile == "") { if(debugNetworkLogFile == "") {
debugNetworkLogFile = debugLogFile; debugNetworkLogFile = debugLogFile;
}
else {
debugNetworkLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugNetworkLogFile;
} }
string debugUnitCommandsLogFile = config.getString("DebugLogFileUnitCommands",""); string debugUnitCommandsLogFile = config.getString("DebugLogFileUnitCommands","");
if(debugUnitCommandsLogFile == "") { if(debugUnitCommandsLogFile == "") {
debugUnitCommandsLogFile = debugLogFile; debugUnitCommandsLogFile = debugLogFile;
}
else {
debugUnitCommandsLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugUnitCommandsLogFile;
} }
string debugPathFinderLogFile = config.getString("DebugLogFilePathFinder",""); string debugPathFinderLogFile = config.getString("DebugLogFilePathFinder","");
if(debugUnitCommandsLogFile == "") { if(debugUnitCommandsLogFile == "") {
debugUnitCommandsLogFile = debugLogFile; debugUnitCommandsLogFile = debugLogFile;
}
else {
debugUnitCommandsLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugUnitCommandsLogFile;
} }
string debugLUALogFile = config.getString("DebugLogFileLUA",""); string debugLUALogFile = config.getString("DebugLogFileLUA","");
if(debugLUALogFile == "") { if(debugLUALogFile == "") {
debugLUALogFile = debugLogFile; debugLUALogFile = debugLogFile;
}
else {
debugLUALogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugLUALogFile;
} }
string debugErrorLogFile = config.getString("DebugLogFileError",""); string debugErrorLogFile = config.getString("DebugLogFileError","");
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).debugLogFileName = debugLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugSystem).debugLogFileName = debugLogFile;
@@ -1052,11 +1161,12 @@ int glestMain(int argc, char** argv) {
createDirectoryPaths(screenShotsPath); createDirectoryPaths(screenShotsPath);
//printf("In [%s::%s Line: %d] screenShotsPath [%s]\n",__FILE__,__FUNCTION__,__LINE__,screenShotsPath.c_str()); //printf("In [%s::%s Line: %d] screenShotsPath [%s]\n",__FILE__,__FUNCTION__,__LINE__,screenShotsPath.c_str());
} }
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
// Cache Player textures - START // Cache Player textures - START
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey); std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
for(int index = 0; index < GameConstants::maxPlayers; ++index) { for(int index = 0; index < GameConstants::maxPlayers; ++index) {
string playerTexture = "data/core/faction_textures/faction" + intToStr(index) + ".tga"; string playerTexture = data_path + "data/core/faction_textures/faction" + intToStr(index) + ".tga";
if(fileExists(playerTexture) == true) { if(fileExists(playerTexture) == true) {
Texture2D *texture = Renderer::getInstance().newTexture2D(rsGlobal); Texture2D *texture = Renderer::getInstance().newTexture2D(rsGlobal);
texture->load(playerTexture); texture->load(playerTexture);

View File

@@ -495,8 +495,8 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
//log start //log start
Logger &logger= Logger::getInstance(); Logger &logger= Logger::getInstance();
string logFile = "glest.log"; string logFile = "glest.log";
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
logFile = getGameReadWritePath() + logFile; logFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + logFile;
} }
logger.setFile(logFile); logger.setFile(logFile);
logger.clear(); logger.clear();

View File

@@ -3,19 +3,19 @@
// //
// Copyright (C) 2001-2008 Martio Figueroa // Copyright (C) 2001-2008 Martio Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the // by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version // License, or (at your option) any later version
// ============================================================== // ==============================================================
#include "main_menu.h" #include "main_menu.h"
#include "renderer.h" #include "renderer.h"
#include "sound.h" #include "sound.h"
#include "config.h" #include "config.h"
#include "program.h" #include "program.h"
#include "game_util.h" #include "game_util.h"
#include "game.h" #include "game.h"
#include "platform_util.h" #include "platform_util.h"
#include "sound_renderer.h" #include "sound_renderer.h"
@@ -49,7 +49,7 @@ MainMenu::MainMenu(Program *program):
{ {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
mouseX=100; mouseX=100;
mouseY=100; mouseY=100;
state= NULL; state= NULL;
@@ -96,7 +96,7 @@ void MainMenu::render(){
fps++; fps++;
renderer.clearBuffers(); renderer.clearBuffers();
//3d //3d
renderer.reset3dMenu(); renderer.reset3dMenu();
@@ -113,7 +113,7 @@ void MainMenu::render(){
//if(config.getBool("DebugMode")){ //if(config.getBool("DebugMode")){
if(renderer.getShowDebugUI() == true) { if(renderer.getShowDebugUI() == true) {
renderer.renderText( renderer.renderText(
"FPS: " + intToStr(lastFps), "FPS: " + intToStr(lastFps),
coreData.getMenuFontNormal(), Vec3f(1.f), 10, 10, false); coreData.getMenuFontNormal(), Vec3f(1.f), 10, 10, false);
} }
@@ -141,11 +141,11 @@ void MainMenu::mouseMove(int x, int y, const MouseState *ms){
//returns if exiting //returns if exiting
void MainMenu::mouseDownLeft(int x, int y){ void MainMenu::mouseDownLeft(int x, int y){
state->mouseClick(x, y, mbLeft); state->mouseClick(x, y, mbLeft);
} }
void MainMenu::mouseDownRight(int x, int y){ void MainMenu::mouseDownRight(int x, int y){
state->mouseClick(x, y, mbRight); state->mouseClick(x, y, mbRight);
} }
void MainMenu::keyDown(char key){ void MainMenu::keyDown(char key){
@@ -199,11 +199,12 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
Config &config = Config::getInstance(); Config &config = Config::getInstance();
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f); float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);
CoreData::getInstance().getMenuMusic()->setVolume(configVolume); CoreData::getInstance().getMenuMusic()->setVolume(configVolume);
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
//camera //camera
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load("data/core/menu/menu.xml"); xmlTree.load(data_path + "data/core/menu/menu.xml");
const XmlNode *menuNode= xmlTree.getRootNode(); const XmlNode *menuNode= xmlTree.getRootNode();
const XmlNode *cameraNode= menuNode->getChild("camera"); const XmlNode *cameraNode= menuNode->getChild("camera");
@@ -226,8 +227,8 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
startRotation.y= rotationNode->getAttribute("y")->getFloatValue(); startRotation.y= rotationNode->getAttribute("y")->getFloatValue();
startRotation.z= rotationNode->getAttribute("z")->getFloatValue(); startRotation.z= rotationNode->getAttribute("z")->getFloatValue();
camera.setOrientation(Quaternion(EulerAngles( camera.setOrientation(Quaternion(EulerAngles(
degToRad(startRotation.x), degToRad(startRotation.x),
degToRad(startRotation.y), degToRad(startRotation.y),
degToRad(startRotation.z)))); degToRad(startRotation.z))));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@@ -0,0 +1,182 @@
// ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Marti<74>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#include "menu_background.h"
#include <ctime>
#include "renderer.h"
#include "core_data.h"
#include "config.h"
#include "xml_parser.h"
#include "util.h"
#include "game_constants.h"
#include "game_util.h"
#include "leak_dumper.h"
using namespace Shared::Util;
using namespace Shared::Xml;
using namespace Shared::Graphics;
namespace Glest{ namespace Game{
// =====================================================
// class MenuBackground
// =====================================================
MenuBackground::MenuBackground(){
Renderer &renderer= Renderer::getInstance();
//load data
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
XmlTree xmlTree;
xmlTree.load(data_path + "data/core/menu/menu.xml");
const XmlNode *menuNode= xmlTree.getRootNode();
//water
const XmlNode *waterNode= menuNode->getChild("water");
water= waterNode->getAttribute("value")->getBoolValue();
if(water){
waterHeight= waterNode->getAttribute("height")->getFloatValue();
//water texture
waterTexture= renderer.newTexture2D(rsMenu);
waterTexture->getPixmap()->init(4);
waterTexture->getPixmap()->load(data_path + "data/core/menu/textures/water.tga");
}
//fog
const XmlNode *fogNode= menuNode->getChild("fog");
fog= fogNode->getAttribute("value")->getBoolValue();
if(fog){
fogDensity= fogNode->getAttribute("density")->getFloatValue();
}
//rain
rain= menuNode->getChild("rain")->getAttribute("value")->getBoolValue();
if(rain){
RainParticleSystem *rps= new RainParticleSystem();
rps->setSpeed(12.f/GameConstants::updateFps);
rps->setEmissionRate(25);
rps->setWind(-90.f, 4.f/GameConstants::updateFps);
rps->setPos(Vec3f(0.f, 25.f, 0.f));
rps->setColor(Vec4f(1.f, 1.f, 1.f, 0.2f));
rps->setRadius(30.f);
renderer.manageParticleSystem(rps, rsMenu);
for(int i=0; i<raindropCount; ++i){
raindropStates[i]= random.randRange(0.f, 1.f);
raindropPos[i]= computeRaindropPos();
}
}
//camera
const XmlNode *cameraNode= menuNode->getChild("camera");
//position
const XmlNode *positionNode= cameraNode->getChild("start-position");
Vec3f startPosition;
startPosition.x= positionNode->getAttribute("x")->getFloatValue();
startPosition.y= positionNode->getAttribute("y")->getFloatValue();
startPosition.z= positionNode->getAttribute("z")->getFloatValue();
camera.setPosition(startPosition);
//rotation
const XmlNode *rotationNode= cameraNode->getChild("start-rotation");
Vec3f startRotation;
startRotation.x= rotationNode->getAttribute("x")->getFloatValue();
startRotation.y= rotationNode->getAttribute("y")->getFloatValue();
startRotation.z= rotationNode->getAttribute("z")->getFloatValue();
camera.setOrientation(Quaternion(EulerAngles(
degToRad(startRotation.x),
degToRad(startRotation.y),
degToRad(startRotation.z))));
//load main model
mainModel= renderer.newModel(rsMenu);
mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
//models
for(int i=0; i<5; ++i){
characterModels[i]= renderer.newModel(rsMenu);
characterModels[i]->load(data_path + "data/core/menu/about_models/character"+intToStr(i)+".g3d");
}
//about position
positionNode= cameraNode->getChild("about-position");
aboutPosition.x= positionNode->getAttribute("x")->getFloatValue();
aboutPosition.y= positionNode->getAttribute("y")->getFloatValue();
aboutPosition.z= positionNode->getAttribute("z")->getFloatValue();
rotationNode= cameraNode->getChild("about-rotation");
targetCamera= NULL;
t= 0.f;
fade= 0.f;
anim= 0.f;
}
void MenuBackground::setTargetCamera(const Camera *targetCamera){
this->targetCamera= targetCamera;
this->lastCamera= camera;
t= 0.f;
}
void MenuBackground::update(){
//rain drops
for(int i=0; i<raindropCount; ++i){
raindropStates[i]+= 1.f / GameConstants::updateFps;
if(raindropStates[i]>=1.f){
raindropStates[i]= 0.f;
raindropPos[i]= computeRaindropPos();
}
}
if(targetCamera!=NULL){
t+= ((0.01f+(1.f-t)/10.f)/20.f)*(60.f/GameConstants::updateFps);
//interpolate position
camera.setPosition(lastCamera.getPosition().lerp(t, targetCamera->getPosition()));
//interpolate orientation
Quaternion q= lastCamera.getOrientation().lerp(t, targetCamera->getOrientation());
camera.setOrientation(q);
if(t>=1.f){
targetCamera= NULL;
t= 0.f;
}
}
//fade
if(fade<=1.f){
fade+= 0.6f/GameConstants::updateFps;
if(fade>1.f){
fade= 1.f;
}
}
//animation
anim+=(0.6f/GameConstants::updateFps)/5+random.randRange(0.f, (0.6f/GameConstants::updateFps)/5.f);
if(anim>1.f){
anim= 0.f;
}
}
Vec2f MenuBackground::computeRaindropPos(){
float f= static_cast<float>(meshSize);
return Vec2f(random.randRange(-f, f), random.randRange(-f, f));
}
}}//end namespace

View File

@@ -2116,8 +2116,8 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) { void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
fileName = getGameReadWritePath() + fileName; fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
@@ -2174,8 +2174,8 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
GameSettings gameSettings; GameSettings gameSettings;
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
fileName = getGameReadWritePath() + fileName; fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());

View File

@@ -52,10 +52,10 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
NetworkManager &networkManager= NetworkManager::getInstance(); NetworkManager &networkManager= NetworkManager::getInstance();
networkManager.end(); networkManager.end();
networkManager.init(nrClient); networkManager.init(nrClient);
serversSavedFile = serverFileName; serversSavedFile = serverFileName;
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
serversSavedFile = getGameReadWritePath() + serversSavedFile; serversSavedFile = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + serversSavedFile;
} }
servers.load(serversSavedFile); servers.load(serversSavedFile);
@@ -119,7 +119,7 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
} }
else{ else{
port=port +" ("+lang.get("StandardPort")+")"; port=port +" ("+lang.get("StandardPort")+")";
} }
labelServerPort.setText(port); labelServerPort.setText(port);
labelStatus.registerGraphicComponent(containerName,"labelStatus"); labelStatus.registerGraphicComponent(containerName,"labelStatus");
@@ -557,11 +557,11 @@ void MenuStateJoinGame::connectToServer()
//save server ip //save server ip
config.setString("ServerIp", serverIp.getString()); config.setString("ServerIp", serverIp.getString());
config.save(); config.save();
abortAutoFind = true; abortAutoFind = true;
clientInterface->stopServerDiscovery(); clientInterface->stopServerDiscovery();
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu)); mainMenu->setState(new MenuStateConnectedGame(program, mainMenu));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
} }

View File

@@ -37,7 +37,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
//modeinfos=list<ModeInfo> (); //modeinfos=list<ModeInfo> ();
Shared::PlatformCommon::getFullscreenVideoModes(&modeInfos); Shared::PlatformCommon::getFullscreenVideoModes(&modeInfos);
activeInputLabel=NULL; activeInputLabel=NULL;
int leftline=700; int leftline=700;
int rightline=700; int rightline=700;
int leftLabelStart=250; int leftLabelStart=250;
@@ -46,18 +46,18 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
int rightColumnStart=rightLabelStart+150; int rightColumnStart=rightLabelStart+150;
int buttonRowPos=80; int buttonRowPos=80;
int captionOffset=75; int captionOffset=75;
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox"); mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
mainMessageBox.init(lang.get("Ok")); mainMessageBox.init(lang.get("Ok"));
mainMessageBox.setEnabled(false); mainMessageBox.setEnabled(false);
mainMessageBoxState=0; mainMessageBoxState=0;
labelAudioSection.registerGraphicComponent(containerName,"labelAudioSection"); labelAudioSection.registerGraphicComponent(containerName,"labelAudioSection");
labelAudioSection.init(leftLabelStart+captionOffset, leftline); labelAudioSection.init(leftLabelStart+captionOffset, leftline);
labelAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig()); labelAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelAudioSection.setText(lang.get("Audio")); labelAudioSection.setText(lang.get("Audio"));
leftline-=30; leftline-=30;
//soundboxes //soundboxes
labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory"); labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory");
labelSoundFactory.init(leftLabelStart, leftline); labelSoundFactory.init(leftLabelStart, leftline);
@@ -81,7 +81,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxVolumeFx.registerGraphicComponent(containerName,"listBoxVolumeFx"); listBoxVolumeFx.registerGraphicComponent(containerName,"listBoxVolumeFx");
listBoxVolumeFx.init(leftColumnStart, leftline, 80); listBoxVolumeFx.init(leftColumnStart, leftline, 80);
leftline-=30; leftline-=30;
labelVolumeAmbient.registerGraphicComponent(containerName,"labelVolumeAmbient"); labelVolumeAmbient.registerGraphicComponent(containerName,"labelVolumeAmbient");
labelVolumeAmbient.init(leftLabelStart, leftline); labelVolumeAmbient.init(leftLabelStart, leftline);
@@ -89,7 +89,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxVolumeAmbient.init(leftColumnStart, leftline, 80); listBoxVolumeAmbient.init(leftColumnStart, leftline, 80);
labelVolumeAmbient.setText(lang.get("AmbientVolume")); labelVolumeAmbient.setText(lang.get("AmbientVolume"));
leftline-=30; leftline-=30;
labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic"); labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic");
labelVolumeMusic.init(leftLabelStart, leftline); labelVolumeMusic.init(leftLabelStart, leftline);
@@ -97,7 +97,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxVolumeMusic.init(leftColumnStart, leftline, 80); listBoxVolumeMusic.init(leftColumnStart, leftline, 80);
labelVolumeMusic.setText(lang.get("MusicVolume")); labelVolumeMusic.setText(lang.get("MusicVolume"));
leftline-=30; leftline-=30;
for(int i=0; i<=100; i+=5){ for(int i=0; i<=100; i+=5){
listBoxVolumeFx.pushBackItem(intToStr(i)); listBoxVolumeFx.pushBackItem(intToStr(i));
listBoxVolumeAmbient.pushBackItem(intToStr(i)); listBoxVolumeAmbient.pushBackItem(intToStr(i));
@@ -106,15 +106,15 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5)); listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5));
listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5)); listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5));
listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5)); listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5));
//leftline-=30; //leftline-=30;
labelMiscSection.registerGraphicComponent(containerName,"labelMiscSection"); labelMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
labelMiscSection.init(leftLabelStart+captionOffset, leftline); labelMiscSection.init(leftLabelStart+captionOffset, leftline);
labelMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig()); labelMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelMiscSection.setText(lang.get("Misc")); labelMiscSection.setText(lang.get("Misc"));
leftline-=30; leftline-=30;
//lang //lang
labelLang.registerGraphicComponent(containerName,"labelLang"); labelLang.registerGraphicComponent(containerName,"labelLang");
labelLang.init(leftLabelStart, leftline); labelLang.init(leftLabelStart, leftline);
@@ -123,36 +123,38 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxLang.registerGraphicComponent(containerName,"listBoxLang"); listBoxLang.registerGraphicComponent(containerName,"listBoxLang");
listBoxLang.init(leftColumnStart, leftline, 170); listBoxLang.init(leftColumnStart, leftline, 170);
vector<string> langResults; vector<string> langResults;
findAll("data/lang/*.lng", langResults, true);
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
findAll(data_path + "data/lang/*.lng", langResults, true);
if(langResults.empty()){ if(langResults.empty()){
throw runtime_error("There is no lang file"); throw runtime_error("There is no lang file");
} }
listBoxLang.setItems(langResults); listBoxLang.setItems(langResults);
listBoxLang.setSelectedItem(config.getString("Lang")); listBoxLang.setSelectedItem(config.getString("Lang"));
leftline-=30; leftline-=30;
//playerName //playerName
labelPlayerNameLabel.registerGraphicComponent(containerName,"labelPlayerNameLabel"); labelPlayerNameLabel.registerGraphicComponent(containerName,"labelPlayerNameLabel");
labelPlayerNameLabel.init(leftLabelStart,leftline); labelPlayerNameLabel.init(leftLabelStart,leftline);
labelPlayerNameLabel.setText(lang.get("Playername")); labelPlayerNameLabel.setText(lang.get("Playername"));
labelPlayerName.registerGraphicComponent(containerName,"labelPlayerName"); labelPlayerName.registerGraphicComponent(containerName,"labelPlayerName");
labelPlayerName.init(leftColumnStart,leftline); labelPlayerName.init(leftColumnStart,leftline);
labelPlayerName.setText(config.getString("NetPlayerName",Socket::getHostName().c_str())); labelPlayerName.setText(config.getString("NetPlayerName",Socket::getHostName().c_str()));
leftline-=30; leftline-=30;
//FontSizeAdjustment //FontSizeAdjustment
labelFontSizeAdjustment.registerGraphicComponent(containerName,"labelFontSizeAdjustment"); labelFontSizeAdjustment.registerGraphicComponent(containerName,"labelFontSizeAdjustment");
labelFontSizeAdjustment.init(leftLabelStart,leftline); labelFontSizeAdjustment.init(leftLabelStart,leftline);
labelFontSizeAdjustment.setText(lang.get("FontSizeAdjustment")); labelFontSizeAdjustment.setText(lang.get("FontSizeAdjustment"));
listFontSizeAdjustment.registerGraphicComponent(containerName,"listFontSizeAdjustment"); listFontSizeAdjustment.registerGraphicComponent(containerName,"listFontSizeAdjustment");
listFontSizeAdjustment.init(leftColumnStart, leftline, 80); listFontSizeAdjustment.init(leftColumnStart, leftline, 80);
for(int i=-5; i<=5; i+=1){ for(int i=-5; i<=5; i+=1){
listFontSizeAdjustment.pushBackItem(intToStr(i)); listFontSizeAdjustment.pushBackItem(intToStr(i));
} }
listFontSizeAdjustment.setSelectedItem(intToStr(config.getInt("FontSizeAdjustment"))); listFontSizeAdjustment.setSelectedItem(intToStr(config.getInt("FontSizeAdjustment")));
leftline-=30; leftline-=30;
// server port // server port
labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel"); labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel");
@@ -166,16 +168,16 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
else{ else{
port=port +" ("+lang.get("StandardPort")+")"; port=port +" ("+lang.get("StandardPort")+")";
} }
labelServerPort.setText(port); labelServerPort.setText(port);
// external server port // external server port
leftline-=30; leftline-=30;
labelPublishServerExternalPort.registerGraphicComponent(containerName,"labelPublishServerExternalPort"); labelPublishServerExternalPort.registerGraphicComponent(containerName,"labelPublishServerExternalPort");
labelPublishServerExternalPort.init(leftLabelStart, leftline, 150); labelPublishServerExternalPort.init(leftLabelStart, leftline, 150);
labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort")); labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort"));
listBoxPublishServerExternalPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort"); listBoxPublishServerExternalPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort");
listBoxPublishServerExternalPort.init(leftColumnStart, leftline, 170); listBoxPublishServerExternalPort.init(leftColumnStart, leftline, 170);
string supportExternalPortList = config.getString("MasterServerExternalPortList",intToStr(GameConstants::serverPort).c_str()); string supportExternalPortList = config.getString("MasterServerExternalPortList",intToStr(GameConstants::serverPort).c_str());
@@ -194,7 +196,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
} }
} }
listBoxPublishServerExternalPort.setSelectedItemIndex(masterServerExternalPortSelectionIndex); listBoxPublishServerExternalPort.setSelectedItemIndex(masterServerExternalPortSelectionIndex);
// Video Section // Video Section
leftline-=30; leftline-=30;
labelVideoSection.registerGraphicComponent(containerName,"labelVideoSection"); labelVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
@@ -211,7 +213,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxScreenModes.registerGraphicComponent(containerName,"listBoxScreenModes"); listBoxScreenModes.registerGraphicComponent(containerName,"listBoxScreenModes");
listBoxScreenModes.init(leftColumnStart, leftline, 170); listBoxScreenModes.init(leftColumnStart, leftline, 170);
string currentResString = config.getString("ScreenWidth") + "x" + string currentResString = config.getString("ScreenWidth") + "x" +
config.getString("ScreenHeight") + "-" + config.getString("ScreenHeight") + "-" +
intToStr(config.getInt("ColorBits")); intToStr(config.getInt("ColorBits"));
bool currentResolutionFound = false; bool currentResolutionFound = false;
@@ -226,8 +228,8 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
} }
listBoxScreenModes.setSelectedItem(currentResString); listBoxScreenModes.setSelectedItem(currentResString);
leftline-=30; leftline-=30;
//FullscreenWindowed //FullscreenWindowed
labelFullscreenWindowed.registerGraphicComponent(containerName,"labelFullscreenWindowed"); labelFullscreenWindowed.registerGraphicComponent(containerName,"labelFullscreenWindowed");
labelFullscreenWindowed.init(leftLabelStart, leftline); labelFullscreenWindowed.init(leftLabelStart, leftline);
@@ -239,7 +241,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxFullscreenWindowed.pushBackItem(lang.get("Yes")); listBoxFullscreenWindowed.pushBackItem(lang.get("Yes"));
listBoxFullscreenWindowed.setSelectedItemIndex(clamp(config.getBool("Windowed"), false, true)); listBoxFullscreenWindowed.setSelectedItemIndex(clamp(config.getBool("Windowed"), false, true));
leftline-=30; leftline-=30;
//filter //filter
labelFilter.registerGraphicComponent(containerName,"labelFilter"); labelFilter.registerGraphicComponent(containerName,"labelFilter");
labelFilter.init(leftLabelStart, leftline); labelFilter.init(leftLabelStart, leftline);
@@ -251,7 +253,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxFilter.pushBackItem("Trilinear"); listBoxFilter.pushBackItem("Trilinear");
listBoxFilter.setSelectedItem(config.getString("Filter")); listBoxFilter.setSelectedItem(config.getString("Filter"));
leftline-=30; leftline-=30;
//shadows //shadows
labelShadows.registerGraphicComponent(containerName,"labelShadows"); labelShadows.registerGraphicComponent(containerName,"labelShadows");
labelShadows.init(leftLabelStart, leftline); labelShadows.init(leftLabelStart, leftline);
@@ -265,7 +267,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
string str= config.getString("Shadows"); string str= config.getString("Shadows");
listBoxShadows.setSelectedItemIndex(clamp(Renderer::strToShadows(str), 0, Renderer::sCount-1)); listBoxShadows.setSelectedItemIndex(clamp(Renderer::strToShadows(str), 0, Renderer::sCount-1));
leftline-=30; leftline-=30;
//textures 3d //textures 3d
labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D"); labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D");
labelTextures3D.init(leftLabelStart, leftline); labelTextures3D.init(leftLabelStart, leftline);
@@ -277,7 +279,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
listBoxTextures3D.pushBackItem(lang.get("Yes")); listBoxTextures3D.pushBackItem(lang.get("Yes"));
listBoxTextures3D.setSelectedItemIndex(clamp(config.getBool("Textures3D"), false, true)); listBoxTextures3D.setSelectedItemIndex(clamp(config.getBool("Textures3D"), false, true));
leftline-=30; leftline-=30;
//lights //lights
labelLights.registerGraphicComponent(containerName,"labelLights"); labelLights.registerGraphicComponent(containerName,"labelLights");
labelLights.init(leftLabelStart, leftline); labelLights.init(leftLabelStart, leftline);
@@ -290,7 +292,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
} }
listBoxLights.setSelectedItemIndex(clamp(config.getInt("MaxLights")-1, 0, 7)); listBoxLights.setSelectedItemIndex(clamp(config.getInt("MaxLights")-1, 0, 7));
leftline-=30; leftline-=30;
//unit particles //unit particles
labelUnitParticles.registerGraphicComponent(containerName,"labelUnitParticles"); labelUnitParticles.registerGraphicComponent(containerName,"labelUnitParticles");
labelUnitParticles.init(leftLabelStart,leftline); labelUnitParticles.init(leftLabelStart,leftline);
@@ -317,7 +319,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
// buttons // buttons
buttonOk.registerGraphicComponent(containerName,"buttonOk"); buttonOk.registerGraphicComponent(containerName,"buttonOk");
buttonOk.init(200, buttonRowPos, 100); buttonOk.init(200, buttonRowPos, 100);
buttonOk.setText(lang.get("Ok")); buttonOk.setText(lang.get("Ok"));
buttonAbort.setText(lang.get("Abort")); buttonAbort.setText(lang.get("Abort"));
@@ -378,7 +380,7 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
} }
else if(buttonOk.mouseClick(x, y)){ else if(buttonOk.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundA()); soundRenderer.playFx(coreData.getClickSoundA());
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits")); string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits"));
string selectedResolution=listBoxScreenModes.getSelectedItem(); string selectedResolution=listBoxScreenModes.getSelectedItem();
if(currentResolution!=selectedResolution){ if(currentResolution!=selectedResolution){
@@ -395,7 +397,7 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
showMessageBox(lang.get("RestartNeeded"), lang.get("FontSizeAdjustmentChanged"), false); showMessageBox(lang.get("RestartNeeded"), lang.get("FontSizeAdjustmentChanged"), false);
return; return;
} }
bool currentFullscreenWindowed=config.getBool("Windowed"); bool currentFullscreenWindowed=config.getBool("Windowed");
bool selectedFullscreenWindowed = (listBoxFullscreenWindowed.getSelectedItemIndex() != 0); bool selectedFullscreenWindowed = (listBoxFullscreenWindowed.getSelectedItemIndex() != 0);
if(currentFullscreenWindowed!=selectedFullscreenWindowed){ if(currentFullscreenWindowed!=selectedFullscreenWindowed){
@@ -404,7 +406,7 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
showMessageBox(lang.get("RestartNeeded"), lang.get("DisplaySettingsChanged"), false); showMessageBox(lang.get("RestartNeeded"), lang.get("DisplaySettingsChanged"), false);
return; return;
} }
saveConfig(); saveConfig();
mainMenu->setState(new MenuStateRoot(program, mainMenu)); mainMenu->setState(new MenuStateRoot(program, mainMenu));
} }
@@ -592,7 +594,7 @@ void MenuStateOptions::saveConfig(){
CoreData::getInstance().getMenuMusic()->setVolume(strToInt(listBoxVolumeMusic.getSelectedItem())/100.f); CoreData::getInstance().getMenuMusic()->setVolume(strToInt(listBoxVolumeMusic.getSelectedItem())/100.f);
config.setString("SoundVolumeMusic", listBoxVolumeMusic.getSelectedItem()); config.setString("SoundVolumeMusic", listBoxVolumeMusic.getSelectedItem());
config.setString("MasterServerExternalPort", listBoxPublishServerExternalPort.getSelectedItem()); config.setString("MasterServerExternalPort", listBoxPublishServerExternalPort.getSelectedItem());
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight"); string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight");
string selectedResolution=listBoxScreenModes.getSelectedItem(); string selectedResolution=listBoxScreenModes.getSelectedItem();
if(currentResolution!=selectedResolution){ if(currentResolution!=selectedResolution){
@@ -605,7 +607,7 @@ void MenuStateOptions::saveConfig(){
} }
} }
} }
config.save(); config.save();
SoundRenderer &soundRenderer= SoundRenderer::getInstance(); SoundRenderer &soundRenderer= SoundRenderer::getInstance();

View File

@@ -80,7 +80,8 @@ void Faction::init(
} }
texture= Renderer::getInstance().newTexture2D(rsGame); texture= Renderer::getInstance().newTexture2D(rsGame);
texture->load("data/core/faction_textures/faction"+intToStr(startLocationIndex)+".tga"); string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
texture->load(data_path + "data/core/faction_textures/faction"+intToStr(startLocationIndex)+".tga");
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
@@ -181,16 +182,16 @@ bool Faction::reqsOk(const RequirableType *rt) const{
return false; return false;
} }
} }
if(dynamic_cast<const UnitType *>(rt) != NULL ) { if(dynamic_cast<const UnitType *>(rt) != NULL ) {
const UnitType *producedUnitType=(UnitType *) rt; const UnitType *producedUnitType=(UnitType *) rt;
if(producedUnitType != NULL && producedUnitType->getMaxUnitCount() > 0) { if(producedUnitType != NULL && producedUnitType->getMaxUnitCount() > 0) {
if(producedUnitType->getMaxUnitCount() <= getCountForMaxUnitCount(producedUnitType)) { if(producedUnitType->getMaxUnitCount() <= getCountForMaxUnitCount(producedUnitType)) {
return false; return false;
} }
} }
} }
return true; return true;
} }

View File

@@ -155,7 +155,7 @@ void World::init(Game *game, bool createUnits){
if(fogOfWarOverride == false) { if(fogOfWarOverride == false) {
fogOfWar = gs->getFogOfWar(); fogOfWar = gs->getFogOfWar();
} }
initFactionTypes(gs); initFactionTypes(gs);
initCells(fogOfWar); //must be done after knowing faction number and dimensions initCells(fogOfWar); //must be done after knowing faction number and dimensions
initMap(); initMap();
@@ -965,7 +965,7 @@ void World::initFactionTypes(GameSettings *gs) {
stats.setPlayerName(i,gs->getNetworkPlayerName(i)); stats.setPlayerName(i,gs->getNetworkPlayerName(i));
stats.setPlayerColor(i,getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0)); stats.setPlayerColor(i,getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0));
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(factions.size() > 0) { if(factions.size() > 0) {
@@ -1355,10 +1355,10 @@ int World::getNextUnitId(Faction *faction) {
} }
std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const { std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
string debugWorldLogFile = Config::getInstance().getString("DebugWorldLogFile","debugWorld.log"); string debugWorldLogFile = Config::getInstance().getString("DebugWorldLogFile","debugWorld.log");
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
debugWorldLogFile = getGameReadWritePath() + debugWorldLogFile; debugWorldLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugWorldLogFile;
} }
if(consoleBasicInfoOnly == true) { if(consoleBasicInfoOnly == true) {
@@ -1369,7 +1369,7 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
for(int i = 0; i < getFactionCount(); ++i) { for(int i = 0; i < getFactionCount(); ++i) {
std::cout << "Faction detail for index: " << i << std::endl; std::cout << "Faction detail for index: " << i << std::endl;
std::cout << "--------------------------" << std::endl; std::cout << "--------------------------" << std::endl;
std::cout << "FactionName = " << getFaction(i)->getType()->getName() << std::endl; std::cout << "FactionName = " << getFaction(i)->getType()->getName() << std::endl;
std::cout << "FactionIndex = " << intToStr(getFaction(i)->getIndex()) << std::endl; std::cout << "FactionIndex = " << intToStr(getFaction(i)->getIndex()) << std::endl;
std::cout << "teamIndex = " << intToStr(getFaction(i)->getTeam()) << std::endl; std::cout << "teamIndex = " << intToStr(getFaction(i)->getTeam()) << std::endl;

View File

@@ -73,8 +73,8 @@ Profiler::~Profiler(){
rootSection->stop(); rootSection->stop();
string profileLog = "profiler.log"; string profileLog = "profiler.log";
if(getGameReadWritePath() != "") { if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
profileLog = getGameReadWritePath() + profileLog; profileLog = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + profileLog;
} }
FILE *f= fopen(profileLog.c_str(), "w"); FILE *f= fopen(profileLog.c_str(), "w");
if(f==NULL) if(f==NULL)