Skip to content

Commit

Permalink
Cleaned up more unnecessary CVideo function arguments and class members
Browse files Browse the repository at this point in the history
* Dropped unused CVideo class member references.
* Replaced the lone usecase of the CVideo member in loadgame with the singleton and removed said member.
* Removed CVideo references from a bunch of addon management functions.
* Cleaned up a *lot* of now-unnecessary forward CVideo declarations.
  • Loading branch information
Vultraz authored and GregoryLundberg committed Nov 30, 2017
1 parent c0749a9 commit d23f15f
Show file tree
Hide file tree
Showing 44 changed files with 29 additions and 88 deletions.
5 changes: 2 additions & 3 deletions src/addon/client.cpp
Expand Up @@ -38,9 +38,8 @@ static lg::log_domain log_addons_client("addons-client");

using gui2::dialogs::network_transmission;

addons_client::addons_client(CVideo& v, const std::string& address)
: v_(v)
, addr_(address)
addons_client::addons_client(const std::string& address)
: addr_(address)
, host_()
, port_()
, conn_(nullptr)
Expand Down
4 changes: 1 addition & 3 deletions src/addon/client.hpp
Expand Up @@ -47,10 +47,9 @@ class addons_client
/**
* Constructor.
*
* @param v Target for UI rendering for the progress dialog.
* @param address Add-ons server host address (i.e. localhost:15999).
*/
addons_client(CVideo& v, const std::string& address);
explicit addons_client(const std::string& address);

/**
* Try to establish a connection to the add-ons server.
Expand Down Expand Up @@ -119,7 +118,6 @@ class addons_client
bool delete_remote_addon(const std::string& id, std::string& response_message);

private:
CVideo& v_;
std::string addr_;
std::string host_;
std::string port_;
Expand Down
12 changes: 6 additions & 6 deletions src/addon/manager_ui.cpp
Expand Up @@ -63,14 +63,14 @@ bool get_addons_list(addons_client& client, addons_list& list)
return true;
}

bool addons_manager_ui(CVideo& v, const std::string& remote_address)
bool addons_manager_ui(const std::string& remote_address)
{
bool need_wml_cache_refresh = false;

preferences::set_campaign_server(remote_address);

try {
addons_client client(v, remote_address);
addons_client client(remote_address);
client.connect();

gui2::dialogs::addon_manager dlg(client);
Expand Down Expand Up @@ -225,7 +225,7 @@ bool uninstall_local_addons()

} // end anonymous namespace

bool manage_addons(CVideo& v)
bool manage_addons()
{
static const int addon_download = 0;
// NOTE: the following two values are also known by WML, so don't change them.
Expand All @@ -244,22 +244,22 @@ bool manage_addons(CVideo& v)

switch(res) {
case addon_download:
return addons_manager_ui(v, host_name);
return addons_manager_ui(host_name);
case addon_uninstall:
return uninstall_local_addons();
default:
return false;
}
}

bool ad_hoc_addon_fetch_session(CVideo& v, const std::vector<std::string>& addon_ids)
bool ad_hoc_addon_fetch_session(const std::vector<std::string>& addon_ids)
{
std::string remote_address = preferences::campaign_server();

// These exception handlers copied from addon_manager_ui fcn above.
try {

addons_client client(v, remote_address);
addons_client client(remote_address);
client.connect();

addons_list addons;
Expand Down
10 changes: 2 additions & 8 deletions src/addon/manager_ui.hpp
Expand Up @@ -18,26 +18,20 @@
#include <string>
#include <vector>

class display;
class CVideo;

/**
* Shows the add-ons server connection dialog, for access to the various management front-ends.
*
* @param v Target for UI rendering.
*
* @return @a true when one or more add-ons have been successfully installed or
* removed, thus requiring a local WML cache refresh. @a false otherwise.
*/
bool manage_addons(CVideo& v);
bool manage_addons();

/**
* Conducts an ad-hoc add-ons server connection to download an add-on with a particular id and all
* it's dependencies. Launches gui dialogs when issues arise.
*
* @param v Target for UI rendering.
* @param addon_ids The ids of the target add-on.
*
* @return @a true when we successfully installed the target (possibly the user chose to ignore failures)
*/
bool ad_hoc_addon_fetch_session(CVideo& v, const std::vector<std::string>& addon_ids);
bool ad_hoc_addon_fetch_session(const std::vector<std::string>& addon_ids);
1 change: 0 additions & 1 deletion src/controller_base.hpp
Expand Up @@ -42,7 +42,6 @@
#include "quit_confirmation.hpp"
#include "video.hpp"

class CVideo;
class display;
class plugins_context;

Expand Down
1 change: 0 additions & 1 deletion src/editor/editor_main.hpp
Expand Up @@ -17,7 +17,6 @@
#include <string>

class config;
class CVideo;

namespace editor {

Expand Down
2 changes: 0 additions & 2 deletions src/game_config_manager.cpp
Expand Up @@ -45,10 +45,8 @@ static game_config_manager * singleton;

game_config_manager::game_config_manager(
const commandline_options& cmdline_opts,
CVideo& video,
const bool jump_to_editor) :
cmdline_opts_(cmdline_opts),
video_(video),
jump_to_editor_(jump_to_editor),
game_config_(),
old_defines_map_(),
Expand Down
5 changes: 1 addition & 4 deletions src/game_config_manager.hpp
Expand Up @@ -19,15 +19,13 @@
#include "filesystem.hpp"
#include "terrain/type_data.hpp"

class CVideo;
class config;
class game_classification;

class game_config_manager
{
public:
game_config_manager(const commandline_options& cmdline_opts,
CVideo& video, const bool jump_to_editor);
game_config_manager(const commandline_options& cmdline_opts, const bool jump_to_editor);
~game_config_manager();
enum FORCE_RELOAD_CONFIG
{
Expand Down Expand Up @@ -68,7 +66,6 @@ class game_config_manager
void set_unit_data();

const commandline_options& cmdline_opts_;
CVideo& video_;
const bool jump_to_editor_;

config game_config_;
Expand Down
3 changes: 1 addition & 2 deletions src/game_initialization/create_engine.cpp
Expand Up @@ -239,7 +239,6 @@ create_engine::create_engine(saved_game& state)
, eras_()
, mods_()
, state_(state)
, video_(CVideo::get_singleton())
, dependency_manager_(nullptr)
, generator_(nullptr)
, selected_campaign_difficulty_()
Expand Down Expand Up @@ -267,7 +266,7 @@ create_engine::create_engine(saved_game& state)

// Initialize dependency_manager_ after refreshing game config.
dependency_manager_.reset(new depcheck::manager(
game_config_manager::get()->game_config(), type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER, video_));
game_config_manager::get()->game_config(), type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER));

// TODO: the editor dir is already configurable, is the preferences value
filesystem::get_files_in_dir(filesystem::get_user_data_dir() + "/editor/maps", &user_map_names_,
Expand Down
3 changes: 0 additions & 3 deletions src/game_initialization/create_engine.hpp
Expand Up @@ -26,7 +26,6 @@
#include <utility>
#include <cctype>

class CVideo;
class saved_game;
class gamemap;

Expand Down Expand Up @@ -450,8 +449,6 @@ class create_engine

saved_game& state_;

CVideo& video_;

// Never nullptr
std::unique_ptr<depcheck::manager> dependency_manager_;

Expand Down
5 changes: 2 additions & 3 deletions src/game_initialization/depcheck.cpp
Expand Up @@ -55,9 +55,8 @@ namespace ng
{
namespace depcheck
{
manager::manager(const config& gamecfg, bool mp, CVideo& video)
: video_(video)
, depinfo_()
manager::manager(const config& gamecfg, bool mp)
: depinfo_()
, era_()
, scenario_()
, mods_()
Expand Down
7 changes: 1 addition & 6 deletions src/game_initialization/depcheck.hpp
Expand Up @@ -20,8 +20,6 @@
#include "gettext.hpp"
#include "utils/make_enum.hpp"

class CVideo;

namespace ng
{

Expand Down Expand Up @@ -54,7 +52,7 @@ MAKE_ENUM(component_availability,
class manager
{
public:
manager(const config& gamecfg, bool mp, CVideo& video);
manager(const config& gamecfg, bool mp);

/**
* Tries to set the selected era
Expand Down Expand Up @@ -187,9 +185,6 @@ class manager
bool operator !=(const elem& e) const { return !(*this == e); }
};

/** the screen to display dialogs on */
CVideo& video_;

/** holds all required info about the components and their dependencies */
config depinfo_;

Expand Down
1 change: 0 additions & 1 deletion src/game_initialization/multiplayer.hpp
Expand Up @@ -20,7 +20,6 @@
#include "scripting/plugins/context.hpp"

class config;
class CVideo;
class wesnothd_connection;
namespace mp {

Expand Down
1 change: 0 additions & 1 deletion src/game_initialization/playcampaign.hpp
Expand Up @@ -24,7 +24,6 @@
#include <set>
#include <string>

class CVideo;
class saved_game;
class terrain_type_data;
class team;
Expand Down
2 changes: 1 addition & 1 deletion src/game_launcher.cpp
Expand Up @@ -619,7 +619,7 @@ bool game_launcher::load_game()

DBG_GENERAL << "Current campaign type: " << state_.classification().campaign_type << std::endl;

savegame::loadgame load(video(), game_config_manager::get()->game_config(), state_);
savegame::loadgame load(game_config_manager::get()->game_config(), state_);
if (load_data_) {
std::unique_ptr<savegame::load_game_metadata> load_data = std::move(load_data_);
load.data() = std::move(*load_data);
Expand Down
1 change: 0 additions & 1 deletion src/generators/map_create.hpp
Expand Up @@ -16,7 +16,6 @@

class config;
class map_generator;
class CVideo;

#include <string>

Expand Down
1 change: 0 additions & 1 deletion src/generators/map_generator.hpp
Expand Up @@ -17,7 +17,6 @@
#pragma once

class config;
class CVideo;

#include "exceptions.hpp"
#include "map/location.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/gui/core/window_builder.hpp
Expand Up @@ -22,7 +22,6 @@
#include "utils/functional.hpp"

class config;
class CVideo;

namespace gui2
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/attack_predictions.hpp
Expand Up @@ -19,7 +19,6 @@
#include "units/map.hpp"

class battle_context;
class CVideo;

struct battle_context_unit_stats;
struct combatant;
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/help_browser.hpp
Expand Up @@ -17,7 +17,6 @@
#include "gui/dialogs/modal_dialog.hpp"

class config;
class CVideo;

namespace gui2
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/loading_screen.hpp
Expand Up @@ -20,7 +20,6 @@
#include <vector>
#include <atomic>

class CVideo;
namespace boost
{
class thread;
Expand Down
2 changes: 0 additions & 2 deletions src/gui/dialogs/lua_interpreter.cpp
Expand Up @@ -57,8 +57,6 @@ static lg::log_domain log_lua_int("lua/interpreter");
#define WRN_LUA LOG_STREAM(warn, log_lua_int)
#define ERR_LUA LOG_STREAM(err, log_lua_int)

class CVideo;

namespace gui2
{
namespace dialogs
Expand Down
2 changes: 0 additions & 2 deletions src/gui/dialogs/modal_dialog.hpp
Expand Up @@ -21,8 +21,6 @@
#include <string>
#include <vector>

class CVideo;

namespace gui2
{
namespace dialogs
Expand Down
2 changes: 0 additions & 2 deletions src/gui/dialogs/modeless_dialog.hpp
Expand Up @@ -17,8 +17,6 @@
#include <memory>
#include <string>

class CVideo;

namespace gui2
{

Expand Down
6 changes: 3 additions & 3 deletions src/gui/dialogs/multiplayer/lobby.cpp
Expand Up @@ -230,7 +230,7 @@ std::string colorize(const std::string& str, const std::string& color)
return (formatter() << "<span color=\"" << color << "\">" << str << "</span>").str();
}

bool handle_addon_requirements_gui(CVideo& v, const std::vector<mp::game_info::required_addon>& reqs, mp::game_info::ADDON_REQ addon_outcome)
bool handle_addon_requirements_gui(const std::vector<mp::game_info::required_addon>& reqs, mp::game_info::ADDON_REQ addon_outcome)
{
if(addon_outcome == mp::game_info::CANNOT_SATISFY) {
std::string e_title = _("Incompatible User-made Content.");
Expand Down Expand Up @@ -269,7 +269,7 @@ bool handle_addon_requirements_gui(CVideo& v, const std::vector<mp::game_info::r

if(gui2::show_message(e_title, err_msg, message::yes_no_buttons, true) == gui2::window::OK) {
// Begin download session
ad_hoc_addon_fetch_session(v, needs_download);
ad_hoc_addon_fetch_session(needs_download);

return true;
}
Expand Down Expand Up @@ -954,7 +954,7 @@ void mp_lobby::enter_game(const mp::game_info& game, JOIN_MODE mode)
return;
}

if(!handle_addon_requirements_gui(window.video(), game.required_addons, game.addons_outcome)) {
if(!handle_addon_requirements_gui(game.required_addons, game.addons_outcome)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/multiplayer/mp_create_game.cpp
Expand Up @@ -782,7 +782,7 @@ void mp_create_game::update_map_settings(window& window)

void mp_create_game::load_game_callback(window& window)
{
savegame::loadgame load(window.video(), cfg_, create_engine_.get_state());
savegame::loadgame load(cfg_, create_engine_.get_state());

if(!load.load_multiplayer_game()) {
return;
Expand Down
2 changes: 0 additions & 2 deletions src/gui/dialogs/outro.hpp
Expand Up @@ -16,8 +16,6 @@

#include "gui/dialogs/modal_dialog.hpp"

class CVideo;

namespace gui2
{
namespace dialogs
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/statistics_dialog.hpp
Expand Up @@ -16,7 +16,6 @@
#include "gui/dialogs/modal_dialog.hpp"
#include "statistics.hpp"

class CVideo;
class team;

namespace gui2
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/terrain_layers.hpp
Expand Up @@ -16,7 +16,6 @@
#include "gui/dialogs/modal_dialog.hpp"
#include "terrain/builder.hpp"

class CVideo;
class display;

namespace gui2
Expand Down

0 comments on commit d23f15f

Please sign in to comment.