Exemple #1
0
/************************************************************************
 A tile's "known" field is used by the server to store whether _each_
 player knows the tile.  Client-side, it's used as an enum known_type
 to track whether the tile is known/fogged/unknown.

 Judicious use of this function also makes things very convenient for
 civworld, since it uses both client and server-style storage; since it
 uses the stock tilespec.c file, this function serves as a wrapper.

*************************************************************************/
enum known_type client_tile_get_known(const struct tile *ptile)
{
  if (NULL == client.conn.playing) {
    if (client_is_observer()) {
      return TILE_KNOWN_SEEN;
    } else {
      return TILE_UNKNOWN;
    }
  }
  return tile_get_known(ptile, client.conn.playing);
}
Exemple #2
0
/**************************************************************************
  Is an evalutaion of the requirement accurate when pow_player evaluates
  it?

  Note: Assumed to use pow_player's data.

  TODO: Move the data to a data file. That will
        - let non programmers help complete it and/or fix what is wrong
        - let clients not written in C use the data
**************************************************************************/
static bool is_req_knowable(const struct player *pow_player,
                            const struct player *target_player,
                            const struct player *other_player,
                            const struct city *target_city,
                            const struct impr_type *target_building,
                            const struct tile *target_tile,
                            const struct unit_type *target_unittype,
                            const struct output_type *target_output,
                            const struct specialist *target_specialist,
                            const struct requirement *req)
{
  fc_assert_ret_val_msg(NULL != pow_player, false, "No point of view");

  if ((req->source.kind == VUT_UTFLAG || req->source.kind == VUT_UTYPE)
      && target_unittype != NULL) {
    return TRUE;
  }

  if (req->source.kind == VUT_DIPLREL
      && pow_player == target_player
      && (req->range == REQ_RANGE_LOCAL
          || req->range == REQ_RANGE_PLAYER)) {
    return TRUE;
  }

  if (req->source.kind == VUT_MINSIZE && target_city != NULL) {
    enum known_type vision =
        tile_get_known(city_tile(target_city), pow_player);

    if (vision == TILE_KNOWN_SEEN
        || city_owner(target_city) == pow_player) {
      return TRUE;
    }
  }

  if (req->source.kind == VUT_CITYTILE
      && req->range == REQ_RANGE_LOCAL) {
    enum known_type vision =
        tile_get_known(target_tile, pow_player);

    if (vision == TILE_KNOWN_SEEN
        || (target_city && city_owner(target_city) == pow_player)) {
      return TRUE;
    }
  }

  if (req->source.kind == VUT_NATION) {
    return TRUE;
  }

  if (req->source.kind == VUT_ADVANCE || req->source.kind == VUT_TECHFLAG) {
    if (req->range == REQ_RANGE_PLAYER
        && (pow_player == target_player
            || player_has_embassy(pow_player, target_player))) {
      return TRUE;
    }
  }

  if (req->source.kind == VUT_GOVERNMENT) {
    if (req->range == REQ_RANGE_PLAYER
        && (pow_player == target_player
            || could_intel_with_player(pow_player, target_player))) {
      return TRUE;
    }
  }

  /* Uncertain or no support added yet. */
  return FALSE;
}