mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 12:12:25 +01:00
- attempt to fix pizza's crash
- safer use of random # in unit updater (not backward compatible with other builds)
This commit is contained in:
parent
ed6961195f
commit
ed9ae076c5
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
PathFinder *pathFinder;
|
||||
RoutePlanner *routePlanner;
|
||||
Game *game;
|
||||
RandomGen random;
|
||||
//RandomGen random;
|
||||
float attackWarnRange;
|
||||
AttackWarnings attackWarnings;
|
||||
|
||||
|
@ -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__);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user