diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 1e2b1ed71..81f801e82 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -919,11 +919,11 @@ void Game::init(bool initForPreviewOnly) { world.init(this, gameSettings.getDefaultUnits()); } catch(const exception &ex) { - char szBuf[8096]=""; - sprintf(szBuf,"In [%s::%s Line: %d]\nError [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); - - SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf); + char szErrBuf[8096]=""; + sprintf(szErrBuf,"In [%s::%s %d]",__FILE__,__FUNCTION__,__LINE__); + string sErrBuf = string(szErrBuf) + string("\nerror [") + string(ex.what()) + string("]\n"); + SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,sErrBuf.c_str()); if(errorMessageBox.getEnabled() == false) { ErrorDisplayMessage(ex.what(),true); @@ -1527,8 +1527,8 @@ void Game::update() { world.init(this, gameSettings.getDefaultUnits(),false); } catch(const exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s Line: %d]\nError [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 96d500cd2..b09f602e8 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -2068,7 +2068,8 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac float damageMultiplier = world->getTechTree()->getDamageMultiplier(ast->getAttackType(), attacked->getType()->getArmorType()); //compute damage - damage += random.randRange(-var, var); + //damage += random.randRange(-var, var); + damage += attacker->getRandom()->randRange(-var, var); damage /= distance+1; damage -= armor; damage *= damageMultiplier; @@ -2625,7 +2626,7 @@ void UnitUpdater::saveGame(XmlNode *rootNode) { // RoutePlanner *routePlanner; // Game *game; // RandomGen random; - unitupdaterNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements); + //unitupdaterNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements); // float attackWarnRange; unitupdaterNode->addAttribute("attackWarnRange",floatToStr(attackWarnRange), mapTagReplacements); // AttackWarnings attackWarnings; @@ -2638,7 +2639,7 @@ void UnitUpdater::loadGame(const XmlNode *rootNode) { const XmlNode *unitupdaterNode = rootNode->getChild("UnitUpdater"); pathFinder->loadGame(unitupdaterNode); - random.setLastNumber(unitupdaterNode->getAttribute("random")->getIntValue()); + //random.setLastNumber(unitupdaterNode->getAttribute("random")->getIntValue()); // float attackWarnRange; attackWarnRange = unitupdaterNode->getAttribute("attackWarnRange")->getFloatValue(); } diff --git a/source/glest_game/world/unit_updater.h b/source/glest_game/world/unit_updater.h index b44e3482d..4af2b9486 100644 --- a/source/glest_game/world/unit_updater.h +++ b/source/glest_game/world/unit_updater.h @@ -81,7 +81,7 @@ private: PathFinder *pathFinder; RoutePlanner *routePlanner; Game *game; - RandomGen random; + //RandomGen random; float attackWarnRange; AttackWarnings attackWarnings; diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index a19d1418a..83a3e41ab 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -259,7 +259,7 @@ void World::init(Game *game, bool createUnits, bool initFactions){ initMinimap(); bool gotError = false; - char szErrBuf[8096]=""; + string sErrBuf = ""; try { if(createUnits) { @@ -267,12 +267,11 @@ void World::init(Game *game, bool createUnits, bool initFactions){ } } catch(const std::exception &ex) { - //printf("***A\n"); gotError = true; - sprintf(szErrBuf,"In [%s::%s %d]\nerror [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); - SystemFlags::OutputDebug(SystemFlags::debugError,szErrBuf); - - //printf("***B\n"); + char szErrBuf[8096]=""; + sprintf(szErrBuf,"In [%s::%s %d]",__FILE__,__FUNCTION__,__LINE__); + sErrBuf = string(szErrBuf) + string("\nerror [") + string(ex.what()) + string("]\n"); + SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str()); } if(loadWorldNode != NULL) { @@ -284,7 +283,7 @@ void World::init(Game *game, bool createUnits, bool initFactions){ computeFow(); if(gotError == true) { - throw megaglest_runtime_error(szErrBuf); + throw megaglest_runtime_error(sErrBuf); } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -1641,7 +1640,7 @@ void World::initUnits() { Logger::getInstance().add(Lang::getInstance().get("LogScreenGameLoadingGenerateGameElements","",true), true); bool gotError = false; - char szErrBuf[8096]=""; + string sErrBuf=""; try { //put starting units if(loadWorldNode == NULL) { @@ -1679,15 +1678,17 @@ void World::initUnits() { } catch(const std::exception &ex) { gotError = true; - sprintf(szErrBuf,"In [%s::%s %d]\nerror [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); - SystemFlags::OutputDebug(SystemFlags::debugError,szErrBuf); + char szErrBuf[8096]=""; + sprintf(szErrBuf,"In [%s::%s %d]",__FILE__,__FUNCTION__,__LINE__); + sErrBuf = string(szErrBuf) + string("\nerror [") + string(ex.what()) + string("]\n"); + SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str()); } map.computeNormals(); map.computeInterpolatedHeights(); if(gotError == true) { - throw megaglest_runtime_error(szErrBuf); + throw megaglest_runtime_error(sErrBuf); } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); }