28 "National",
"NationalIC",
"IN",
"INIC",
"Ally",
29 "AllyIC",
"Enemy",
"EnemyIC",
"Team",
"TeamIC"};
52 const struct city *pcity2)
208 return (pc1 && pc2 && pc1 != pc2
222 struct trade_route_list *would_remove)
231 for (j = num; j > 0 && (proute->value <
sorted[j - 1]->value); j--) {
251 for (i = j = 0; i < num; i++) {
253 if (
nullptr != would_remove) {
254 trade_route_list_append(would_remove,
sorted[i]);
268 const struct city *pc2)
318 if (
nullptr == pc1 ||
nullptr == pc1->
tile ||
nullptr == pc2
319 ||
nullptr == pc2->
tile) {
323 if (
game.
info.trade_revenue_style == TRS_CLASSIC) {
326 int weighted_distance =
327 ((100 -
game.
info.trade_world_rel_pct) * real_dist
333 }
else if (
game.
info.trade_revenue_style == TRS_SIMPLE) {
355 if (route->
dir == RDIR_TO) {
367 return trade_route_list_size(pcity->
routes);
377 std::vector<int> tile_trade;
382 if (pcity->
tile ==
nullptr) {
390 if (ptile ==
nullptr) {
409 std::sort(tile_trade.begin(), tile_trade.end());
411 for (i = 0; i < pcity->
size && i <
size; i++) {
412 total += tile_trade[i];
447 const struct city *pc2,
450 const bool establish_trade)
452 int rmd, trade2, max_trade_2;
453 int tb = 0, bonus = 0;
465 if (
game.
info.caravan_bonus_style == CBS_CLASSIC) {
468 }
else if (
game.
info.caravan_bonus_style == CBS_LOGARITHMIC) {
470 tb = pow(log(rmd + 20 +
max_trade_prod(pc1, seen_as) + max_trade_2) * 2,
472 }
else if (
game.
info.caravan_bonus_style == CBS_LINEAR) {
476 }
else if (
game.
info.caravan_bonus_style == CBS_DISTANCE) {
481 if (pgood !=
nullptr) {
488 nullptr,
city_tile(pc1),
nullptr,
nullptr,
nullptr,
nullptr,
490 : ACTION_MARKETPLACE),
491 EFT_TRADE_REVENUE_EXPONENT);
492 tb = ceil(pow(
static_cast<float>(tb),
493 1.0f +
static_cast<float>(bonus) / 1000.0));
502 nullptr,
nullptr,
nullptr,
nullptr,
507 : ACTION_MARKETPLACE),
508 EFT_TRADE_REVENUE_BONUS);
511 tb = ceil(
static_cast<float>(tb)
512 * pow(2.0,
static_cast<double>(bonus) / 1000.0));
524 if (route_to->id == pc2->
id) {
543 requirement_vector_init(&(
goods[i].
reqs));
557 requirement_vector_free(&(
goods[i].
reqs));
583 return pgood -
goods;
620 if (
name ==
nullptr) {
670 if (punit !=
nullptr) {
677 city_tile(pcity), punit, ptype,
nullptr,
nullptr,
689 if (proute->goods == pgood
690 && (proute->dir == RDIR_TO || proute->dir == RDIR_BIDIRECTIONAL)) {
711 potential[i++] = pgood;
struct action * action_by_number(action_id act_id)
Return the action with the given id.
bool BV_ISSET(const BV &bv, int bit)
bool base_city_celebrating(const struct city *pcity)
Return TRUE if the city was celebrating at the start of the turn, and it still has sufficient size to...
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
bool base_city_can_work_tile(const struct player *restriction, const struct city *pcity, const struct tile *ptile)
Returns TRUE when a tile is available to be worked, or the city itself is currently working the tile ...
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
struct tile * city_map_to_tile(const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Finds the map position for a given city map coordinate of a certain city.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
int city_tile_output(const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype)
Calculate the output for the tile.
int city_map_tiles(int city_radius_sq)
Return the number of tiles for the given city radius.
citizens city_size_get(const struct city *pcity)
Get the city size.
#define city_map_iterate_end
#define is_city_center_index(city_tile_index)
#define city_map_iterate(_radius_sq, _index, _x, _y)
std::vector< unit * > sorted(const unit_list *units)
Returns a version of units sorted in the way the user would like to see them.
static void base(QVariant data1, QVariant data2)
Action "Build Base" for choice dialog.
int get_target_bonus_effects(struct effect_list *plist, 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 *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, enum effect_type effect_type, enum vision_layer vision_layer, enum national_intelligence nintel)
Returns the effect bonus of a given type for any target.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
bool are_reqs_active(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 *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement_vector *reqs, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement(s) to see if they are active on the given target.
#define CLIP(lower, current, upper)
struct trade_route_list * routes
struct packet_ruleset_control control
struct packet_game_info info
struct requirement_vector reqs
QVector< QString > * helptext
struct name_translation name
struct goods_type * goods
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
struct goods_type * goods_by_number(Goods_type_id id)
Return goods type of given id.
const char * goods_rule_name(struct goods_type *pgood)
Return untranslated name of this goods type.
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
Return TRUE iff the two cities are capable of trade; i.e., if a caravan from one city can enter the o...
enum trade_route_type cities_trade_route_type(const struct city *pcity1, const struct city *pcity2)
What is type of the traderoute between two cities.
int trade_route_type_trade_pct(enum trade_route_type type)
Return percentage bonus for trade route type.
int max_trade_routes(const struct city *pcity)
Return current maximum number of trade routes city can have.
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
Return the trade that exists between these cities, assuming they have a trade route.
enum traderoute_illegal_cancelling traderoute_cancelling_type_by_name(const char *name)
Get traderoute cancelling type by name.
struct goods_type * goods_by_rule_name(const char *name)
Returns goods type matching rule name or nullptr if there is no goods type with such name.
int city_num_trade_routes(const struct city *pcity)
Return number of trade route city has.
Goods_type_id goods_number(const struct goods_type *pgood)
Return the goods id.
static struct goods_type goods[MAX_GOODS_TYPES]
const char * goods_name_translation(struct goods_type *pgood)
Return translated name of this goods type.
bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag)
Check if goods has given flag.
void trade_route_types_init()
Initialize trade route types.
struct trade_route_settings trtss[TRT_LAST]
struct goods_type * goods_from_city_to_unit(struct city *src, struct unit *punit)
Return goods type for the new traderoute between given cities.
int trade_from_route(const struct city *pc1, const struct trade_route *route, int base)
Get trade income specific to route's good.
struct goods_type * goods_by_translated_name(const char *name)
const char * trade_route_type_name(enum trade_route_type type)
Return human readable name of trade route type.
void goods_init()
Initialize goods structures.
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
Get trade route settings related to type.
static int max_trade_prod(const struct city *pcity, const player *seen_as)
Returns the maximum trade production of a city.
const char * traderoute_cancelling_type_names[]
Goods_type_id goods_index(const struct goods_type *pgood)
Return the goods index.
void goods_free()
Free the memory associated with goods.
int city_trade_removable(const struct city *pcity, struct trade_route_list *would_remove)
Return the minimum value of the sum of trade routes which could be replaced by a new one.
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const player *seen_as, struct goods_type *pgood, const bool establish_trade)
Returns the revenue trade bonus - you get this when establishing a trade route and also when you simp...
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
Returns TRUE iff the two cities can establish a trade route.
static int max_tile_trade(const struct city *pcity, const player *seen_as)
Returns the maximum trade production of the tiles of the city.
bool city_receives_goods(const struct city *pcity, const struct goods_type *pgood)
Does city receive goods.
const char * traderoute_cancelling_type_name(enum traderoute_illegal_cancelling type)
Return human readable name of traderoute cancelling type.
bool goods_can_be_provided(struct city *pcity, struct goods_type *pgood, struct unit *punit)
Can the city provide goods.
const char * trade_route_type_names[]
enum trade_route_type trade_route_type_by_name(const char *name)
Get trade route type by name.
bool have_cities_trade_route(const struct city *pc1, const struct city *pc2)
Check if cities have an established trade route.
traderoute_illegal_cancelling
#define goods_type_iterate_end
#define goods_type_iterate(_p)
#define trade_routes_iterate_end
#define trade_partners_iterate_end
#define trade_routes_iterate(c, proute)
#define trade_partners_iterate(c, p)
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.