From d23f15f79c85b176ebc80b17e02849fa338f83e6 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Tue, 21 Nov 2017 03:07:23 +1100 Subject: [PATCH] Cleaned up more unnecessary CVideo function arguments and class members * 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. --- src/addon/client.cpp | 5 ++--- src/addon/client.hpp | 4 +--- src/addon/manager_ui.cpp | 12 ++++++------ src/addon/manager_ui.hpp | 10 ++-------- src/controller_base.hpp | 1 - src/editor/editor_main.hpp | 1 - src/game_config_manager.cpp | 2 -- src/game_config_manager.hpp | 5 +---- src/game_initialization/create_engine.cpp | 3 +-- src/game_initialization/create_engine.hpp | 3 --- src/game_initialization/depcheck.cpp | 5 ++--- src/game_initialization/depcheck.hpp | 7 +------ src/game_initialization/multiplayer.hpp | 1 - src/game_initialization/playcampaign.hpp | 1 - src/game_launcher.cpp | 2 +- src/generators/map_create.hpp | 1 - src/generators/map_generator.hpp | 1 - src/gui/core/window_builder.hpp | 1 - src/gui/dialogs/attack_predictions.hpp | 1 - src/gui/dialogs/help_browser.hpp | 1 - src/gui/dialogs/loading_screen.hpp | 1 - src/gui/dialogs/lua_interpreter.cpp | 2 -- src/gui/dialogs/modal_dialog.hpp | 2 -- src/gui/dialogs/modeless_dialog.hpp | 2 -- src/gui/dialogs/multiplayer/lobby.cpp | 6 +++--- src/gui/dialogs/multiplayer/mp_create_game.cpp | 2 +- src/gui/dialogs/outro.hpp | 2 -- src/gui/dialogs/statistics_dialog.hpp | 1 - src/gui/dialogs/terrain_layers.hpp | 1 - src/gui/dialogs/title_screen.cpp | 4 ++-- src/gui/dialogs/tooltip.hpp | 1 - src/hotkey/hotkey_item.hpp | 1 - src/play_controller.cpp | 2 +- src/preferences/display.hpp | 2 +- src/savegame.cpp | 5 ++--- src/savegame.hpp | 4 +--- src/scripting/application_lua_kernel.cpp | 1 - src/scripting/application_lua_kernel.hpp | 1 - src/scripting/game_lua_kernel.hpp | 1 - src/scripting/lua_gui2.cpp | 2 -- src/scripting/lua_gui2.hpp | 1 - src/scripting/lua_kernel_base.hpp | 1 - src/wesnoth.cpp | 3 +-- src/wml_exception.hpp | 2 -- 44 files changed, 29 insertions(+), 88 deletions(-) diff --git a/src/addon/client.cpp b/src/addon/client.cpp index 09586475f6d18..1734c3a95f41c 100644 --- a/src/addon/client.cpp +++ b/src/addon/client.cpp @@ -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) diff --git a/src/addon/client.hpp b/src/addon/client.hpp index 5a389b2ed4f5f..9903852c6910b 100644 --- a/src/addon/client.hpp +++ b/src/addon/client.hpp @@ -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. @@ -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_; diff --git a/src/addon/manager_ui.cpp b/src/addon/manager_ui.cpp index 0ca8a4c607a48..675e3d4f58cf1 100644 --- a/src/addon/manager_ui.cpp +++ b/src/addon/manager_ui.cpp @@ -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); @@ -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. @@ -244,7 +244,7 @@ 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: @@ -252,14 +252,14 @@ bool manage_addons(CVideo& v) } } -bool ad_hoc_addon_fetch_session(CVideo& v, const std::vector& addon_ids) +bool ad_hoc_addon_fetch_session(const std::vector& 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; diff --git a/src/addon/manager_ui.hpp b/src/addon/manager_ui.hpp index 1b6a9de9c5461..30aa5dbaf51eb 100644 --- a/src/addon/manager_ui.hpp +++ b/src/addon/manager_ui.hpp @@ -18,26 +18,20 @@ #include #include -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& addon_ids); +bool ad_hoc_addon_fetch_session(const std::vector& addon_ids); diff --git a/src/controller_base.hpp b/src/controller_base.hpp index 850309f33f819..98b8427884952 100644 --- a/src/controller_base.hpp +++ b/src/controller_base.hpp @@ -42,7 +42,6 @@ #include "quit_confirmation.hpp" #include "video.hpp" -class CVideo; class display; class plugins_context; diff --git a/src/editor/editor_main.hpp b/src/editor/editor_main.hpp index 237bfad2600ce..9e74f67ecbfde 100644 --- a/src/editor/editor_main.hpp +++ b/src/editor/editor_main.hpp @@ -17,7 +17,6 @@ #include class config; -class CVideo; namespace editor { diff --git a/src/game_config_manager.cpp b/src/game_config_manager.cpp index c901d0bfaa599..6324849cb414a 100644 --- a/src/game_config_manager.cpp +++ b/src/game_config_manager.cpp @@ -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_(), diff --git a/src/game_config_manager.hpp b/src/game_config_manager.hpp index 877d99c6dc1ae..f7b9b8cef4ea9 100644 --- a/src/game_config_manager.hpp +++ b/src/game_config_manager.hpp @@ -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 { @@ -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_; diff --git a/src/game_initialization/create_engine.cpp b/src/game_initialization/create_engine.cpp index 38e3e6a1996c1..a5f368cd2d8c8 100644 --- a/src/game_initialization/create_engine.cpp +++ b/src/game_initialization/create_engine.cpp @@ -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_() @@ -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_, diff --git a/src/game_initialization/create_engine.hpp b/src/game_initialization/create_engine.hpp index 341cb703c5f35..82a3872326daf 100644 --- a/src/game_initialization/create_engine.hpp +++ b/src/game_initialization/create_engine.hpp @@ -26,7 +26,6 @@ #include #include -class CVideo; class saved_game; class gamemap; @@ -450,8 +449,6 @@ class create_engine saved_game& state_; - CVideo& video_; - // Never nullptr std::unique_ptr dependency_manager_; diff --git a/src/game_initialization/depcheck.cpp b/src/game_initialization/depcheck.cpp index 71deab819685f..338d22a716e36 100644 --- a/src/game_initialization/depcheck.cpp +++ b/src/game_initialization/depcheck.cpp @@ -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_() diff --git a/src/game_initialization/depcheck.hpp b/src/game_initialization/depcheck.hpp index f1db7c0e29657..4e7443bf38233 100644 --- a/src/game_initialization/depcheck.hpp +++ b/src/game_initialization/depcheck.hpp @@ -20,8 +20,6 @@ #include "gettext.hpp" #include "utils/make_enum.hpp" -class CVideo; - namespace ng { @@ -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 @@ -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_; diff --git a/src/game_initialization/multiplayer.hpp b/src/game_initialization/multiplayer.hpp index d9076750e79e9..cb620460fdbb1 100644 --- a/src/game_initialization/multiplayer.hpp +++ b/src/game_initialization/multiplayer.hpp @@ -20,7 +20,6 @@ #include "scripting/plugins/context.hpp" class config; -class CVideo; class wesnothd_connection; namespace mp { diff --git a/src/game_initialization/playcampaign.hpp b/src/game_initialization/playcampaign.hpp index de1e420d24225..4761f86bd0e81 100644 --- a/src/game_initialization/playcampaign.hpp +++ b/src/game_initialization/playcampaign.hpp @@ -24,7 +24,6 @@ #include #include -class CVideo; class saved_game; class terrain_type_data; class team; diff --git a/src/game_launcher.cpp b/src/game_launcher.cpp index 43e8f12a2de06..58643a6f2ff84 100644 --- a/src/game_launcher.cpp +++ b/src/game_launcher.cpp @@ -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 load_data = std::move(load_data_); load.data() = std::move(*load_data); diff --git a/src/generators/map_create.hpp b/src/generators/map_create.hpp index 4021705ae4b0f..cd40152a24d7e 100644 --- a/src/generators/map_create.hpp +++ b/src/generators/map_create.hpp @@ -16,7 +16,6 @@ class config; class map_generator; -class CVideo; #include diff --git a/src/generators/map_generator.hpp b/src/generators/map_generator.hpp index 3a6a4eba7dab5..2df96d3633f6f 100644 --- a/src/generators/map_generator.hpp +++ b/src/generators/map_generator.hpp @@ -17,7 +17,6 @@ #pragma once class config; -class CVideo; #include "exceptions.hpp" #include "map/location.hpp" diff --git a/src/gui/core/window_builder.hpp b/src/gui/core/window_builder.hpp index d64b52a08a56f..41adf449eda50 100644 --- a/src/gui/core/window_builder.hpp +++ b/src/gui/core/window_builder.hpp @@ -22,7 +22,6 @@ #include "utils/functional.hpp" class config; -class CVideo; namespace gui2 { diff --git a/src/gui/dialogs/attack_predictions.hpp b/src/gui/dialogs/attack_predictions.hpp index 6a066ddcf9bcd..f94b9bdaecb01 100644 --- a/src/gui/dialogs/attack_predictions.hpp +++ b/src/gui/dialogs/attack_predictions.hpp @@ -19,7 +19,6 @@ #include "units/map.hpp" class battle_context; -class CVideo; struct battle_context_unit_stats; struct combatant; diff --git a/src/gui/dialogs/help_browser.hpp b/src/gui/dialogs/help_browser.hpp index 9258bf8282d40..74cab126f7738 100644 --- a/src/gui/dialogs/help_browser.hpp +++ b/src/gui/dialogs/help_browser.hpp @@ -17,7 +17,6 @@ #include "gui/dialogs/modal_dialog.hpp" class config; -class CVideo; namespace gui2 { diff --git a/src/gui/dialogs/loading_screen.hpp b/src/gui/dialogs/loading_screen.hpp index aa090a85d8d52..8c1bb45a73de8 100644 --- a/src/gui/dialogs/loading_screen.hpp +++ b/src/gui/dialogs/loading_screen.hpp @@ -20,7 +20,6 @@ #include #include -class CVideo; namespace boost { class thread; diff --git a/src/gui/dialogs/lua_interpreter.cpp b/src/gui/dialogs/lua_interpreter.cpp index 7c1c905531110..6658ca0463962 100644 --- a/src/gui/dialogs/lua_interpreter.cpp +++ b/src/gui/dialogs/lua_interpreter.cpp @@ -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 diff --git a/src/gui/dialogs/modal_dialog.hpp b/src/gui/dialogs/modal_dialog.hpp index 6cb6993f1358e..4437fb639bef7 100644 --- a/src/gui/dialogs/modal_dialog.hpp +++ b/src/gui/dialogs/modal_dialog.hpp @@ -21,8 +21,6 @@ #include #include -class CVideo; - namespace gui2 { namespace dialogs diff --git a/src/gui/dialogs/modeless_dialog.hpp b/src/gui/dialogs/modeless_dialog.hpp index 48d9017aeab32..26df2d3bccfc2 100644 --- a/src/gui/dialogs/modeless_dialog.hpp +++ b/src/gui/dialogs/modeless_dialog.hpp @@ -17,8 +17,6 @@ #include #include -class CVideo; - namespace gui2 { diff --git a/src/gui/dialogs/multiplayer/lobby.cpp b/src/gui/dialogs/multiplayer/lobby.cpp index 708b52808cb2b..705d81af48283 100644 --- a/src/gui/dialogs/multiplayer/lobby.cpp +++ b/src/gui/dialogs/multiplayer/lobby.cpp @@ -230,7 +230,7 @@ std::string colorize(const std::string& str, const std::string& color) return (formatter() << "" << str << "").str(); } -bool handle_addon_requirements_gui(CVideo& v, const std::vector& reqs, mp::game_info::ADDON_REQ addon_outcome) +bool handle_addon_requirements_gui(const std::vector& reqs, mp::game_info::ADDON_REQ addon_outcome) { if(addon_outcome == mp::game_info::CANNOT_SATISFY) { std::string e_title = _("Incompatible User-made Content."); @@ -269,7 +269,7 @@ bool handle_addon_requirements_gui(CVideo& v, const std::vectorgame_config()); - if(manage_addons(w.video())) { + if(manage_addons()) { game_config_manager::get()->reload_changed_game_config(); } }); diff --git a/src/gui/dialogs/tooltip.hpp b/src/gui/dialogs/tooltip.hpp index bd6348098c2a2..b34e27a4a1ab5 100644 --- a/src/gui/dialogs/tooltip.hpp +++ b/src/gui/dialogs/tooltip.hpp @@ -17,7 +17,6 @@ #include #include -class CVideo; class t_string; struct point; diff --git a/src/hotkey/hotkey_item.hpp b/src/hotkey/hotkey_item.hpp index 8eacfcc9e0445..f32e23914d9f0 100644 --- a/src/hotkey/hotkey_item.hpp +++ b/src/hotkey/hotkey_item.hpp @@ -22,7 +22,6 @@ #include class config; -class CVideo; namespace hotkey { /* forward declarations */ diff --git a/src/play_controller.cpp b/src/play_controller.cpp index d8fa81a0292c3..9e817efa73475 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -873,7 +873,7 @@ void play_controller::save_map() void play_controller::load_game() { - savegame::loadgame load(gui_->video(), game_config_, saved_game_); + savegame::loadgame load(game_config_, saved_game_); load.load_game_ingame(); } diff --git a/src/preferences/display.hpp b/src/preferences/display.hpp index 41219856c9910..abe633e9e0cbe 100644 --- a/src/preferences/display.hpp +++ b/src/preferences/display.hpp @@ -16,7 +16,7 @@ class config; class display; -class CVideo; + #include namespace preferences { diff --git a/src/savegame.cpp b/src/savegame.cpp index edd243f58966c..7bf8bbbef3c19 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -77,9 +77,8 @@ void clean_saves(const std::string& label) } } -loadgame::loadgame(CVideo& video, const config& game_config, saved_game& gamestate) +loadgame::loadgame(const config& game_config, saved_game& gamestate) : game_config_(game_config) - , video_(video) , gamestate_(gamestate) , load_data_() {} @@ -119,7 +118,7 @@ bool loadgame::show_difficulty_dialog() // throws a "load_game_exception" to signal a resulting load game request. bool loadgame::load_game_ingame() { - if (video_.faked()) { + if(CVideo::get_singleton().faked()) { return false; } diff --git a/src/savegame.hpp b/src/savegame.hpp index e34193fe71690..dd974ab04e128 100644 --- a/src/savegame.hpp +++ b/src/savegame.hpp @@ -25,7 +25,6 @@ class config_writer; class game_display; class saved_game; -class CVideo; class version_info; namespace savegame { @@ -98,7 +97,7 @@ class load_game_exception class loadgame { public: - loadgame(CVideo& video, const config& game_config, saved_game& gamestate); + loadgame(const config& game_config, saved_game& gamestate); virtual ~loadgame() {} /* In any of the following three function, a bool value of false indicates @@ -136,7 +135,6 @@ class loadgame void copy_era(config& cfg); const config& game_config_; - CVideo& video_; saved_game& gamestate_; /** Primary output information. */ diff --git a/src/scripting/application_lua_kernel.cpp b/src/scripting/application_lua_kernel.cpp index 23192e91537e3..172c8b285370f 100644 --- a/src/scripting/application_lua_kernel.cpp +++ b/src/scripting/application_lua_kernel.cpp @@ -53,7 +53,6 @@ #include "lua/lua.h" #include "lua/luaconf.h" -class CVideo; struct lua_State; static lg::log_domain log_scripting_lua("scripting/lua"); diff --git a/src/scripting/application_lua_kernel.hpp b/src/scripting/application_lua_kernel.hpp index a2876fa05c979..73e5e069faab9 100644 --- a/src/scripting/application_lua_kernel.hpp +++ b/src/scripting/application_lua_kernel.hpp @@ -21,7 +21,6 @@ #include #include -class CVideo; struct lua_State; class application_lua_kernel : public lua_kernel_base { diff --git a/src/scripting/game_lua_kernel.hpp b/src/scripting/game_lua_kernel.hpp index d2239697f9cc7..a789c63e6d102 100644 --- a/src/scripting/game_lua_kernel.hpp +++ b/src/scripting/game_lua_kernel.hpp @@ -22,7 +22,6 @@ #include // for string class config; -class CVideo; class unit; class vconfig; namespace ai { class engine_lua; } diff --git a/src/scripting/lua_gui2.cpp b/src/scripting/lua_gui2.cpp index 6b0765fcf7e24..84c8b6709e367 100644 --- a/src/scripting/lua_gui2.cpp +++ b/src/scripting/lua_gui2.cpp @@ -68,8 +68,6 @@ #include "lua/lauxlib.h" // for luaL_checkinteger, etc #include "lua/lua.h" // for lua_setfield, etc -class CVideo; - static lg::log_domain log_scripting_lua("scripting/lua"); #define ERR_LUA LOG_STREAM(err, log_scripting_lua) diff --git a/src/scripting/lua_gui2.hpp b/src/scripting/lua_gui2.hpp index 5c304ec4f69dd..5e30810f2bd9c 100644 --- a/src/scripting/lua_gui2.hpp +++ b/src/scripting/lua_gui2.hpp @@ -15,7 +15,6 @@ #pragma once struct lua_State; -class CVideo; class lua_kernel_base; class vconfig; class game_data; diff --git a/src/scripting/lua_kernel_base.hpp b/src/scripting/lua_kernel_base.hpp index f9393658d39f8..20b7455820b3e 100644 --- a/src/scripting/lua_kernel_base.hpp +++ b/src/scripting/lua_kernel_base.hpp @@ -21,7 +21,6 @@ #include struct lua_State; -class CVideo; class config; class lua_kernel_base { diff --git a/src/wesnoth.cpp b/src/wesnoth.cpp index b3718359843a8..c11476428f0fb 100644 --- a/src/wesnoth.cpp +++ b/src/wesnoth.cpp @@ -647,8 +647,7 @@ static int do_gameloop(const std::vector& args) gui2::init(); const gui2::event::manager gui_event_manager; - game_config_manager config_manager(cmdline_opts, game->video(), - game->jump_to_editor()); + game_config_manager config_manager(cmdline_opts, game->jump_to_editor()); gui2::dialogs::loading_screen::display([&res, &config_manager]() { gui2::dialogs::loading_screen::progress(loading_stage::load_config); diff --git a/src/wml_exception.hpp b/src/wml_exception.hpp index 1b42bf030b8a0..93104c5a60fa6 100644 --- a/src/wml_exception.hpp +++ b/src/wml_exception.hpp @@ -25,8 +25,6 @@ #include -class CVideo; - /** * The macro to use for the validation of WML *