diff options
author | ancarola <raffaele.ancarola@epfl.ch> | 2019-01-19 20:31:46 +0100 |
---|---|---|
committer | ancarola <raffaele.ancarola@epfl.ch> | 2019-01-19 20:31:46 +0100 |
commit | ba86c8245484279ed7e78912b1ecd9ff4ac82e1e (patch) | |
tree | 7f3a04a92b862c4d145f2e79b87d524f98b54eed /engine/flatland.cpp | |
parent | Test two completed successfully (diff) | |
download | flatland-ba86c8245484279ed7e78912b1ecd9ff4ac82e1e.tar.gz flatland-ba86c8245484279ed7e78912b1ecd9ff4ac82e1e.zip |
minor fixes
Diffstat (limited to 'engine/flatland.cpp')
-rw-r--r-- | engine/flatland.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/engine/flatland.cpp b/engine/flatland.cpp index 531d42c..cbb9842 100644 --- a/engine/flatland.cpp +++ b/engine/flatland.cpp @@ -12,6 +12,8 @@ using namespace std; #include "flattask.h" #include "flatsignal.h" #include "flatwindow.h" +#include "flatexception.h" +#include "exceptions/forcequit.h" float flatland_dt; @@ -125,11 +127,37 @@ int init_flatland(FlatWindow* w, gameloop loop, const flat_status& s, float _fps delay = clock(); - /* Execute loop function */ - loop_function(flatland_dt); + try { - /* Execute tasks */ - task_s::executeAll(); + try { + + /* Execute loop function */ + loop_function(flatland_dt); + + } catch (const exception &e) { + + cerr << "Flatland: exception thrown while executing loop" << endl; + cerr << e.what() << endl; + } + + try { + + /* Execute tasks */ + task_s::executeAll(); + + } catch (const exception &e) { + + cerr << "Flatland: exception thrown while executing tasks" << endl; + cerr << e.what() << endl; + } + + } catch (const ForceQuit& f) { + + cerr << "Flatland: a force quit call was thrown" << endl; + cerr << "Possible reason: " << f.reason << endl; + + quit_flatland(); + } SDL_Delay((Uint32) (1000.0f / fps)); @@ -141,6 +169,10 @@ int init_flatland(FlatWindow* w, gameloop loop, const flat_status& s, float _fps } while(status.running); + cout << "Flatland: closing window" << endl; + + window->close(); + cout << "Flatland: destroying core channel" << endl; delete core; |