Beispiel #1
0
/****************************************************************************
  Set the given terrain at the specified tile.
****************************************************************************/
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
{
  /* The terrain change is valid if one of the following is TRUE:
   * - pterrain is NULL (= unknown terrain)
   * - ptile is a virtual tile
   * - pterrain does not has the flag TER_NO_CITIES
   * - there is no city on ptile.
   * This should be read as: The terrain change is INVALID if a terrain with
   * the flag TER_NO_CITIES is given for a real tile with a city (i.e. all
   * check evaluate to TRUE). */
  fc_assert_msg(NULL == pterrain
                || tile_virtual_check(ptile)
                || !terrain_has_flag(pterrain, TER_NO_CITIES)
                || NULL == tile_city(ptile),
                "At (%d, %d), the terrain \"%s\" (nb %d) doesn't "
                "support cities, whereas \"%s\" (nb %d) is built there.",
                TILE_XY(ptile), terrain_rule_name(pterrain),
                terrain_number(pterrain), city_name(tile_city(ptile)),
                tile_city(ptile)->id);

  ptile->terrain = pterrain;
  if (NULL != pterrain
      && NULL != ptile->resource
      && terrain_has_resource(pterrain, ptile->resource)) {
    ptile->resource_valid = TRUE;
  } else {
    ptile->resource_valid = FALSE;
  }
}
Beispiel #2
0
/****************************************************************************
  Called when terrain info is received from the server.
****************************************************************************/
void color_system_setup_terrain(struct color_system *colors,
                                const struct terrain *pterrain,
                                const char *tag)
{
  struct rgbcolor *rgb;

  if (terrain_color_hash_lookup(colors->terrain_hash, tag, &rgb)) {
    colors->terrain_colors[terrain_index(pterrain)] = *rgb;
  } else {
    log_error("[colors] missing [tile_%s] for \"%s\".",
              tag, terrain_rule_name(pterrain));
    /* Fallback: the color remains black. */
  }
}
PyObject* get_unit_properties(struct unit* s) {
    struct terrain* t = tile_terrain(s->tile);
    return Py_BuildValue("llOs", (long)s, (long)s->tile, py_mapper_city(tile_city(s->tile)),
                terrain_rule_name(t));
}