/****************************************************************************
  Return a pointer to the given "terrain" color.

  Each terrain has a color associated.  This is usually used to draw the
  overview.
****************************************************************************/
struct color *get_terrain_color(const struct tileset *t,
				const struct terrain *pterrain)
{
  if (pterrain) {
    struct color_system *colors = get_color_system(t);

    return ensure_color(&colors->terrain_colors[terrain_index(pterrain)]);
  } else {
    /* Always fails. */
    fc_assert(NULL != pterrain);
    return NULL;
  }
}
/**********************************************************************
  Not sure which module to put this in...
  It used to be that each nation had a color, when there was
  fixed number of nations.  Now base on player number instead,
  since still limited to less than 14.  Could possibly improve
  to allow players to choose their preferred color etc.
  A hack added to avoid returning more that COLOR_STD_RACE13.
  But really there should be more colors available -- jk.
***********************************************************************/
struct color *get_player_color(const struct tileset *t,
			       const struct player *pplayer)
{
  if (pplayer) {
    struct color_system *colors = get_color_system(t);
    int index = player_index(pplayer);

    fc_assert_ret_val(index >= 0 && colors->num_player_colors > 0, NULL);
    index %= colors->num_player_colors;
    return ensure_color(&colors->player_colors[index]);
  } else {
    /* Always fails. */
    fc_assert(NULL != pplayer);
    return NULL;
  }
}
Exemple #3
0
/****************************************************************************
  Return a pointer to the given "theme" color.
****************************************************************************/
struct color *theme_get_color(const struct theme *t, enum theme_color color)
{
  return ensure_color(&theme_get_color_system(t)->colors[color]);
}
/****************************************************************************
  Return a pointer to the given "standard" color.
****************************************************************************/
struct color *get_color(const struct tileset *t, enum color_std color)
{
  return ensure_color(&get_color_system(t)->colors[color]);
}