better error handling for game / scenario loading problems (like bad xml)
This commit is contained in:
parent
995617e91e
commit
831bbda6c9
|
@ -628,7 +628,8 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||
|
||||
static bool inErrorNow = false;
|
||||
if(inErrorNow == true) {
|
||||
printf("\n** Already in error handler, msg [%s]\n",msg);
|
||||
printf("\n=====================================\n");
|
||||
printf("\n** Already in error handler aborting, msg [%s]\n",msg);
|
||||
fflush(stdout);
|
||||
abort();
|
||||
return;
|
||||
|
@ -678,9 +679,16 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
|
||||
//program->getState()->render();
|
||||
Shared::Platform::Window::handleEvent();
|
||||
mainProgram->loop();
|
||||
|
||||
//printf("\nhandle error #1\n");
|
||||
try {
|
||||
mainProgram->loop();
|
||||
}
|
||||
catch(const exception &e) {
|
||||
printf("\n=====================================\n");
|
||||
printf("\n** Already in error handler exiting errror rendering, msg [%s]\n",e.what());
|
||||
fflush(stdout);
|
||||
//abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -693,9 +701,16 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
|
||||
//program->renderProgramMsgBox();
|
||||
Shared::Platform::Window::handleEvent();
|
||||
mainProgram->loop();
|
||||
|
||||
//printf("\nhandle error #2\n");
|
||||
try {
|
||||
mainProgram->loop();
|
||||
}
|
||||
catch(const exception &e) {
|
||||
printf("\n=====================================\n");
|
||||
printf("\n** Already in error handler exiting errror rendering, msg [%s]\n",e.what());
|
||||
fflush(stdout);
|
||||
//abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu,
|
|||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%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,"%s",szBuf);
|
||||
|
||||
|
@ -139,7 +139,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu,
|
|||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%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,"%s",szBuf);
|
||||
|
||||
|
@ -160,7 +160,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu,
|
|||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%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,"%s",szBuf);
|
||||
|
||||
|
@ -201,7 +201,7 @@ MenuStateScenario::~MenuStateScenario() {
|
|||
}
|
||||
|
||||
void MenuStateScenario::cleanupPreviewTexture() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] scenarioLogoTexture [%p]\n",__FILE__,__FUNCTION__,__LINE__,scenarioLogoTexture);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] scenarioLogoTexture [%p]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioLogoTexture);
|
||||
|
||||
if(scenarioLogoTexture != NULL) {
|
||||
Renderer::getInstance().endTexture(rsGlobal, scenarioLogoTexture, false);
|
||||
|
@ -248,7 +248,7 @@ void MenuStateScenario::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%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,"%s",szBuf);
|
||||
|
||||
|
@ -308,15 +308,27 @@ void MenuStateScenario::update() {
|
|||
this->autoloadScenarioName = "";
|
||||
}
|
||||
else {
|
||||
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 && listBoxScenario.getSelectedItemIndex() < scenarioFiles.size()) {
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
labelInfo.setText(scenarioInfo.desc);
|
||||
try {
|
||||
this->autoloadScenarioName = "";
|
||||
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 && listBoxScenario.getSelectedItemIndex() < scenarioFiles.size()) {
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
labelInfo.setText(scenarioInfo.desc);
|
||||
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
soundRenderer.playFx(coreData.getClickSoundC());
|
||||
launchGame();
|
||||
return;
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
soundRenderer.playFx(coreData.getClickSoundC());
|
||||
launchGame();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] Error detected:\n%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,"%s",szBuf);
|
||||
|
||||
mainMessageBoxState=1;
|
||||
showMessageBox( "Error: " + string(ex.what()), "Error detected", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +379,7 @@ void MenuStateScenario::loadScenarioPreviewTexture(){
|
|||
|
||||
Game::extractScenarioLogoFile(&gameSettings, scenarioLogo, loadingImageUsed);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] scenarioLogo [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioLogo.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] scenarioLogo [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioLogo.c_str());
|
||||
|
||||
if(scenarioLogo != "") {
|
||||
cleanupPreviewTexture();
|
||||
|
|
|
@ -456,7 +456,7 @@ Checksum World::loadScenario(const string &path, Checksum *checksum, bool resetC
|
|||
|
||||
if(resetCurrentScenario == true) {
|
||||
scenario = Scenario();
|
||||
scriptManager->init(this, this->getGame()->getGameCameraPtr(),rootNode);
|
||||
if(scriptManager) scriptManager->init(this, this->getGame()->getGameCameraPtr(),rootNode);
|
||||
}
|
||||
|
||||
scenarioChecksum = scenario.load(path);
|
||||
|
@ -492,7 +492,7 @@ void World::updateAllFactionUnits() {
|
|||
char perfBuf[8096]="";
|
||||
std::vector<string> perfList;
|
||||
|
||||
scriptManager->onTimerTriggerEvent();
|
||||
if(scriptManager) scriptManager->onTimerTriggerEvent();
|
||||
|
||||
// Prioritize grouped command units so closest units to target go first
|
||||
// units
|
||||
|
@ -754,7 +754,7 @@ void World::update() {
|
|||
|
||||
//time
|
||||
timeFlow.update();
|
||||
scriptManager->onDayNightTriggerEvent();
|
||||
if(scriptManager) scriptManager->onDayNightTriggerEvent();
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
|
@ -1076,7 +1076,7 @@ void World::moveUnitCells(Unit *unit) {
|
|||
}
|
||||
}
|
||||
|
||||
scriptManager->onCellTriggerEvent(unit);
|
||||
if(scriptManager) scriptManager->onCellTriggerEvent(unit);
|
||||
}
|
||||
|
||||
void World::addAttackEffects(const Unit *unit) {
|
||||
|
@ -1223,7 +1223,7 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po
|
|||
if(placeUnit(pos, generationArea, unit, spaciated)) {
|
||||
unit->create(true);
|
||||
unit->born(NULL);
|
||||
scriptManager->onUnitCreated(unit);
|
||||
if(scriptManager) scriptManager->onUnitCreated(unit);
|
||||
}
|
||||
else {
|
||||
delete unit;
|
||||
|
|
Loading…
Reference in New Issue
Block a user