diff --git a/configure b/configure index f6d52a3179..5c32856325 100755 --- a/configure +++ b/configure @@ -113,6 +113,10 @@ def build_type(args): ret = 'Debug' elif mode == 'release': ret = 'Release' + elif mode == 'relwithdebinfo': + ret = 'RelWithDebInfo' + elif mode == 'minsizerel': + ret = 'MinSizeRel' return { "build_type": ret @@ -355,7 +359,7 @@ def parse_args(): formatter_class=argparse.ArgumentDefaultsHelpFormatter) cli.add_argument("--mode", "-m", - choices=["debug", "release"], + choices=["debug", "release", "relwithdebinfo", "minsizerel"], default=getenv("BUILDMODE", default="debug"), help="controls cmake build mode") cli.add_argument("--optimize", "-O", diff --git a/libopenage/engine/engine.cpp b/libopenage/engine/engine.cpp index c3a9985986..9af6d4fe89 100644 --- a/libopenage/engine/engine.cpp +++ b/libopenage/engine/engine.cpp @@ -32,32 +32,28 @@ Engine::Engine(mode mode, // time loop this->time_loop = std::make_shared(); + // game simulation + // this is run in the main thread this->simulation = std::make_shared(this->root_dir, this->cvar_manager, this->time_loop); this->simulation->set_modpacks(mods); + // presenter (optional) if (this->run_mode == mode::FULL) { this->presenter = std::make_shared(this->root_dir, this->simulation, this->time_loop); } + // spawn thread to run time loop this->threads.emplace_back([&]() { this->time_loop->run(); this->time_loop.reset(); }); - this->threads.emplace_back([&]() { - this->simulation->run(); - - this->simulation.reset(); - - if (this->run_mode != mode::FULL) { - this->running = false; - } - }); + // if presenter is used, run it in a separate thread if (this->run_mode == mode::FULL) { this->threads.emplace_back([&]() { this->presenter->run(debug_graphics); @@ -69,13 +65,18 @@ Engine::Engine(mode mode, }); } - log::log(INFO << "Created " << this->threads.size() << " threads" - << " (" << std::jthread::hardware_concurrency() << " available)"); + log::log(INFO << "Using " << this->threads.size() + 1 << " threads " + << "(" << std::jthread::hardware_concurrency() << " available)"); } void Engine::loop() { - while (this->running) { - // TODO + // Run the main game simulation loop: + this->simulation->run(); + + // After stopping, clean up the simulation + this->simulation.reset(); + if (this->run_mode != mode::FULL) { + this->running = false; } }