![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "fcintl.h"#include "log.h"#include "rand.h"#include "city.h"#include "effects.h"#include "game.h"#include "map.h"#include "tile.h"#include "unittype.h"#include "traderoutes.h"
Include dependency graph for traderoutes.cpp:Go to the source code of this file.
Functions | |
| int | max_trade_routes (const struct city *pcity) |
| Return current maximum number of trade routes city can have. More... | |
| 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. More... | |
| int | trade_route_type_trade_pct (enum trade_route_type type) |
| Return percentage bonus for trade route type. More... | |
| void | trade_route_types_init () |
| Initialize trade route types. More... | |
| const char * | trade_route_type_name (enum trade_route_type type) |
| Return human readable name of trade route type. More... | |
| enum trade_route_type | trade_route_type_by_name (const char *name) |
| Get trade route type by name. More... | |
| const char * | traderoute_cancelling_type_name (enum traderoute_illegal_cancelling type) |
| Return human readable name of traderoute cancelling type. More... | |
| enum traderoute_illegal_cancelling | traderoute_cancelling_type_by_name (const char *name) |
| Get traderoute cancelling type by name. More... | |
| struct trade_route_settings * | trade_route_settings_by_type (enum trade_route_type type) |
| Get trade route settings related to type. More... | |
| 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 other to sell its goods. More... | |
| 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. More... | |
| bool | can_establish_trade_route (const struct city *pc1, const struct city *pc2) |
| Returns TRUE iff the two cities can establish a trade route. More... | |
| 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. More... | |
| int | trade_from_route (const struct city *pc1, const struct trade_route *route, int base) |
| Get trade income specific to route's good. More... | |
| int | city_num_trade_routes (const struct city *pcity) |
| Return number of trade route city has. More... | |
| static int | max_tile_trade (const struct city *pcity, const player *seen_as) |
| Returns the maximum trade production of the tiles of the city. More... | |
| static int | max_trade_prod (const struct city *pcity, const player *seen_as) |
| Returns the maximum trade production of a city. More... | |
| 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 simply sell your trade goods at the new city. More... | |
| bool | have_cities_trade_route (const struct city *pc1, const struct city *pc2) |
| Check if cities have an established trade route. More... | |
| void | goods_init () |
| Initialize goods structures. More... | |
| void | goods_free () |
| Free the memory associated with goods. More... | |
| Goods_type_id | goods_number (const struct goods_type *pgood) |
| Return the goods id. More... | |
| Goods_type_id | goods_index (const struct goods_type *pgood) |
| Return the goods index. More... | |
| struct goods_type * | goods_by_number (Goods_type_id id) |
| Return goods type of given id. More... | |
| const char * | goods_name_translation (struct goods_type *pgood) |
| Return translated name of this goods type. More... | |
| const char * | goods_rule_name (struct goods_type *pgood) |
| Return untranslated name of this goods type. More... | |
| 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. More... | |
| struct goods_type * | goods_by_translated_name (const char *name) |
| bool | goods_has_flag (const struct goods_type *pgood, enum goods_flag_id flag) |
| Check if goods has given flag. More... | |
| bool | goods_can_be_provided (struct city *pcity, struct goods_type *pgood, struct unit *punit) |
| Can the city provide goods. More... | |
| bool | city_receives_goods (const struct city *pcity, const struct goods_type *pgood) |
| Does city receive goods. More... | |
| struct goods_type * | goods_from_city_to_unit (struct city *src, struct unit *punit) |
| Return goods type for the new traderoute between given cities. More... | |
Variables | |
| const char * | trade_route_type_names [] |
| const char * | traderoute_cancelling_type_names [] |
| struct trade_route_settings | trtss [TRT_LAST] |
| static struct goods_type | goods [MAX_GOODS_TYPES] |
Return TRUE iff the two cities are capable of trade; i.e., if a caravan from one city can enter the other to sell its goods.
See also can_establish_trade_route().
Definition at line 204 of file traderoutes.cpp.
Referenced by can_establish_trade_route(), dai_caravan_can_trade_cities_diff_cont(), dai_choose_trade_route(), dai_manage_caravan(), do_unit_establish_trade(), popup_info_text(), reestablish_city_trade_routes(), set_city_production(), trade_benefit(), unit_can_est_trade_route_here(), update_city_activities(), and windfall_benefit().
Returns TRUE iff the two cities can establish a trade route.
We look at the distance and ownership of the cities as well as their existing trade routes. Should only be called if you already know that can_cities_trade().
Definition at line 267 of file traderoutes.cpp.
Referenced by trade_generator::calculate(), dai_manage_caravan(), popup_info_text(), reestablish_city_trade_routes(), trade_benefit(), and windfall_benefit().
| 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.
Definition at line 41 of file traderoutes.cpp.
Referenced by can_cities_trade(), do_unit_establish_trade(), reestablish_city_trade_routes(), set_city_production(), trade_base_between_cities(), and update_city_activities().
| int city_num_trade_routes | ( | const struct city * | pcity | ) |
Return number of trade route city has.
Definition at line 365 of file traderoutes.cpp.
Referenced by adjust_improvement_wants_by_effects(), trade_generator::calculate(), can_establish_trade_route(), dai_choose_trade_route(), dai_effect_value(), do_unit_establish_trade(), handle_city_info(), and one_city_trade_benefit().
| bool city_receives_goods | ( | const struct city * | pcity, |
| const struct goods_type * | pgood | ||
| ) |
Does city receive goods.
Definition at line 684 of file traderoutes.cpp.
| 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.
The target routes to be removed will be put into 'would_remove', if set.
Definition at line 221 of file traderoutes.cpp.
Referenced by can_establish_trade_route(), do_unit_establish_trade(), and one_city_trade_benefit().
| 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 simply sell your trade goods at the new city.
pgood can be nullptr for ignoring good's onetime_pct.
pc2 can be nullptr for using an imaginary city at distance 10 with 75% of pc1's trade (for dai_choose_trade_route()).
Definition at line 446 of file traderoutes.cpp.
Referenced by dai_choose_trade_route(), do_unit_establish_trade(), get_act_sel_action_custom_text(), and windfall_benefit().
| struct goods_type* goods_by_number | ( | Goods_type_id | id | ) |
Return goods type of given id.
Definition at line 589 of file traderoutes.cpp.
Referenced by tab_good::add_now(), handle_ruleset_goods(), handle_traderoute_info(), sg_load_player_city(), sg_save_player_cities(), universal_value_initial(), and unpackage_unit().
| 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.
Definition at line 616 of file traderoutes.cpp.
Referenced by tab_good::initialize_new_good(), tab_good::select_good(), sg_load_player_city(), sg_load_player_unit(), and universal_by_number().
| struct goods_type* goods_by_translated_name | ( | const char * | name | ) |
Definition at line 641 of file traderoutes.cpp.
Referenced by help_widget::set_topic_goods().
| bool goods_can_be_provided | ( | struct city * | pcity, |
| struct goods_type * | pgood, | ||
| struct unit * | punit | ||
| ) |
Can the city provide goods.
Definition at line 665 of file traderoutes.cpp.
Referenced by goods_from_city_to_unit(), and update_city_activities().
| void goods_free | ( | ) |
Free the memory associated with goods.
Definition at line 552 of file traderoutes.cpp.
Referenced by game_ruleset_free().
| struct goods_type* goods_from_city_to_unit | ( | struct city * | src, |
| struct unit * | punit | ||
| ) |
Return goods type for the new traderoute between given cities.
Definition at line 702 of file traderoutes.cpp.
Referenced by do_unit_establish_trade(), and unit_get_goods().
| bool goods_has_flag | ( | const struct goods_type * | pgood, |
| enum goods_flag_id | flag | ||
| ) |
Check if goods has given flag.
Definition at line 657 of file traderoutes.cpp.
Referenced by do_unit_establish_trade(), save_game_ruleset(), and update_city_activities().
| Goods_type_id goods_index | ( | const struct goods_type * | pgood | ) |
Return the goods index.
Currently same as goods_number(), paired with goods_count() indicates use as an array index.
Definition at line 579 of file traderoutes.cpp.
Referenced by load_game_names(), load_ruleset_game(), package_unit(), and tab_good::refresh().
| void goods_init | ( | ) |
Initialize goods structures.
Definition at line 536 of file traderoutes.cpp.
Referenced by game_ruleset_init().
| const char* goods_name_translation | ( | struct goods_type * | pgood | ) |
Return translated name of this goods type.
Definition at line 599 of file traderoutes.cpp.
Referenced by boot_help_texts(), do_unit_establish_trade(), get_city_dialog_output_text(), goods_by_translated_name(), req_text_insert(), universal_name_translation(), and worklist_item_postpone_req_vec().
| Goods_type_id goods_number | ( | const struct goods_type * | pgood | ) |
Return the goods id.
Definition at line 566 of file traderoutes.cpp.
Referenced by package_city(), send_ruleset_goods(), and universal_number().
| const char* goods_rule_name | ( | struct goods_type * | pgood | ) |
Return untranslated name of this goods type.
Definition at line 607 of file traderoutes.cpp.
Referenced by tab_good::delete_now(), tab_good::edit_effects(), tab_good::edit_reqs(), goods_by_rule_name(), is_universal_needed(), load_ruleset_game(), tab_good::name_given(), tab_good::refresh(), sanity_check_ruleset_data(), sg_save_player_cities(), sg_save_player_units(), universal_kind_values(), universal_rule_name(), and tab_good::update_good_info().
Check if cities have an established trade route.
Definition at line 520 of file traderoutes.cpp.
Referenced by trade_generator::calculate(), can_establish_trade_route(), do_unit_establish_trade(), and draw_calculated_trade_routes().
Returns the maximum trade production of the tiles of the city.
Definition at line 373 of file traderoutes.cpp.
Referenced by max_trade_prod().
Returns the maximum trade production of a city.
Definition at line 421 of file traderoutes.cpp.
Referenced by get_caravan_enter_city_trade_bonus().
| int max_trade_routes | ( | const struct city * | pcity | ) |
Return current maximum number of trade routes city can have.
Definition at line 41 of file traderoutes.cpp.
Referenced by trade_generator::calculate(), can_establish_trade_route(), trade_generator::check_if_done(), city_trade_removable(), dai_choose_trade_route(), dai_effect_value(), do_unit_establish_trade(), get_city_mapview_trade_routes(), one_city_trade_benefit(), and trade_benefit().
Return the trade that exists between these cities, assuming they have a trade route.
Definition at line 314 of file traderoutes.cpp.
Referenced by can_establish_trade_route(), dai_effect_value(), do_unit_establish_trade(), get_act_sel_action_custom_text(), max_trade_prod(), popup_info_text(), set_city_production(), and trade_benefit().
| int trade_from_route | ( | const struct city * | pc1, |
| const struct trade_route * | route, | ||
| int | base | ||
| ) |
Get trade income specific to route's good.
Definition at line 351 of file traderoutes.cpp.
Referenced by set_city_production().
| struct trade_route_settings* trade_route_settings_by_type | ( | enum trade_route_type | type | ) |
Get trade route settings related to type.
Definition at line 191 of file traderoutes.cpp.
Referenced by do_unit_establish_trade(), handle_ruleset_trade(), load_ruleset_game(), reestablish_city_trade_routes(), save_game_ruleset(), send_ruleset_trade_routes(), set_city_production(), trade_route_types_init(), and update_city_activities().
| enum trade_route_type trade_route_type_by_name | ( | const char * | name | ) |
Get trade route type by name.
Definition at line 140 of file traderoutes.cpp.
Referenced by load_ruleset_game().
| const char* trade_route_type_name | ( | enum trade_route_type | type | ) |
Return human readable name of trade route type.
Definition at line 140 of file traderoutes.cpp.
Referenced by save_game_ruleset().
| int trade_route_type_trade_pct | ( | enum trade_route_type | type | ) |
Return percentage bonus for trade route type.
Definition at line 115 of file traderoutes.cpp.
Referenced by can_cities_trade(), dai_choose_trade_route(), and trade_base_between_cities().
| void trade_route_types_init | ( | ) |
Initialize trade route types.
Definition at line 127 of file traderoutes.cpp.
Referenced by game_ruleset_init().
| enum traderoute_illegal_cancelling traderoute_cancelling_type_by_name | ( | const char * | name | ) |
Get traderoute cancelling type by name.
Definition at line 165 of file traderoutes.cpp.
Referenced by load_ruleset_game().
| const char* traderoute_cancelling_type_name | ( | enum traderoute_illegal_cancelling | type | ) |
Return human readable name of traderoute cancelling type.
Definition at line 165 of file traderoutes.cpp.
Referenced by save_game_ruleset().
|
static |
Definition at line 31 of file traderoutes.cpp.
Referenced by goods_by_number(), goods_free(), goods_index(), and goods_init().
| const char* trade_route_type_names[] |
Definition at line 27 of file traderoutes.cpp.
Referenced by trade_route_type_by_name().
| const char* traderoute_cancelling_type_names[] |
Definition at line 31 of file traderoutes.cpp.
Referenced by traderoute_cancelling_type_by_name().
| struct trade_route_settings trtss[TRT_LAST] |
Definition at line 31 of file traderoutes.cpp.
Referenced by trade_route_settings_by_type(), and trade_route_type_trade_pct().