Skip to content

Commit

Permalink
MP Manager: used an optional for host parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Feb 7, 2021
1 parent fa95eb7 commit 1f7a0e2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/game_initialization/multiplayer.cpp
Expand Up @@ -48,6 +48,7 @@
#include <fstream>
#include <functional>
#include <future>
#include <optional>
#include <thread>

static lg::log_domain log_mp("mp/main");
Expand All @@ -68,7 +69,7 @@ class mp_manager
// Declare this as a friend to allow direct access to enter_create_mode
friend void mp::start_local_game();

mp_manager(const std::string& host);
mp_manager(const std::optional<std::string> host);

~mp_manager()
{
Expand Down Expand Up @@ -151,7 +152,7 @@ class mp_manager
}
};

mp_manager::mp_manager(const std::string& host)
mp_manager::mp_manager(const std::optional<std::string> host)
: network_worker()
, stop(false)
, connection(nullptr)
Expand All @@ -164,9 +165,9 @@ mp_manager::mp_manager(const std::string& host)

state.classification().campaign_type = game_classification::CAMPAIGN_TYPE::MULTIPLAYER;

if(!host.empty()) {
if(host) {
gui2::dialogs::loading_screen::display([&]() {
connection = open_connection(host);
connection = open_connection(*host);

// If for whatever reason our connection is null at this point (dismissing the password prompt, for
// instance), treat it as a normal condition and exit. Any actual error conditions throw exceptions
Expand Down Expand Up @@ -724,7 +725,7 @@ void start_local_game()

preferences::set_message_private(false);

mp_manager("").enter_create_mode();
mp_manager(std::nullopt).enter_create_mode();
}

void start_local_game_commandline(const commandline_options& cmdline_opts)
Expand Down

0 comments on commit 1f7a0e2

Please sign in to comment.