48 requirement_vector_init(&p->
reqs);
61 requirement_vector_free(&p->
reqs);
81 pimprove->allows_units =
false;
85 pimprove->allows_units =
true;
91 pimprove->allows_extras =
false;
95 pimprove->allows_extras =
true;
101 pimprove->prevents_disaster =
false;
105 pimprove->prevents_disaster =
true;
111 pimprove->protects_vs_actions =
false;
115 &act->target_reqs)) {
116 pimprove->protects_vs_actions =
true;
196 if (
nullptr == pimprove) {
246 const struct tile *ptile,
252 nullptr, pimprove, ptile,
nullptr,
253 nullptr,
nullptr,
nullptr,
254 nullptr, EFT_IMPR_BUILD_COST_PCT))
279 int shields_in_stock)
294 if (shields_in_stock == 0) {
362 enum impr_flag_id flag)
383 return requirement_vector_size(&pimprove->
obsolete_by) > 0;
391 const struct city *pcity)
393 struct tile *ptile =
nullptr;
395 if (pcity !=
nullptr) {
401 if (
is_req_active(pplayer,
nullptr, pcity, pimprove, ptile,
nullptr,
402 nullptr,
nullptr,
nullptr,
nullptr, preq,
543 .kind = VUT_IMPROVEMENT};
617 bool space_part =
false;
625 if (preq->range >= REQ_RANGE_PLAYER
626 && !
is_req_active(p,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
627 nullptr,
nullptr,
nullptr,
nullptr, preq,
710 && !
is_req_active(p,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
711 nullptr,
nullptr,
nullptr,
nullptr, preq,
728 return (pimprove->
genus == IG_GREAT_WONDER);
736 return (pimprove->
genus == IG_SMALL_WONDER);
744 return (pimprove->
genus == IG_IMPROVEMENT);
753 return pimprove->
genus == IG_SPECIAL;
862 if (
nullptr == pcity) {
863 qCritical(
"Player %s (nb %d) has outdated wonder info for "
864 "%s (nb %d), it points to city nb %d.",
869 qCritical(
"Player %s (nb %d) has outdated wonder info for "
870 "%s (nb %d), the city %s (nb %d) doesn't have this wonder.",
938 qCritical(
"Game has outdated wonder info for %s (nb %d), "
939 "the player %s (nb %d) doesn't have this wonder.",
979 if (
nullptr == pplayer) {
1013 if (pcity->
owner != pplayer) {
1038 if (pobs->source.kind == VUT_IMPROVEMENT && pobs->present) {
1039 return pobs->source.value.building;
bool is_action_possible_on_city(action_id act_id, const struct player *actor_player, const struct city *target_city)
Returns TRUE if the wanted action can be done to the target city.
#define action_enablers_iterate_end
#define action_enablers_iterate(_enabler_)
bool BV_ISSET(const BV &bv, int bit)
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city has this building in it.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
#define city_tile_iterate_end
static void base(QVariant data1, QVariant data2)
Action "Build Base" for choice dialog.
bool can_disaster_happen(const struct disaster_type *pdis, const struct city *pcity)
Whether disaster can happen in given city.
#define disaster_type_iterate(_p)
#define disaster_type_iterate_end
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_potential_improvement_bonus(const struct impr_type *pimprove, const struct city *pcity, enum effect_type effect_type, const enum req_problem_type prob_type)
Returns the effect bonus the improvement would or does provide if present.
bool is_building_replaced(const struct city *pcity, const struct impr_type *pimprove, const enum req_problem_type prob_type)
Returns TRUE if a building is replaced.
struct effect_list * get_req_source_effects(struct universal *psource)
Get a list of effects with this requirement source.
int get_building_bonus(const struct city *pcity, const struct impr_type *building, enum effect_type effect_type)
Returns the effect bonus at a building.
bool building_has_effect(const struct impr_type *pimprove, enum effect_type effect_type)
Returns TRUE if the building has any effect bonuses of the given type.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
#define effect_list_iterate_end
#define effect_list_iterate(effect_list, peffect)
bool is_server()
Is program type server?
void improvements_free()
Frees the memory associated with all improvements.
bool can_sell_building(const struct impr_type *pimprove)
Return TRUE iff the improvement can be sold.
int impr_sell_gold(const struct impr_type *pimprove)
Returns the amount of gold received when this improvement is sold.
Impr_type_id improvement_count()
Return the number of improvements.
struct city * city_from_great_wonder(const struct impr_type *pimprove)
Get the world city with this great wonder.
bool can_city_sell_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city can sell the given improvement.
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.
bool great_wonder_is_built(const struct impr_type *pimprove)
Returns whether this wonder is currently built.
static bool improvement_has_side_effects(const struct city *pcity, const struct impr_type *pimprove)
Check if an improvement has side effects for a city.
const char * improvement_rule_name(const struct impr_type *pimprove)
Return the (untranslated) rule name of the improvement.
struct impr_type * improvement_array_first()
Return the first item of improvements.
bool is_special_improvement(const struct impr_type *pimprove)
Returns TRUE if this is a "special" improvement.
static bool impr_prevents_disaster(const struct city *pcity, const struct impr_type *pimprove)
Returns TRUE iff improvement prevents a disaster in city.
struct impr_type * improvement_by_rule_name(const char *name)
Does a linear search of improvement_types[].name.vernacular Returns nullptr when none match.
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 lo...
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 avai...
void wonder_built(const struct city *pcity, const struct impr_type *pimprove)
Build a wonder in the city.
struct city * city_from_small_wonder(const struct player *pplayer, const struct impr_type *pimprove)
Get the player city with this small wonder.
void improvements_init()
Initialize building structures.
void improvement_feature_cache_init()
Cache features of the improvement.
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
Returns whether this wonder has been destroyed.
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
Returns pointer when the improvement_type "exists" in this game, returns nullptr otherwise.
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).
bool can_player_build_improvement_now(const struct player *p, struct impr_type *pimprove)
Whether player can build given building somewhere immediately.
bool is_improvement(const struct impr_type *pimprove)
Is this building a regular improvement?
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
static bool improvement_has_effects(const struct city *pcity, const struct impr_type *pimprove)
Returns TRUE iff improvement provides some effect (good or bad).
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) and it hasn't b...
int impr_base_build_shield_cost(const struct impr_type *pimprove)
Returns the base number of shields it takes to build this improvement.
Impr_type_id improvement_number(const struct impr_type *pimprove)
Return the improvement index.
const struct impr_type * improvement_array_last()
Return the last item of improvements.
static bool impr_provides_buildable_extras(const struct city *pcity, const struct impr_type *pimprove)
Returns TRUE iff improvement provides extras buildable in city.
bool can_improvement_go_obsolete(const struct impr_type *pimprove)
Return TRUE if the improvement can ever go obsolete.
bool is_improvement_visible(const struct impr_type *pimprove)
Return TRUE if the improvement should be visible to others without spying.
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
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.
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.
struct impr_type * improvement_by_translated_name(const char *name)
Does a linear search of improvement_types[].name.translated Returns nullptr when none match.
static void improvement_free(struct impr_type *p)
Frees the memory associated with this improvement.
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
static bool impr_protects_vs_actions(const struct city *pcity, const struct impr_type *pimprove)
Returns TRUE iff improvement protects against an action on the city FIXME: This is prone to false pos...
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
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.
struct player * great_wonder_owner(const struct impr_type *pimprove)
Get the player owning this small wonder.
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Return TRUE if the impr has this flag otherwise FALSE.
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.
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 t...
struct city * city_from_wonder(const struct player *pplayer, const struct impr_type *pimprove)
Get the world city with this wonder (small or great).
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
static struct impr_type improvement_types[B_LAST]
All the city improvements: Use improvement_by_number(id) to access the array.
static bool impr_provides_buildable_units(const struct city *pcity, const struct impr_type *pimprove)
Returns TRUE iff improvement provides units buildable in city.
bool is_small_wonder(const struct impr_type *pimprove)
Is this building a small wonder?
enum test_result test_player_sell_building_now(struct player *pplayer, const city *pcity, const struct impr_type *pimprove)
Return TRUE iff the player can sell the given improvement from city.
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.
bool great_wonder_is_available(const struct impr_type *pimprove)
Returns whether this wonder can be currently built.
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.
#define WONDER_BUILT(city_id)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define WONDER_OWNED(player_id)
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
int player_number(const struct player *pplayer)
Return the player index/number/id.
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool is_req_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 *req, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement to see if it is active on the given target.
bool is_req_unchanging(const struct requirement *req)
Return TRUE if this is an "unchanging" requirement.
#define requirement_fulfilled_by_improvement(_imp_, _rqs_)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
#define requirement_needs_improvement(_imp_, _rqs_)
#define NUM_SS_COMPONENTS
#define NUM_SS_STRUCTURALS
struct packet_ruleset_control control
struct packet_game_info info
struct requirement_vector obsolete_by
struct requirement_vector reqs
struct name_translation name
QVector< QString > * helptext
enum spaceship_state state
int wonder_build_turn[B_LAST]
struct player_spaceship spaceship
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
const struct impr_type * building
#define unit_type_iterate(_p)
#define unit_type_iterate_end
bool victory_enabled(enum victory_condition_type victory)
Whether victory condition is enabled.