Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/cityrepdata.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
cityrepdata.c File Reference
`#include <errno.h>`
`#include <math.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "fcintl.h"`
`#include "log.h"`
`#include "support.h"`
`#include "city.h"`
`#include "culture.h"`
`#include "game.h"`
`#include "map.h"`
`#include "specialist.h"`
`#include "unitlist.h"`
`#include "cma_fec.h"`
`#include "citydlg_common.h"`
`#include "options.h"`
`#include "cityrepdata.h"`
`#include "specvec.h"`

Go to the source code of this file.

## Data Structures

struct | datum

## Macros

#define | FUNC_TAG(var) cr_entry_##var, #var
#define | SPECVEC_TAG datum

## Functions

static const char * | cr_entry_cityname (const struct city *pcity, const void *data)
static const char * | cr_entry_nation (const struct city *pcity, const void *data)
static const char * | cr_entry_size (const struct city *pcity, const void *data)
static const char * | cr_entry_hstate_concise (const struct city *pcity, const void *data)
static const char * | cr_entry_hstate_verbose (const struct city *pcity, const void *data)
static const char * | cr_entry_workers (const struct city *pcity, const void *data)
static const char * | cr_entry_happy (const struct city *pcity, const void *data)
static const char * | cr_entry_culture (const struct city *pcity, const void *data)
static const char * | cr_entry_history (const struct city *pcity, const void *data)
static const char * | cr_entry_performance (const struct city *pcity, const void *data)
static const char * | cr_entry_content (const struct city *pcity, const void *data)
static const char * | cr_entry_unhappy (const struct city *pcity, const void *data)
static const char * | cr_entry_angry (const struct city *pcity, const void *data)
static const char * | cr_entry_specialists (const struct city *pcity, const void *data)
static const char * | cr_entry_specialist (const struct city *pcity, const void *data)
static const char * | cr_entry_attack (const struct city *pcity, const void *data)
static const char * | cr_entry_defense (const struct city *pcity, const void *data)
static const char * | cr_entry_supported (const struct city *pcity, const void *data)
static const char * | cr_entry_present (const struct city *pcity, const void *data)
static const char * | cr_entry_resources (const struct city *pcity, const void *data)
static const char * | cr_entry_foodplus (const struct city *pcity, const void *data)
static const char * | cr_entry_prodplus (const struct city *pcity, const void *data)
static const char * | cr_entry_tradeplus (const struct city *pcity, const void *data)
static const char * | cr_entry_output (const struct city *pcity, const void *data)
static const char * | cr_entry_gold (const struct city *pcity, const void *data)
static const char * | cr_entry_luxury (const struct city *pcity, const void *data)
static const char * | cr_entry_science (const struct city *pcity, const void *data)
static const char * | cr_entry_growturns (const struct city *pcity, const void *data)
static const char * | cr_entry_pollution (const struct city *pcity, const void *data)
static const char * | cr_entry_trade_routes (const struct city *pcity, const void *data)
static const char * | cr_entry_build_slots (const struct city *pcity, const void *data)
static const char * | cr_entry_building (const struct city *pcity, const void *data)
static const char * | cr_entry_build_cost (const struct city *pcity, const void *data)
static const char * | cr_entry_corruption (const struct city *pcity, const void *data)
static const char * | cr_entry_waste (const struct city *pcity, const void *data)
static const char * | cr_entry_plague_risk (const struct city *pcity, const void *data)
static const char * | cr_entry_continent (const struct city *pcity, const void *data)
static const char * | cr_entry_cma (const struct city *pcity, const void *data)
int | num_city_report_spec (void)
bool * | city_report_spec_show_ptr (int i)
const char * | city_report_spec_tagname (int i)
void | init_city_report_game_data (void)
static void | init_datum_string (struct datum *dat, const char *left, const char *right)
static void | init_datum_number (struct datum *dat, float val)
static void | free_datum (struct datum *dat)
static int | datum_compare (const struct datum *a, const struct datum *b)
static int | data_compare (const struct datum_vector *a, const struct datum_vector *b)
static void | split_string (struct datum_vector *data, const char *str)
static void | free_data (struct datum_vector *data)
int | cityrepfield_compare (const char *str1, const char *str2)
bool | can_city_sell_universal (const struct city *pcity, const struct universal *target)

## Variables

static const struct city_report_spec | base_city_report_specs []
struct city_report_spec * | city_report_specs
static int | num_creport_cols

## Macro Definition Documentation

## ◆ FUNC_TAG

#define FUNC_TAG | ( |  | var | ) | cr_entry_##var, #var

Definition at line 695 of file cityrepdata.c.

## ◆ SPECVEC_TAG

#define SPECVEC_TAG datum

Definition at line 924 of file cityrepdata.c.

## Function Documentation

## ◆ can_city_sell_universal()

bool can_city_sell_universal | ( | const struct city * | pcity,
|  | const struct universal * | target
| ) |  |

Same as can_city_sell_building(), but with universal argument.

Definition at line 1104 of file cityrepdata.c.

Referenced by city_widget::display_list_menu(), recreate_sell_menu(), and recreate_sell_menu().

## ◆ city_report_spec_show_ptr()

bool * city_report_spec_show_ptr | ( | int | i | ) |

Simple wrapper for city_report_specs.show

Definition at line 812 of file cityrepdata.c.

Referenced by options_dialogs_set(), and options_dialogs_update().

## ◆ city_report_spec_tagname()

const char * city_report_spec_tagname | ( | int | i | ) |

Simple wrapper for city_report_specs.tagname

Definition at line 820 of file cityrepdata.c.

Referenced by options_dialogs_set(), and options_dialogs_update().

## ◆ cityrepfield_compare()

int cityrepfield_compare | ( | const char * | str1,
|  | const char * | str2
| ) |  |

The real function: split the two strings, and compare them.

Definition at line 1077 of file cityrepdata.c.

Referenced by cityrep_sort_func(), and city_sort_model::lessThan().

## ◆ cr_entry_angry()

static const char * cr_entry_angry | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of angry citizens written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 226 of file cityrepdata.c.

## ◆ cr_entry_attack()

static const char * cr_entry_attack | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns string with best attack values of units in city. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 267 of file cityrepdata.c.

## ◆ cr_entry_build_cost()

static const char * cr_entry_build_cost | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns cost of buying current production and turns to completion written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 592 of file cityrepdata.c.

## ◆ cr_entry_build_slots()

static const char * cr_entry_build_slots | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of build slots written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 551 of file cityrepdata.c.

## ◆ cr_entry_building()

static const char * cr_entry_building | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns name of current production. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 564 of file cityrepdata.c.

## ◆ cr_entry_cityname()

static const char * cr_entry_cityname | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

cr_entry = return an entry (one column for one city) for the city report These return ptrs to filled in static strings. Note the returned string may not be exactly the right length; that is handled later.

Definition at line 52 of file cityrepdata.c.

## ◆ cr_entry_cma()

static const char * cr_entry_cma | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns city cma description. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 682 of file cityrepdata.c.

## ◆ cr_entry_content()

static const char * cr_entry_content | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of content citizens written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 198 of file cityrepdata.c.

## ◆ cr_entry_continent()

static const char * cr_entry_continent | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of continent

Definition at line 669 of file cityrepdata.c.

## ◆ cr_entry_corruption()

static const char * cr_entry_corruption | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns corruption amount written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 627 of file cityrepdata.c.

## ◆ cr_entry_culture()

static const char * cr_entry_culture | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns city total culture written to string

Definition at line 150 of file cityrepdata.c.

## ◆ cr_entry_defense()

static const char * cr_entry_defense | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns string with best defend values of units in city. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 304 of file cityrepdata.c.

## ◆ cr_entry_foodplus()

static const char * cr_entry_foodplus | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns food surplus written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 390 of file cityrepdata.c.

## ◆ cr_entry_gold()

static const char * cr_entry_gold | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns gold surplus written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 445 of file cityrepdata.c.

## ◆ cr_entry_growturns()

static const char * cr_entry_growturns | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of turns before city grows written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 489 of file cityrepdata.c.

## ◆ cr_entry_happy()

static const char * cr_entry_happy | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of happy citizens written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 138 of file cityrepdata.c.

## ◆ cr_entry_history()

static const char * cr_entry_history | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns city history culture value written to string

Definition at line 161 of file cityrepdata.c.

## ◆ cr_entry_hstate_concise()

static const char * cr_entry_hstate_concise | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns concise city happiness state written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 88 of file cityrepdata.c.

## ◆ cr_entry_hstate_verbose()

static const char * cr_entry_hstate_verbose | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns verbose city happiness state written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 103 of file cityrepdata.c.

## ◆ cr_entry_luxury()

static const char * cr_entry_luxury | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns luxury output written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 463 of file cityrepdata.c.

## ◆ cr_entry_nation()

static const char * cr_entry_nation | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Translated name of nation who owns this city.

Definition at line 64 of file cityrepdata.c.

## ◆ cr_entry_output()

static const char * cr_entry_output | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns string describing resource output. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 429 of file cityrepdata.c.

## ◆ cr_entry_performance()

static const char * cr_entry_performance | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns city performance culture value written to string

Definition at line 178 of file cityrepdata.c.

## ◆ cr_entry_plague_risk()

static const char * cr_entry_plague_risk | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns risk percentage of plague written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 653 of file cityrepdata.c.

## ◆ cr_entry_pollution()

static const char * cr_entry_pollution | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns pollution output written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 514 of file cityrepdata.c.

## ◆ cr_entry_present()

static const char * cr_entry_present | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of present units written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 358 of file cityrepdata.c.

## ◆ cr_entry_prodplus()

static const char * cr_entry_prodplus | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns production surplus written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 403 of file cityrepdata.c.

## ◆ cr_entry_resources()

static const char * cr_entry_resources | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns string listing amounts of resources. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 374 of file cityrepdata.c.

## ◆ cr_entry_science()

static const char * cr_entry_science | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns science output written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 476 of file cityrepdata.c.

## ◆ cr_entry_size()

static const char * cr_entry_size | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns city size written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 74 of file cityrepdata.c.

## ◆ cr_entry_specialist()

static const char * cr_entry_specialist | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of specialists of type given as data written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 251 of file cityrepdata.c.

Referenced by init_city_report_game_data().

## ◆ cr_entry_specialists()

static const char * cr_entry_specialists | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns list of specialists written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 240 of file cityrepdata.c.

Referenced by init_city_report_game_data().

## ◆ cr_entry_supported()

static const char * cr_entry_supported | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of supported units written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 342 of file cityrepdata.c.

## ◆ cr_entry_trade_routes()

static const char * cr_entry_trade_routes | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number and output of trade routes written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 527 of file cityrepdata.c.

## ◆ cr_entry_tradeplus()

static const char * cr_entry_tradeplus | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns trade surplus written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 416 of file cityrepdata.c.

## ◆ cr_entry_unhappy()

static const char * cr_entry_unhappy | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of unhappy citizens written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 212 of file cityrepdata.c.

## ◆ cr_entry_waste()

static const char * cr_entry_waste | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns waste amount written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 640 of file cityrepdata.c.

## ◆ cr_entry_workers()

static const char * cr_entry_workers | ( | const struct city * | pcity,
|  | const void * | data
| ) |  |

static

Returns number of citizens of each happiness state written to string. Returned string is statically allocated and its contents change when this function is called again.

Definition at line 120 of file cityrepdata.c.

## ◆ data_compare()

static int data_compare | ( | const struct datum_vector * | a,
|  | const struct datum_vector * | b
| ) |  |

static

Compare two strings of data lexicographically.

Definition at line 996 of file cityrepdata.c.

Referenced by cityrepfield_compare().

## ◆ datum_compare()

static int datum_compare | ( | const struct datum * | a,
|  | const struct datum * | b
| ) |  |

static

Compare two data items as described above:

- numbers in the obvious way
- strings alphabetically
- number < string for no good reason

Definition at line 968 of file cityrepdata.c.

Referenced by data_compare().

## ◆ free_data()

static void free_data | ( | struct datum_vector * | data | ) |

static

Free every datum in the vector.

Definition at line 1064 of file cityrepdata.c.

Referenced by cityrepfield_compare().

## ◆ free_datum()

static void free_datum | ( | struct datum * | dat | ) |

static

Free the data associated with a datum – that is, free the string if it was allocated.

Definition at line 955 of file cityrepdata.c.

Referenced by free_data().

## ◆ init_city_report_game_data()

void init_city_report_game_data | ( | void |  | ) |

Initialize city report data. This deals with ruleset-dependent columns and pre-translates the fields (to make things easier on the GUI writers). Should be called before the GUI starts up.

Definition at line 830 of file cityrepdata.c.

Referenced by set_client_state().

## ◆ init_datum_number()

static void init_datum_number | ( | struct datum * | dat,
|  | float | val
| ) |  |

static

Init a datum from a number (a float because we happen to use strtof).

Definition at line 945 of file cityrepdata.c.

Referenced by split_string().

## ◆ init_datum_string()

static void init_datum_string | ( | struct datum * | dat,
|  | const char * | left,
|  | const char * | right
| ) |  |

static

Init a datum from a substring.

Definition at line 930 of file cityrepdata.c.

Referenced by split_string().

## ◆ num_city_report_spec()

int num_city_report_spec | ( | void |  | ) |

Simple wrapper for num_creport_cols()

Definition at line 804 of file cityrepdata.c.

Referenced by options_dialogs_set(), and options_dialogs_update().

## ◆ split_string()

static void split_string | ( | struct datum_vector * | data,
|  | const char * | str
| ) |  |

static

Split a string into a vector of datum.

Definition at line 1019 of file cityrepdata.c.

Referenced by cityrepfield_compare().

## Variable Documentation

## ◆ base_city_report_specs

const struct city_report_spec base_city_report_specs[]

static

Definition at line 697 of file cityrepdata.c.

Referenced by init_city_report_game_data().

## ◆ city_report_specs

struct city_report_spec* city_report_specs

Definition at line 798 of file cityrepdata.c.

Referenced by city_model_set(), city_report_spec_show_ptr(), city_report_spec_tagname(), create_city_report_dialog(), create_display_menu(), create_display_menu_item(), city_item::data(), city_widget::display_header_menu(), get_city_table_header(), city_model::headerData(), city_model::hide_data(), init_city_report_game_data(), city_model::menu_data(), city_item_delegate::paint(), toggle_view(), and update_view_menu().

## ◆ num_creport_cols

int num_creport_cols

static

Definition at line 799 of file cityrepdata.c.

Referenced by init_city_report_game_data(), and num_city_report_spec().