78 enum event_type
event);
86#define HISTORIAN_FIRST HISTORIAN_RICHEST
87#define HISTORIAN_LAST HISTORIAN_LARGEST
91 N_(
"%s %s reports on the RICHEST Civilizations in the World."),
93 N_(
"%s %s reports on the most ADVANCED Civilizations in the World."),
95 N_(
"%s %s reports on the most MILITARIZED Civilizations in the World."),
97 N_(
"%s %s reports on the HAPPIEST Civilizations in the World."),
99 N_(
"%s %s reports on the LARGEST Civilizations in the World.")
108 N_(
"Pliny the Elder"),
122#define MAX_SCORELOG_LINE_LEN (119 + 1)
155#define GOOD_PLAYER(p) ((p)->is_alive && !is_barbarian(p))
164 const char *(*to_text) (int);
195 N_(
"%2d: The Supreme %s"),
197 N_(
"%2d: The Magnificent %s"),
199 N_(
"%2d: The Great %s"),
201 N_(
"%2d: The Glorious %s"),
203 N_(
"%2d: The Excellent %s"),
205 N_(
"%2d: The Eminent %s"),
207 N_(
"%2d: The Distinguished %s"),
209 N_(
"%2d: The Average %s"),
211 N_(
"%2d: The Mediocre %s"),
213 N_(
"%2d: The Ordinary %s"),
215 N_(
"%2d: The Pathetic %s"),
217 N_(
"%2d: The Useless %s"),
219 N_(
"%2d: The Valueless %s"),
221 N_(
"%2d: The Worthless %s"),
223 N_(
"%2d: The Wretched %s"),
241 int i, j = 0, rank = 0;
247 switch (which_news) {
249 size[j].value = pplayer->economic.gold;
256 size[j].value = pplayer->score.units;
260 (((pplayer->score.happy - pplayer->score.unhappy
261 - 2 * pplayer->score.angry) * 1000) /
268 size[j].player = pplayer;
274 report->
body[0] =
'\0';
275 for (i = 0; i < j; i++) {
329 const int NUM_BEST_CITIES = 5;
331 const int WONDER_FACTOR = 5;
336 for (i = 0; i < NUM_BEST_CITIES; i++) {
346 if (value_of_pcity >
size[NUM_BEST_CITIES - 1].
value) {
347 size[NUM_BEST_CITIES - 1].value = value_of_pcity;
348 size[NUM_BEST_CITIES - 1].city = pcity;
355 for (i = 0; i < NUM_BEST_CITIES; i++) {
374 _(
"%2d: The %s City of %s (%s) of size %d, "), i + 1,
380 _(
"%2d: The %s City of %s of size %d, "), i + 1,
387 cat_snprintf(buffer,
sizeof(buffer),
_(
"with no Great Wonders\n"));
390 PL_(
"with %d Great Wonder\n",
"with %d Great Wonders\n", wonders),
394 _(
"The Five Greatest Cities in the World!"), buffer);
420 _(
"%s in %s (%s, %s)\n"),
432 cat_snprintf(buffer,
sizeof(buffer),
_(
"%s has been DESTROYED\n"),
442 if (VUT_IMPROVEMENT == pcity->production.kind
443 && pcity->production.value.building == i) {
452 _(
"(building %s in %s (%s, %s))\n"),
457 _(
"(building %s in %s (%s))\n"),
468 _(
"Wonders of the World"), buffer);
496 return 1000 *
get_pop(pplayer);
704 if (pcity->anarchy > 0) {
766 result += pcity->waste[
O_TRADE];
796 log_error(
"String truncated in value_units()!");
827 int clip =
MAX(0, value);
912 struct player *best_player = pplayer;
930 && (pplayer != best_player))) {
948 int len = strlen(demography), i;
952 for (i = 0; i <
len; i++) {
958 if (demography[i] ==
coltable[j].key) {
970 if (demography[i] ==
rowtable[j].key) {
1025 _(
"Sorry, the Demographics report is unavailable."),
"");
1051 page_conn(pconn->
self,
_(
"Demographics Report:"), civbuf, buffer);
1063 if (pplayer == NULL) {
1112 if (plrdata->
name != NULL) {
1113 free(plrdata->
name);
1114 plrdata->
name = NULL;
1127 int line_nr, turn, plr_no, spaces;
1143 for (line_nr = 1;; line_nr++) {
1148 log_error(
"[%s:-] Can't read scorelog file header!",
1153 ptr = strchr(line,
'\n');
1167 if (strncmp(line,
"id ", strlen(
"id ")) == 0) {
1168 if (strlen(
id) > 0) {
1174 if (strcmp(
id,
server.game_identifier) != 0) {
1175 log_error(
"[%s:%d] IDs don't match! game='%s' scorelog='%s'",
1182 if (strncmp(line,
"turn ", strlen(
"turn ")) == 0) {
1183 if (sscanf(line + strlen(
"turn "),
"%d", &turn) != 1) {
1193 if (strncmp(line,
"addplayer ", strlen(
"addplayer ")) == 0) {
1196 if (3 != sscanf(line + strlen(
"addplayer "),
"%d %d %s",
1197 &turn, &plr_no, plr_name)) {
1198 log_error(
"[%s:%d] Bad line (addplayer)!",
1204 ptr = line + strlen(
"addplayer ");
1206 while (*ptr !=
'\0' && spaces < 2) {
1212 fc_snprintf(plr_name,
sizeof(plr_name),
"%s", ptr);
1213 log_debug(
"add player '%s' (from line %d: '%s')", plr_name, line_nr,
1217 log_error(
"[%s:%d] Invalid player number: %d!",
1223 if (plrdata->
name != NULL) {
1224 log_error(
"[%s:%d] Two names for one player (id %d)!",
1232 if (strncmp(line,
"delplayer ", strlen(
"delplayer ")) == 0) {
1233 if (2 != sscanf(line + strlen(
"delplayer "),
"%d %d",
1235 log_error(
"[%s:%d] Bad line (delplayer)!",
1241 log_error(
"[%s:%d] Invalid player number: %d!",
1247 if (plrdata->
name == NULL) {
1248 log_error(
"[%s:%d] Trying to remove undefined player (id %d)!",
1262 if (strlen(
id) == 0) {
1268 log_error(
"[%s:-] Scorelog doesn't match savegame!",
1293 plrdata->
name = NULL;
1318 if (plrdata->
name != NULL) {
1319 free(plrdata->
name);
1334 enum { SL_CREATE, SL_APPEND, SL_UNSPEC } oper = SL_UNSPEC;
1340 static const struct {
1342 int (*get_value) (
const struct player *);
1398 goto log_civ_score_disable;
1411 log_error(
"Can't open scorelog file '%s' for creation!",
1413 goto log_civ_score_disable;
1418 "# For a specification of the format of this see doc/README.scorelog or\n"
1419 "# <https://raw.githubusercontent.com/freeciv/freeciv/S3_1/doc/README.scorelog>.\n"
1423 for (i = 0; i <
ARRAY_SIZE(score_tags); i++) {
1424 fprintf(
score_log->
fp,
"tag %d %s\n", i, score_tags[i].name);
1430 log_error(
"Can't open scorelog file '%s' for appending!",
1432 goto log_civ_score_disable;
1436 log_error(
"[%s] bad operation %d", __FUNCTION__, (
int) oper);
1437 goto log_civ_score_disable;
1450 if (plrdata->
name != NULL
1468 if (
is_ai(pplayer)) {
1488 if (
is_ai(pplayer) && plrdata->
name == NULL) {
1497 log_debug(
"player names does not match '%s' != '%s'", plrdata->
name,
1509 for (i = 0; i <
ARRAY_SIZE(score_tags); i++) {
1525log_civ_score_disable:
1557 static const struct {
1559 int (*score) (
const struct player *);
1560 } score_categories[] = {
1582 const size_t score_categories_num =
ARRAY_SIZE(score_categories);
1595 for (j = 0; j < score_categories_num; j++) {
1602 size[i].value = pplayer->score.game;
1603 size[i].player = pplayer;
1616 const struct player *pplayer =
size[i].player;
1621 for (j = 0; j < score_categories_num; j++) {
1653 enum event_type
event)
1672 for (i = 0; i < packet.
parts; i++) {
1678 part.lines[plen] =
'\0';
bool achievement_player_has(const struct achievement *pach, const struct player *pplayer)
int get_literacy(const struct player *pplayer)
const char * achievement_name_translation(struct achievement *pach)
#define achievements_iterate_end
#define achievements_iterate(_ach_)
#define BV_DEFINE(name, bits)
#define BV_ISSET(bv, bit)
const char * calendar_text(void)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
const char * city_name_get(const struct city *pcity)
#define city_list_iterate(citylist, pcity)
static citizens city_size_get(const struct city *pcity)
#define city_owner(_pcity_)
#define city_list_iterate_end
#define city_built_iterate(_pcity, _p)
#define city_built_iterate_end
const char const char * headline
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
#define MAX_LEN_GAME_IDENTIFIER
size_t get_internal_string_length(const char *text)
#define PL_(String1, String2, n)
const char * population_to_text(int thousand_citizen)
#define GAME_DEFAULT_SCORETURN
struct government * government_of_player(const struct player *pplayer)
const char * government_name_for_player(const struct player *pplayer)
Government_type_id government_number(const struct government *pgovern)
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
struct city * city_from_great_wonder(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
#define log_error(message,...)
#define fc_calloc(n, esz)
const char * nation_adjective_for_player(const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
void lsend_packet_endgame_player(struct conn_list *dest, const struct packet_endgame_player *packet)
void lsend_packet_endgame_report(struct conn_list *dest, const struct packet_endgame_report *packet)
void lsend_packet_page_msg(struct conn_list *dest, const struct packet_page_msg *packet)
void lsend_packet_page_msg_part(struct conn_list *dest, const struct packet_page_msg_part *packet)
bool player_slot_is_used(const struct player_slot *pslot)
int player_slot_count(void)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
int player_slot_index(const struct player_slot *pslot)
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
int player_index(const struct player *pplayer)
struct player * player_slot_get_player(const struct player_slot *pslot)
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define player_slots_iterate_end
#define shuffled_players_iterate_end
#define shuffled_players_iterate(NAME_pplayer)
static int get_units_killed(const struct player *pplayer)
static int get_units_built(const struct player *pplayer)
static int get_contentpop(const struct player *pplayer)
static struct logging_civ_score * score_log
static int nr_wonders(struct city *pcity)
static const char * ranking[]
void report_final_scores(struct conn_list *dest)
static const char * economics_to_text(int value)
static const char * production_to_text(int value)
static int get_munits(const struct player *pplayer)
static const char * science_to_text(int value)
static int get_pollution(const struct player *pplayer)
static int get_economics(const struct player *pplayer)
static int get_techs(const struct player *pplayer)
static void plrdata_slot_init(struct plrdata_slot *plrdata, const char *name)
static void page_conn_etype(struct conn_list *dest, const char *caption, const char *headline, const char *lines, enum event_type event)
static int get_pop(const struct player *pplayer)
static int get_riots(const struct player *pplayer)
static void historian_generic(struct history_report *report, enum historian_type which_news)
static const char * pollution_to_text(int value)
static void plrdata_slot_replace(struct plrdata_slot *plrdata, const char *name)
static int get_production(const struct player *pplayer)
struct history_report latest_history_report
static bool scan_score_log(char *id)
static int get_scirate(const struct player *pplayer)
static int get_taxrate(const struct player *pplayer)
void send_current_history_report(struct conn_list *dest)
static int get_spaceship(const struct player *pplayer)
void report_wonders_of_the_world(struct conn_list *dest)
void report_demographics(struct connection *pconn)
static const char * historian_message[]
static int get_corruption(const struct player *pplayer)
static int get_wonders(const struct player *pplayer)
static int get_landarea(const struct player *pplayer)
static int get_total_score(const struct player *pplayer)
static const char * area_to_text(int value)
static const char scorelog_magic[]
static int get_population(const struct player *pplayer)
static struct dem_col coltable[]
static const char * historian_name[]
struct history_report * history_report_get(void)
void report_top_five_cities(struct conn_list *dest)
void make_history_report(void)
void log_civ_score_free(void)
static int get_culture(const struct player *pplayer)
static const char * value_units(int val, const char *uni)
static int get_techout(const struct player *pplayer)
static int get_specialists(const struct player *pplayer)
static struct dem_row rowtable[]
static int get_unhappypop(const struct player *pplayer)
bool is_valid_demography(const char *demography, int *error)
static int get_settledarea(const struct player *pplayer)
void page_conn(struct conn_list *dest, const char *caption, const char *headline, const char *lines)
void log_civ_score_init(void)
static int get_literacy2(const struct player *pplayer)
static void dem_line_item(char *outptr, size_t out_size, struct player *pplayer, struct dem_row *prow, bv_cols selcols)
static const char * culture_to_text(int value)
static int get_mil_service(const struct player *pplayer)
void report_achievements(struct connection *pconn)
static const char * percent_to_text(int value)
static int secompare(const void *a, const void *b)
static int get_happypop(const struct player *pplayer)
static void plrdata_slot_free(struct plrdata_slot *plrdata)
static int get_settlers(const struct player *pplayer)
static int get_real_pop(const struct player *pplayer)
static int get_luxrate(const struct player *pplayer)
void log_civ_score_now(void)
static int get_units_lost(const struct player *pplayer)
static int get_gold(const struct player *pplayer)
#define MAX_SCORELOG_LINE_LEN
static int get_cities(const struct player *pplayer)
static const char * mil_service_to_text(int value)
static int get_gov(const struct player *pplayer)
static int get_research(const struct player *pplayer)
struct research * research_get(const struct player *pplayer)
int total_player_citizens(const struct player *pplayer)
const char * int_to_text(unsigned int number)
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
struct civ_game::@30::@34 server
char demography[MAX_LEN_DEMOGRAPHY]
struct conn_list * est_connections
struct packet_game_info info
enum scorelog_level scoreloglevel
struct packet_scenario_info scenario
char scorefile[MAX_LEN_NAME]
int(* get_value)(const struct player *)
const char *(* to_text)(int)
bool greater_values_are_better
char title[REPORT_TITLESIZE]
char body[REPORT_BODYSIZE]
struct plrdata_slot * plrdata
char category_name[32][MAX_LEN_NAME]
char headline[MAX_LEN_MSG]
char caption[MAX_LEN_MSG]
const struct player * player
struct city_list * cities
struct player_economic economic
struct player_score score
int fc_snprintf(char *str, size_t n, const char *format,...)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
size_t fc_strlcat(char *dest, const char *src, size_t n)
int cat_snprintf(char *str, size_t n, const char *format,...)
FILE * fc_fopen(const char *filename, const char *opentype)
#define sz_strlcpy(dest, src)
#define sz_strlcat(dest, src)
int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len)
static int best_value(const void *a, const void *b)
bool is_military_unit(const struct unit *punit)
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end