From 109a5e8d828a262dcf2f623e3f02ed27c346507a Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Mon, 29 Jan 2018 21:23:41 +0200 Subject: [PATCH] More debug logs --- src/newgrf.cpp | 2 +- src/openttd.cpp | 13 +++++++++++-- todo.txt | 2 -- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 9c7188ec70..f2b618a027 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -203,7 +203,7 @@ static inline bool IsValidNewGRFImageIndex(uint8 image_index) return image_index == 0xFD || IsValidImageIndex(image_index); } -class OTTDByteReaderSignal { }; +class OTTDByteReaderSignal: public std::runtime_error { public: OTTDByteReaderSignal():std::runtime_error("OTTDByteReaderSignal: NewGRF byte data invalid") {} }; /** Class to read from a NewGRF file */ class ByteReader { diff --git a/src/openttd.cpp b/src/openttd.cpp index 95a899ca18..78d115e754 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -70,6 +70,7 @@ #include "safeguards.h" #ifdef __ANDROID__ +#include #include #endif #include @@ -501,7 +502,7 @@ struct AfterNewGRFScan : NewGRFScanCallback { unlink("libsdl-DownloadFinished-1.flag"); //_exit_game = true; //_restart_game = true; - abort(); // Kill myself with contempt, user will restart the app, because otherwise we enter infinite restart loop + _exit(0); // kill(getpid(), SIG_KILL); //abort(); // Kill myself with contempt, user will restart the app, because otherwise we enter infinite restart loop } checked = true; @@ -891,7 +892,15 @@ int openttd_main(int argc, char *argv[]) ScanNewGRFFiles(scanner); scanner = NULL; - VideoDriver::GetInstance()->MainLoop(); + try { + VideoDriver::GetInstance()->MainLoop(); + } catch (const std::exception & e) { + DEBUG(misc, 0, "Main thread got exception: %s", e.what()); + throw; + } catch (...) { + DEBUG(misc, 0, "Main thread got unknown exception"); + throw; + } WaitTillSaved(); diff --git a/todo.txt b/todo.txt index 0517c1bdfa..068af5c537 100644 --- a/todo.txt +++ b/todo.txt @@ -12,5 +12,3 @@ - New game crashes with AdmiralAI enabled. - 'Title bars' text should be black, and the button should be bigger. - -- AI crashes the game.