From e3f4a59d793929fef62c636e9160d620a00eeef3 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Tue, 21 Nov 2017 02:30:19 +1100 Subject: [PATCH] Cleaned up the mess of CVideo references passed around the game initialization process Essentially, we had CVideo arguments being passed down this chain: - game_launcher - free-standing MP initialization functions - campaign_controller - playsingle_controller/playmp_controller - play_controller - game_display - display And likewise down through - game_launcher - editor_controller - editor_display - display With only a minimal number of actual calls along the way. :| There were maybe... two remaining? This removes the CVideo arguments and class members from both chains (except of course, game_launcher. That's where the "real" CVideo object lives). The display class now initializes its CVideo reference from the singleton, which is also used in the very few other places it's needed. I also replaced a check for a null video ptr in show_tooltip() with a faked() check (see src/tooltips.cpp). That seems to make more sense, since CVideo is never null now. --- src/display.cpp | 10 +++---- src/display.hpp | 2 +- src/editor/controller/editor_controller.cpp | 6 ++--- src/editor/controller/editor_controller.hpp | 2 +- src/editor/editor_display.cpp | 6 ++--- src/editor/editor_display.hpp | 2 +- src/editor/editor_main.cpp | 4 +-- src/editor/editor_main.hpp | 2 +- src/game_display.cpp | 10 +++---- src/game_display.hpp | 4 +-- src/game_initialization/multiplayer.cpp | 29 +++++++++------------ src/game_initialization/multiplayer.hpp | 8 +++--- src/game_initialization/playcampaign.cpp | 6 ++--- src/game_initialization/playcampaign.hpp | 6 ++--- src/game_launcher.cpp | 20 +++++++------- src/play_controller.cpp | 14 +++++----- src/play_controller.hpp | 5 ++-- src/playmp_controller.cpp | 5 ++-- src/playmp_controller.hpp | 3 +-- src/playsingle_controller.cpp | 5 ++-- src/playsingle_controller.hpp | 2 +- src/tooltips.cpp | 8 ++---- src/tooltips.hpp | 3 +-- 23 files changed, 72 insertions(+), 90 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 0f94538c222a5..4eb69d9d3209a 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -153,13 +153,13 @@ void display::remove_single_overlay(const map_location& loc, const std::string& } } -display::display(const display_context * dc, CVideo& video, std::weak_ptr wb, reports & reports_object, const config& theme_cfg, const config& level, bool auto_join) : +display::display(const display_context * dc, std::weak_ptr wb, reports & reports_object, const config& theme_cfg, const config& level, bool auto_join) : video2::draw_layering(auto_join), dc_(dc), halo_man_(new halo::manager(*this)), wb_(wb), exclusive_unit_draw_requests_(), - screen_(video), + screen_(CVideo::get_singleton()), currentTeam_(0), dont_show_all_(false), xpos_(0), @@ -236,9 +236,9 @@ display::display(const display_context * dc, CVideo& video, std::weak_ptr wb, + display(const display_context * dc, std::weak_ptr wb, reports & reports_object, const config& theme_cfg, const config& level, bool auto_join=true); virtual ~display(); diff --git a/src/editor/controller/editor_controller.cpp b/src/editor/controller/editor_controller.cpp index 1436e015813c0..f411daa25057d 100644 --- a/src/editor/controller/editor_controller.cpp +++ b/src/editor/controller/editor_controller.cpp @@ -59,17 +59,17 @@ static std::vector saved_windows_; namespace editor { -editor_controller::editor_controller(const config &game_config, CVideo& video) +editor_controller::editor_controller(const config &game_config) : controller_base(game_config) , mouse_handler_base() , quit_confirmation(std::bind(&editor_controller::quit_confirm, this)) , active_menu_(editor::MAP) , reports_(new reports()) - , gui_(new editor_display(*this, video, *reports_, controller_base::get_theme(game_config, "editor"))) + , gui_(new editor_display(*this, *reports_, controller_base::get_theme(game_config, "editor"))) , tods_() , context_manager_(new context_manager(*gui_.get(), game_config_)) , toolkit_(nullptr) - , tooltip_manager_(video) + , tooltip_manager_() , floating_label_manager_(nullptr) , help_manager_(nullptr) , do_quit_(false) diff --git a/src/editor/controller/editor_controller.hpp b/src/editor/controller/editor_controller.hpp index 3c99b076d56e7..49b1297fea30e 100644 --- a/src/editor/controller/editor_controller.hpp +++ b/src/editor/controller/editor_controller.hpp @@ -79,7 +79,7 @@ class editor_controller : public controller_base, * to the map can be retrieved between the main loop's end and the controller's * destruction. */ - editor_controller(const config &game_config, CVideo& video); + explicit editor_controller(const config &game_config); ~editor_controller(); diff --git a/src/editor/editor_display.cpp b/src/editor/editor_display.cpp index 879005ef45207..858f695c64d4c 100644 --- a/src/editor/editor_display.cpp +++ b/src/editor/editor_display.cpp @@ -54,12 +54,12 @@ const display_context * get_dummy_display_context() { // End dummy display context -editor_display::editor_display(editor_controller& controller, CVideo& video, reports& reports_object, const config& theme_cfg) - : display(get_dummy_display_context(), video, std::shared_ptr(), reports_object, theme_cfg, config()) +editor_display::editor_display(editor_controller& controller, reports& reports_object, const config& theme_cfg) + : display(get_dummy_display_context(), std::shared_ptr(), reports_object, theme_cfg, config()) , brush_locations_() , controller_(controller) { - video.clear_screen(); + video().clear_screen(); } void editor_display::add_brush_loc(const map_location& hex) diff --git a/src/editor/editor_display.hpp b/src/editor/editor_display.hpp index 7170a14fde3f0..3db023311dcdd 100644 --- a/src/editor/editor_display.hpp +++ b/src/editor/editor_display.hpp @@ -24,7 +24,7 @@ const display_context * get_dummy_display_context(); class editor_display : public display { public: - editor_display(editor_controller& controller, CVideo& video, reports& reports_object, const config& theme_cfg); + editor_display(editor_controller& controller, reports& reports_object, const config& theme_cfg); bool in_editor() const override { return true; } diff --git a/src/editor/editor_main.cpp b/src/editor/editor_main.cpp index c49f67a688d86..3dbb1261fe84d 100644 --- a/src/editor/editor_main.cpp +++ b/src/editor/editor_main.cpp @@ -25,7 +25,7 @@ lg::log_domain log_editor("editor"); namespace editor { -EXIT_STATUS start(const config& game_conf, CVideo& video, const std::string& filename /* = "" */, +EXIT_STATUS start(const config& game_conf, const std::string& filename /* = "" */, bool take_screenshot /* = false */, const std::string& screenshot_filename /* = "map_screenshot.bmp" */) { EXIT_STATUS e = EXIT_ERROR; @@ -33,7 +33,7 @@ EXIT_STATUS start(const config& game_conf, CVideo& video, const std::string& fil hotkey::scope_changer h_; hotkey::deactivate_all_scopes(); hotkey::set_scope_active(hotkey::SCOPE_EDITOR); - editor_controller editor(game_conf, video); + editor_controller editor(game_conf); if (!filename.empty() && filesystem::file_exists (filename)) { if (filesystem::is_directory(filename)) { editor.context_manager_->set_default_dir(filename); diff --git a/src/editor/editor_main.hpp b/src/editor/editor_main.hpp index 17078e671e9cf..237bfad2600ce 100644 --- a/src/editor/editor_main.hpp +++ b/src/editor/editor_main.hpp @@ -34,6 +34,6 @@ enum EXIT_STATUS { * go back to the titlescreen or quit to desktop altogether) */ -EXIT_STATUS start(const config& game_config, CVideo& video, const std::string& filename = "", bool take_screenshot = false, const std::string& screenshot_filename = "map_screenshot.bmp"); +EXIT_STATUS start(const config& game_config, const std::string& filename = "", bool take_screenshot = false, const std::string& screenshot_filename = "map_screenshot.bmp"); } //end namespace editor diff --git a/src/game_display.cpp b/src/game_display.cpp index 44527ef484c01..a16e32712d241 100644 --- a/src/game_display.cpp +++ b/src/game_display.cpp @@ -62,13 +62,13 @@ std::map game_display::debugHighlights_; */ std::vector footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_); -game_display::game_display(game_board& board, CVideo& video, std::weak_ptr wb, +game_display::game_display(game_board& board, std::weak_ptr wb, reports & reports_object, const tod_manager& tod, const config& theme_cfg, const config& level, bool) : - display(&board, video, wb, reports_object, theme_cfg, level, false), + display(&board, wb, reports_object, theme_cfg, level, false), overlay_map_(), attack_indicator_src_(), attack_indicator_dst_(), @@ -83,17 +83,17 @@ game_display::game_display(game_board& board, CVideo& video, std::weak_ptr(dummy_cfg), dummy_cfg2); static tod_manager dummy_tod(dummy_cfg); static reports rep_; - return new game_display(dummy_board, video, std::shared_ptr(), rep_, dummy_tod, + return new game_display(dummy_board, std::shared_ptr(), rep_, dummy_tod, dummy_cfg, dummy_cfg, true); } diff --git a/src/game_display.hpp b/src/game_display.hpp index 3c767652c150d..ba53b41e14b41 100644 --- a/src/game_display.hpp +++ b/src/game_display.hpp @@ -36,7 +36,7 @@ class game_board; class game_display : public display { public: - game_display(game_board& board, CVideo& video, + game_display(game_board& board, std::weak_ptr wb, reports & reports_object, const tod_manager& tod_manager, @@ -44,7 +44,7 @@ class game_display : public display const config& level, bool dummy=false); - static game_display* create_dummy_display(CVideo& video); + static game_display* create_dummy_display(); ~game_display(); static game_display* get_singleton() diff --git a/src/game_initialization/multiplayer.cpp b/src/game_initialization/multiplayer.cpp index ee87385c060f1..3a3ecc52afaf8 100644 --- a/src/game_initialization/multiplayer.cpp +++ b/src/game_initialization/multiplayer.cpp @@ -50,7 +50,7 @@ static lg::log_domain log_mp("mp/main"); namespace { /** Opens a new server connection and prompts the client for login credentials, if necessary. */ -std::pair open_connection(CVideo& video, std::string host) +std::pair open_connection(std::string host) { DBG_MP << "opening connection" << std::endl; @@ -323,7 +323,7 @@ std::pair open_connection(CVideo& video, std::s gui2::dialogs::mp_login dlg(host, error_message, !((*error)["password_request"].empty())); // Need to show the dialog from the main thread or it won't appear. - events::call_in_main_thread([&dlg, &video]() { dlg.show(); }); + events::call_in_main_thread([&dlg]() { dlg.show(); }); switch(dlg.get_retval()) { //Log in with password @@ -360,16 +360,13 @@ std::pair open_connection(CVideo& video, std::s /** Helper struct to manage the MP workflow arguments. */ struct mp_workflow_helper { - mp_workflow_helper(CVideo& video, const config& gc, saved_game& state, wesnothd_connection* connection, mp::lobby_info* li) - : video(video) - , game_config(gc) + mp_workflow_helper(const config& gc, saved_game& state, wesnothd_connection* connection, mp::lobby_info* li) + : game_config(gc) , state(state) , connection(connection) , lobby_info(li) {} - CVideo& video; - const config& game_config; saved_game& state; @@ -423,7 +420,7 @@ void enter_wait_mode(mp_workflow_helper_ptr helper, int game_id, bool observe) } if(dlg_ok) { - campaign_controller controller(helper->video, helper->state, helper->game_config, game_config_manager::get()->terrain_types()); + campaign_controller controller(helper->state, helper->game_config, game_config_manager::get()->terrain_types()); controller.set_mp_info(campaign_info.get()); controller.play_game(); } @@ -454,7 +451,7 @@ void enter_staging_mode(mp_workflow_helper_ptr helper) } // end connect_engine_ptr, dlg scope if(dlg_ok) { - campaign_controller controller(helper->video, helper->state, helper->game_config, game_config_manager::get()->terrain_types()); + campaign_controller controller(helper->state, helper->game_config, game_config_manager::get()->terrain_types()); controller.set_mp_info(campaign_info.get()); controller.play_game(); } @@ -569,7 +566,7 @@ bool enter_lobby_mode(mp_workflow_helper_ptr helper, const std::vector(video, game_config, state, nullptr, &li); + mp_workflow_helper_ptr workflow_helper = std::make_shared(game_config, state, nullptr, &li); enter_create_mode(workflow_helper); } -void start_local_game_commandline(CVideo& video, const config& game_config, saved_game& state, const commandline_options& cmdline_opts) +void start_local_game_commandline(const config& game_config, saved_game& state, const commandline_options& cmdline_opts) { DBG_MP << "starting local MP game from commandline" << std::endl; @@ -750,7 +747,7 @@ void start_local_game_commandline(CVideo& video, const config& game_config, save unsigned int repeat = (cmdline_opts.multiplayer_repeat) ? *cmdline_opts.multiplayer_repeat : 1; for(unsigned int i = 0; i < repeat; i++){ saved_game state_copy(state); - campaign_controller controller(video, state_copy, game_config, game_config_manager::get()->terrain_types()); + campaign_controller controller(state_copy, game_config, game_config_manager::get()->terrain_types()); controller.play_game(); } } diff --git a/src/game_initialization/multiplayer.hpp b/src/game_initialization/multiplayer.hpp index 68c5a045e87af..d9076750e79e9 100644 --- a/src/game_initialization/multiplayer.hpp +++ b/src/game_initialization/multiplayer.hpp @@ -33,10 +33,9 @@ const size_t max_login_size = 20; /** Starts a multiplayer game in single-user mode. * - * @param video The global display * @param game_config The global, top-level WML configuration for the game */ -void start_local_game(CVideo& video, const config& game_config, +void start_local_game(const config& game_config, saved_game& state); /** Starts a multiplayer game in single-user mode. @@ -44,16 +43,15 @@ void start_local_game(CVideo& video, const config& game_config, * Same parameters as start_local_game plus: * cmdline_opts The commandline options */ -void start_local_game_commandline(CVideo& video, const config& game_config, +void start_local_game_commandline(const config& game_config, saved_game& state, const commandline_options& cmdline_opts); /** Starts a multiplayer game in client mode. * - * @param video The global display * @param game_config The global, top-level WML configuration for the game * @param host The host to connect to. */ -void start_client(CVideo& video, const config& game_config, +void start_client(const config& game_config, saved_game& state, const std::string& host); /** diff --git a/src/game_initialization/playcampaign.cpp b/src/game_initialization/playcampaign.cpp index 211b7fc330e1f..65fdb3c9a9184 100644 --- a/src/game_initialization/playcampaign.cpp +++ b/src/game_initialization/playcampaign.cpp @@ -186,7 +186,7 @@ void campaign_controller::show_carryover_message(playsingle_controller& playcont LEVEL_RESULT campaign_controller::playsingle_scenario(end_level_data &end_level) { - playsingle_controller playcontroller(is_replay_ ? state_.get_replay_starting_pos() : state_.get_starting_pos(), state_, game_config_, tdata_, video_, false); + playsingle_controller playcontroller(is_replay_ ? state_.get_replay_starting_pos() : state_.get_starting_pos(), state_, game_config_, tdata_, false); LOG_NG << "created objects... " << (SDL_GetTicks() - playcontroller.get_ticks()) << "\n"; if(is_replay_) { playcontroller.enable_replay(is_unit_test_); @@ -208,7 +208,7 @@ LEVEL_RESULT campaign_controller::playsingle_scenario(end_level_data &end_level) end_level = playcontroller.get_end_level_data_const(); show_carryover_message(playcontroller, end_level, res); - if(!video_.faked()) + if(!CVideo::get_singleton().faked()) { playcontroller.maybe_linger(); } @@ -221,7 +221,7 @@ LEVEL_RESULT campaign_controller::playmp_scenario(end_level_data &end_level) { playmp_controller playcontroller(state_.get_starting_pos(), state_, - game_config_, tdata_, video_, mp_info_); + game_config_, tdata_, mp_info_); LEVEL_RESULT res = playcontroller.play_scenario(state_.get_starting_pos()); //Check if the player started as mp client and changed to host diff --git a/src/game_initialization/playcampaign.hpp b/src/game_initialization/playcampaign.hpp index b3ef2f609d191..de1e420d24225 100644 --- a/src/game_initialization/playcampaign.hpp +++ b/src/game_initialization/playcampaign.hpp @@ -57,7 +57,6 @@ struct mp_campaign_info class campaign_controller { - CVideo& video_; saved_game& state_; const config& game_config_; const ter_data_cache & tdata_; @@ -65,9 +64,8 @@ class campaign_controller bool is_replay_; mp_campaign_info* mp_info_; public: - campaign_controller(CVideo& video, saved_game& state, const config& game_config, const ter_data_cache & tdata, bool is_unit_test = false) - : video_(video) - , state_(state) + campaign_controller(saved_game& state, const config& game_config, const ter_data_cache & tdata, bool is_unit_test = false) + : state_(state) , game_config_(game_config) , tdata_(tdata) , is_unit_test_(is_unit_test) diff --git a/src/game_launcher.cpp b/src/game_launcher.cpp index 7557c850c4e0a..43e8f12a2de06 100644 --- a/src/game_launcher.cpp +++ b/src/game_launcher.cpp @@ -487,7 +487,7 @@ bool game_launcher::play_test() load_game_config_for_game(state_.classification()); try { - campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types()); + campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types()); ccontroller.play_game(); } catch (savegame::load_game_exception &e) { load_data_.reset(new savegame::load_game_metadata(std::move(e.data_))); @@ -521,7 +521,7 @@ int game_launcher::unit_test() load_game_config_for_game(state_.classification()); try { - campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true); + campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true); LEVEL_RESULT res = ccontroller.play_game(); if (!(res == LEVEL_RESULT::VICTORY) || lg::broke_strict()) { return 1; @@ -547,7 +547,7 @@ int game_launcher::unit_test() } try { - campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true); + campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true); LEVEL_RESULT res = ccontroller.play_replay(); if (!(res == LEVEL_RESULT::VICTORY)) { std::cerr << "Observed failure on replay" << std::endl; @@ -571,7 +571,7 @@ bool game_launcher::play_screenshot_mode() ::init_textdomains(game_config_manager::get()->game_config()); - editor::start(game_config_manager::get()->game_config(), video(), + editor::start(game_config_manager::get()->game_config(), screenshot_map_, true, screenshot_filename_); return false; } @@ -849,10 +849,10 @@ bool game_launcher::play_multiplayer(mp_selection res) cursor::set(cursor::NORMAL); if(res == MP_LOCAL) { - mp::start_local_game(video(), + mp::start_local_game( game_config_manager::get()->game_config(), state_); } else { - mp::start_client(video(), game_config_manager::get()->game_config(), + mp::start_client(game_config_manager::get()->game_config(), state_, multiplayer_server_); multiplayer_server_.clear(); } @@ -912,7 +912,7 @@ bool game_launcher::play_multiplayer_commandline() events::discard_input(); // prevent the "keylogger" effect cursor::set(cursor::NORMAL); - mp::start_local_game_commandline(video(), + mp::start_local_game_commandline( game_config_manager::get()->game_config(), state_, cmdline_opts_); return false; @@ -959,7 +959,7 @@ void game_launcher::launch_game(RELOAD_GAME_DATA reload) }); try { - campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types()); + campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types()); LEVEL_RESULT result = ccontroller.play_game(); // don't show The End for multiplayer scenario // change this if MP campaigns are implemented @@ -986,7 +986,7 @@ void game_launcher::play_replay() { assert(!load_data_); try { - campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types()); + campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types()); ccontroller.play_replay(); } catch (savegame::load_game_exception &e) { load_data_.reset(new savegame::load_game_metadata(std::move(e.data_))); @@ -1004,7 +1004,7 @@ editor::EXIT_STATUS game_launcher::start_editor(const std::string& filename) ::init_textdomains(game_config_manager::get()->game_config()); editor::EXIT_STATUS res = editor::start( - game_config_manager::get()->game_config(), video(), filename); + game_config_manager::get()->game_config(), filename); if(res != editor::EXIT_RELOAD_DATA) return res; diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 9a422cefda824..d8fa81a0292c3 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -132,8 +132,7 @@ static void clear_resources() } play_controller::play_controller(const config& level, saved_game& state_of_game, - const config& game_config, const ter_data_cache& tdata, - CVideo& video, bool skip_replay) + const config& game_config, const ter_data_cache& tdata, bool skip_replay) : controller_base(game_config) , observer() , quit_confirmation() @@ -182,7 +181,7 @@ play_controller::play_controller(const config& level, saved_game& state_of_game, hotkey::deactivate_all_scopes(); hotkey::set_scope_active(hotkey::SCOPE_GAME); try { - init(video, level); + init(level); } catch (...) { clear_resources(); throw; @@ -203,10 +202,9 @@ struct throw_end_level } }; -void play_controller::init(CVideo& video, const config& level) +void play_controller::init(const config& level) { - - gui2::dialogs::loading_screen::display([this, &video, &level]() { + gui2::dialogs::loading_screen::display([this, &level]() { gui2::dialogs::loading_screen::progress(loading_stage::load_level); LOG_NG << "initializing game_state..." << (SDL_GetTicks() - ticks()) << std::endl; @@ -239,7 +237,7 @@ void play_controller::init(CVideo& video, const config& level) LOG_NG << "building terrain rules... " << (SDL_GetTicks() - ticks()) << std::endl; gui2::dialogs::loading_screen::progress(loading_stage::build_terrain); - gui_.reset(new game_display(gamestate().board_, video, whiteboard_manager_, *gamestate().reports_, gamestate().tod_manager_, theme_cfg, level)); + gui_.reset(new game_display(gamestate().board_, whiteboard_manager_, *gamestate().reports_, gamestate().tod_manager_, theme_cfg, level)); map_start_ = map_location(level.child_or_empty("display").child_or_empty("location")); if (!gui_->video().faked()) { if (saved_game_.mp_settings().mp_countdown) @@ -334,7 +332,7 @@ void play_controller::init_managers() { LOG_NG << "initializing managers... " << (SDL_GetTicks() - ticks()) << std::endl; preferences::set_preference_display_settings(); - tooltips_manager_.reset(new tooltips::manager(gui_->video())); + tooltips_manager_.reset(new tooltips::manager()); soundsources_manager_.reset(new soundsource::manager(*gui_)); resources::soundsources = soundsources_manager_.get(); diff --git a/src/play_controller.hpp b/src/play_controller.hpp index f2d0aaceb0880..1a8f145c274c7 100644 --- a/src/play_controller.hpp +++ b/src/play_controller.hpp @@ -77,8 +77,7 @@ class play_controller : public controller_base, public events::observer, public public: play_controller(const config& level, saved_game& state_of_game, const config& game_config, - const ter_data_cache& tdata, - CVideo& video, bool skip_replay); + const ter_data_cache& tdata, bool skip_replay); virtual ~play_controller(); //event handler, overridden from observer @@ -351,7 +350,7 @@ class play_controller : public controller_base, public events::observer, public private: - void init(CVideo& video, const config& level); + void init(const config& level); bool victory_when_enemies_defeated_; bool remove_from_carryover_on_defeat_; diff --git a/src/playmp_controller.cpp b/src/playmp_controller.cpp index 471e73bbd9f3b..e66609cbb84cc 100644 --- a/src/playmp_controller.cpp +++ b/src/playmp_controller.cpp @@ -41,10 +41,9 @@ static lg::log_domain log_engine("engine"); playmp_controller::playmp_controller(const config& level, saved_game& state_of_game, const config& game_config, - const ter_data_cache & tdata, CVideo& video, + const ter_data_cache & tdata, mp_campaign_info* mp_info) - : playsingle_controller(level, state_of_game, game_config, tdata, video, - mp_info && mp_info->skip_replay) + : playsingle_controller(level, state_of_game, game_config, tdata, mp_info && mp_info->skip_replay) , network_processing_stopped_(false) , blindfold_(*gui_, mp_info && mp_info->skip_replay_blindfolded) , mp_info_(mp_info) diff --git a/src/playmp_controller.hpp b/src/playmp_controller.hpp index f77f5abc2cb4e..58a2c43523f31 100644 --- a/src/playmp_controller.hpp +++ b/src/playmp_controller.hpp @@ -25,8 +25,7 @@ class playmp_controller : public playsingle_controller, public syncmp_handler public: playmp_controller(const config& level, saved_game& state_of_game, const config& game_config, - const ter_data_cache & tdata, CVideo& video, - mp_campaign_info* mp_info); + const ter_data_cache & tdata, mp_campaign_info* mp_info); virtual ~playmp_controller(); void maybe_linger() override; diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index c325ffecaa3d5..fad7effc8a379 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -67,9 +67,8 @@ static lg::log_domain log_enginerefac("enginerefac"); playsingle_controller::playsingle_controller(const config& level, saved_game& state_of_game, - const config& game_config, const ter_data_cache & tdata, - CVideo& video, bool skip_replay) - : play_controller(level, state_of_game, game_config, tdata, video, skip_replay) + const config& game_config, const ter_data_cache & tdata, bool skip_replay) + : play_controller(level, state_of_game, game_config, tdata, skip_replay) , cursor_setter_(cursor::NORMAL) , textbox_info_() , replay_sender_(*resources::recorder) diff --git a/src/playsingle_controller.hpp b/src/playsingle_controller.hpp index 1804f1d206221..c053aeaa18726 100644 --- a/src/playsingle_controller.hpp +++ b/src/playsingle_controller.hpp @@ -37,7 +37,7 @@ class playsingle_controller : public play_controller { public: playsingle_controller(const config& level, saved_game& state_of_game, - const config& game_config, const ter_data_cache & tdata, CVideo& video, bool skip_replay); + const config& game_config, const ter_data_cache & tdata, bool skip_replay); virtual ~playsingle_controller(); LEVEL_RESULT play_scenario(const config& level); diff --git a/src/tooltips.cpp b/src/tooltips.cpp index 20c263bfd686f..f1315d4e5e7f6 100644 --- a/src/tooltips.cpp +++ b/src/tooltips.cpp @@ -27,8 +27,6 @@ namespace { -CVideo* video_ = nullptr; - static const int font_size = font::SIZE_NORMAL; static const int text_width = 400; @@ -64,7 +62,7 @@ static void clear_tooltip() static void show_tooltip(const tooltip& tip) { - if(video_ == nullptr) { + if(CVideo::get_singleton().faked()) { return; } @@ -108,10 +106,9 @@ static void show_tooltip(const tooltip& tip) namespace tooltips { -manager::manager(CVideo& video) +manager::manager() { clear_tooltips(); - video_ = &video; } manager::~manager() @@ -119,7 +116,6 @@ manager::~manager() try { clear_tooltips(); } catch (...) {} - video_ = nullptr; } void clear_tooltips() diff --git a/src/tooltips.hpp b/src/tooltips.hpp index 9f33cc03c0546..54cf41dd06f57 100644 --- a/src/tooltips.hpp +++ b/src/tooltips.hpp @@ -17,14 +17,13 @@ #include #include "sdl/surface.hpp" -class CVideo; struct SDL_Rect; namespace tooltips { struct manager { - manager(CVideo& video); + manager(); ~manager(); };