Skip to content

Commit

Permalink
Fix Travis GCC warnings for f2b31ba
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Vultraz authored and GregoryLundberg committed Nov 30, 2017
1 parent 9b8e322 commit 4e6f50f
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/game_initialization/playcampaign.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/game_launcher.cpp
Expand Up @@ -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 });

Expand Down
8 changes: 5 additions & 3 deletions src/gui/dialogs/title_screen.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<config> cores;
for(const config& core : game_config_manager::get()->game_config().child_range("core")) {
Expand Down
4 changes: 2 additions & 2 deletions src/menu_events.cpp
Expand Up @@ -660,7 +660,7 @@ typedef std::pair<const unit_type*, unit_race::GENDER> 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
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/play_controller.cpp
Expand Up @@ -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);
}
Expand All @@ -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);
}
}

Expand All @@ -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);
}
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/playmp_controller.cpp
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion src/playsingle_controller.cpp
Expand Up @@ -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<ingame_wesnothd_error*>(&e)) {
return LEVEL_RESULT::QUIT;
} else {
Expand Down
49 changes: 24 additions & 25 deletions src/savegame.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -335,41 +335,41 @@ 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();
else
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;

Expand All @@ -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;
Expand All @@ -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'. "
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
};
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;

Expand All @@ -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;
}

Expand Down
19 changes: 9 additions & 10 deletions src/savegame.hpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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; }
Expand All @@ -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. */
Expand Down Expand Up @@ -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_;
};

Expand Down

0 comments on commit 4e6f50f

Please sign in to comment.