Skip to content

Commit

Permalink
Game Config: fixed red_to_green and blue_to_white returning incorrect…
Browse files Browse the repository at this point in the history
… values

The issue was that load_config is (for some reason) called twice, and the respective vectors of colors
were simply added on to each time, resulting in incorrect color values when queried.

I figured it would be slightly more efficient to simply assign the vector a new value since the size remains the same.
I'm not sure if a simple vec.clear() call would be more or as efficient, though, not that it really matters at this size.
  • Loading branch information
Vultraz committed Dec 1, 2016
1 parent dcbf25e commit 80c372b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/game_config.cpp
Expand Up @@ -347,10 +347,10 @@ void load_config(const config &v)

const auto parse_config_color_list = [&](
const std::string& key,
std::vector<color_t>& color_vec,
const color_t fallback)
const color_t fallback)->std::vector<color_t>
{
std::vector<std::string> temp = utils::split(v[key].str());
std::vector<color_t> color_vec;

for(const auto& s : temp) {
try {
Expand All @@ -360,12 +360,14 @@ void load_config(const config &v)
color_vec.push_back(fallback);
}
}

return color_vec;
};

parse_config_color_list("red_green_scale", red_green_scale, {255, 255, 255});
parse_config_color_list("red_green_scale_text", red_green_scale_text, {255, 255, 255});
parse_config_color_list("blue_white_scale", blue_white_scale, {0 , 0 , 255});
parse_config_color_list("blue_white_scale_text", blue_white_scale_text, {0 , 0 , 255});
red_green_scale = parse_config_color_list("red_green_scale", {255, 255, 255});
red_green_scale_text = parse_config_color_list("red_green_scale_text", {255, 255, 255});
blue_white_scale = parse_config_color_list("blue_white_scale", {0 , 0 , 255});
blue_white_scale_text = parse_config_color_list("blue_white_scale_text", {0 , 0 , 255});

server_list.clear();

Expand Down

0 comments on commit 80c372b

Please sign in to comment.