46 #define USER_AREA_MULT 1000
58 #define LAND_AREA_DEBUG 0
60 #if LAND_AREA_DEBUG >= 2
66 static char when_char(
int when)
68 static char list[] = {
69 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
70 'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
71 'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'a',
'b',
'c',
72 'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
73 'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z'};
75 return (when >= 0 && when <
sizeof(list)) ? list[when] :
'?';
85 #define WRITE_MAP_DATA(type, map_char_expr) \
88 for (nat_x = 0; nat_x < map.xsize; nat_x++) { \
89 printf("%d", nat_x % 10); \
92 for (nat_y = 0; nat_y < map.ysize; nat_y++) { \
93 printf("%d ", nat_y % 10); \
94 for (nat_x = 0; nat_x < map.xsize; nat_x++) { \
96 NATIVE_TO_MAP_POS(&x, &y, nat_x, nat_y); \
97 printf(type, map_char_expr); \
99 printf(" %d\n", nat_y % 10); \
106 static void print_landarea_map(
struct claim_map *pcmap,
int turn)
113 qCritical(
"Debugging not possible! Player slots >= 32 are used.");
124 printf(
"Player Info...\n");
127 printf(
".know (%d)\n ", p);
132 printf(
".cities (%d)\n ", p);
140 printf(
"Turn %d (%c)...\n", turn, when_char(turn));
163 memset(pcmap, 0,
sizeof(*pcmap));
184 struct player *owner =
nullptr;
185 bv_player *pclaim = &claims[
tile_index(ptile)];
189 }
else if (
nullptr !=
tile_city(ptile)) {
195 }
else if (unit_list_size(ptile->units) > 0) {
197 owner =
unit_owner(unit_list_get(ptile->units, 0));
216 #if LAND_AREA_DEBUG >= 2
217 print_landarea_map(pcmap, turn);
225 struct player *pplayer,
int *return_landarea,
226 int *return_settledarea)
228 if (pcmap && pplayer) {
229 #if LAND_AREA_DEBUG >= 1
232 if (return_landarea) {
235 #if LAND_AREA_DEBUG >= 1
239 if (return_settledarea) {
240 *return_settledarea =
242 #if LAND_AREA_DEBUG >= 1
246 #if LAND_AREA_DEBUG >= 1
258 struct city *wonder_city;
259 int landarea = 0, settledarea = 0;
326 bonus =
CLIP(0, bonus, 100);
397 return static_cast<int>(
443 int i, t_winner_score = 0;
444 enum victory_state { VS_NONE, VS_LOSER, VS_WINNER };
446 struct player *spacerace_winner =
nullptr;
447 struct team *t_winner =
nullptr;
458 qCritical(
"couldn't open ranking log file: \"%s\"",
465 plr_state[i] = VS_NONE;
472 spacerace_winner = pplayer;
480 if (spacerace_winner) {
483 if (pplayer != spacerace_winner) {
499 }
else if (pplayer->is_alive
514 if (aplayer->team == pplayer->team) {
528 const struct player_list *members =
team_members(pteam);
531 if (pplayer->is_alive
537 if (t_score > t_winner_score) {
539 t_winner_score = t_score;
548 if (pplayer->team == t_winner) {
560 fprintf(fp,
"turns: %d\n",
game.
info.turn);
561 fprintf(fp,
"winners: ");
565 fprintf(fp,
"%s,%s,%s,%i,, ", pplayer->ranked_username,
571 fprintf(fp,
"\nlosers: ");
575 fprintf(fp,
"%s,%s,%s,%i,, ", pplayer->ranked_username,
bool BV_ISSET(const BV &bv, int bit)
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
int city_population(const struct city *pcity)
Returns how many thousand citizen live in this city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
int get_final_city_output_bonus(const struct city *pcity, Output_type_id otype)
Return the factor (in %) by which the city's output should be multiplied.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
#define city_list_iterate(citylist, pcity)
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
#define city_list_iterate_end
#define city_tile_iterate_end
#define city_built_iterate(_pcity, _p)
#define city_built_iterate_end
int player_culture(const struct player *plr)
Return current culture score of the player.
#define MAX_NUM_PLAYER_SLOTS
struct city * city_from_great_wonder(const struct impr_type *pimprove)
Get the world city with this great wonder.
bool is_improvement(const struct impr_type *pimprove)
Is this building a regular improvement?
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
#define improvement_iterate_end
#define improvement_iterate(_p)
static int map_pos_to_index(struct civ_map *nmap, int map_x, int map_y)
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
struct city_list * cities
bool player_slot_is_used(const struct player_slot *pslot)
Returns TRUE is this slot is "used" i.e.
int player_count()
Return the number of players.
int player_slot_index(const struct player_slot *pslot)
Returns the index of the player slot.
int player_index(const struct player *pplayer)
Return the player index.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool player_owns_city(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the given player owns the city.
#define players_iterate_end
#define players_iterate(_pplayer)
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define player_list_iterate_end
#define player_slots_iterate_end
void player_status_add(struct player *plr, enum player_status pstatus)
Add a status flag to a player.
bool player_status_check(struct player *plr, enum player_status pstatus)
Check player status flag.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
static void get_player_landarea(struct claim_map *pcmap, struct player *pplayer, int *return_landarea, int *return_settledarea)
Returns the given player's land and settled areas from a claim map.
void calc_civ_score(struct player *pplayer)
Calculates the civilization score for the player.
#define USER_AREA_MULT
Allocates, fills and returns a land area claim map.
int get_civ_score(const struct player *pplayer)
Return the civilization score (a numerical value) for the player.
static void build_landarea_map(struct claim_map *pcmap)
Count landarea, settled area, and claims map for all players.
void rank_users(bool interrupt)
At the end of a game, figure the winners and losers of the game and output to a suitable place.
static int get_units_score(const struct player *pplayer)
Return the score given by the units stats.
static int get_spaceship_score(const struct player *pplayer)
Return the spaceship score.
int total_player_citizens(const struct player *pplayer)
Return the total number of citizens in the player's nation.
#define CLIP(lower, current, upper)
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
struct server_arguments srvarg
struct packet_game_info info
struct claim_map::@107 player[MAX_NUM_PLAYER_SLOTS]
enum spaceship_state state
struct city_list * cities
struct player_spaceship spaceship
struct player_score score
FILE * fc_fopen(const char *filename, const char *opentype)
Wrapper function for fopen() with filename conversion to local encoding on Windows.
const struct player_list * team_members(const struct team *pteam)
Returns the member list of the team.
#define teams_iterate_end
#define teams_iterate(_pteam)
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
#define is_ocean_tile(ptile)
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_worked(_tile)
#define tile_owner(_tile)
bool is_military_unit(const struct unit *punit)
Military units are capable of enforcing martial law.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end