From 4e6f50f87cf09fce1ea996c3145739c3e9156490 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Mon, 20 Nov 2017 21:06:45 +1100 Subject: [PATCH] Fix Travis GCC warnings for f2b31ba082e1 This also removes a bunch of unnecessary CVideo arguments from various savegame functions that emerged as I cleaned up the unused parameters. savegame::save_game did take a CVideo pointer that did look like it was intended to be a sort of do-show-dialog flag, but since that parameter was never passed as null, I removed it. --- src/game_initialization/playcampaign.cpp | 4 +- src/game_launcher.cpp | 2 +- src/gui/dialogs/title_screen.cpp | 8 ++-- src/menu_events.cpp | 4 +- src/play_controller.cpp | 12 +++--- src/playmp_controller.cpp | 2 +- src/playsingle_controller.cpp | 2 +- src/savegame.cpp | 49 ++++++++++++------------ src/savegame.hpp | 19 +++++---- 9 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/game_initialization/playcampaign.cpp b/src/game_initialization/playcampaign.cpp index 604deb22deeab..211b7fc330e1f 100644 --- a/src/game_initialization/playcampaign.cpp +++ b/src/game_initialization/playcampaign.cpp @@ -327,7 +327,7 @@ LEVEL_RESULT campaign_controller::play_game() } if (preferences::save_replays() && end_level.replay_save) { savegame::replay_savegame save(state_, preferences::save_compression_format()); - save.save_game_automatic(video_, true); + save.save_game_automatic(true); } state_.convert_to_start_save(); @@ -398,7 +398,7 @@ LEVEL_RESULT campaign_controller::play_game() savegame::scenariostart_savegame save(state_, preferences::save_compression_format()); - save.save_game_automatic(video_); + save.save_game_automatic(); } } diff --git a/src/game_launcher.cpp b/src/game_launcher.cpp index a40fba3a94f47..3ca385d7d4790 100644 --- a/src/game_launcher.cpp +++ b/src/game_launcher.cpp @@ -537,7 +537,7 @@ int game_launcher::unit_test() return 0; //we passed, huzzah! savegame::replay_savegame save(state_, compression::NONE); - save.save_game_automatic(video(), false, "unit_test_replay"); //false means don't check for overwrite + save.save_game_automatic(false, "unit_test_replay"); //false means don't check for overwrite load_data_.reset(new savegame::load_game_metadata{ "unit_test_replay" , "", true, true, false }); diff --git a/src/gui/dialogs/title_screen.cpp b/src/gui/dialogs/title_screen.cpp index 94ec4411a62c0..ab7338a182a91 100644 --- a/src/gui/dialogs/title_screen.cpp +++ b/src/gui/dialogs/title_screen.cpp @@ -171,7 +171,7 @@ static bool fullscreen(CVideo& video) return true; } -static bool launch_lua_console(window& window) +static bool launch_lua_console() { gui2::dialogs::lua_interpreter::display(gui2::dialogs::lua_interpreter::APP); return true; @@ -247,7 +247,9 @@ void title_screen::pre_show(window& win) }); win.register_hotkey(hotkey::HOTKEY_FULLSCREEN, std::bind(fullscreen, std::ref(win.video()))); - win.register_hotkey(hotkey::LUA_CONSOLE, std::bind(&launch_lua_console, std::ref(win))); + + // std::bind is needed here since the bare function signature isn't what register_hotkey expects. + win.register_hotkey(hotkey::LUA_CONSOLE, std::bind(&launch_lua_console)); // // Background and logo images @@ -421,7 +423,7 @@ void title_screen::pre_show(window& win) // // Cores // - register_button(win, "cores", hotkey::TITLE_SCREEN__CORES, [](window& w) { + register_button(win, "cores", hotkey::TITLE_SCREEN__CORES, [](window&) { int current = 0; std::vector cores; for(const config& core : game_config_manager::get()->game_config().child_range("core")) { diff --git a/src/menu_events.cpp b/src/menu_events.cpp index f32d25ac7f729..620ad73a96fca 100644 --- a/src/menu_events.cpp +++ b/src/menu_events.cpp @@ -660,7 +660,7 @@ typedef std::pair type_and_gender; * @returns the selected type and gender. If this is canceled, the * returned type is nullptr. */ -type_and_gender choose_unit(game_display& gui) +type_and_gender choose_unit() { // // The unit creation dialog makes sure unit types @@ -726,7 +726,7 @@ void menu_handler::create_unit(mouse_handler& mousehandler) assert(gui_ != nullptr); // Let the user select the kind of unit to create. - type_and_gender selection = choose_unit(*gui_); + type_and_gender selection = choose_unit(); if(selection.first != nullptr) { // Make it so. create_and_place(*gui_, map(), units(), destination, *selection.first, selection.second); diff --git a/src/play_controller.cpp b/src/play_controller.cpp index abc86504dc79d..a08e699e3b2ea 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -826,7 +826,7 @@ void play_controller::save_game() save_blocker::save_unblocker unblocker; scoped_savegame_snapshot snapshot(*this); savegame::ingame_savegame save(saved_game_, *gui_, preferences::save_compression_format()); - save.save_game_interactive(gui_->video(), "", savegame::savegame::OK_CANCEL); + save.save_game_interactive("", savegame::savegame::OK_CANCEL); } else { save_blocker::on_unblock(this,&play_controller::save_game); } @@ -839,7 +839,7 @@ void play_controller::save_game_auto(const std::string& filename) scoped_savegame_snapshot snapshot(*this); savegame::ingame_savegame save(saved_game_, *gui_, preferences::save_compression_format()); - save.save_game_automatic(gui_->video(), false, filename); + save.save_game_automatic(false, filename); } } @@ -848,7 +848,7 @@ void play_controller::save_replay() if(save_blocker::try_block()) { save_blocker::save_unblocker unblocker; savegame::replay_savegame save(saved_game_, preferences::save_compression_format()); - save.save_game_interactive(gui_->video(), "", savegame::savegame::OK_CANCEL); + save.save_game_interactive("", savegame::savegame::OK_CANCEL); } else { save_blocker::on_unblock(this,&play_controller::save_replay); } @@ -859,7 +859,7 @@ void play_controller::save_replay_auto(const std::string& filename) if(save_blocker::try_block()) { save_blocker::save_unblocker unblocker; savegame::replay_savegame save(saved_game_, preferences::save_compression_format()); - save.save_game_automatic(gui_->video(), false, filename); + save.save_game_automatic(false, filename); } } @@ -987,7 +987,7 @@ void play_controller::process_oos(const std::string& msg) const scoped_savegame_snapshot snapshot(*this); savegame::oos_savegame save(saved_game_, *gui_, ignore_replay_errors_); - save.save_game_interactive(gui_->video(), message.str(), savegame::savegame::YES_NO); // can throw quit_game_exception + save.save_game_interactive(message.str(), savegame::savegame::YES_NO); // can throw quit_game_exception } void play_controller::update_gui_to_player(const int team_index, const bool observe) @@ -1009,7 +1009,7 @@ void play_controller::do_consolesave(const std::string& filename) { scoped_savegame_snapshot snapshot(*this); savegame::ingame_savegame save(saved_game_, *gui_, preferences::save_compression_format()); - save.save_game_automatic(gui_->video(), true, filename); + save.save_game_automatic(true, filename); } void play_controller::update_savegame_snapshot() const diff --git a/src/playmp_controller.cpp b/src/playmp_controller.cpp index da6c0077f6cdb..471e73bbd9f3b 100644 --- a/src/playmp_controller.cpp +++ b/src/playmp_controller.cpp @@ -379,7 +379,7 @@ void playmp_controller::process_oos(const std::string& err_msg) const { } scoped_savegame_snapshot snapshot(*this); savegame::oos_savegame save(saved_game_, *gui_, ignore_replay_errors_); - save.save_game_interactive(gui_->video(), temp_buf.str(), savegame::savegame::YES_NO); + save.save_game_interactive(temp_buf.str(), savegame::savegame::YES_NO); } void playmp_controller::handle_generic_event(const std::string& name){ diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index 3043d10926aea..c325ffecaa3d5 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -351,7 +351,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level) scoped_savegame_snapshot snapshot(*this); savegame::ingame_savegame save(saved_game_, *gui_, preferences::save_compression_format()); - save.save_game_interactive(gui_->video(), _("A network disconnection has occurred, and the game cannot continue. Do you want to save the game?"), savegame::savegame::YES_NO); + save.save_game_interactive(_("A network disconnection has occurred, and the game cannot continue. Do you want to save the game?"), savegame::savegame::YES_NO); if(dynamic_cast(&e)) { return LEVEL_RESULT::QUIT; } else { diff --git a/src/savegame.cpp b/src/savegame.cpp index 7433789f1a268..edd243f58966c 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -149,7 +149,7 @@ bool loadgame::load_game_ingame() return false; } - if (!loadgame::check_version_compatibility(summary["version"].str(), video_)) { + if (!loadgame::check_version_compatibility(summary["version"].str())) { return false; } @@ -214,10 +214,10 @@ bool loadgame::load_game() bool loadgame::check_version_compatibility() { - return loadgame::check_version_compatibility(gamestate_.classification().version, video_); + return loadgame::check_version_compatibility(gamestate_.classification().version); } -bool loadgame::check_version_compatibility(const version_info & save_version, CVideo & video) +bool loadgame::check_version_compatibility(const version_info & save_version) { if (save_version == game_config::version) { return true; @@ -335,7 +335,7 @@ savegame::savegame(saved_game& gamestate, const compression::format compress_sav , compress_saves_(compress_saves) {} -bool savegame::save_game_automatic(CVideo& video, bool ask_for_overwrite, const std::string& filename) +bool savegame::save_game_automatic(bool ask_for_overwrite, const std::string& filename) { if (filename.empty()) create_filename(); @@ -343,33 +343,33 @@ bool savegame::save_game_automatic(CVideo& video, bool ask_for_overwrite, const filename_ = filename; if (ask_for_overwrite){ - if (!check_overwrite(video)) { - return save_game_interactive(video, "", savegame::OK_CANCEL); + if (!check_overwrite()) { + return save_game_interactive("", savegame::OK_CANCEL); } } - return save_game(&video); + return save_game(); } -bool savegame::save_game_interactive(CVideo& video, const std::string& message, DIALOG_TYPE dialog_type) +bool savegame::save_game_interactive(const std::string& message, DIALOG_TYPE dialog_type) { show_confirmation_ = true; create_filename(); - const int res = show_save_dialog(video, message, dialog_type); + const int res = show_save_dialog(message, dialog_type); if (res == 2) { throw_quit_game_exception(); //Quit game } - if (res == gui2::window::OK && check_overwrite(video)) { - return save_game(&video); + if (res == gui2::window::OK && check_overwrite()) { + return save_game(); } return false; } -int savegame::show_save_dialog(CVideo& video, const std::string& message, DIALOG_TYPE dialog_type) +int savegame::show_save_dialog(const std::string& message, DIALOG_TYPE dialog_type) { int res = 0; @@ -386,14 +386,14 @@ int savegame::show_save_dialog(CVideo& video, const std::string& message, DIALOG set_filename(filename_); - if (!check_filename(filename_, video)) { + if (!check_filename(filename_)) { res = gui2::window::CANCEL; } return res; } -bool savegame::check_overwrite(CVideo& video) +bool savegame::check_overwrite() { if(!save_game_exists(filename_, compress_saves_)) { return true; @@ -406,7 +406,7 @@ bool savegame::check_overwrite(CVideo& video) } -bool savegame::check_filename(const std::string& filename, CVideo& video) +bool savegame::check_filename(const std::string& filename) { if (filesystem::is_compressed_file(filename)) { gui2::show_error_message(_("Save names should not end on '.gz' or '.bz2'. " @@ -437,7 +437,7 @@ void savegame::before_save() { } -bool savegame::save_game(CVideo* video, const std::string& filename) +bool savegame::save_game(const std::string& filename) { try { @@ -458,16 +458,15 @@ bool savegame::save_game(CVideo* video, const std::string& filename) end = SDL_GetTicks(); LOG_SAVE << "Milliseconds to save " << filename_ << ": " << end - start << std::endl; - if (video != nullptr && show_confirmation_) + if (show_confirmation_) gui2::show_transient_message(_("Saved"), _("The game has been saved.")); return true; } catch(game::save_game_failed& e) { ERR_SAVE << error_message_ << e.message << std::endl; - if (video != nullptr){ - gui2::show_error_message(error_message_ + e.message); - //do not bother retrying, since the user can just try to save the game again - //maybe show a yes-no dialog for "disable autosaves now"? - } + + gui2::show_error_message(error_message_ + e.message); + //do not bother retrying, since the user can just try to save the game again + //maybe show a yes-no dialog for "disable autosaves now"? return false; }; @@ -575,7 +574,7 @@ void autosave_savegame::autosave(const bool disable_autosave, const int autosave if(disable_autosave) return; - save_game_automatic(gui_.video()); + save_game_automatic(); remove_old_auto_saves(autosave_max, infinite_autosaves); } @@ -596,7 +595,7 @@ oos_savegame::oos_savegame(saved_game& gamestate, game_display& gui, bool& ignor , ignore_(ignore) {} -int oos_savegame::show_save_dialog(CVideo& video, const std::string& message, DIALOG_TYPE /*dialog_type*/) +int oos_savegame::show_save_dialog(const std::string& message, DIALOG_TYPE /*dialog_type*/) { int res = 0; @@ -610,7 +609,7 @@ int oos_savegame::show_save_dialog(CVideo& video, const std::string& message, DI set_filename(filename); - if (!check_filename(filename, video)) { + if (!check_filename(filename)) { res = gui2::window::CANCEL; } diff --git a/src/savegame.hpp b/src/savegame.hpp index 7948e5e424f33..e34193fe71690 100644 --- a/src/savegame.hpp +++ b/src/savegame.hpp @@ -120,7 +120,7 @@ class loadgame } /** GUI Dialog sequence which confirms attempts to load saves from previous game versions. */ - static bool check_version_compatibility(const version_info & version, CVideo & video); + static bool check_version_compatibility(const version_info & version); static bool is_replay_save(const config& cfg) { @@ -164,28 +164,27 @@ class savegame This is used by automatically generated replays, start-of-scenario saves, autosaves, and saves from the console (e.g. ":w"). */ - bool save_game_automatic(CVideo& video, bool ask_for_overwrite = false, const std::string& filename = ""); + bool save_game_automatic(bool ask_for_overwrite = false, const std::string& filename = ""); /** Save a game interactively through the savegame dialog. Used for manual midgame and replay saves. The return value denotes, if the save was successful or not. */ - bool save_game_interactive(CVideo& video, const std::string& message, + bool save_game_interactive(const std::string& message, DIALOG_TYPE dialog_type); const std::string& filename() const { return filename_; } protected: /** - Save a game without any further user interaction. If you want notifying messages - or error messages to appear, you have to provide the gui parameter. + Save a game without any further user interaction. The return value denotes, if the save was successful or not. */ - bool save_game(CVideo* video = nullptr, const std::string& filename = ""); + bool save_game(const std::string& filename = ""); /** Sets the filename and removes invalid characters. Don't set the filename directly but use this method instead. */ void set_filename(std::string filename); /** Check, if the filename contains illegal constructs like ".gz". */ - bool check_filename(const std::string& filename, CVideo& video); + bool check_filename(const std::string& filename); /** Customize the standard error message */ void set_error_message(const std::string& error_message) { error_message_ = error_message; } @@ -207,9 +206,9 @@ class savegame override this to take effect. */ virtual void create_filename() {} /** Display the save game dialog. */ - virtual int show_save_dialog(CVideo& video, const std::string& message, DIALOG_TYPE dialog_type); + virtual int show_save_dialog(const std::string& message, DIALOG_TYPE dialog_type); /** Ask the user if an existing file should be overwritten. */ - bool check_overwrite(CVideo& video); + bool check_overwrite(); /** The actual method for saving the game to disk. All interactive filename choosing and data manipulation has to happen before calling this method. */ @@ -286,7 +285,7 @@ class oos_savegame : public ingame_savegame private: /** Display the save game dialog. */ - virtual int show_save_dialog(CVideo& video, const std::string& message, DIALOG_TYPE dialog_type) override; + virtual int show_save_dialog(const std::string& message, DIALOG_TYPE dialog_type) override; bool& ignore_; };