From e5b218d693006404e1c362ef78e719a2f5db8106 Mon Sep 17 00:00:00 2001 From: "Michael D. Reiley" Date: Sat, 14 Jul 2012 14:57:16 -0700 Subject: [PATCH] Use ASSERTS in main. --- doc/sphinx/chapter_3.rst | 2 +- src/log.h | 2 +- src/main.cpp | 21 +++++++++------------ src/python.cpp | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/doc/sphinx/chapter_3.rst b/doc/sphinx/chapter_3.rst index 7726944..439d1ea 100644 --- a/doc/sphinx/chapter_3.rst +++ b/doc/sphinx/chapter_3.rst @@ -16,7 +16,7 @@ Configuring Tiled .. image:: _static/tiled_01.png :scale: 25 -This is Tiled. It looks very simple because it is very simple. In this chapter, the features and usage of Tiled will be documented by breaking down the recreation of a few areas that show up in the Tsunagari testing world. +This is Tiled. It looks very simple because it is very simple. This chapter explains the features of Tiled, and its use in creating Tsunagari maps. First, Tiled needs to be configured to produce files that Tsunagari can understand. Navigate to ``Edit > Preferences`` in the topbar menu. diff --git a/src/log.h b/src/log.h index 0538df1..c795281 100644 --- a/src/log.h +++ b/src/log.h @@ -11,7 +11,7 @@ #include enum verbosity_t { - V_QUIET, //! Display fatals. + V_QUIET = 1, //! Display fatals. V_NORMAL, //! Display fatals and errors. V_VERBOSE //! Display fatals, errors and info. }; diff --git a/src/main.cpp b/src/main.cpp index af719aa..a667b16 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,8 @@ #include "os-windows.h" #endif +#define ASSERT_MAIN(x) if (!(x)) return 1 + struct libraries { libraries() @@ -58,17 +60,13 @@ int main(int argc, char** argv) wFixConsole(); #endif - if (!parseConfig(CLIENT_CONF_PATH)) - {} // client.ini no longer required. - if (!parseCommandLine(argc, argv)) - return 1; - if (!conf.validate(CLIENT_CONF_PATH)) - return 1; - if (conf.verbosity) - Log::setVerbosity(conf.verbosity); + parseConfig(CLIENT_CONF_PATH) + + ASSERT_MAIN(parseCommandLine(argc, argv)) + ASSERT_MAIN(conf.validate(CLIENT_CONF_PATH)) - if (!Log::init()) - exit(1); + Log::setVerbosity(conf.verbosity); + ASSERT_MAIN(Log::init()) std::cout << "[0.000] Starting " << TSUNAGARI_RELEASE_VERSION << std::endl; Log::reportVerbosityOnStartup(); @@ -77,8 +75,7 @@ int main(int argc, char** argv) libraries libs; GameWindow window; - if (!window.init(argv[0])) - return 1; + ASSERT_MAIN(window.init(argv[0])) window.show(); return 0; } diff --git a/src/python.cpp b/src/python.cpp index a6c5d98..fb728d8 100644 --- a/src/python.cpp +++ b/src/python.cpp @@ -243,7 +243,7 @@ void pythonErr() if (conf.scriptHalt) { Log::fatal("Python", extractException(exc, val, tb)); GameWindow::instance().close(); - exit(0); + exit(1); } else Log::err("Python", extractException(exc, val, tb)); -- 2.11.4.GIT