From 03f050fc04caf93b8664246cfe4a320099d86452 Mon Sep 17 00:00:00 2001 From: darkf Date: Tue, 2 Aug 2016 04:45:05 -0700 Subject: [PATCH] Use C++11 member initializers in RWGame --- rwgame/RWGame.cpp | 8 +------- rwgame/RWGame.hpp | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index a92a42f0..e4a6a68b 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -34,17 +34,11 @@ const std::string kWindowTitle = "RWGame"; #define MOUSE_SENSITIVITY_SCALE 2.5f -DebugDraw* debug; +DebugDraw* debug = nullptr; StdOutReciever logPrinter; RWGame::RWGame(int argc, char* argv[]) - : config("openrw.ini") - , state(nullptr), world(nullptr), renderer(nullptr), script(nullptr), - window(nullptr), work(nullptr), - debugScript(false), inFocus(true), - showDebugStats(false), showDebugPaths(false), showDebugPhysics(false), - accum(0.f), timescale(1.f) { if (!config.isValid()) { diff --git a/rwgame/RWGame.hpp b/rwgame/RWGame.hpp index f6e6476c..9262b4e8 100644 --- a/rwgame/RWGame.hpp +++ b/rwgame/RWGame.hpp @@ -20,31 +20,31 @@ class HttpServer; class RWGame { Logger log; - GameConfig config; - GameState* state; - GameData* data; - GameWorld* world; + GameConfig config {"openrw.ini"}; + GameState* state = nullptr; + GameData* data = nullptr; + GameWorld* world = nullptr; // must be allocated after Logger setup. - GameRenderer* renderer; - ScriptMachine* script; - GameWindow *window; + GameRenderer* renderer = nullptr; + ScriptMachine* script = nullptr; + GameWindow *window = nullptr; // Background worker - WorkContext *work; - bool debugScript; + WorkContext *work = nullptr; + bool debugScript = false; HttpServer* httpserver = nullptr; std::thread* httpserver_thread = nullptr; std::chrono::steady_clock clock; std::chrono::steady_clock::time_point last_clock_time; - bool inFocus; + bool inFocus = true; ViewCamera lastCam, nextCam; - bool showDebugStats; - bool showDebugPaths; - bool showDebugPhysics; + bool showDebugStats = false; + bool showDebugPaths = false; + bool showDebugPhysics = false; int lastDraws; /// Number of draws issued for the last frame. - float accum; - float timescale; + float accum = 0.f; + float timescale = 1.f; public: RWGame(int argc, char* argv[]);