97 buf,
sizeof(buf),
"%s",
263 int attack_best[4] = {-1, -1, -1, -1}, i;
272 for (i = 2; i >= 0 && attack_best[i] < attack_best[i + 1]; i--) {
273 int tmp = attack_best[i];
274 attack_best[i] = attack_best[i + 1];
275 attack_best[i + 1] = tmp;
281 for (i = 0; i < 3; i++) {
282 if (attack_best[i] >= 0) {
283 cat_snprintf(buf,
sizeof(buf),
"%s%d", (i > 0) ?
"/" :
"",
286 cat_snprintf(buf,
sizeof(buf),
"%s-", (i > 0) ?
"/" :
"");
301 int defense_best[4] = {-1, -1, -1, -1}, i;
310 for (i = 2; i >= 0 && defense_best[i] < defense_best[i + 1]; i--) {
311 int tmp = defense_best[i];
313 defense_best[i] = defense_best[i + 1];
314 defense_best[i + 1] = tmp;
320 for (i = 0; i < 3; i++) {
321 if (defense_best[i] >= 0) {
322 cat_snprintf(buf,
sizeof(buf),
"%s%d", (i > 0) ?
"/" :
"",
325 cat_snprintf(buf,
sizeof(buf),
"%s-", (i > 0) ?
"/" :
"");
342 fc_snprintf(buf,
sizeof(buf),
"%2d", num_supported);
355 int num_present = unit_list_size(pcity->
tile->
units);
511 int num = 0, value = 0;
516 value += proute->value;
523 fc_snprintf(buf,
sizeof(buf),
"%d (+%d)", num, value);
548 static char buf[192];
586 price = pcity->
client.buy_cost;
599 fc_snprintf(buf,
sizeof(buf),
"%s/%s", buftwo, bufone);
620 price = pcity->
client.buy_cost;
731 #define FUNC_TAG(var) cr_entry_##var, #var
735 {
true, -15, 0,
nullptr,
N_(
"?city:Name"),
N_(
"City: Name"),
nullptr,
737 {
false, -15, 0,
nullptr,
N_(
"Nation"),
N_(
"City: Nation"),
nullptr,
739 {
false, 3, 1,
nullptr,
N_(
"?Continent:Cn"),
N_(
"City: Continent number"),
741 {
true, 2, 1,
nullptr,
N_(
"?size [short]:Sz"),
N_(
"City: Size"),
nullptr,
744 true, 14, 1,
N_(
"?food (population):Grow"),
745 N_(
"?Stock/Target:(Have/Need)"),
N_(
"City: Turns until growth/famine"),
747 {
true, -8, 1,
nullptr,
N_(
"State"),
748 N_(
"City: State: Celebrating/Happy/Peace/Disorder"),
nullptr,
750 {
false, 1, 1,
nullptr,
nullptr,
751 N_(
"City: Concise state: *=Celebrating, +=Happy, X=Disorder"),
nullptr,
753 {
true, 15, 1,
nullptr,
N_(
"?cma:Governor"),
N_(
"City: Governor"),
755 {
false, 4, 1,
N_(
"?plague risk [short]:Pla"),
N_(
"(%)"),
756 N_(
"City: Plague risk per turn"),
nullptr,
FUNC_TAG(plague_risk)},
759 {
false, 2, 1,
nullptr,
N_(
"?Happy workers:H"),
N_(
"Citizens: Happy"),
761 {
false, 2, 1,
nullptr,
N_(
"?Content workers:C"),
N_(
"Citizens: Content"),
763 {
false, 2, 1,
nullptr,
N_(
"?Unhappy workers:U"),
N_(
"Citizens: Unhappy"),
765 {
false, 2, 1,
nullptr,
N_(
"?Angry workers:A"),
N_(
"Citizens: Angry"),
767 {
false, 10, 1,
N_(
"?city:Citizens"),
768 N_(
"?happy/content/unhappy/angry:H/C/U/A"),
769 N_(
"Citizens: Concise: Happy/Content/Unhappy/Angry"),
nullptr,
773 {
false, 8, 1,
N_(
"Best"),
N_(
"attack"),
N_(
"Units: Best attackers"),
775 {
false, 8, 1,
N_(
"Best"),
N_(
"defense"),
N_(
"Units: Best defenders"),
777 {
false, 2, 1,
N_(
"Units"),
779 N_(
"?Present (units):Here"),
N_(
"Units: Number present"),
nullptr,
781 {
false, 2, 1,
N_(
"Units"),
783 N_(
"?Supported (units):Owned"),
N_(
"Units: Number supported"),
nullptr,
786 {
false, 3, 1,
nullptr,
N_(
"UpT"),
787 N_(
"Units: Maximum buildable per turn"),
nullptr,
791 {
false, 10, 1,
N_(
"Surplus"),
N_(
"?food/production/trade:F/P/T"),
792 N_(
"Resources: Surplus Food, Production, Trade"),
nullptr,
794 {
true, 3, 1,
nullptr,
N_(
"?Food surplus [short]:+F"),
795 N_(
"Resources: Surplus Food"),
nullptr,
FUNC_TAG(foodplus)},
796 {
true, 3, 1,
nullptr,
N_(
"?Production surplus [short]:+P"),
797 N_(
"Resources: Surplus Production"),
nullptr,
FUNC_TAG(prodplus)},
798 {
false, 3, 1,
nullptr,
N_(
"?Production loss (waste) [short]:-P"),
799 N_(
"Resources: Waste (lost production)"),
nullptr,
FUNC_TAG(waste)},
800 {
true, 3, 1,
nullptr,
N_(
"?Trade surplus [short]:+T"),
801 N_(
"Resources: Surplus Trade"),
nullptr,
FUNC_TAG(tradeplus)},
802 {
true, 3, 1,
nullptr,
N_(
"?Trade loss (corruption) [short]:-T"),
803 N_(
"Resources: Corruption (lost trade)"),
nullptr,
805 {
false, 1, 1,
N_(
"?number_trade_routes:n"),
N_(
"?number_trade_routes:R"),
806 N_(
"Resources: Number (and total value) of trade routes"),
nullptr,
808 {
false, 3, 1,
nullptr,
N_(
"?pollution [short]:Pol"),
809 N_(
"Production: Pollution"),
nullptr,
FUNC_TAG(pollution)},
812 {
false, 10, 1,
N_(
"Surplus"),
N_(
"?gold/luxury/science:G/L/S"),
813 N_(
"Surplus: Gold, Luxuries, Science"),
nullptr,
FUNC_TAG(output)},
814 {
true, 3, 1,
nullptr,
N_(
"?Gold:G"),
N_(
"Surplus: Gold"),
nullptr,
816 {
false, 3, 1,
nullptr,
N_(
"?Luxury:L"),
N_(
"Surplus: Luxury Goods"),
818 {
true, 3, 1,
nullptr,
N_(
"?Science:S"),
N_(
"Surplus: Science"),
nullptr,
822 {
false, 3, 1,
nullptr,
N_(
"?Culture:Clt"),
823 N_(
"Culture: History + Performance"),
nullptr,
FUNC_TAG(culture)},
824 {
false, 3, 1,
nullptr,
N_(
"?History:Hst"),
825 N_(
"Culture: History (and gain per turn)"),
nullptr,
FUNC_TAG(history)},
826 {
false, 3, 1,
nullptr,
N_(
"?Performance:Prf"),
827 N_(
"Culture: Performance"),
nullptr,
FUNC_TAG(performance)},
830 {
true, 9, 1,
N_(
"Production"),
N_(
"Turns/Buy"),
833 N_(
"Production: Turns/gold to complete"),
nullptr,
835 {
false, 0, 1,
N_(
"Buy"),
N_(
"(Gold)"),
N_(
"Production: Buy Cost"),
836 nullptr,
FUNC_TAG(build_cost_gold)},
837 {
false, 0, 1,
N_(
"Finish"),
N_(
"(Turns)"),
N_(
"Production: Build Turns"),
838 nullptr,
FUNC_TAG(build_cost_turns)},
839 {
true, 0, 1,
N_(
"Currently Building"),
N_(
"?Stock/Target:(Have/Need)"),
840 N_(
"Production: Currently Building"),
nullptr,
FUNC_TAG(building)}};
873 static char sp_explanation[
SP_MAX][128];
874 static char sp_explanations[
SP_MAX * 128];
883 fc_snprintf(sp_explanations,
sizeof(sp_explanations),
"%s",
894 fc_snprintf(sp_explanation[sp],
sizeof(sp_explanation[sp]),
896 cat_snprintf(sp_explanations,
sizeof(sp_explanations),
"%s%s",
908 static char sp_summary[128];
965 #define SPECVEC_TAG datum
974 int len = right - left;
1038 const struct datum_vector *b)
1042 n =
MIN(a->size, b->size);
1044 for (i = 0; i < n; i++) {
1054 return a->size - b->size;
1062 const char *string_start;
1064 datum_vector_init(data);
1071 value = strtof(str, &endptr);
1072 if (errno != 0 || endptr == str || !std::isfinite(value)) {
1080 if (str != string_start) {
1082 datum_vector_append(data, d);
1086 datum_vector_append(data, d);
1089 string_start = str = endptr;
1094 if (str != string_start) {
1098 datum_vector_append(data, d);
1109 for (i = 0; i < data->size; i++) {
1112 datum_vector_free(data);
1120 struct datum_vector data1, data2;
1125 }
else if (
nullptr == str1) {
1127 }
else if (
nullptr == str2) {
1148 return target->
kind == VUT_IMPROVEMENT
int city_granary_size(int city_size)
Generalized formula used to calculate granary size.
int city_build_slots(const struct city *pcity)
The maximum number of units a city can build per turn.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
Return TRUE when the current production has this flag.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Calculates the turns which are needed to build the requested production in the city.
bool city_unhappy(const struct city *pcity)
Return TRUE iff the city is unhappy.
bool city_celebrating(const struct city *pcity)
cities celebrate only after consecutive happy turns
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Calculate city's illness in tenth of percent:
bool city_happy(const struct city *pcity)
Return TRUE iff the city is happy.
static int cmp(int v1, int v2)
Compare two integer values, as required by qsort.
int city_turns_to_grow(const struct city *pcity)
Calculates the turns which are needed for the city to grow.
citizens city_size_get(const struct city *pcity)
Get the city size.
const char * city_production_name_translation(const struct city *pcity)
Return the extended name of the current production.
QString get_city_dialog_status_text(const struct city *pcity)
Return text describing the city's status: disorder/celebrating/...
char * city_production_cost_str(const struct city *pcity)
Return a string describing the cost for the production of the city considerung several build slots fo...
int city_history_gain(const struct city *pcity)
How much history city gains this turn.
static void attack(QVariant data1, QVariant data2)
Action "Attack" for choice dialog.
const char * cmafec_get_short_descr_of_city(const struct city *pcity)
Return short description of city governor preset.
bool can_city_sell_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city can sell the given improvement.
#define fc_assert(condition)
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
client_options * gui_options
const char * specialists_string(const citizens *specialist_list)
Return a string showing the number of specialists in the array.
const char * specialist_rule_name(const struct specialist *sp)
Return the (untranslated) rule name of the specialist type.
Specialist_type_id specialist_index(const struct specialist *sp)
Return the specialist index.
const char * specialist_abbreviation_translation(const struct specialist *sp)
Return the (translated) abbreviation of the specialist type.
const char * specialists_abbreviation_string()
Return a string containing all the specialist abbreviations, for instance "E/S/T".
struct specialist * specialist_by_number(const Specialist_type_id id)
Return the specialist pointer for the given number.
Specialist_type_id specialist_count()
Return the number of specialist_types.
const char * specialist_plural_translation(const struct specialist *sp)
Return the (translated, plural) name of the specialist type.
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
QString(* func)(const struct city *pcity, const void *data)
struct city::@15::@18 client
citizens feel[CITIZEN_LAST][FEELING_LAST]
citizens specialists[SP_MAX]
struct unit_list * units_supported
struct packet_game_info info
bool concise_city_production
The following several functions allow intelligent sorting city report fields by column.
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
int cat_snprintf(char *str, size_t n, const char *format,...)
cat_snprintf is like a combination of fc_snprintf and fc_strlcat; it does snprintf to the end of an e...
#define sz_strlcpy(dest, src)
#define trade_routes_iterate_end
#define trade_routes_iterate(c, proute)
const struct impr_type * building
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
static QString cr_entry_defense(const struct city *pcity, const void *data)
Returns string with best defend values of units in city.
const char * city_report_spec_tagname(int i)
Simple wrapper for city_report_specs.tagname.
static QString cr_entry_culture(const struct city *pcity, const void *data)
Returns city total culture written to string.
static QString cr_entry_history(const struct city *pcity, const void *data)
Returns city history culture value written to string.
static QString cr_entry_plague_risk(const struct city *pcity, const void *data)
Returns risk percentage of plague written to string.
static QString cr_entry_size(const struct city *pcity, const void *data)
Returns city size written to string.
static QString cr_entry_trade_routes(const struct city *pcity, const void *data)
Returns number and output of trade routes written to string.
static QString cr_entry_present(const struct city *pcity, const void *data)
Returns number of present units written to string.
static QString cr_entry_tradeplus(const struct city *pcity, const void *data)
Returns trade surplus written to string.
static QString cr_entry_resources(const struct city *pcity, const void *data)
Returns string listing amounts of resources.
static void init_datum_string(struct datum *dat, const char *left, const char *right)
Init a datum from a substring.
static QString cr_entry_supported(const struct city *pcity, const void *data)
Returns number of supported units written to string.
static QString cr_entry_growturns(const struct city *pcity, const void *data)
Returns number of turns before city grows written to string.
static QString cr_entry_angry(const struct city *pcity, const void *data)
Returns number of angry citizens written to string.
static QString cr_entry_cma(const struct city *pcity, const void *data)
Returns city cma description.
static QString cr_entry_prodplus(const struct city *pcity, const void *data)
Returns production surplus written to string.
static QString cr_entry_build_cost_turns(const struct city *pcity, const void *data)
Returns current production turns to completion written to string.
static void split_string(struct datum_vector *data, const char *str)
Split a string into a vector of datum.
static QString cr_entry_content(const struct city *pcity, const void *data)
Returns number of content citizens written to string.
static void free_data(struct datum_vector *data)
Free every datum in the vector.
static QString cr_entry_performance(const struct city *pcity, const void *data)
Returns city performance culture value written to string.
static QString cr_entry_continent(const struct city *pcity, const void *data)
Returns number of continent.
static QString cr_entry_build_cost_gold(const struct city *pcity, const void *data)
Returns cost of buying current production only written to string.
static int data_compare(const struct datum_vector *a, const struct datum_vector *b)
Compare two strings of data lexicographically.
static const struct city_report_spec base_city_report_specs[]
static QString cr_entry_building(const struct city *pcity, const void *data)
Returns name of current production.
static QString cr_entry_luxury(const struct city *pcity, const void *data)
Returns luxury output written to string.
static QString cr_entry_build_cost(const struct city *pcity, const void *data)
Returns cost of buying current production and turns to completion written to string.
static QString cr_entry_build_slots(const struct city *pcity, const void *data)
Returns number of build slots written to string.
static QString cr_entry_cityname(const struct city *pcity, const void *data)
cr_entry = return an entry (one column for one city) for the city report These return ptrs to filled ...
bool can_city_sell_universal(const struct city *pcity, const struct universal *target)
Same as can_city_sell_building(), but with universal argument.
static QString cr_entry_hstate_verbose(const struct city *pcity, const void *data)
Returns verbose city happiness state written to string.
static QString cr_entry_corruption(const struct city *pcity, const void *data)
Returns corruption amount written to string.
static QString cr_entry_workers(const struct city *pcity, const void *data)
Returns number of citizens of each happiness state written to string.
int cityrepfield_compare(const char *str1, const char *str2)
The real function: split the two strings, and compare them.
int num_city_report_spec()
Simple wrapper for num_creport_cols()
static QString cr_entry_happy(const struct city *pcity, const void *data)
Returns number of happy citizens written to string.
static QString cr_entry_pollution(const struct city *pcity, const void *data)
Returns pollution output written to string.
std::vector< city_report_spec > city_report_specs
static void free_datum(struct datum *dat)
Free the data associated with a datum – that is, free the string if it was allocated.
static QString cr_entry_specialist(const struct city *pcity, const void *data)
Returns number of specialists of type given as data written to string.
bool * city_report_spec_show_ptr(int i)
Simple wrapper for city_report_specs.show.
static QString cr_entry_output(const struct city *pcity, const void *data)
Returns string describing resource output.
static QString cr_entry_specialists(const struct city *pcity, const void *data)
Returns list of specialists written to string.
static QString cr_entry_hstate_concise(const struct city *pcity, const void *data)
Returns concise city happiness state written to string.
static QString cr_entry_unhappy(const struct city *pcity, const void *data)
Returns number of unhappy citizens written to string.
void init_city_report_game_data()
Initialize city report data.
static void init_datum_number(struct datum *dat, float val)
Init a datum from a number (a float because we happen to use strtof).
static QString cr_entry_attack(const struct city *pcity, const void *data)
Returns string with best attack values of units in city.
static int datum_compare(const struct datum *a, const struct datum *b)
Compare two data items as described above:
static QString cr_entry_nation(const struct city *pcity, const void *data)
Translated name of nation who owns this city.
static QString cr_entry_science(const struct city *pcity, const void *data)
Returns science output written to string.
static QString cr_entry_waste(const struct city *pcity, const void *data)
Returns waste amount written to string.
static int num_creport_cols
static QString cr_entry_foodplus(const struct city *pcity, const void *data)
Returns food surplus written to string.
static QString cr_entry_gold(const struct city *pcity, const void *data)
Returns gold surplus written to string.
bool worklist_is_empty(const struct worklist *pwl)
Returns whether worklist has no elements.