X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FEngine.cc;h=be8ca5fac61e184f0b54a0da244355e5b33e89a2;hp=bcc336c1244f1f8b0a8ed041507c4b5f3e0f7834;hb=16d1a05b0777e97a45c48e2874aa4e5cc791282e;hpb=15cd32dc28e7fa5997d9850d7e10b889f69a7cae diff --git a/src/Moof/Engine.cc b/src/Moof/Engine.cc index bcc336c..be8ca5f 100644 --- a/src/Moof/Engine.cc +++ b/src/Moof/Engine.cc @@ -28,7 +28,6 @@ #include // exit #include -#include #include #include @@ -48,26 +47,32 @@ namespace Mf { class Engine::EngineImpl { public: - EngineImpl(const std::string& name, int argc, char* argv[], - const std::string& configFile, Engine* outer) : - settings(argc, argv), - interface(outer) + EngineImpl(int argc, char* argv[], const std::string& configFile, + const std::string& name, const std::string& iconFile, + Engine* outer) : + interface(outer), + settings(argc, argv) { if (SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_EVENTTHREAD) != 0) { - throw std::runtime_error(SDL_GetError()); + throw Exception(SDL_GetError()); } if (FE_Init() != 0) { - throw std::runtime_error(FE_GetError()); + throw Exception(FE_GetError()); } - setSeed(); - settings.loadFromFile(configFile); - video = VideoPtr(new Video(name)); - video->makeActive(); + long randomSeed; + if (settings.get("engine.rngseed", randomSeed)) + { + setSeed(randomSeed); + } + else + { + setSeed(); + } double ts = 0.01; settings.get("engine.timestep", ts); @@ -79,11 +84,14 @@ public: printFps = false; settings.get("video.printfps", printFps); + + video = VideoPtr(new Video(name, iconFile)); + video->makeActive(); } ~EngineImpl() { - // The video object must be destroyed before we can shutdown SDL. + // the video object must be destroyed before we can shutdown SDL video.reset(); FE_Quit(); @@ -201,6 +209,8 @@ public: } + Engine* interface; + Settings settings; Dispatcher dispatcher; VideoPtr video; @@ -212,14 +222,13 @@ public: long fps; bool printFps; - - Engine* interface; }; -Engine::Engine(const std::string& name, int argc, char* argv[], - const std::string& configFile) : - impl_(new Engine::EngineImpl(name, argc, argv, configFile, this)) {} +Engine::Engine(int argc, char* argv[], const std::string& configFile, + const std::string& name, const std::string& iconFile) : + impl_(new Engine::EngineImpl(argc, argv, configFile, name, iconFile, this)) +{} Engine::~Engine() {}