Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/improvement.h File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
improvement.h File Reference
`#include "bitvector.h"`
`#include "support.h"`
`#include "fc_types.h"`
`#include "name_translation.h"`
`#include "requirements.h"`
`#include "specenum_gen.h"`

Go to the source code of this file.

## Data Structures

struct | impr_type

## Macros

#define | B_LAST MAX_NUM_BUILDINGS
#define | B_NEVER (NULL)
#define | SPECENUM_NAME impr_flag_id
#define | SPECENUM_VALUE0 IF_VISIBLE_BY_OTHERS
#define | SPECENUM_VALUE0NAME "VisibleByOthers"
#define | SPECENUM_VALUE1 IF_SAVE_SMALL_WONDER
#define | SPECENUM_VALUE1NAME "SaveSmallWonder"
#define | SPECENUM_VALUE2 IF_GOLD
#define | SPECENUM_VALUE2NAME "Gold"
#define | SPECENUM_VALUE3 IF_DISASTER_PROOF
#define | SPECENUM_VALUE3NAME "DisasterProof"
#define | SPECENUM_COUNT IF_COUNT
#define | SPECENUM_BITVECTOR bv_impr_flags
#define | WONDER_DESTROYED (MAX_NUM_PLAYER_SLOTS + 1) /* Used as player id. */
#define | WONDER_NOT_OWNED (MAX_NUM_PLAYER_SLOTS + 2) /* Used as player id. */
#define | WONDER_OWNED(player_id) ((player_id) < MAX_NUM_PLAYER_SLOTS)
#define | WONDER_LOST (-1) /* Used as city id. */
#define | WONDER_NOT_BUILT 0 /* Used as city id. */
#define | WONDER_BUILT(city_id) ((city_id) > 0)
#define | improvement_iterate(_p)
#define | improvement_iterate_end
#define | improvement_re_active_iterate(_p)
#define | improvement_re_active_iterate_end
#define | genus_iterate(_p)
#define | genus_iterate_end

## Functions

| BV_DEFINE (bv_imprs, B_LAST)
Impr_type_id | improvement_count (void)
Impr_type_id | improvement_index (const struct impr_type *pimprove)
Impr_type_id | improvement_number (const struct impr_type *pimprove)
struct impr_type * | improvement_by_number (const Impr_type_id id)
const struct impr_type * | valid_improvement (const struct impr_type *pimprove)
const struct impr_type * | valid_improvement_by_number (const Impr_type_id id)
struct impr_type * | improvement_by_rule_name (const char *name)
struct impr_type * | improvement_by_translated_name (const char *name)
const char * | improvement_rule_name (const struct impr_type *pimprove)
const char * | improvement_name_translation (const struct impr_type *pimprove)
bool | improvement_has_flag (const struct impr_type *pimprove, enum impr_flag_id flag)
int | impr_build_shield_cost (const struct city *pcity, const struct impr_type *pimprove)
int | impr_base_build_shield_cost (const struct impr_type *pimprove)
int | impr_estimate_build_shield_cost (const struct player *pplayer, const struct tile *ptile, const struct impr_type *pimprove)
int | impr_buy_gold_cost (const struct city *pcity, const struct impr_type *pimprove, int shields_in_stock)
int | impr_sell_gold (const struct impr_type *pimprove)
bool | is_improvement_visible (const struct impr_type *pimprove)
bool | is_great_wonder (const struct impr_type *pimprove)
bool | is_small_wonder (const struct impr_type *pimprove)
bool | is_wonder (const struct impr_type *pimprove)
bool | is_improvement (const struct impr_type *pimprove)
bool | is_special_improvement (const struct impr_type *pimprove)
bool | can_improvement_go_obsolete (const struct impr_type *pimprove)
bool | can_sell_building (const struct impr_type *pimprove)
bool | can_city_sell_building (const struct city *pcity, const struct impr_type *pimprove)
enum test_result | test_player_sell_building_now (struct player *pplayer, struct city *pcity, const struct impr_type *pimprove)
const struct impr_type * | improvement_replacement (const struct impr_type *pimprove)
void | wonder_built (const struct city *pcity, const struct impr_type *pimprove)
void | wonder_destroyed (const struct city *pcity, const struct impr_type *pimprove)
bool | wonder_is_lost (const struct player *pplayer, const struct impr_type *pimprove)
bool | wonder_is_built (const struct player *pplayer, const struct impr_type *pimprove)
struct city * | city_from_wonder (const struct player *pplayer, const struct impr_type *pimprove)
bool | wonder_visible_to_player (const struct impr_type *wonder, const struct player *pplayer, const struct player *owner)
bool | great_wonder_is_built (const struct impr_type *pimprove)
bool | great_wonder_is_destroyed (const struct impr_type *pimprove)
bool | great_wonder_is_available (const struct impr_type *pimprove)
struct city * | city_from_great_wonder (const struct impr_type *pimprove)
struct player * | great_wonder_owner (const struct impr_type *pimprove)
bool | small_wonder_is_built (const struct player *pplayer, const struct impr_type *pimprove)
struct city * | city_from_small_wonder (const struct player *pplayer, const struct impr_type *pimprove)
bool | improvement_obsolete (const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
bool | is_improvement_productive (const struct city *pcity, const struct impr_type *pimprove)
bool | is_improvement_redundant (const struct city *pcity, const struct impr_type *pimprove)
bool | can_player_build_improvement_direct (const struct player *p, const struct impr_type *pimprove)
bool | can_player_build_improvement_later (const struct player *p, const struct impr_type *pimprove)
bool | can_player_build_improvement_now (const struct player *p, struct impr_type *pimprove)
void | improvements_init (void)
void | improvements_free (void)
void | improvement_feature_cache_init (void)
struct impr_type * | improvement_array_first (void)
const struct impr_type * | improvement_array_last (void)

## Macro Definition Documentation

## ◆ B_LAST

#define B_LAST MAX_NUM_BUILDINGS

Definition at line 42 of file improvement.h.

## ◆ B_NEVER

#define B_NEVER (NULL)

Definition at line 44 of file improvement.h.

## ◆ genus_iterate

#define genus_iterate | ( |  | _p | ) |

Value:
{ \
enum impr_genus_id _p; \
for (_p = (enum impr_genus_id)0; _p < IG_COUNT; \
_p = (enum impr_genus_id)((int)_p + 1)) {

Definition at line 224 of file improvement.h.

## ◆ genus_iterate_end

#define genus_iterate_end

Value:
} \
}

Definition at line 230 of file improvement.h.

## ◆ improvement_iterate

#define improvement_iterate | ( |  | _p | ) |

Value:
{ \
struct impr_type *_p = improvement_array_first(); \
if (NULL != _p) { \
for (; _p <= improvement_array_last(); _p++) {
improvement_array_last
const struct impr_type * improvement_array_last(void)
Definition improvement.c:151
improvement_array_first
struct impr_type * improvement_array_first(void)
Definition improvement.c:140
impr_type
Definition improvement.h:68

Definition at line 205 of file improvement.h.

## ◆ improvement_iterate_end

#define improvement_iterate_end

Value:
} \
} \
}

Definition at line 211 of file improvement.h.

## ◆ improvement_re_active_iterate

#define improvement_re_active_iterate | ( |  | _p | ) |

Value:
improvement_iterate(_p) { \
if (!_p->ruledit_disabled) {
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:205

Definition at line 216 of file improvement.h.

## ◆ improvement_re_active_iterate_end

#define improvement_re_active_iterate_end

Value:
} \
} improvement_iterate_end;
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:211

Definition at line 220 of file improvement.h.

## ◆ SPECENUM_BITVECTOR

#define SPECENUM_BITVECTOR bv_impr_flags

Definition at line 61 of file improvement.h.

## ◆ SPECENUM_COUNT

#define SPECENUM_COUNT IF_COUNT

Definition at line 60 of file improvement.h.

## ◆ SPECENUM_NAME

#define SPECENUM_NAME impr_flag_id

Definition at line 47 of file improvement.h.

## ◆ SPECENUM_VALUE0

#define SPECENUM_VALUE0 IF_VISIBLE_BY_OTHERS

Definition at line 49 of file improvement.h.

## ◆ SPECENUM_VALUE0NAME

#define SPECENUM_VALUE0NAME "VisibleByOthers"

Definition at line 50 of file improvement.h.

## ◆ SPECENUM_VALUE1

#define SPECENUM_VALUE1 IF_SAVE_SMALL_WONDER

Definition at line 52 of file improvement.h.

## ◆ SPECENUM_VALUE1NAME

#define SPECENUM_VALUE1NAME "SaveSmallWonder"

Definition at line 53 of file improvement.h.

## ◆ SPECENUM_VALUE2

#define SPECENUM_VALUE2 IF_GOLD

Definition at line 55 of file improvement.h.

## ◆ SPECENUM_VALUE2NAME

#define SPECENUM_VALUE2NAME "Gold"

Definition at line 56 of file improvement.h.

## ◆ SPECENUM_VALUE3

#define SPECENUM_VALUE3 IF_DISASTER_PROOF

Definition at line 58 of file improvement.h.

## ◆ SPECENUM_VALUE3NAME

#define SPECENUM_VALUE3NAME "DisasterProof"

Definition at line 59 of file improvement.h.

## ◆ WONDER_BUILT

#define WONDER_BUILT | ( |  | city_id | ) | ((city_id) > 0)

Definition at line 153 of file improvement.h.

## ◆ WONDER_DESTROYED

#define WONDER_DESTROYED (MAX_NUM_PLAYER_SLOTS + 1) /* Used as player id. */

Definition at line 146 of file improvement.h.

## ◆ WONDER_LOST

#define WONDER_LOST (-1) /* Used as city id. */

Definition at line 151 of file improvement.h.

## ◆ WONDER_NOT_BUILT

#define WONDER_NOT_BUILT 0 /* Used as city id. */

Definition at line 152 of file improvement.h.

## ◆ WONDER_NOT_OWNED

#define WONDER_NOT_OWNED (MAX_NUM_PLAYER_SLOTS + 2) /* Used as player id. */

Definition at line 147 of file improvement.h.

## ◆ WONDER_OWNED

#define WONDER_OWNED | ( |  | player_id | ) | ((player_id) < MAX_NUM_PLAYER_SLOTS)

Definition at line 148 of file improvement.h.

## Function Documentation

## ◆ BV_DEFINE()

BV_DEFINE | ( | bv_imprs | ,
|  | B_LAST |
| ) |  |

## ◆ can_city_sell_building()

bool can_city_sell_building | ( | const struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

Return TRUE iff the city can sell the given improvement.

Definition at line 1072 of file improvement.c.

Referenced by can_city_sell_universal(), city_balance_treasury_buildings(), city_landlocked_sell_coastal_improvements(), dai_city_sell_noncritical(), do_sell_building(), enable_city_dlg_widgets(), player_balance_treasury_units_and_buildings(), remove_obsolete_buildings_city(), test_player_sell_building_now(), and try_to_sell_stuff().

## ◆ can_improvement_go_obsolete()

bool can_improvement_go_obsolete | ( | const struct impr_type * | pimprove | ) |

Return TRUE if the improvement can ever go obsolete. Can be used for buildings or wonders.

Definition at line 401 of file improvement.c.

Referenced by dai_can_requirement_be_met_in_city(), is_req_preventing(), is_req_unchanging(), and req_text_insert().

## ◆ can_player_build_improvement_direct()

bool can_player_build_improvement_direct | ( | const struct player * | p,
|  | const struct impr_type * | pimprove
| ) |  |

Whether player can build given building somewhere, ignoring whether it is obsolete.

Definition at line 659 of file improvement.c.

Referenced by api_methods_player_can_build_impr_direct(), can_city_build_improvement_direct(), can_player_build_improvement_now(), can_player_build_unit_direct(), dai_wants_defender_against(), and dai_wants_role_unit().

## ◆ can_player_build_improvement_later()

bool can_player_build_improvement_later | ( | const struct player * | p,
|  | const struct impr_type * | pimprove
| ) |  |

Whether player can eventually build given building somewhere – i.e., returns TRUE if building is available with current tech OR will be available with future tech. Returns FALSE if building is obsolete.

Definition at line 734 of file improvement.c.

Referenced by ba_human_wants(), can_city_build_improvement_later(), collect_eventually_buildable_targets(), dai_build_adv_adjust(), and popup_worklist_editor().

## ◆ can_player_build_improvement_now()

bool can_player_build_improvement_now | ( | const struct player * | p,
|  | struct impr_type * | pimprove
| ) |  |

Whether player can build given building somewhere immediately. Returns FALSE if building is obsolete.

Definition at line 717 of file improvement.c.

Referenced by collect_buildable_targets(), collect_eventually_buildable_targets(), and popup_worklist_editor().

## ◆ can_sell_building()

bool can_sell_building | ( | const struct impr_type * | pimprove | ) |

Return TRUE iff the improvement can be sold.

Definition at line 1064 of file improvement.c.

Referenced by economy_report_command_callback(), economy_report_selection_callback(), and eco_report::selection_changed().

## ◆ city_from_great_wonder()

struct city * city_from_great_wonder | ( | const struct impr_type * | pimprove | ) |

Get the world city with this great wonder. This doesn't always success on the client side.

Definition at line 989 of file improvement.c.

Referenced by build_or_move_building(), calc_civ_score(), found_new_tech(), and report_wonders_of_the_world().

## ◆ city_from_small_wonder()

struct city * city_from_small_wonder | ( | const struct player * | pplayer,
|  | const struct impr_type * | pimprove
| ) |  |

Get the player city with this small wonder.

Definition at line 1049 of file improvement.c.

Referenced by base_want(), build_free_small_wonders(), and build_or_move_building().

## ◆ city_from_wonder()

struct city * city_from_wonder | ( | const struct player * | pplayer,
|  | const struct impr_type * | pimprove
| ) |  |

Get the world city with this wonder (small or great). This doesn't always succeed on the client side, and even when it does, it may return an "invisible" city whose members are unexpectedly NULL; take care.

Definition at line 872 of file improvement.c.

Referenced by can_player_build_unit_direct(), city_from_great_wonder(), city_from_small_wonder(), plr_widget::nation_selected(), num_continent_buildings(), update_intel_dialog(), and update_intel_wonder_dialog().

## ◆ great_wonder_is_available()

bool great_wonder_is_available | ( | const struct impr_type * | pimprove | ) |

Returns whether this wonder can be currently built.

Definition at line 977 of file improvement.c.

Referenced by can_player_build_improvement_direct(), can_player_build_improvement_later(), city_improvement_name_translation(), city_turns_to_build(), dai_can_player_build_improvement_later(), and unchanging_building().

## ◆ great_wonder_is_built()

bool great_wonder_is_built | ( | const struct impr_type * | pimprove | ) |

Returns whether this wonder is currently built.

Definition at line 955 of file improvement.c.

Referenced by can_player_build_unit_direct(), get_city_dialog_production_row(), num_world_buildings(), num_world_buildings_total(), and popup_worklist_editor().

## ◆ great_wonder_is_destroyed()

bool great_wonder_is_destroyed | ( | const struct impr_type * | pimprove | ) |

Returns whether this wonder has been destroyed.

Definition at line 966 of file improvement.c.

Referenced by can_player_build_unit_direct(), city_improvement_name_translation(), get_city_dialog_production_row(), num_world_buildings_total(), popup_worklist_editor(), report_wonders_of_the_world(), sg_save_players(), and unchanging_building().

## ◆ great_wonder_owner()

struct player * great_wonder_owner | ( | const struct impr_type * | pimprove | ) |

Get the player owning this small wonder. This doesn't always success on the client side.

Definition at line 1021 of file improvement.c.

Referenced by can_player_build_unit_direct().

## ◆ impr_base_build_shield_cost()

int impr_base_build_shield_cost | ( | const struct impr_type * | pimprove | ) |

Returns the base number of shields it takes to build this improvement. This one does not take city specific bonuses in to account.

Definition at line 259 of file improvement.c.

Referenced by help_update_improvement(), help_update_wonder(), popup_impr_info(), and help_widget::set_topic_building().

## ◆ impr_build_shield_cost()

int impr_build_shield_cost | ( | const struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

Returns the number of shields it takes to build this improvement.

Definition at line 292 of file improvement.c.

Referenced by adjust_improvement_wants_by_effects(), city_build_building(), city_gold_worth(), city_incite_cost(), city_migration_score(), city_turn_notify(), dai_war_desire(), get_city_dialog_production_row(), get_tooltip_improvement(), impr_buy_gold_cost(), name_and_sort_items(), popup_worklist_editor(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), redraw_city_dialog(), universal_build_shield_cost(), and city_dialog::update_improvements().

## ◆ impr_buy_gold_cost()

int impr_buy_gold_cost | ( | const struct city * | pcity,
|  | const struct impr_type * | pimprove,
|  | int | shields_in_stock
| ) |  |

Returns the amount of gold it takes to rush this improvement.

Definition at line 304 of file improvement.c.

Referenced by city_production_buy_gold_cost(), military_advisor_choose_build(), and wonder_benefit().

## ◆ impr_estimate_build_shield_cost()

int impr_estimate_build_shield_cost | ( | const struct player * | pplayer,
|  | const struct tile * | ptile,
|  | const struct impr_type * | pimprove
| ) |  |

Returns estimate of the number of shields it takes to build this improvement. pplayer and ptile can be NULL, but that might reduce quality of the estimate.

Definition at line 271 of file improvement.c.

Referenced by get_city_dialog_production_row(), and get_tooltip_improvement().

## ◆ impr_sell_gold()

int impr_sell_gold | ( | const struct impr_type * | pimprove | ) |

Returns the amount of gold received when this improvement is sold.

Definition at line 332 of file improvement.c.

Referenced by city_gold_worth(), city_landlocked_sell_coastal_improvements(), dai_city_sell_noncritical(), do_sell_building(), impr_item::mouseDoubleClickEvent(), popup_sell_impr_callback(), really_handle_city_sell(), remove_obsolete_buildings_city(), sell_all_improvements(), sell_callback(), sell_impr_iterate(), and sell_imprvm_dlg_callback().

## ◆ improvement_array_first()

struct impr_type * improvement_array_first | ( | void |  | ) |

Return the first item of improvements.

Definition at line 140 of file improvement.c.

## ◆ improvement_array_last()

const struct impr_type * improvement_array_last | ( | void |  | ) |

Return the last item of improvements.

Definition at line 151 of file improvement.c.

## ◆ improvement_by_number()

struct impr_type * improvement_by_number | ( | const Impr_type_id | id | ) |

Returns the improvement type for the given index/ID. Returns NULL for an out-of-range index.

Definition at line 192 of file improvement.c.

Referenced by tab_building::add_now2(), adjust_ai_unit_choice(), api_find_building_type(), building_has_effect(), cid_decode(), city_build_free_buildings(), diplomat_sabotage(), city_widget::display_list_menu(), do_unit_strike_city_building(), enable_city_dlg_widgets(), handle_city_sell(), handle_ruleset_building(), helptext_building(), helptext_nation(), load_building_names(), load_ruleset_buildings(), military_advisor_choose_build(), ok_sell_impr_callback(), package_player_info(), popup_impr_info(), popup_sell_impr_callback(), save_building_list(), eco_report::sell_buildings(), sell_imprvm_dlg_callback(), eco_report::sell_redundant(), sg_load_player_unit(), simple_action_callback(), simple_action_callback(), unit_order_list_is_sane(), unit_perform_action(), universal_by_number(), universal_value_initial(), and valid_improvement_by_number().

## ◆ improvement_by_rule_name()

struct impr_type * improvement_by_rule_name | ( | const char * | name | ) |

Does a linear search of improvement_types[].name.vernacular Returns NULL when none match.

Definition at line 365 of file improvement.c.

Referenced by api_find_building_type_by_name(), tab_building::initialize_new_bldg(), lookup_building(), lookup_building_list(), tab_building::select_bldg(), sg_load_player_city(), sg_load_player_city(), sg_load_player_main(), sg_load_player_main(), sg_load_player_vision_city(), sg_load_player_vision_city(), sg_load_players_basic(), sg_load_players_basic(), and universal_value_from_str().

## ◆ improvement_by_translated_name()

struct impr_type * improvement_by_translated_name | ( | const char * | name | ) |

Does a linear search of improvement_types[].name.translated Returns NULL when none match.

Definition at line 350 of file improvement.c.

Referenced by help_update_improvement(), help_update_wonder(), help_dialog::make_tree(), and help_widget::set_topic_building().

## ◆ improvement_count()

Impr_type_id improvement_count | ( | void |  | ) |

Return the number of improvements.

Definition at line 162 of file improvement.c.

Referenced by collect_production_targets(), get_req_source_effects(), handle_ruleset_building(), improvement_by_number(), popup_info_text(), sg_save_player_cities(), sg_save_player_main(), sg_save_player_vision(), sg_save_players(), and sg_save_savefile().

## ◆ improvement_feature_cache_init()

void improvement_feature_cache_init | ( | void |  | ) |

Cache features of the improvement

Definition at line 90 of file improvement.c.

Referenced by handle_rulesets_ready(), and load_rulesetdir().

## ◆ improvement_has_flag()

bool improvement_has_flag | ( | const struct impr_type * | pimprove,
|  | enum impr_flag_id | flag
| ) |  |

Return TRUE if the impr has this flag otherwise FALSE

Definition at line 381 of file improvement.c.

Referenced by adjust_improvement_wants_by_effects(), apply_disaster(), ba_human_wants(), build_free_small_wonders(), city_build_free_buildings(), city_can_buy(), city_production_has_flag(), dai_build_adv_adjust(), get_city_dialog_production_full(), get_city_dialog_production_row(), get_tooltip(), helptext_building(), impr_buy_gold_cost(), is_improvement_productive(), is_improvement_redundant(), is_improvement_visible(), name_and_sort_items(), city_production_delegate::paint(), city_production_model::populate(), popup_impr_info(), popup_worklist_editor(), redraw_city_dialog(), refresh_production_label(), rs_buildings(), save_buildings_ruleset(), city_widget::select_building_something(), should_force_recalc(), target_get_section(), and city_dialog::update_improvements().

## ◆ improvement_index()

Impr_type_id improvement_index | ( | const struct impr_type * | pimprove | ) |

Return the improvement index.

Currently same as improvement_number(), paired with improvement_count() indicates use as an array index.

Definition at line 173 of file improvement.c.

Referenced by adjust_improvement_wants_by_effects(), adv_data_city_impr_calc(), ba_human_wants(), base_want(), build_free_small_wonders(), building_advisor_choose(), city_add_improvement(), city_from_great_wonder(), city_from_wonder(), city_has_building(), city_production_caravan_shields_init(), city_production_gets_caravan_shields(), city_remove_improvement(), dai_build_adv_adjust(), dai_build_adv_override(), dai_can_requirement_be_met_in_city(), dai_choose_help_wonder(), dai_city_want(), extviewer_refresh_widgets(), get_building_sprite(), great_wonder_is_available(), great_wonder_is_built(), great_wonder_is_destroyed(), great_wonder_owner(), handle_city_info(), handle_city_sabotage_list(), handle_city_short_info(), initialize_globals(), package_city(), propval_as_string(), propval_equal(), tab_building::refresh(), remove_city(), sg_load_player_city(), sg_load_player_main(), sg_load_player_main(), sg_load_player_vision_city(), sg_load_player_vision_city(), sg_load_players_basic(), sg_load_players_basic(), sg_save_player_cities(), sg_save_player_main(), sg_save_player_vision(), sg_save_players(), sg_save_savefile(), spy_send_sabotage_list(), tileset_setup_impr_type(), transfer_city(), update_dumb_city(), update_improvement_from_packet(), wonder_is_built(), and wonder_is_lost().

## ◆ improvement_name_translation()

const char * improvement_name_translation | ( | const struct impr_type * | pimprove | ) |

Return the (translated) name of the given improvement. You don't have to free the return pointer.

Definition at line 241 of file improvement.c.

Referenced by api_methods_building_type_name_translation(), apply_disaster(), boot_help_texts(), build_free_small_wonders(), city_build_building(), city_dialog_update_building(), city_global_turn_notify(), city_improvement_name_translation(), city_increase_size(), city_landlocked_sell_coastal_improvements(), city_turn_notify(), cityrep_buy(), client_change_all(), go_act_menu::create(), create_tech_info(), dai_city_sell_noncritical(), diplomat_sabotage(), city_widget::display_list_menu(), do_unit_strike_city_building(), economy_report_command_callback(), economy_report_dialog_popup(), economy_report_update(), extviewer_refresh_widgets(), found_new_tech(), get_prod_complete_string(), get_tooltip_improvement(), handle_edit_city(), help_callback(), help_update_tech(), helptext_building(), helptext_nation(), impr_callback(), improvement_by_translated_name(), insert_allows(), manual_command(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), city_production_delegate::paint(), city_production_model::populate(), popup_impr_info(), popup_info_text(), popup_sell_impr_callback(), popup_worklist_editor(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), real_menus_init(), real_menus_update(), really_handle_city_buy(), really_handle_city_sell(), redraw_city_dialog(), remove_obsolete_buildings_city(), report_wonders_of_the_world(), req_text_insert(), research_tech_lost(), sanity_check_req_individual(), select_impr_or_unit_callback(), select_impr_or_unit_callback(), sell_all_improvements(), eco_report::sell_buildings(), sell_random_building(), eco_report::sell_redundant(), help_widget::set_topic_tech(), universal_name_translation(), update_intel_dialog(), update_intel_wonder_dialog(), eco_report::update_report(), upgrade_building_prod(), and wl_help_from_iter().

## ◆ improvement_number()

Impr_type_id improvement_number | ( | const struct impr_type * | pimprove | ) |

Return the improvement index.

Definition at line 182 of file improvement.c.

Referenced by building_has_effect(), cid_encode(), city_from_great_wonder(), city_from_wonder(), go_act_menu::create(), create_improvements_list(), create_tech_info(), dai_action_choose_sub_tgt_unit_vs_city(), dai_find_source_building(), diplomat_sabotage(), city_widget::display_list_menu(), economy_report_dialog_popup(), get_target_help_data(), handle_edit_city(), load_ruleset_units(), lookup_building_list(), impr_item::mouseDoubleClickEvent(), popup_impr_info(), popup_sabotage_dialog(), popup_sabotage_dialog(), popup_worklist_editor(), rebuild_imprm_list(), sell_all_improvements(), eco_report::sell_buildings(), sell_callback(), sell_impr_iterate(), eco_report::sell_redundant(), send_ruleset_buildings(), set_global_worklist(), unit_goto_and_callback(), unit_goto_and_callback(), universal_number(), wonder_built(), and wonder_destroyed().

## ◆ improvement_obsolete()

bool improvement_obsolete | ( | const struct player * | pplayer,
|  | const struct impr_type * | pimprove,
|  | const struct city * | pcity
| ) |  |

Returns TRUE if the improvement or wonder is obsolete

Definition at line 409 of file improvement.c.

Referenced by can_city_build_improvement_now(), can_player_build_improvement_later(), can_player_build_improvement_now(), city_gold_worth(), city_improvement_name_translation(), dai_can_player_build_improvement_later(), dai_can_requirement_be_met_in_city(), dai_war_desire(), get_city_dialog_production_row(), improvement_has_effects(), is_building_req_active(), is_improvement_productive(), is_improvement_redundant(), is_req_unchanging(), plr_widget::nation_selected(), popup_worklist_editor(), remove_obsolete_buildings_city(), unchanging_building(), update_intel_dialog(), and update_intel_wonder_dialog().

## ◆ improvement_replacement()

const struct impr_type * improvement_replacement | ( | const struct impr_type * | pimprove | ) |

Try to find a sensible replacement building, based on other buildings that may have caused this one to become obsolete.

Definition at line 1109 of file improvement.c.

Referenced by building_upgrades_to().

## ◆ improvement_rule_name()

const char * improvement_rule_name | ( | const struct impr_type * | pimprove | ) |

Return the (untranslated) rule name of the improvement. You don't have to free the return pointer.

Definition at line 250 of file improvement.c.

Referenced by adjust_improvement_wants_by_effects(), adv_choice_rule_name(), api_methods_building_type_rule_name(), ba_human_wants(), building_advisor_choose(), choose_build_target(), city_from_great_wonder(), city_from_wonder(), city_production_caravan_shields_init(), city_remove_improvement(), dai_build_adv_adjust(), dai_build_adv_override(), tab_building::delete_now(), diplomat_sabotage(), tab_building::edit_effects(), edit_impr::edit_impr(), tab_building::edit_reqs(), handle_ruleset_building(), improvement_by_rule_name(), is_universal_needed(), load_ruleset_buildings(), tab_building::name_given(), process_attacker_want(), tab_building::refresh(), rs_buildings(), sanity_check_ruleset_data(), save_building_list(), sg_save_savefile(), tileset_setup_impr_type(), universal_kind_values(), universal_rule_name(), tab_building::update_bldg_info(), and want_tech_for_improvement_effect().

## ◆ improvements_free()

void improvements_free | ( | void |  | ) |

Frees the memory associated with all improvements.

Definition at line 80 of file improvement.c.

Referenced by game_ruleset_free().

## ◆ improvements_init()

void improvements_init | ( | void |  | ) |

Initialize building structures.

Definition at line 46 of file improvement.c.

Referenced by game_ruleset_init().

## ◆ is_great_wonder()

bool is_great_wonder | ( | const struct impr_type * | pimprove | ) |

Is this building a great wonder?

Definition at line 767 of file improvement.c.

Referenced by api_edit_remove_building(), api_methods_building_type_is_great_wonder(), base_want(), boot_help_texts(), build_or_move_building(), calc_civ_score(), can_player_build_improvement_direct(), can_player_build_improvement_later(), can_player_build_unit_direct(), change_build_target(), city_build_building(), city_build_free_buildings(), city_dialog_update_improvement_list(), city_from_great_wonder(), city_global_turn_notify(), city_improvement_name_translation(), city_turns_to_build(), dai_build_adv_adjust(), dai_can_player_build_improvement_later(), dai_war_desire(), found_new_tech(), get_city_dialog_production_row(), great_wonder_is_available(), great_wonder_is_built(), great_wonder_is_destroyed(), great_wonder_owner(), help_callback(), help_type_by_requirement(), help_update_improvement(), help_update_tech(), help_update_wonder(), impr_callback(), initialize_globals(), is_wonder(), manual_command(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), nr_wonders(), num_world_buildings(), num_world_buildings_total(), popup_worklist_editor(), propval_as_string(), remove_city(), report_wonders_of_the_world(), req_text_insert(), sanity_check_req_individual(), help_widget::set_topic_building(), help_widget::set_topic_tech(), sg_save_players(), tactical_req_cb(), target_get_section(), transfer_city(), unchanging_building(), update_intel_wonder_dialog(), wl_help_from_iter(), wonder_built(), wonder_destroyed(), and wonder_visible_to_player().

## ◆ is_improvement()

bool is_improvement | ( | const struct impr_type * | pimprove | ) |

Is this building a regular improvement?

Definition at line 783 of file improvement.c.

Referenced by api_methods_building_type_is_improvement(), apply_disaster(), can_city_sell_building(), can_sell_building(), dai_find_source_building(), edit_buffer_copy(), get_economy_report_data(), city_production_model::populate(), and raze_city().

## ◆ is_improvement_productive()

bool is_improvement_productive | ( | const struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

Returns TRUE if an improvement in a city is productive, in some way.

Note that unproductive improvements may become productive later, if appropriate conditions are met (e.g. a special building that isn't producing units under the current government might under another).

Definition at line 615 of file improvement.c.

Referenced by ba_human_wants(), building_advisor(), and building_crucial().

## ◆ is_improvement_redundant()

bool is_improvement_redundant | ( | const struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

Returns TRUE if an improvement in a city is redundant, that is, the city wouldn't lose anything by losing the improvement, or gain anything by building it. This means:

- all of its effects (if any) are provided by other means, or it's obsolete (and thus assumed to have no effect); and
- it's not enabling the city to build some kind of units; and
- it's not Coinage (IF_GOLD). (Note that it's not impossible that this improvement could become useful if circumstances changed, say if a new government enabled the building of its special units.)

Definition at line 636 of file improvement.c.

Referenced by cell_render_func(), city_dialog_update_building(), city_dialog_update_improvement_list(), city_improvement_name_translation(), dai_city_sell_noncritical(), get_city_dialog_production_row(), get_economy_report_data(), city_production_delegate::paint(), popup_worklist_editor(), and sell_all_improvements().

## ◆ is_improvement_visible()

bool is_improvement_visible | ( | const struct impr_type * | pimprove | ) |

Return TRUE if the improvement should be visible to others without spying

Definition at line 391 of file improvement.c.

Referenced by handle_city_short_info(), is_req_knowable(), popup_info_text(), and update_dumb_city().

## ◆ is_small_wonder()

bool is_small_wonder | ( | const struct impr_type * | pimprove | ) |

Is this building a small wonder?

Definition at line 775 of file improvement.c.

Referenced by api_methods_building_type_is_small_wonder(), base_want(), build_or_move_building(), can_player_build_unit_direct(), city_build_building(), city_build_free_buildings(), city_dialog_update_improvement_list(), city_from_small_wonder(), dai_war_desire(), get_city_dialog_production_row(), helptext_building(), is_wonder(), popup_worklist_editor(), propval_as_string(), raze_city(), remove_city(), small_wonder_is_built(), target_get_section(), transfer_city(), and wonder_visible_to_player().

## ◆ is_special_improvement()

bool is_special_improvement | ( | const struct impr_type * | pimprove | ) |

Returns TRUE if this is a "special" improvement. For example, spaceship parts and coinage in the default ruleset are considered special.

Definition at line 792 of file improvement.c.

Referenced by api_edit_create_building(), extviewer_refresh_widgets(), handle_edit_city(), and city_production_model::populate().

## ◆ is_wonder()

bool is_wonder | ( | const struct impr_type * | pimprove | ) |

Returns whether improvement is some kind of wonder. Both great wonders and small wonders count.

Definition at line 341 of file improvement.c.

Referenced by adjust_improvement_wants_by_effects(), api_edit_remove_building(), api_methods_building_type_is_wonder(), are_prods_same_class(), ba_human_wants(), base_want(), building_advisor(), building_advisor_choose(), city_add_improvement(), city_change_production_penalty(), city_from_wonder(), city_gold_worth(), city_improvement_upkeep(), city_migration_score(), city_remove_improvement(), city_select_building_callback(), city_select_building_callback(), city_worklist_commit(), collect_production_targets(), create_tech_info(), dai_build_adv_adjust(), dai_build_adv_override(), dai_choose_help_wonder(), dai_spend_gold(), do_city_migration(), economy_report_dialog_popup(), initialize_globals(), is_improvement_visible(), plr_widget::nation_selected(), num_continent_buildings(), num_player_buildings(), player_has_ever_built(), city_production_model::populate(), popup_impr_info(), popup_worklist_editor(), rebuild_imprm_list(), req_text_insert(), rs_buildings(), rscompat_adjust_pre_sanity(), sanity_check_req_individual(), city_widget::select_building_something(), sg_save_player_main(), update_intel_dialog(), update_intel_wonder_dialog(), wonder_benefit(), wonder_built(), wonder_destroyed(), wonder_is_built(), and wonder_is_lost().

## ◆ small_wonder_is_built()

bool small_wonder_is_built | ( | const struct player * | pplayer,
|  | const struct impr_type * | pimprove
| ) |  |

Returns whether the player has built this small wonder.

Definition at line 1037 of file improvement.c.

Referenced by popup_worklist_editor().

## ◆ test_player_sell_building_now()

enum test_result test_player_sell_building_now | ( | struct player * | pplayer,
|  | struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

Return TRUE iff the player can sell the given improvement from city. If pimprove is NULL, returns iff city could sell some building type (this does not check if such building is in this city)

Definition at line 1083 of file improvement.c.

Referenced by impr_item::mouseDoubleClickEvent(), really_handle_city_sell(), and sell_callback().

## ◆ valid_improvement()

const struct impr_type * valid_improvement | ( | const struct impr_type * | pimprove | ) |

Returns pointer when the improvement_type "exists" in this game, returns NULL otherwise.

An improvement_type doesn't exist for any of:

- the improvement_type has been flagged as removed by setting its tech_req to A_LAST; [was not in current 2007-07-27]
- it is a space part, and the spacerace is not enabled.

Definition at line 209 of file improvement.c.

Referenced by advisor_choose_build(), boot_help_texts(), building_upgrades_to(), can_player_build_improvement_direct(), can_player_build_improvement_later(), can_sell_building(), create_tech_info(), research_diagram::create_tooltip_help(), dai_can_player_build_improvement_later(), draw_reqtree(), help_update_tech(), insert_allows(), manual_command(), node_rectangle_minimum_size(), help_widget::set_topic_tech(), and valid_improvement_by_number().

## ◆ valid_improvement_by_number()

const struct impr_type * valid_improvement_by_number | ( | const Impr_type_id | id | ) |

Returns pointer when the improvement_type "exists" in this game, returns NULL otherwise.

In addition to valid_improvement(), tests for id is out of range.

Definition at line 232 of file improvement.c.

## ◆ wonder_built()

void wonder_built | ( | const struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

Build a wonder in the city.

Definition at line 800 of file improvement.c.

Referenced by city_add_improvement().

## ◆ wonder_destroyed()

void wonder_destroyed | ( | const struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

Remove a wonder from a city and destroy it if it's a great wonder. To transfer a great wonder, use great_wonder_transfer.

Definition at line 820 of file improvement.c.

Referenced by city_remove_improvement().

## ◆ wonder_is_built()

bool wonder_is_built | ( | const struct player * | pplayer,
|  | const struct impr_type * | pimprove
| ) |  |

Returns whether the player is currently in possession of this wonder (small or great).

Definition at line 857 of file improvement.c.

Referenced by api_methods_player_has_wonder(), get_city_dialog_production_row(), plr_widget::nation_selected(), num_player_buildings(), player_has_ever_built(), small_wonder_is_built(), update_intel_dialog(), and update_intel_wonder_dialog().

## ◆ wonder_is_lost()

bool wonder_is_lost | ( | const struct player * | pplayer,
|  | const struct impr_type * | pimprove
| ) |  |

Returns whether the player has lost this wonder after having owned it (small or great).

Definition at line 844 of file improvement.c.

Referenced by plr_widget::nation_selected(), player_has_ever_built(), sg_save_player_main(), update_intel_dialog(), and update_intel_wonder_dialog().

## ◆ wonder_visible_to_player()

bool wonder_visible_to_player | ( | const struct impr_type * | wonder,
|  | const struct player * | pplayer,
|  | const struct player * | owner
| ) |  |

Can the player see wonder owned by the other player?

Definition at line 921 of file improvement.c.

Referenced by package_player_info().