Simplify computed color reset

gr_find_closest_color did not need it.  Remove it.  For the others,
resetting the count is sufficient.  There is no need to reset the
individual elements.
This commit is contained in:
Kp 2021-09-04 12:17:14 +00:00
parent 347b8d9f77
commit ae3dc7f934
4 changed files with 5 additions and 9 deletions

View file

@ -61,7 +61,7 @@ color_t gr_find_closest_color_current( int r, int g, int b );
#if !DXX_USE_OGL
void gr_palette_read(palette_array_t &palette);
#endif
extern void init_computed_colors(void);
void reset_computed_colors();
extern ubyte gr_palette_gamma;
extern palette_array_t gr_current_pal;
extern palette_array_t gr_palette;

View file

@ -250,17 +250,13 @@ static void add_computed_color(int r, int g, int b, color_t color_num)
}
void init_computed_colors(void)
void reset_computed_colors()
{
range_for (auto &i, Computed_colors)
i.r = 255; // Make impossible to match.
Num_computed_colors = 0;
}
color_palette_index gr_find_closest_color(const int r, const int g, const int b)
{
if (Num_computed_colors == 0)
init_computed_colors();
// If we've already computed this color, return it!
for (unsigned i=0; i<Num_computed_colors; i++)
{

View file

@ -1129,7 +1129,7 @@ void gr_palette_load( palette_array_t &pal )
copy_bound_palette(gr_current_pal, pal);
gr_palette_step_up(0, 0, 0); // make ogl_setbrightness_internal get run so that menus get brightened too.
init_computed_colors();
reset_computed_colors();
}
#define GL_BGR_EXT 0x80E0

View file

@ -284,7 +284,7 @@ void gr_palette_load( palette_array_t &pal )
}
SDL_SetColors(canvas, colors.data(), 0, colors.size());
init_computed_colors();
reset_computed_colors();
gr_remap_color_fonts();
}