Game Load: append leader TC if image path resolves at runtime (change by @newfrenchy83)

Closes #2257. This fixes instances where save_index entries created *before* the relevant
binary paths were loaded resulted in leader images without TC when viewed in Game Load
even once the relevant paths were loaded.

Do note as of 3b0eb6b986 this likely isn't a problem unless the save_index file is
deleted, since otherwise all relevant save data (including independent image paths) will
be created in-game when they're saved.

One thing to note, though, is @newfrenchy83 mentioned that the final autosaves of games
were lacking TC in the Load Game dialog. *This* change should fixe that, but I don't know
if the above change affects that too.
This commit is contained in:
Charles Dang 2017-12-03 06:51:20 +11:00
parent 3b0eb6b986
commit cc62dcf9c4

View file

@ -179,11 +179,17 @@ void game_load::display_savegame(window& window)
string_map item;
// First, we evaluate whether the leader image as provided exists.
// If not, we try getting a binary-path independent path. If that still doesn't
// If not, we try getting a binary path-independent path. If that still doesn't
// work, we fallback on unknown-unit.png.
std::string leader_image = leader["leader_image"].str();
if(!::image::exists(leader_image)) {
leader_image = filesystem::get_independent_image_path(leader_image);
// The leader TC modifier isn't appending if the independent image path can't
// be resolved during save_index entry creation, so we need to add it here.
if(!leader_image.empty()) {
leader_image += leader["leader_image_tc_modifier"].str();
}
}
if(leader_image.empty()) {