14 #include <fc_config.h>
18 #include <QCoreApplication>
20 #include <QElapsedTimer>
132 #define IDENTITY_NUMBER_SIZE 250000
215 QMutex *mutex =
new QMutex;
223 int emerg_version,
const char *distribution)
227 if (emerg_version > 0) {
228 log_debug(
"It's emergency release .%d", emerg_version);
230 if (strcmp(distribution,
"")) {
231 log_debug(
"It comes from %s distribution.", distribution);
267 int candidates, defeated;
280 str = QString(
Q_(
"?winners:, the %1"))
284 str = QString(
Q_(
"?winners:the %1"))
287 pplayer->is_winner =
true;
295 _(
"Scenario victory to %s."), qUtf8Printable(str));
321 if (0 == candidates) {
325 }
else if (0 < defeated) {
334 const struct player_list *members =
team_members(pteam);
335 int team_candidates = 0, team_defeated = 0;
337 if (1 == player_list_size(members)) {
344 if (pplayer->is_alive
353 fc_assert(team_candidates + team_defeated
354 == player_list_size(members));
356 if (team_candidates == candidates && team_defeated < defeated) {
359 _(
"Team victory to %s."),
364 pplayer->is_winner =
true;
375 struct player_list *winner_list = player_list_new();
388 player_list_destroy(winner_list);
389 winner_list =
nullptr;
395 if (
nullptr == winner_list) {
398 player_list_append(winner_list, pplayer);
402 if (
nullptr != winner_list) {
405 fc_assert(candidates == player_list_size(winner_list));
407 str = QLatin1String(
"");
412 str += QString(
Q_(
"?winners:the %1"))
417 str += QString(
Q_(
"?winners:, the %1"))
420 pplayer->is_winner =
true;
425 _(
"Allied victory to %s."), qUtf8Printable(str));
426 player_list_destroy(winner_list);
432 if (1 == candidates &&
nullptr != victor) {
438 && (!pplayer->is_alive
440 && pplayer->team != victor->
team
451 _(
"Game ended in conquest victory for %s."),
461 struct player *best =
nullptr;
463 int second_value = -1;
471 if (pplayer->score.culture > best_value) {
473 second_value = best_value;
475 }
else if (pplayer->score.culture > second_value) {
476 second_value = pplayer->score.culture;
481 if (best !=
nullptr && best_value >=
game.
info.culture_vic_points
483 > second_value * (100 +
game.
info.culture_vic_lead) / 100) {
485 _(
"Game ended in cultural domination victory for %s."),
496 _(
"Game ended as the turn limit was exceeded."));
501 _(
"Notice: game will end at the end of this turn due "
502 "to 'endturn' server setting."));
515 for (i = 0; i < n; i++) {
516 struct player *pplayer = arrivals[i];
517 const struct player_list *members;
554 if (1 < player_list_size(members)) {
556 _(
"Team victory to %s."),
561 pteammate->is_winner =
true;
566 _(
"Game ended in victory for %s."),
581 const struct player *pplayer = arrivals[i];
582 struct packet_game_info next_info =
game.
info;
593 _(
"Notice: the %s spaceship will likely arrive at "
594 "Alpha Centauri next turn."),
699 bool new_border_vision;
704 if (new_border_vision != plr->server.border_vision) {
718 int *current,
int *accum,
int *
level,
720 void (*upset_action_fn)(
int))
739 *current = (count * percent) / 100;
741 if (*accum < *
level) {
753 log_debug(
"environmental_upset: type=%-4d current=%-2d "
754 "level=%-2d accum=%-2d",
755 type, *current, *
level, *accum);
766 struct unit *a_unit =
nullptr;
780 PL_(
"Warning: you still have %1 military unit in %2 territory.",
781 "Warning: you still have %1 military units in %2 territory.",
783 .arg(QString::number(nunits),
791 PL_(
"%s Any such units will be disbanded in %d turn, "
792 "in accordance with peace treaty.",
793 "%s Any such units will be disbanded in %d turns, "
794 "in accordance with peace treaty.",
796 qUtf8Printable(unitstr), turns_left);
811 _(
"Your %s was disbanded in accordance with "
812 "your peace treaty with the %s."),
814 wipe_unit(punit, ULR_ARMISTICE,
nullptr);
822 _(
"Your %s was disbanded in accordance with "
823 "your peace treaty with the %s."),
825 wipe_unit(punit, ULR_ARMISTICE,
nullptr);
855 if (state->
type == DS_ARMISTICE
861 state->
type = DS_PEACE;
862 state2->
type = DS_PEACE;
871 if (state->
type == DS_CEASEFIRE) {
877 _(
"Concerned citizens point out that the cease-fire "
878 "with %s will run out soon."),
892 bool extend_ceasefire =
false;
896 if (plr3 != plr1 && plr3 != plr2
901 _(
"The cease-fire with %s would have run out, but "
902 "your common ally %s convinces you to extend it."),
905 extend_ceasefire =
true;
910 if (extend_ceasefire) {
919 _(
"The cease-fire with %s has run out. "
920 "You are now at war with the %s."),
923 _(
"The cease-fire with %s has run out. "
924 "You are now at war with the %s."),
926 state->
type = DS_WAR;
927 state2->
type = DS_WAR;
963 _(
"The cease-fire between %s and %s has run out. "
964 "They are at war. You cancel your alliance "
966 plr1name, plr2name, plr2name);
973 _(
"The cease-fire between %s and %s has run out. "
974 "They are at war. You cancel your alliance "
976 plr1name, plr2name, plr1name);
983 _(
"The cease-fire between %s and %s has run out. "
984 "They are at war. You cancel your alliance "
1040 bool voter_died =
false;
1045 if (0 == city_list_size(pplayer->cities)
1046 && 0 == unit_list_size(pplayer->units)) {
1052 voter_died = voter_died || pplayer->is_connected;
1070 if (
is_ai(pplayer)) {
1085 QElapsedTimer timer;
1101 case PMT_CONCURRENT:
1104 case PMT_PLAYERS_ALTERNATE:
1107 case PMT_TEAMS_ALTERNATE:
1111 qCritical(
"Unrecognized phase mode %d in begin_turn().",
1137 struct tile *ptile = punit->tile;
1158 if (pplayer->unassigned_ranked
1160 && pplayer->is_alive) {
1161 sz_strlcpy(pplayer->ranked_username, pplayer->username);
1162 pplayer->unassigned_ranked = pplayer->unassigned_user;
1179 if (
game.
info.phase_mode == PMT_CONCURRENT) {
1197 QStringLiteral(
"Begin turn:%1 milliseconds").arg(timer.elapsed()));
1206 return (*a)->wake_up > (*b)->wake_up;
1215 QElapsedTimer timer;
1223 if (is_new_phase || !
game.
server.turnblock) {
1225 pplayer->phase_done =
false;
1227 pplayer->ai_phase_done =
false;
1234 if (!is_new_phase) {
1254 unit_wait_list_clear(
server.unit_waits);
1258 if (ptile->placing !=
nullptr) {
1259 struct player *owner =
nullptr;
1266 if (pcity !=
nullptr) {
1271 if (
owner ==
nullptr) {
1273 ptile->placing =
nullptr;
1278 ptile->infra_turns--;
1279 if (ptile->infra_turns <= 0) {
1281 ptile->placing =
nullptr;
1304 struct unit *punit =
1307 punit->
server.wait = plink;
1355 if (
is_ai(pplayer)) {
1366 if (
is_ai(pplayer)) {
1390 QStringLiteral(
"Start phase:%1 milliseconds").arg(timer.elapsed()));
1399 QElapsedTimer timer;
1413 lsend_packet_end_phase(pplayer->connections);
1427 if (pplayer->multipliers[idx] != pmul->def) {
1429 _(
"%s restored to the default value %d"),
1431 pplayer->multipliers[idx] = pmul->def;
1434 if (pplayer->multipliers[idx] != pplayer->multipliers_target[idx]) {
1436 _(
"%s now at value %d"),
1438 pplayer->multipliers_target[idx]);
1440 pplayer->multipliers[idx] = pplayer->multipliers_target[idx];
1484 if (
is_ai(pplayer)) {
1507 _(
"Automatically placed spaceship parts that were still "
1548 log_time(QStringLiteral(
"End phase:%1 milliseconds").arg(timer.elapsed()));
1556 QElapsedTimer timer;
1564 if (
nullptr == pconn->playing) {
1565 send_packet_end_phase(pconn);
1588 int food = 0, shields = 0, trade = 0;
1592 food += pcity->prod[
O_FOOD];
1593 trade += pcity->prod[
O_TRADE];
1596 log_debug(
"%s T%d cities:%d pop:%d food:%d prod:%d "
1597 "trade:%d settlers:%d units:%d",
1599 city_list_size(pplayer->cities),
1601 unit_list_size(pplayer->units));
1634 struct player_list *achievers = player_list_new();
1636 struct packet_achievement_info pack;
1641 if (first !=
nullptr) {
1647 lsend_packet_achievement_info(first->
connections, &pack);
1658 if (pplayer != first) {
1662 lsend_packet_achievement_info(pplayer->connections, &pack);
1671 player_list_destroy(achievers);
1697 &&
fc_rand(10000) < pextra->disappearance_chance
1709 _(
"%s disappears from %s."),
1727 &&
fc_rand(10000) < pextra->appearance_chance
1739 _(
"%s appears to %s."),
1782 log_time(QStringLiteral(
"End turn:%1 milliseconds").arg(timer.elapsed()));
1791 const char *reason_filename =
nullptr;
1793 if (!(
game.
server.autosaves & (1 << type))) {
1799 reason_filename =
nullptr;
1802 reason_filename =
"final";
1805 reason_filename =
"quitidle";
1808 reason_filename =
"interrupted";
1811 reason_filename =
"timer";
1821 fc_snprintf(filename,
sizeof(filename),
"%s-timer",
1824 save_game(filename, save_reason,
false);
1840 if (pconn->access_level == ALLOW_CTRL) {
1842 _(
"%s lost control cmdlevel on "
1843 "game start. Use voting from now on."),
1922 QCoreApplication::exit(EXIT_SUCCESS);
1930 struct conn_list *dest = pconn->
self;
1933 qCritical(
"Got a report request %d before game start", type);
1938 qCritical(
"Got a report request %d from detached connection", type);
1958 _(
"request for unknown report (type %d)"), type);
1986 return server.identity_number;
2002 "Exhausted city and unit numbers!");
2006 return server.identity_number;
2017 return PACKET_EDIT_MODE <= type && type <= PACKET_EDIT_GAME;
2040 unsigned char buffer[4096];
2053 _(
"Your client is too old. To use this server, "
2054 "please upgrade your client to a more recent "
2055 "Freeciv21 release."));
2073 if (type == PACKET_SERVER_JOIN_REQ) {
2075 pconn,
static_cast<struct packet_server_join_req *
>(packet));
2079 if (type == PACKET_AUTHENTICATION_REPLY) {
2081 pconn, (
static_cast<struct packet_authentication_reply *
>(packet))
2085 if (type == PACKET_CONN_PONG) {
2091 qCritical(
"Received game packet %s(%d) from unaccepted connection %s.",
2097 if (type == PACKET_CHAT_MSG_REQ || type == PACKET_SINGLE_WANT_HACK_REQ
2098 || type == PACKET_NATION_SELECT_REQ || type == PACKET_REPORT_REQ
2099 || type == PACKET_CLIENT_INFO || type == PACKET_CONN_PONG
2100 || type == PACKET_CLIENT_HEARTBEAT || type == PACKET_SAVE_SCENARIO
2107 _(
"You are not allowed to edit."));
2111 if (!server_handle_packet(packet_type(type), packet,
nullptr, pconn)) {
2112 qCritical(
"Received unknown packet %d from %s.", type,
2120 if (
nullptr == pplayer || pconn->
observer) {
2121 if (type == PACKET_PLAYER_READY && pconn->
observer) {
2126 qCritical(
"Received packet %s(%d) from non-player connection %s.",
2131 if (S_S_RUNNING !=
server_state() && type != PACKET_NATION_SELECT_REQ
2132 && type != PACKET_PLAYER_READY && type != PACKET_VOTE_SUBMIT) {
2136 log_debug(
"Got a packet of type %s(%d) in %s.",
2138 server_states_name(S_S_OVER));
2140 qCritical(
"Got a packet of type %s(%d) outside %s.",
2142 server_states_name(S_S_RUNNING));
2149 if (!pplayer->
is_alive && type != PACKET_REPORT_REQ) {
2150 qCritical(
"Got a packet of type %s(%d) from a dead player.",
2158 if (!server_handle_packet(packet_type(type), packet, pplayer, pconn)) {
2159 qCritical(
"Received unknown packet %d from %s.", type,
2163 if (S_S_RUNNING ==
server_state() && type != PACKET_PLAYER_READY) {
2181 bool connected =
false;
2199 if (pplayer->is_connected
2200 && (
is_human(pplayer) || pplayer->phase_done)) {
2213 if (!pplayer->phase_done && pplayer->is_alive) {
2214 if (pplayer->is_connected) {
2223 if (
is_ai(pplayer) && !pplayer->ai_phase_done) {
2243 for (
auto &pnation :
nations) {
2245 nullptr == pnation.player,
2246 if (pnation.player->nation == &pnation) {
2249 pnation.server.no_startpos = false;
2251 }
else if (
nullptr != pnation.player->nation) {
2254 pnation.player->nation->player = nullptr;
2255 pnation.player = nullptr;
2259 pnation.player = nullptr;
2261 "Player assigned to nation before %s()!", __FUNCTION__);
2266 pnation.server.no_startpos =
false;
2272 pnation.server.no_startpos =
true;
2284 pnation.server.no_startpos =
false;
2292 for (
auto &pnation :
nations) {
2293 pnation.server.no_startpos =
false;
2305 const char *
name,
int style)
2320 if (style < 0 || style >=
game.
control.num_styles) {
2326 _(
"%s nation is not available for user selection."),
2330 if (new_nation->
player && new_nation->
player != pplayer) {
2332 _(
"%s nation is already in use."),
2348 _(
"%s is the %s ruler %s."), pplayer->
username,
2354 }
else if (
name[0] ==
'\0') {
2391 if (
nullptr == pplayer || S_S_INITIAL !=
server_state()) {
2395 if (pplayer != requestor) {
2410 int num_ready = 0, num_unready = 0;
2414 if (other_player->is_connected) {
2415 if (other_player->is_ready) {
2423 if (num_unready > 0) {
2425 _(
"Waiting to start game: %d out of %d players "
2426 "are ready to start."),
2427 num_ready, num_ready + num_unready);
2442 const char *limitreason =
nullptr;
2450 if (limit < amount) {
2451 limitreason =
_(
"requested more than 'maxplayers' setting");
2455 if (limit >
server.playable_nations) {
2456 limit =
server.playable_nations;
2458 limitreason =
_(
"not enough playable nations in this nation set "
2459 "(see 'nationset' setting)");
2461 limitreason =
_(
"not enough playable nations");
2502 fc_snprintf(leader_name,
sizeof(leader_name),
"AI*%d", filled++);
2515 qInfo(
_(
"%s has been added as %s level AI-controlled player (%s)."),
2521 _(
"%s has been added as %s level AI-controlled player (%s)."),
2598 int nations_to_assign = 0;
2619 struct nation_list *candidates = nation_list_new();
2622 for (
auto &pnation :
nations) {
2626 &&
nullptr == pnation.player
2628 nation_list_append(candidates, &pnation);
2635 nation_list_get(candidates,
fc_rand(n)));
2637 nation_list_destroy(candidates);
2642 nations_to_assign++;
2651 QHash<struct startpos *, int> hash;
2652 QHash<struct startpos *, int>::const_iterator it;
2678 hash.insert(psp, c);
2697 for (
auto &pnation :
nations) {
2704 it = hash.constBegin();
2705 while (it != hash.constEnd()) {
2711 if (it.value() < min) {
2717 }
else if (it.value() == min && 0 ==
fc_rand(++i)) {
2729 nations_to_assign--;
2732 it = hash.constBegin();
2733 while (it != hash.constEnd()) {
2735 hash.insert(it.key(), it.value() + 1);
2749 if (0 < nations_to_assign) {
2757 bool needs_startpos =
true;
2762 pick_a_nation(
nullptr,
false, needs_startpos, NOT_A_BARBARIAN);
2764 needs_startpos =
false;
2766 pick_a_nation(
nullptr,
false, needs_startpos, NOT_A_BARBARIAN);
2770 nations_to_assign--;
2789 const char *choice =
nullptr;
2790 struct nation_leader_list *candidates = nation_leader_list_new();
2798 nation_leader_list_append(candidates, pleader);
2803 n = nation_leader_list_size(candidates);
2808 nation_leader_list_destroy(candidates);
2845 _(
"The game is over..."));
2872 pplayer->revolution_finishes = 0;
2895 if (!pplayer->is_connected &&
is_human(pplayer)) {
2907 test_random1(20000);
2908 test_random1(200000);
2930 } mapgen_settings[] = {{
2944 int max = retry_ok ? 3 : 1;
2945 bool created =
false;
2947 int sucount = qstrlen(
game.
server.start_units);
2950 for (i = 0; utype ==
nullptr && i < sucount; i++) {
2960 for (i = 0; i <
ARRAY_SIZE(mapgen_settings); i++) {
2965 sizeof(mapgen_settings[i].
value));
2967 sizeof(mapgen_settings[i].pretty));
2970 for (i = 0; !created && i < max; i++) {
2972 if (!created && max > 1) {
2980 qInfo(
_(
"Failed to create suitable map, retrying with "
2981 "another mapseed."));
2987 qInfo(
_(
"Attempt %d/%d"), i + 2, max);
2995 for (set = 0; set <
ARRAY_SIZE(mapgen_settings); set++) {
3002 nullptr, error,
sizeof(error));
3003 fc_assert_msg(success ==
true,
"Failed to restore '%s': %s",
3004 mapgen_settings[set].
name, error);
3011 qCCritical(bugs_category,
3012 _(
"Cannot create suitable map with given settings."));
3024 for (i = 0; i <
ARRAY_SIZE(mapgen_settings); i++) {
3026 char pretty[
sizeof(mapgen_settings[i].pretty)];
3031 mapgen_settings[i].pretty)) {
3035 _(
"Setting '%s' has been adjusted from %s to %s."),
3036 setting_name(pset), mapgen_settings[i].pretty, pretty);
3037 qInfo(
_(
"Setting '%s' has been adjusted from %s to %s."),
3038 setting_name(pset), mapgen_settings[i].pretty, pretty);
3063 pplayer->economic.gold =
game.
info.gold;
3109 if (
is_ai(pplayer)) {
3132 if (
game.
server.revealmap & REVEAL_MAP_START) {
3154 qDebug(
"srv_running() mostly redundant send_server_settings()");
3171 punit->
server.wait = NULL;
3182 server.playable_nations = 0;
3220 punit->server.vision =
nullptr;
3230 pcity->server.vision =
nullptr;
3246 unit_wait_list_destroy(
server.unit_waits);
3255 const struct player *pplayer)
3259 return plrtile && plrtile->
site ? plrtile->
site->identity
3273 qCritical(
"No server setting named %s exists.",
name);
3288 qCritical(
"No server setting with the id %d exists.",
id);
3303 qCritical(
"No server setting with the id %d exists.",
id);
3304 return sset_type_invalid();
3318 qCritical(
"No server setting with the id %d exists.",
id);
3333 qCritical(
"No server setting with the id %d exists.",
id);
3348 qCritical(
"No server setting with the id %d exists.",
id);
3357 const struct player *pplayer,
3360 if (knowledge && pplayer) {
3371 const struct player *pplayer,
3374 if (knowledge && pplayer) {
3386 const struct player *pplayer,
3389 if (knowledge && pplayer
3392 return plrtile->
owner;
3402 const struct player *pplayer,
bool knowledge)
3410 if (knowledge && pplayer) {
3414 return pdcity->
owner;
3427 const struct player *pplayer,
bool knowledge)
3429 int unit_count = unit_list_size(ptile->
units);
3431 if (unit_count == 0) {
3435 if (knowledge && pplayer
const char * achievement_first_msg(struct achievement *pach)
Return message to send to first player gaining the achievement.
const char * achievement_later_msg(struct achievement *pach)
Return message to send to other players gaining the achievement.
int achievement_index(const struct achievement *pach)
Return the achievement index.
struct player * achievement_plr(struct achievement *ach, struct player_list *achievers)
Check if some player has now achieved the achievement and return the player in question.
#define achievements_iterate_end
#define achievements_iterate(_ach_)
void building_advisor(struct player *pplayer)
Prime pcity->server.adv.building_want[].
void adv_data_analyze_rulesets(struct player *pplayer)
Analyze rulesets.
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Make and cache lots of calculations needed for other functions.
void adv_data_phase_done(struct player *pplayer)
Clean up our mess.
void adv_data_default(struct player *pplayer)
Initialize with sane values.
bool adv_spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Place all available spaceship components.
const char * ai_name(const struct ai_type *ai)
Return the name of the ai type.
#define ai_timer_free(...)
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
void ai_init()
Initialize ai stuff.
const char * default_ai_type_name()
Return name of default ai type.
void ai_traits_init(struct player *pplayer)
Initialize ai traits for player.
void create_animals()
Create animal kingdom player and his units.
bool auth_handle_reply(struct connection *pconn, char *password)
Receives a password from a client and verifies it.
void auto_settlers_player(struct player *pplayer)
Run through all the players settlers and let those on ai.control work automagically.
void adv_settlers_free()
Free resources allocated for autosettlers system.
void summon_barbarians()
Summon barbarians out of the blue.
bool BV_ISSET(const BV &bv, int bit)
void game_advance_year()
Advance the game year.
void game_next_year(struct packet_game_info *info)
Advance the calendar in the passed game_info structure (may only be a copy of the real one).
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
void free_city_map_index()
Free memory allocated by generate_citymap_index.
#define cities_iterate_end
#define city_list_iterate(citylist, pcity)
#define cities_iterate(pcity)
#define city_list_iterate_end
void citymap_free()
Free resources allocated for citymap.
bool check_city_migrations()
Check for citizens who want to migrate between the cities that overlap.
void send_city_turn_notifications(struct connection *pconn)
Send global and player specific city turn notifications.
void update_city_activities(struct player *pplayer)
Update all cities of one nation (costs for buildings, unit upkeep, ...).
void check_disasters()
Check for any disasters hitting any city, and apply those disasters.
bool handle_login_request(struct connection *pconn, struct packet_server_join_req *req)
Returns FALSE if the clients gets rejected and the connection should be closed.
void conn_set_access(struct connection *pconn, enum cmdlevel new_level, bool granted)
Set the access level of a connection, and re-send some needed info.
void conn_list_do_unbuffer(struct conn_list *dest)
Convenience functions to unbuffer a list of connections.
bool can_conn_edit(const struct connection *pconn)
Return TRUE iff the connection is currently allowed to edit.
void conn_list_compression_thaw(const struct conn_list *pconn_list)
Thaw a connection list.
const char * conn_description(const struct connection *pconn, bool is_private)
° Return pointer to static string containing a description for this ° connection, based on pconn->nam...
void conn_list_do_buffer(struct conn_list *dest)
Convenience functions to buffer a list of connections.
void conn_list_compression_freeze(const struct conn_list *pconn_list)
Freeze a connection list.
bool conn_controls_player(const struct connection *pconn)
Returns TRUE if the given connection is attached to a player which it also controls (i....
bool connection_send_data(struct connection *pconn, const unsigned char *data, int len)
Write data to socket.
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
void con_log_close()
Deinitialize logging.
void con_puts(enum rfc_status rfc_status, const char *str)
Write to console and add line-break, and show prompt if required.
int nation_history_gain(const struct player *pplayer)
How much nation-wide history player gains this turn.
void dio_output_init(struct raw_data_out *dout, void *destination, size_t dest_size)
Initializes the output to the given output buffer and the given buffer size.
void dio_put_uint16_raw(struct raw_data_out *dout, int value)
Insert value using 16 bits.
void dio_put_uint8_raw(struct raw_data_out *dout, int value)
Insert value using 8 bits.
void dio_put_string_raw(struct raw_data_out *dout, const char *value)
Insert nullptr-terminated string.
size_t dio_output_used(struct raw_data_out *dout)
Return the maximum number of bytes used.
void dio_put_bool32_raw(struct raw_data_out *dout, bool value)
Insert value 0 or 1 using 32 bits.
void dio_output_rewind(struct raw_data_out *dout)
Rewinds the stream so that the put-functions start from the beginning.
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
Set an AI level and related quantities, with no feedback.
void send_diplomatic_meetings(struct connection *dest)
Send information on any on-going diplomatic meetings for connection's player.
void free_treaties()
Free all the treaties currently in treaty list.
void diplhand_free()
Free all the resources allocated by diplhand.
const int TURNS_EXTEND_CEASEFIRE
void edithand_free()
Free all memory used by data structures required for edit mode.
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Returns the effect bonus at a unit.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
void free_libfreeciv()
Free misc resources allocated for libfreeciv.
#define MAX_NUM_PLAYER_SLOTS
#define IDENTITY_NUMBER_ZERO
void fcdb_free(void)
Free resources allocated by fcdb system.
void init_character_encodings(const char *my_internal_encoding, bool my_use_transliteration)
Must be called during the initialization phase of server and client to initialize the character encod...
const char * get_internal_encoding()
Return the internal encoding.
#define FC_DEFAULT_DATA_ENCODING
const char * get_locale_dir()
Return directory containing locales.
#define PL_(String1, String2, n)
const char * tile_link(const struct tile *ptile)
Get a text link to a tile.
const char * unit_tile_link(const struct unit *punit)
Get a text link to a unit tile (make a clickable link to a tile with the unit type name as text).
const struct ft_color ftc_server
const struct ft_color ftc_editor
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
bool is_player_phase(const struct player *pplayer, int phase)
Return TRUE if it is this player's phase.
void game_map_init()
Initialize map-specific parts of the game structure.
void i_am_server()
Set program type to server.
void game_init(bool keep_ruleset_value)
Initialise all game settings.
int current_turn_timeout()
Return timeout value for the current turn.
int generate_save_name(const char *format, char *buf, int buflen, const char *reason)
Generate a default save file name and place it in the provided buffer.
void game_free()
Frees all memory of the game.
#define TURNS_NEEDED_TO_RANK
void init_new_game()
Initialize a new game: place the players' units onto the map, etc.
struct unit_type * crole_to_unit_type(char crole, struct player *pplayer)
Get unit_type for given role character.
void send_game_info(struct conn_list *dest)
Send game_info packet; some server options and various stuff...
void send_year_to_clients()
Tell clients the year, and also update turn_done and nturns_idle fields for all players.
int update_timeout()
adjusts game.info.timeout based on various server options
void adv_city_free(struct city *pcity)
Free advisors related city data.
void log_time(const QString &msg, bool log)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert_exit_msg(condition, message,...)
#define fc_assert(condition)
#define fc_assert_action_msg(condition, action, message,...)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
void main_map_free()
Free main map and related global structures.
bool startpos_nation_allowed(const struct startpos *psp, const struct nation_type *pnation)
Returns TRUE if the given nation can start here.
bool map_is_empty()
Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded.
int map_num_tiles()
Returns the total number of (real) positions (or tiles) on the map.
bool startpos_allows_all(const struct startpos *psp)
Returns TRUE if any nation can start here.
int map_startpos_count()
Is there start positions set for map.
void main_map_allocate()
Allocate main map and related global structures.
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
bool map_generate(bool autosize, struct unit_type *initial_unit)
See stdinhand.c for information on map generation methods.
void generator_free()
Free resources allocated by the generator.
void disable_fog_of_war()
Turns FoW off for everyone.
void player_map_init(struct player *pplayer)
Allocate space for map, and initialise the tiles.
void map_calculate_borders()
Update borders for all sources.
void map_set_border_vision(struct player *pplayer, const bool is_enabled)
Turn a players ability to see inside his borders on or off.
void send_map_info(struct conn_list *dest)
Send basic map information: map size, topology, and is_earth.
void send_all_known_tiles(struct conn_list *dest)
Send all tiles known to specified clients.
void show_map_to_all()
Unfogs all tiles for all players.
void enable_fog_of_war()
Turns FoW on for everyone.
void map_show_all(struct player *pplayer)
Shows the area to the player.
void map_show_tile(struct player *src_player, struct tile *ptile)
Shows the area to the player.
void nuclear_winter(int effect)
Wrapper for climate_change().
void create_extra(struct tile *ptile, const extra_type *pextra, struct player *pplayer)
Create extra to tile.
void update_tile_knowledge(struct tile *ptile)
Update playermap knowledge for everybody who sees the tile, and send a packet to everyone whose info ...
void give_shared_vision(struct player *pfrom, struct player *pto)
Starts shared vision between two players.
struct player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
Players' information of tiles is tracked so that fogged area can be kept consistent even when the cli...
struct vision_site * map_get_player_city(const struct tile *ptile, const struct player *pplayer)
Returns city located at given tile from player map.
void global_warming(int effect)
Wrapper for climate_change().
void mapimg_free()
Free all memory allocated by the map image subsystem.
const char * multiplier_name_translation(const struct multiplier *pmul)
Return the (translated) name of the multiplier.
bool multiplier_can_be_changed(struct multiplier *pmul, struct player *pplayer)
Can player change multiplier value.
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Returns multiplier index.
#define multipliers_iterate(_mul_)
#define multipliers_iterate_end
struct nation_type * nation_by_number(const Nation_type_id nation)
Return the nation with the given index.
struct nation_style * style_of_nation(const struct nation_type *pnation)
Returns nation's style.
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Returns the nation leader structure which match 'name' or nullptr if not found.
bool nation_leader_is_male(const struct nation_leader *pleader)
Return the sex of the nation leader.
struct government * init_government_of_nation(const struct nation_type *pnation)
Returns initial government type for this nation.
int nation_set_count()
Return the number of nation sets.
std::vector< nation_type > nations
bool is_nation_playable(const struct nation_type *nation)
Return whether a nation is "playable"; i.e., whether a human player can choose this nation.
const char * nation_adjective_translation(const struct nation_type *pnation)
Return the (translated) adjective for the given nation.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
bool can_conn_edit_players_nation(const struct connection *pconn, const struct player *pplayer)
Return TRUE iff the editor is allowed to edit the player's nation in pregame.
const char * nation_leader_name(const struct nation_leader *pleader)
Return the name of the nation leader.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Returns the list the nation leader names.
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Returns which kind of barbarians can use this nation.
#define nation_leader_list_iterate(leaderlist, pleader)
#define nation_leader_list_iterate_end
#define NO_NATION_SELECTED
void event_cache_init()
Initializes the event cache.
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Similar to notify_conn_packet (see also), but takes player as "destination".
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
See notify_conn_packet - this is just the "non-v" version, with varargs.
void event_cache_remove_old()
Remove the old events from the cache.
void event_cache_free()
Frees the event cache.
void event_cache_phases_invalidate()
Mark all existing phase values in event cache invalid.
void send_attribute_block(const struct player *pplayer, struct connection *pconn)
Split the attribute block into chunks and send them over pconn.
const char * packet_name(enum packet_type type)
@ REPORT_WONDERS_OF_THE_WORLD
struct player * player_by_name(const char *name)
Find player by given name.
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Return TRUE if players are in the same team.
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
int player_number(const struct player *pplayer)
Return the player index/number/id.
int player_count()
Return the number of players.
int player_index(const struct player *pplayer)
Return the player index.
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Set the player's nation to the given nation (may be nullptr).
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
struct player * player_by_user(const char *name)
Find player by its user name (not player/leader name)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
#define players_iterate_end
#define players_iterate(_pplayer)
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_list_iterate_end
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
void server_player_set_name(struct player *pplayer, const char *name)
Try to set the player name to 'name'.
void send_player_all_c(struct player *src, struct conn_list *dest)
Send all information about a player (player_info and all player_diplstates) to the given connections.
void player_status_add(struct player *plr, enum player_status pstatus)
Add a status flag to a player.
void playercolor_init()
Initialise the player colors.
void playercolor_free()
Free the memory allocated for the player color.
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Creates a new, uninitialized, used player slot.
bool server_player_set_name_full(const struct connection *caller, struct player *pplayer, const struct nation_type *pnation, const char *name, char *error_buf, size_t error_buf_len)
Try to set the player name to 'name'.
void assign_player_colors()
Permanently assign colors to any players that don't already have them.
struct rgbcolor * playercolor_get(int id)
Get the player color with the index 'id'.
void kill_player(struct player *pplayer)
Murder a player in cold blood.
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
void handle_diplomacy_cancel_pact_explicit(struct player *pplayer, int other_player_id, enum clause_type clause, bool protect_alliances)
A variant of handle_diplomacy_cancel_pact that allows the caller to explicitely control if war declar...
bool player_status_check(struct player *plr, enum player_status pstatus)
Check player status flag.
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
This function returns a random-ish nation that is suitable for 'barb_type' and is usable (not already...
void server_remove_player(struct player *pplayer)
This function does not close any connections attached to this player.
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Initialize ANY newly-created player on the server.
int normal_player_count()
Return the number of non-barbarian players.
void make_contact(struct player *pplayer1, struct player *pplayer2, struct tile *ptile)
Update contact info.
void update_capital(struct player *pplayer)
Recalculate what city is the named capital.
struct player_economic player_limit_to_max_rates(struct player *pplayer)
The following limits a player's rates to those that are acceptable for the present form of government...
void shuffle_players()
Shuffle or reshuffle the player order, storing in static variables above.
int playercolor_count()
Number of player colors defined.
bool client_can_pick_nation(const struct nation_type *pnation)
Return whether a nation is "pickable" – whether players can select it at game start.
bool nation_is_in_current_set(const struct nation_type *pnation)
Is the nation in the currently selected nationset? If not, it's not allowed to appear in the game.
void enter_war(struct player *pplayer, struct player *pplayer2)
Two players enter war.
void update_revolution(struct player *pplayer)
See if the player has finished their revolution.
#define alive_phase_players_iterate(pplayer)
#define alive_phase_players_iterate_end
#define phase_players_iterate(pplayer)
#define phase_players_iterate_end
void fc_rand_set_init(bool init)
Sets whether the current state has been initialized.
std::mt19937 & fc_rand_state()
Returns a reference to the current random generator state; eg for save/restore.
void fc_srand(std::uint_fast32_t seed)
Initialize the generator; see comment at top of file.
void fc_rand_seed(std::mt19937 &gen)
Seeds the given generator with a random value.
void report_final_scores(struct conn_list *dest)
Inform clients about player scores and statistics when the game ends.
void report_wonders_of_the_world(struct conn_list *dest)
Send report listing all built and destroyed wonders, and wonders currently being built.
void report_demographics(struct connection *pconn)
Send demographics report; what gets reported depends on value of demographics server option.
void make_history_report()
Produce random history report if it's time for one.
void report_top_five_cities(struct conn_list *dest)
Send report listing the "best" 5 cities in the world.
void log_civ_score_free()
Free resources allocated for score logging system.
void report_achievements(struct connection *pconn)
Send achievements list.
void log_civ_score_now()
Create a log file of the civilizations so you can see what was happening.
int player_tech_upkeep(const struct player *pplayer)
Calculate the bulb upkeep needed for all techs of a player.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
Tech_type_id research_goal_step(const struct research *presearch, Tech_type_id goal)
Return the next tech we should research to advance towards our goal.
bool research_is_valid(const struct research &presearch)
Checks whether the research object is valid in the current game.
std::vector< research > research_array
void rulesets_deinit()
Completely deinitialize ruleset system.
void save_game(const char *orig_filename, const char *save_reason, bool scenario)
Unconditionally save the game, with specified filename.
void calc_civ_score(struct player *pplayer)
Calculates the civilization score for the player.
int total_player_citizens(const struct player *pplayer)
Return the total number of citizens in the player's nation.
void script_server_signal_emit(const char *signal_name,...)
Invoke all the callback functions attached to a given signal.
void handle_conn_pong(struct connection *pconn)
Handle response to ping.
void close_connections_and_socket()
Close all network stuff: connections, listening sockets, metaserver connection...
void flush_packets()
Attempt to flush all information in the send buffers for upto 'netwait' seconds.
#define SERVER_SETTING_NONE
int setting_int_get(struct setting *pset)
Get value of integer setting.
void settings_game_start()
Save setting values at the start of the game.
void settings_free()
Deinitialize stuff related to this code module.
int setting_number(const struct setting *pset)
Returns the id to the given setting.
enum sset_type setting_type(const struct setting *pset)
Access function for the setting type.
struct setting * setting_by_number(int id)
Returns the setting to the given id.
struct setting * setting_by_name(const char *name)
Returns the setting to the given name.
struct setting_list * level[OLEVELS_NUM]
const char * setting_name(const struct setting *pset)
Access function for the setting name.
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Compute the name of the current value of the setting.
void settings_turn()
Update stuff every turn that is related to this code module.
bool setting_enum_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Set the setting to 'val'.
int setting_bitwise_get(struct setting *pset)
Get value of bitwise setting.
bool setting_bool_get(struct setting *pset)
Get value of boolean setting.
void send_server_settings(struct conn_list *dest)
Tell the client about all server settings.
void free_nls()
Free memory allocated by Native Language Support.
void init_nls()
Setup for Native Language Support, if configured to use it.
int rank_spaceship_arrival(struct player **result)
Rank launched player spaceships in order of arrival.
double spaceship_arrival(const struct player *pplayer)
Return arrival year of player's spaceship (fractional, as one spaceship may arrive before another in ...
void send_spaceship_info(struct player *src, struct conn_list *dest)
Send details of src's spaceship (or spaceships of all players if src is nullptr) to specified destina...
void spaceship_arrived(struct player *pplayer)
Handle spaceship arrival.
void timing_log_init()
Initialize AI timing system.
void timing_log_free()
Free AI timing system resources.
void server_game_init(bool keep_ruleset_value)
Initialize game data for the server (corresponds to server_game_free).
void srv_scores()
Score calculation.
static int unit_wait_cmp(const struct unit_wait *const *a, const struct unit_wait *const *b)
Comparator for sorting unit_waits in chronological order.
void handle_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
Handles a pick-nation packet from the client.
void srv_ready()
Set up one game.
static void ai_start_phase()
Called at the start of each (new) phase to do AI activities.
const char * aifill(int amount)
Fill or remove players to meet the given aifill.
void check_for_full_turn_done()
Check if turn is really done.
int mapimg_server_plrcolor_count()
Helper function for the mapimg module - number of player colors.
void identity_number_release(int id)
Mark identity number free.
void end_phase()
End a phase of movement.
int server_plr_tile_city_id_get(const struct tile *ptile, const struct player *pplayer)
Returns the id of the city the player map of 'pplayer' has at 'ptile' or IDENTITY_NUMBER_ZERO if the ...
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
Set nation for player with nation default values.
void server_game_free()
Free game data that we reinitialize as part of a server soft restart.
bv_identity_numbers identity_numbers_used
static void handle_observer_ready(struct connection *pconn)
Handle a player-ready packet from global observer.
BV_DEFINE(bv_identity_numbers, IDENTITY_NUMBER_SIZE)
static void do_reveal_effects()
Give map information to players with EFT_REVEAL_CITIES or EFT_REVEAL_MAP effects (traditionally from ...
static void unit_wait_destroy(struct unit_wait *pwait)
Free function for unit_wait.
void handle_report_req(struct connection *pconn, enum report_type type)
Handle request asking report to be sent to client.
player * mapimg_server_tile_owner(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Helper function for the mapimg module - tile owner.
static void generate_players()
Assign random nations to players at game start.
void handle_player_ready(struct player *requestor, int player_no, bool is_ready)
Handle a player-ready packet.
static bool identity_number_is_used(int id)
Check whether identity number is currently allocated.
static int increment_identity_number()
Increment identity_number and return result.
static void do_have_contacts_effect()
Give contact to players with the EFT_HAVE_CONTACTS effect (traditionally from Marco Polo's Embassy).
static enum server_states civserver_state
static void update_diplomatics()
Check for cease-fires and armistices running out; update cancelling reasons and contact information.
void save_game_auto(const char *save_reason, enum autosave_type type)
Save game with autosave filename.
const char * server_ss_name_get(server_setting_id id)
Returns the name of the server setting with the specified id.
bool check_for_game_over()
Returns TRUE if any one game end condition is fulfilled, FALSE otherwise.
void start_game()
Start actual game.
static civtimer * eot_timer
player * mapimg_server_tile_unit(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Helper function for the mapimg module - unit owner.
void set_server_state(enum server_states newstate)
Set current server state.
void end_turn()
Handle the end of each turn.
static void update_environmental_upset(enum environment_upset_type type, int *current, int *accum, int *level, int percent, void(*upset_action_fn)(int))
Handle environmental upsets, meaning currently pollution or fallout.
void identity_number_reserve(int id)
Mark identity number allocated.
void server_quit()
Quit the server and exit.
struct server_arguments srvarg
void init_game_seed()
Initialize the game seed.
#define IDENTITY_NUMBER_SIZE
known_type mapimg_server_tile_known(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Helper function for the mapimg module - tile knowledge.
static void final_ruleset_adjustments()
Apply some final adjustments from the ruleset on to the game state.
static bool is_client_edit_packet(int type)
Returns TRUE if the packet type is an edit packet sent by the client.
bool game_was_started()
Returns iff the game was started once upon a time.
static void notify_illegal_armistice_units(struct player *phost, struct player *pguest, int turns_left)
Notify about units at risk of disband due to armistice.
bool server_ss_val_bool_get(server_setting_id id)
Returns the value of the boolean server setting with the specified id.
static void remove_illegal_armistice_units(struct player *plr1, struct player *plr2)
Remove illegal units when armistice turns into peace treaty.
server_setting_id server_ss_by_name(const char *name)
Returns the id of the server setting with the specified name.
enum server_states server_state()
Return current server state.
static void do_border_vision_effect()
Handle the vision granting effect EFT_BORDER_VISION.
static void player_set_nation_full(struct player *pplayer, struct nation_type *pnation)
Tool for generate_players().
static void announce_player(struct player *pplayer)
Announce what nation player rules to everyone.
rgbcolor * mapimg_server_plrcolor_get(int i)
Helper function for the mapimg module - one player color.
static civtimer * between_turns
void begin_phase(bool is_new_phase)
Begin a phase of movement.
bool server_packet_input(struct connection *pconn, void *packet, int type)
Returns FALSE if connection should be closed (because the clients was rejected).
void srv_init()
Initialize freeciv server.
void handle_client_info(struct connection *pc, int obsolete, int emerg_version, const char *distribution)
Handle client info packet.
int server_ss_val_int_get(server_setting_id id)
Returns the value of the integer server setting with the specified id.
unsigned int server_ss_val_bitwise_get(server_setting_id id)
Returns the value of the bitwise server setting with the specified id.
static bool has_been_srv_init
void begin_turn(bool is_new_turn)
Handle the beginning of each turn.
void send_all_info(struct conn_list *dest)
Send all information for when game starts or client reconnects.
const char * pick_random_player_name(const struct nation_type *pnation)
Returns a random ruler name picked from given nation's ruler names that is not already in use.
static void kill_dying_players()
Check all players to see whether they are dying.
int identity_number()
Identity ids wrap at IDENTITY_NUMBER_SIZE, skipping IDENTITY_NUMBER_ZERO Setup in server_game_init()
enum sset_type server_ss_type_get(server_setting_id id)
Returns the type of the server setting with the specified id.
void update_nations_with_startpos()
Update information about which nations have start positions on the map.
terrain * mapimg_server_tile_terrain(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Helper function for the mapimg module - tile terrain.
player * mapimg_server_tile_city(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Helper function for the mapimg module - city owner.
#define IDENTITY_NUMBER_SKIP
void stdinhand_turn()
Update stuff every turn that is related to this code module.
void set_ai_level_direct(struct player *pplayer, enum ai_level level)
Set an AI level from the server prompt.
bool start_command(struct connection *caller, bool check, bool notify)
Handle start command.
void stdinhand_free()
Deinitialize stuff related to this code module.
void toggle_ai_player_direct(struct connection *caller, struct player *pplayer)
Handle ai player ai toggling.
void set_running_game_access_level()
Adjust default command level on game start.
void(* unit_deallocate)(int unit_id)
struct civ_game::@28::@32 server
struct packet_ruleset_control control
struct civ_game::@30 callbacks
struct conn_list * est_connections
struct packet_game_info info
struct packet_scenario_info scenario
struct packet_timeout_info tinfo
struct government * government_during_revolution
QHash< struct tile *, struct startpos * > * startpos_table
struct civ_map::@39::@41 server
enum cmdlevel access_level
government * init_government
enum ai_level skill_level
std::unique_ptr< vision_site > site
struct player_ai ai_common
char username[MAX_LEN_NAME]
struct connection * current_conn
const struct ai_type * ai
struct conn_list * connections
struct player_score score
struct nation_type * nation
struct nation_style * style
Tech_type_id researching_saved
bool metaconnection_persistent
QString scenarios_pathname
struct unit::@76::@79 server
struct nation_style * style_by_number(int id)
Return style of given id.
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
#define sz_strlcpy(dest, src)
const char * team_name_translation(const struct team *pteam)
Returns the name (translated) of the team.
int team_count()
Return the current number of teams.
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)
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Remove extra and adjust other extras accordingly.
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Return a known_type enumeration value for the tile.
bool tile_extra_apply(struct tile *ptile, const extra_type *tgt)
Add extra and adjust other extras accordingly.
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_terrain(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
void timer_destroy(civtimer *t)
Deletes timer.
void timer_start(civtimer *t)
Start timing, adding to previous accumulated time if timer has not been cleared.
civtimer * timer_renew(civtimer *t, enum timer_timetype type, enum timer_use use)
Allocate a new timer, or reuse t, with specified "type" and "use".
bool is_military_unit(const struct unit *punit)
Military units are capable of enforcing martial law.
bool unit_is_cityfounder(const struct unit *punit)
Is a cityfounder unit?
#define unit_wait_list_link_iterate_end
#define unit_wait_list_link_iterate(unit_wait_list, plink)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
struct unit_type * get_role_unit(int role, int role_index)
Return index-th unit with specified role/flag.
bool victory_enabled(enum victory_condition_type victory)
Whether victory condition is enabled.
void vision_free(struct vision *vision)
Free the vision source.
#define vision_layer_iterate(v)
#define vision_layer_iterate_end
void voting_turn()
Check running votes.
void send_updated_vote_totals(struct conn_list *dest)
Sends a packet_vote_update to every conn in dest.
void voting_free()
Free all memory used by this module.
void clear_all_votes()
Remove all votes.