Skip to content

Commit

Permalink
Cleaned up SP initialization function parameters
Browse files Browse the repository at this point in the history
As of f4584b6 the game_config isn't needed in SP initialization anymore, and
enter_connect_mode can be made to return void.
  • Loading branch information
Vultraz authored and GregoryLundberg committed Nov 30, 2017
1 parent 2cbba7e commit b53b69e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
20 changes: 9 additions & 11 deletions src/game_initialization/singleplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/

#include "game_initialization/singleplayer.hpp"

#include "config.hpp"
#include "game_config_manager.hpp"
#include "gui/dialogs/campaign_selection.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/multiplayer/mp_staging.hpp"
Expand All @@ -24,9 +24,9 @@
static lg::log_domain log_engine("engine");
#define ERR_NG LOG_STREAM(err, log_engine)

namespace sp {

bool enter_create_mode(const config& game_config, saved_game& state, jump_to_campaign_info jump_to_campaign)
namespace sp
{
bool enter_create_mode(saved_game& state, jump_to_campaign_info jump_to_campaign)
{
bool configure_canceled = false;

Expand Down Expand Up @@ -92,7 +92,7 @@ bool enter_create_mode(const config& game_config, saved_game& state, jump_to_cam
}

// Canceled difficulty dialog, relaunch the campaign selection dialog
return enter_create_mode(game_config, state, jump_to_campaign);
return enter_create_mode(state, jump_to_campaign);
}

create_eng.prepare_for_era_and_mods();
Expand All @@ -109,14 +109,14 @@ bool enter_create_mode(const config& game_config, saved_game& state, jump_to_cam
return false;
}

configure_canceled = !enter_configure_mode(game_config_manager::get()->game_config(), state, create_eng);
configure_canceled = !enter_configure_mode(state, create_eng);

} while (configure_canceled);

return true;
}

bool enter_configure_mode(const config& game_config, saved_game& state, ng::create_engine& create_eng)
bool enter_configure_mode(saved_game& state, ng::create_engine& create_eng)
{
// We create the config engine here in order to ensure values like use_map_settings are set correctly
// TODO: should this be passed to this function instead of created here?
Expand All @@ -132,17 +132,15 @@ bool enter_configure_mode(const config& game_config, saved_game& state, ng::crea
create_eng.get_parameters();
create_eng.prepare_for_new_level();

enter_connect_mode(game_config, state);
enter_connect_mode(state);

return true;
}

bool enter_connect_mode(const config& /*game_config*/, saved_game& state)
void enter_connect_mode(saved_game& state)
{
ng::connect_engine connect_eng(state, true, nullptr);
connect_eng.start_game();

return true;
}

} // end namespace sp
17 changes: 7 additions & 10 deletions src/game_initialization/singleplayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@

#pragma once

#include "game_launcher.hpp"
#include "create_engine.hpp"
#include "configure_engine.hpp"
#include "connect_engine.hpp"
#include "create_engine.hpp"
#include "game_launcher.hpp"

namespace sp {

bool enter_create_mode(const config& game_config,
saved_game& state, jump_to_campaign_info jump_to);
namespace sp
{
bool enter_create_mode(saved_game& state, jump_to_campaign_info jump_to);

bool enter_configure_mode(const config& game_config,
saved_game& state, ng::create_engine& create_eng);
bool enter_configure_mode(saved_game& state, ng::create_engine& create_eng);

bool enter_connect_mode(const config& game_config,
saved_game& state);
void enter_connect_mode(saved_game& state);

} // end namespace sp
3 changes: 1 addition & 2 deletions src/game_launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ bool game_launcher::new_campaign()
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::SCENARIO;
play_replay_ = false;

return sp::enter_create_mode(game_config_manager::get()->game_config(),
state_, jump_to_campaign_);
return sp::enter_create_mode(state_, jump_to_campaign_);
}

std::string game_launcher::jump_to_campaign_id() const
Expand Down

0 comments on commit b53b69e

Please sign in to comment.