Freeciv-3.2
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 "nation.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 charcr_entry_cityname (const struct city *pcity, const void *data)
 
static const charcr_entry_nation (const struct city *pcity, const void *data)
 
static const charcr_entry_size (const struct city *pcity, const void *data)
 
static const charcr_entry_hstate_concise (const struct city *pcity, const void *data)
 
static const charcr_entry_hstate_verbose (const struct city *pcity, const void *data)
 
static const charcr_entry_workers (const struct city *pcity, const void *data)
 
static const charcr_entry_happy (const struct city *pcity, const void *data)
 
static const charcr_entry_culture (const struct city *pcity, const void *data)
 
static const charcr_entry_history (const struct city *pcity, const void *data)
 
static const charcr_entry_performance (const struct city *pcity, const void *data)
 
static const charcr_entry_content (const struct city *pcity, const void *data)
 
static const charcr_entry_unhappy (const struct city *pcity, const void *data)
 
static const charcr_entry_angry (const struct city *pcity, const void *data)
 
static const charcr_entry_specialists (const struct city *pcity, const void *data)
 
static const charcr_entry_specialist (const struct city *pcity, const void *data)
 
static const charcr_entry_attack (const struct city *pcity, const void *data)
 
static const charcr_entry_defense (const struct city *pcity, const void *data)
 
static const charcr_entry_supported (const struct city *pcity, const void *data)
 
static const charcr_entry_present (const struct city *pcity, const void *data)
 
static const charcr_entry_resources (const struct city *pcity, const void *data)
 
static const charcr_entry_foodplus (const struct city *pcity, const void *data)
 
static const charcr_entry_prodplus (const struct city *pcity, const void *data)
 
static const charcr_entry_tradeplus (const struct city *pcity, const void *data)
 
static const charcr_entry_output (const struct city *pcity, const void *data)
 
static const charcr_entry_gold (const struct city *pcity, const void *data)
 
static const charcr_entry_luxury (const struct city *pcity, const void *data)
 
static const charcr_entry_science (const struct city *pcity, const void *data)
 
static const charcr_entry_growturns (const struct city *pcity, const void *data)
 
static const charcr_entry_pollution (const struct city *pcity, const void *data)
 
static const charcr_entry_trade_routes (const struct city *pcity, const void *data)
 
static const charcr_entry_build_slots (const struct city *pcity, const void *data)
 
static const charcr_entry_building (const struct city *pcity, const void *data)
 
static const charcr_entry_build_cost (const struct city *pcity, const void *data)
 
static const charcr_entry_corruption (const struct city *pcity, const void *data)
 
static const charcr_entry_waste (const struct city *pcity, const void *data)
 
static const charcr_entry_plague_risk (const struct city *pcity, const void *data)
 
static const charcr_entry_continent (const struct city *pcity, const void *data)
 
static const charcr_entry_cma (const struct city *pcity, const void *data)
 
int num_city_report_spec (void)
 
boolcity_report_spec_show_ptr (int i)
 
const charcity_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_speccity_report_specs
 
static int num_creport_cols
 

Macro Definition Documentation

◆ FUNC_TAG

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

Definition at line 741 of file cityrepdata.c.

◆ SPECVEC_TAG

#define SPECVEC_TAG   datum

Definition at line 970 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 1150 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 858 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 866 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 1123 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 234 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 278 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 630 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 581 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 596 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 53 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 728 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 203 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 713 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 665 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 153 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 316 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 404 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 466 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 515 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 140 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 165 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 89 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 105 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 485 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 65 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 449 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 183 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 695 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 541 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 370 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 419 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 386 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 500 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 75 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 261 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 250 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 354 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 556 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 434 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 218 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 680 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 122 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 1042 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 1014 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 1110 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 1001 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 876 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 991 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 976 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 850 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 1065 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 743 of file cityrepdata.c.

Referenced by init_city_report_game_data().

◆ city_report_specs

struct city_report_spec* city_report_specs

◆ num_creport_cols

int num_creport_cols
static

Definition at line 845 of file cityrepdata.c.

Referenced by init_city_report_game_data(), and num_city_report_spec().