![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <fc_config.h>#include <cstdio>#include <cstring>#include <math.h>#include "bitvector.h"#include "fciconv.h"#include "fcintl.h"#include "log.h"#include "rand.h"#include "support.h"#include "achievements.h"#include "calendar.h"#include "connection.h"#include "events.h"#include "game.h"#include "government.h"#include "nation.h"#include "packets.h"#include "player.h"#include "research.h"#include "specialist.h"#include "unitlist.h"#include "version.h"#include "plrhand.h"#include "score.h"#include "srv_main.h"#include "report.h"
Include dependency graph for report.cpp:Go to the source code of this file.
Classes | |
| struct | plrdata_slot |
| struct | logging_civ_score |
| struct | player_score_entry |
| struct | city_score_entry |
| struct | dem_row |
| struct | dem_col |
Macros | |
| #define | HISTORIAN_FIRST HISTORIAN_RICHEST |
| #define | HISTORIAN_LAST HISTORIAN_LARGEST |
| #define | GOOD_PLAYER(p) ((p)->is_alive && !is_barbarian(p)) |
Enumerations | |
| enum | historian_type { HISTORIAN_RICHEST = 0 , HISTORIAN_ADVANCED = 1 , HISTORIAN_MILITARY = 2 , HISTORIAN_HAPPIEST = 3 , HISTORIAN_LARGEST = 4 } |
| enum | dem_flag { DEM_COL_QUANTITY , DEM_COL_RANK , DEM_COL_BEST , DEM_COL_LAST } |
Functions | |
| static void | plrdata_slot_init (struct plrdata_slot *plrdata, const char *name) |
| Allocate and initialize plrdata slot. More... | |
| static void | plrdata_slot_replace (struct plrdata_slot *plrdata, const char *name) |
| Replace plrdata slot with new one named according to input parameter. More... | |
| static void | plrdata_slot_free (struct plrdata_slot *plrdata) |
| Free resources allocated for plrdata slot. More... | |
| static void | page_conn_etype (struct conn_list *dest, const char *caption, const char *headline, const char *lines, enum event_type event) |
| This function pops up a non-modal message dialog on the player's desktop. More... | |
| static int | get_great_wonders (const struct player *pplayer) |
| Great wonders for wonder score. More... | |
| static int | get_total_score (const struct player *pplayer) |
| Total score. More... | |
| static int | get_league_score (const struct player *pplayer) |
| League score Score = N_techs^1. More... | |
| static int | get_population (const struct player *pplayer) |
| Helper functions which return the value for the given player. More... | |
| static int | get_landarea (const struct player *pplayer) |
| Land area controlled by player. More... | |
| static int | get_settledarea (const struct player *pplayer) |
| Area settled. More... | |
| static int | get_research (const struct player *pplayer) |
| Research speed. More... | |
| static int | get_income (const struct player *pplayer) |
| Gold income. More... | |
| static int | get_production (const struct player *pplayer) |
| Production of player. More... | |
| static int | get_economics (const struct player *pplayer) |
| BNP of player. More... | |
| static int | get_agriculture (const struct player *pplayer) |
| Food output. More... | |
| static int | get_pollution (const struct player *pplayer) |
| Pollution of player. More... | |
| static int | get_mil_service (const struct player *pplayer) |
| Military service length. More... | |
| static int | get_culture (const struct player *pplayer) |
| Culture score. More... | |
| static int | get_pop (const struct player *pplayer) |
| Number of citizen units of player. More... | |
| static int | get_cities (const struct player *pplayer) |
| Number of cities. More... | |
| static int | get_improvements (const struct player *pplayer) |
| Number of buildings in cities (not wonders) More... | |
| static int | get_all_wonders (const struct player *pplayer) |
| All wonders, including small wonders. More... | |
| static int | get_mil_units (const struct player *pplayer) |
| Military units. More... | |
| static int | get_units_built (const struct player *pplayer) |
| Number of units built. More... | |
| static int | get_units_killed (const struct player *pplayer) |
| Number of units killed. More... | |
| static int | get_units_lost (const struct player *pplayer) |
| Number of units lost. More... | |
| static const char * | area_to_text (int value) |
| Helper functions which transform the given value to a string depending on the unit. More... | |
| static const char * | percent_to_text (int value) |
| Construct string containing value followed by ''. More... | |
| static const char * | production_to_text (int value) |
| Construct string containing value followed by unit suitable for production stats. More... | |
| static const char * | economics_to_text (int value) |
| Construct string containing value followed by unit suitable for economics stats. More... | |
| static const char * | agriculture_to_text (int value) |
| Construct string containing value followed by unit suitable for agriculture stats. More... | |
| static const char * | science_to_text (int value) |
| Construct string containing value followed by unit suitable for science stats. More... | |
| static const char * | income_to_text (int value) |
| Construct string containing value followed by unit suitable for gold income stats. More... | |
| static const char * | mil_service_to_text (int value) |
| Construct string containing value followed by unit suitable for military service stats. More... | |
| static const char * | pollution_to_text (int value) |
| Construct string containing value followed by unit suitable for pollution stats. More... | |
| static const char * | culture_to_text (int value) |
| Construct string containing value followed by unit suitable for culture stats. More... | |
| static const char * | citizenunits_to_text (int value) |
| Construct string containing value followed by unit suitable for citizen unit stats. More... | |
| static const char * | cities_to_text (int value) |
| Construct string containing value followed by unit suitable for city stats. More... | |
| static const char * | improvements_to_text (int value) |
| Construct string containing value followed by unit suitable for improvement stats. More... | |
| static const char * | wonders_to_text (int value) |
| Construct string containing value followed by unit suitable for wonders stats. More... | |
| static const char * | mil_units_to_text (int value) |
| Construct string containing value followed by unit suitable for military unit stats. More... | |
| static const char * | score_to_text (int value) |
| Construct string containing value followed by unit suitable for score stats. More... | |
| BV_DEFINE (bv_cols, DEM_COL_LAST) | |
| static int | secompare (const void *a, const void *b) |
| Compare two player score entries. More... | |
| static void | historian_generic (struct history_report *report, enum historian_type which_news) |
| Construct Historian Report. More... | |
| void | send_current_history_report (struct conn_list *dest) |
| Send history report of this turn. More... | |
| static int | nr_wonders (struct city *pcity) |
| Returns the number of wonders the given city has. More... | |
| void | report_top_five_cities (struct conn_list *dest) |
| Send report listing the "best" 5 cities in the world. More... | |
| void | report_wonders_of_the_world (struct conn_list *dest) |
| Send report listing all built and destroyed wonders, and wonders currently being built. More... | |
| static int | get_real_pop (const struct player *pplayer) |
| Number of citizens of player. More... | |
| static int | get_techs (const struct player *pplayer) |
| Number of techs. More... | |
| static int | get_munits (const struct player *pplayer) |
| Number of military units. More... | |
| static int | get_settlers (const struct player *pplayer) |
| Number of city building units. More... | |
| static int | get_techout (const struct player *pplayer) |
| Technology output. More... | |
| static int | get_literacy2 (const struct player *pplayer) |
| Literacy score calculated one way. More... | |
| static int | get_spaceship (const struct player *pplayer) |
| Spaceship score. More... | |
| static int | get_gold (const struct player *pplayer) |
| Amount of gold. More... | |
| static int | get_taxrate (const struct player *pplayer) |
| Tax rate. More... | |
| static int | get_scirate (const struct player *pplayer) |
| Science rate. More... | |
| static int | get_luxrate (const struct player *pplayer) |
| Luxury rate. More... | |
| static int | get_riots (const struct player *pplayer) |
| Number of rioting cities. More... | |
| static int | get_happypop (const struct player *pplayer) |
| Number of happy citizens. More... | |
| static int | get_contentpop (const struct player *pplayer) |
| Number of content citizens. More... | |
| static int | get_unhappypop (const struct player *pplayer) |
| Number of unhappy citizens. More... | |
| static int | get_specialists (const struct player *pplayer) |
| Number of specialists. More... | |
| static int | get_gov (const struct player *pplayer) |
| Current government. More... | |
| static int | get_corruption (const struct player *pplayer) |
| Total corruption. More... | |
| static const char * | value_units (int val, const char *uni) |
| Construct string containing value and its unit. More... | |
| static void | dem_line_item (char *outptr, size_t out_size, struct player *pplayer, struct dem_row *prow, bv_cols selcols) |
| Construct one demographics line. More... | |
| bool | is_valid_demography (const char *demography, int *error) |
| Verify that a given demography string is valid. More... | |
| void | report_demographics (struct connection *pconn) |
| Send demographics report; what gets reported depends on value of demographics server option. More... | |
| void | report_achievements (struct connection *pconn) |
| Send achievements list. More... | |
| static bool | scan_score_log (char *id) |
| Reads the whole file denoted by fp. More... | |
| void | log_civ_score_init () |
| Initialize score logging system. More... | |
| void | log_civ_score_free () |
| Free resources allocated for score logging system. More... | |
| void | log_civ_score_now () |
| Create a log file of the civilizations so you can see what was happening. More... | |
| void | make_history_report () |
| Produce random history report if it's time for one. More... | |
| void | report_final_scores (struct conn_list *dest) |
| Inform clients about player scores and statistics when the game ends. More... | |
| void | page_conn (struct conn_list *dest, const char *caption, const char *headline, const char *lines) |
| This function pops up a non-modal message dialog on the player's desktop. More... | |
| struct history_report * | history_report_get () |
| Return current history report. More... | |
Variables | |
| struct history_report | latest_history_report = {-2} |
| static struct logging_civ_score * | score_log = nullptr |
| static const char * | historian_message [] |
| static const char * | historian_name [] |
| static const char | scorelog_magic [] = "#FREECIV SCORELOG2 " |
| static struct dem_row | rowtable [] |
| static struct dem_col | coltable [] = {{'q'}, {'r'}, {'b'}} |
| static const char * | ranking [] |
| #define GOOD_PLAYER | ( | p | ) | ((p)->is_alive && !is_barbarian(p)) |
Definition at line 172 of file report.cpp.
| #define HISTORIAN_FIRST HISTORIAN_RICHEST |
Definition at line 85 of file report.cpp.
| #define HISTORIAN_LAST HISTORIAN_LARGEST |
Definition at line 86 of file report.cpp.
| enum dem_flag |
| Enumerator | |
|---|---|
| DEM_COL_QUANTITY | |
| DEM_COL_RANK | |
| DEM_COL_BEST | |
| DEM_COL_LAST | |
Definition at line 211 of file report.cpp.
| enum historian_type |
| Enumerator | |
|---|---|
| HISTORIAN_RICHEST | |
| HISTORIAN_ADVANCED | |
| HISTORIAN_MILITARY | |
| HISTORIAN_HAPPIEST | |
| HISTORIAN_LARGEST | |
Definition at line 77 of file report.cpp.
|
static |
Construct string containing value followed by unit suitable for agriculture stats.
Definition at line 948 of file report.cpp.
|
static |
Helper functions which transform the given value to a string depending on the unit.
Definition at line 908 of file report.cpp.
| BV_DEFINE | ( | bv_cols | , |
| DEM_COL_LAST | |||
| ) |
|
static |
Construct string containing value followed by unit suitable for city stats.
Definition at line 1024 of file report.cpp.
|
static |
Construct string containing value followed by unit suitable for citizen unit stats.
Definition at line 1006 of file report.cpp.
|
static |
Construct string containing value followed by unit suitable for culture stats.
Definition at line 996 of file report.cpp.
|
static |
Construct one demographics line.
Definition at line 1059 of file report.cpp.
Referenced by report_demographics().
|
static |
Construct string containing value followed by unit suitable for economics stats.
Definition at line 938 of file report.cpp.
|
static |
Food output.
Definition at line 590 of file report.cpp.
|
static |
All wonders, including small wonders.
Definition at line 638 of file report.cpp.
|
static |
Number of cities.
Definition at line 622 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Number of content citizens.
Definition at line 809 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
|
static |
Culture score.
Definition at line 885 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
BNP of player.
Definition at line 582 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
|
static |
|
static |
Great wonders for wonder score.
Definition at line 694 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Number of happy citizens.
Definition at line 801 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
Number of buildings in cities (not wonders)
Definition at line 630 of file report.cpp.
|
static |
Gold income.
Definition at line 566 of file report.cpp.
|
static |
Land area controlled by player.
Definition at line 542 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
League score Score = N_techs^1.
7 + N_units_built + 3xN_units_killedx[N_units_killed/(N_units_lost+1)]^0.5
Definition at line 872 of file report.cpp.
|
static |
Literacy score calculated one way.
See also get_literacy() to see alternative way.
Definition at line 711 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
|
static |
Military service length.
Definition at line 606 of file report.cpp.
Referenced by report_final_scores().
|
static |
Military units.
Definition at line 614 of file report.cpp.
|
static |
Number of military units.
Definition at line 654 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
|
static |
Number of citizen units of player.
Definition at line 526 of file report.cpp.
Referenced by get_real_pop(), and log_civ_score_now().
|
static |
Helper functions which return the value for the given player.
Population of player
Definition at line 518 of file report.cpp.
|
static |
Production of player.
Definition at line 574 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Number of citizens of player.
Definition at line 534 of file report.cpp.
Referenced by report_final_scores().
|
static |
|
static |
Number of rioting cities.
Definition at line 783 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
|
static |
Area settled.
Definition at line 550 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Number of city building units.
Definition at line 673 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
Spaceship score.
Definition at line 719 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Number of specialists.
Definition at line 825 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
|
static |
|
static |
Number of techs.
Definition at line 646 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
|
static |
Number of unhappy citizens.
Definition at line 817 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
Number of units built.
Definition at line 727 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Number of units killed.
Definition at line 735 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Number of units lost.
Definition at line 743 of file report.cpp.
Referenced by log_civ_score_now(), and report_final_scores().
|
static |
Construct Historian Report.
Definition at line 263 of file report.cpp.
Referenced by make_history_report().
| struct history_report* history_report_get | ( | ) |
Return current history report.
Definition at line 1877 of file report.cpp.
Referenced by sg_load_history(), and sg_save_history().
|
static |
Construct string containing value followed by unit suitable for improvement stats.
Definition at line 1042 of file report.cpp.
|
static |
Construct string containing value followed by unit suitable for gold income stats.
Definition at line 969 of file report.cpp.
| bool is_valid_demography | ( | const char * | demography, |
| int * | error | ||
| ) |
Verify that a given demography string is valid.
See game.demography. If the string is not valid the index of the first invalid character is return as 'error'.
Other settings callback functions are in settings.c, but this one uses static values from this file so it's done separately.
Definition at line 1128 of file report.cpp.
Referenced by demography_callback().
| void log_civ_score_free | ( | ) |
Free resources allocated for score logging system.
Definition at line 1474 of file report.cpp.
Referenced by log_civ_score_now(), scorelog_action(), and server_game_free().
| void log_civ_score_init | ( | ) |
Initialize score logging system.
Definition at line 1450 of file report.cpp.
Referenced by scorelog_action().
| void log_civ_score_now | ( | ) |
Create a log file of the civilizations so you can see what was happening.
Definition at line 1505 of file report.cpp.
Referenced by begin_turn(), and srv_scores().
| void make_history_report | ( | ) |
Produce random history report if it's time for one.
Definition at line 1718 of file report.cpp.
Referenced by end_turn().
|
static |
Construct string containing value followed by unit suitable for military service stats.
Definition at line 978 of file report.cpp.
|
static |
Construct string containing value followed by unit suitable for military unit stats.
Definition at line 1015 of file report.cpp.
|
static |
Returns the number of wonders the given city has.
Definition at line 336 of file report.cpp.
Referenced by report_top_five_cities().
| void page_conn | ( | struct conn_list * | dest, |
| const char * | caption, | ||
| const char * | headline, | ||
| const char * | lines | ||
| ) |
This function pops up a non-modal message dialog on the player's desktop.
Definition at line 1822 of file report.cpp.
Referenced by report_achievements(), report_demographics(), report_top_five_cities(), and report_wonders_of_the_world().
|
static |
This function pops up a non-modal message dialog on the player's desktop.
event == E_REPORT: message should not be ignored by clients watching AI players with ai_popup_windows off. Example: Server Options, Demographics Report, etc.
event == E_BROADCAST_REPORT: message can safely be ignored by clients watching AI players with ai_popup_windows off. For example: Herodot's report... and similar messages.
Definition at line 1839 of file report.cpp.
Referenced by page_conn(), and send_current_history_report().
|
static |
Construct string containing value followed by ''.
So value is already considered to be in units of 1/100.
Definition at line 918 of file report.cpp.
|
static |
Free resources allocated for plrdata slot.
Definition at line 1290 of file report.cpp.
Referenced by log_civ_score_free(), log_civ_score_init(), log_civ_score_now(), and scan_score_log().
|
static |
Allocate and initialize plrdata slot.
Definition at line 1268 of file report.cpp.
Referenced by log_civ_score_now(), and scan_score_log().
|
static |
Replace plrdata slot with new one named according to input parameter.
Definition at line 1279 of file report.cpp.
Referenced by log_civ_score_now(), and plrdata_slot_init().
|
static |
Construct string containing value followed by unit suitable for pollution stats.
Definition at line 987 of file report.cpp.
|
static |
Construct string containing value followed by unit suitable for production stats.
Definition at line 927 of file report.cpp.
| void report_achievements | ( | struct connection * | pconn | ) |
Send achievements list.
Definition at line 1237 of file report.cpp.
Referenced by handle_report_req().
| void report_demographics | ( | struct connection * | pconn | ) |
Send demographics report; what gets reported depends on value of demographics server option.
Definition at line 1175 of file report.cpp.
Referenced by handle_report_req().
| void report_final_scores | ( | struct conn_list * | dest | ) |
Inform clients about player scores and statistics when the game ends.
Called only from server/srv_main.c srv_scores()
Definition at line 1741 of file report.cpp.
Referenced by connection_attach_real(), and srv_scores().
| void report_top_five_cities | ( | struct conn_list * | dest | ) |
Send report listing the "best" 5 cities in the world.
Definition at line 354 of file report.cpp.
Referenced by handle_report_req().
| void report_wonders_of_the_world | ( | struct conn_list * | dest | ) |
Send report listing all built and destroyed wonders, and wonders currently being built.
Definition at line 433 of file report.cpp.
Referenced by handle_report_req().
|
static |
Reads the whole file denoted by fp.
Sets last_turn and id to the values contained in the file. Returns the player_names indexed by player_no at the end of the log file.
Returns TRUE iff the file had read successfully.
Definition at line 1303 of file report.cpp.
Referenced by log_civ_score_now().
|
static |
Construct string containing value followed by unit suitable for science stats.
Definition at line 960 of file report.cpp.
|
static |
Construct string containing value followed by unit suitable for score stats.
Definition at line 1033 of file report.cpp.
|
static |
Compare two player score entries.
Used as callback for qsort.
Definition at line 254 of file report.cpp.
Referenced by historian_generic(), report_final_scores(), and report_top_five_cities().
| void send_current_history_report | ( | struct conn_list * | dest | ) |
Send history report of this turn.
Definition at line 323 of file report.cpp.
Referenced by establish_new_connection(), and make_history_report().
|
static |
Construct string containing value and its unit.
Definition at line 893 of file report.cpp.
Referenced by agriculture_to_text(), area_to_text(), cities_to_text(), citizenunits_to_text(), culture_to_text(), economics_to_text(), improvements_to_text(), income_to_text(), mil_service_to_text(), mil_units_to_text(), percent_to_text(), pollution_to_text(), production_to_text(), science_to_text(), score_to_text(), and wonders_to_text().
|
static |
Construct string containing value followed by unit suitable for wonders stats.
Definition at line 1051 of file report.cpp.
|
static |
Referenced by is_valid_demography(), and report_demographics().
|
static |
Definition at line 88 of file report.cpp.
Referenced by historian_generic().
|
static |
| struct history_report latest_history_report = {-2} |
Definition at line 1 of file report.cpp.
Referenced by history_report_get(), log_civ_score_init(), make_history_report(), and send_current_history_report().
|
static |
Definition at line 218 of file report.cpp.
Referenced by historian_generic().
|
static |
Referenced by is_valid_demography(), and report_demographics().
|
static |
Definition at line 66 of file report.cpp.
Referenced by log_civ_score_free(), log_civ_score_init(), log_civ_score_now(), and scan_score_log().
|
static |
Definition at line 118 of file report.cpp.
Referenced by log_civ_score_now(), and scan_score_log().