From bab30040d8a2c133c20ac9d8fe6519a56d02b26c Mon Sep 17 00:00:00 2001 From: Ali El Gariani Date: Mon, 3 Sep 2007 20:02:28 +0000 Subject: [PATCH] ~TC was incompletely restored after the adhesion storm Now initialize and reset TC in titlescreen for add-ons and campaigns icons (previously was only initialized after having played a game) This also restore coloring for case like ~TC(not a playing side) --- src/game.cpp | 4 ++++ src/game_display.cpp | 2 +- src/image.cpp | 21 ++++++++++++++++----- src/image.hpp | 3 ++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 6ab2daafe54..643fa55b1e2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2013,6 +2013,10 @@ static int play_game(int argc, char** argv) //make sure the game config is always set to how it should be at the title screen game.reset_game_cfg(); + // reset the TC, since a game can modify it, and it may be used + // by images in add-ons or campaigns dialogs + image::set_team_colors(); + statistics::fresh_stats(); sound::play_music_repeatedly(game_config::title_music); diff --git a/src/game_display.cpp b/src/game_display.cpp index 07521a56336..87ac5409bd0 100644 --- a/src/game_display.cpp +++ b/src/game_display.cpp @@ -117,7 +117,7 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map, flags_.back().start_animation(rand()%flags_.back().get_end_time(), true); } - image::set_team_colors(side_colors); + image::set_team_colors(&side_colors); // Clear the screen contents surface const disp(screen_.getSurface()); diff --git a/src/image.cpp b/src/image.cpp index 761a4003cf9..2407deb9e7d 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -335,9 +335,16 @@ surface locator::load_image_sub_file() const break; std::string f1,f2; int side_n = lexical_cast_default(field.substr(0,pos),-1); - if (side_n > static_cast(team_colors.size()) || side_n < 1) - break; - f1 = team_colors[side_n-1]; + if (side_n < 1) + break; + else if (side_n < static_cast(team_colors.size())) { + f1 = team_colors[side_n-1]; + } else { + // this side is not inialized use default "n" + f1 = lexical_cast(side_n); + } + + f2 = field.substr(pos+1); if(game_config::tc_info(f2).size()){ function="RC"; @@ -461,9 +468,13 @@ void set_colour_adjustment(int r, int g, int b) } } -void set_team_colors(const std::vector& colors) +void set_team_colors(const std::vector* colors) { - team_colors = colors; + if (colors == NULL) + team_colors.clear(); + else { + team_colors = *colors; + } } void set_image_mask(const std::string& /*image*/) diff --git a/src/image.hpp b/src/image.hpp index 7535a351104..ee43704f556 100644 --- a/src/image.hpp +++ b/src/image.hpp @@ -171,7 +171,8 @@ namespace image { ///set the team colors used by the TC image modification ///use a vector with one string for each team - void set_team_colors(const std::vector& colors); + ///using NULL will reset to default TC + void set_team_colors(const std::vector* colors = NULL); ///function which sets a certain image as a 'mask' for all scaled images. ///the 'mask' is blitted onto all scaled images.