14 #include <fc_config.h>
28 #include "fc_version.h"
48 #include "packhand_gen.h"
112 #undef DEBUG_TRANSPORT
116 struct tile_list *worked_tiles,
bool is_new,
117 bool popup,
bool investigate);
124 }
invisible = {.cities =
nullptr, .placeholder =
nullptr};
128 enum event_type
event;
176 invisible.placeholder->unassigned_user =
true;
178 invisible.placeholder->unassigned_ranked =
true;
198 punit->
id = packet->id;
200 punit->
facing = packet->facing;
203 QString::fromUtf8(QByteArray(packet->name,
ARRAY_SIZE(packet->name)));
207 punit->
hp = packet->hp;
227 punit->
fuel = packet->fuel;
231 punit->
stay = packet->stay;
234 punit->
client.occupied = packet->occupied;
235 if (packet->transported) {
236 punit->
client.transported_by = packet->transported_by;
238 punit->
client.transported_by = -1;
240 if (packet->carrying >= 0) {
255 for (i = 0; i < packet->orders_length; i++) {
271 QDateTime localtime(utctime.toLocalTime());
278 punit->
client.asking_city_name =
false;
301 punit->
id = packet->id;
303 punit->
facing = packet->facing;
305 punit->
veteran = packet->veteran;
306 punit->
hp = packet->hp;
307 punit->
activity =
static_cast<unit_activity
>(packet->activity);
309 QString::fromUtf8(QByteArray(packet->name,
ARRAY_SIZE(packet->name)));
318 punit->
client.occupied = packet->occupied;
319 if (packet->transported) {
320 punit->
client.transported_by = packet->transported_by;
322 punit->
client.transported_by = -1;
333 const char *capability,
334 const char *challenge_file,
int conn_id)
341 struct packet_client_info client_info;
343 qDebug(
"join game accept:%s",
message);
354 client_info._obsolete = 5;
355 client_info._obsolete2 = 0;
356 qstrncpy(client_info.distribution, FREECIV_DISTRIBUTOR,
357 sizeof(client_info.distribution));
358 send_packet_client_info(&
client.
conn, &client_info);
371 _(
"You were rejected from the game: %s"),
message);
375 qInfo(
_(
"You were rejected from the game: %s"),
message);
396 bool need_menus_update;
407 if (need_menus_update) {
419 struct unit_list *cargos;
421 bool need_economy_report_update;
424 qCritical(
"Server wants us to remove unit id %d, "
425 "but we don't know about this unit!",
438 need_economy_report_update = (0 < punit->
upkeep[
O_GOLD]);
443 if (unit_list_size(cargos) > 0) {
452 punit->
client.transported_by = -1;
458 if (need_economy_report_update) {
493 bool show_combat =
false;
497 if (punit0 && punit1) {
499 packet->attacker_hp, packet->defender_hp,
500 packet->make_att_veteran, packet->make_def_veteran);
514 int hp0 = packet->attacker_hp, hp1 = packet->defender_hp;
532 if (packet->make_att_veteran && punit0) {
536 if (packet->make_def_veteran && punit1) {
644 bool city_is_new =
false;
645 bool city_has_changed_owner =
false;
646 bool need_science_dialog_update =
false;
647 bool need_units_dialog_update =
false;
648 bool need_economy_dialog_update =
false;
649 bool name_changed =
false;
650 bool update_descriptions =
false;
651 bool shield_stock_changed =
false;
652 bool production_changed =
false;
653 bool trade_routes_changed =
false;
655 struct tile_list *worked_tiles =
nullptr;
657 struct tile *ptile =
nullptr;
665 if (!universals_n_is_valid(
666 static_cast<universals_n
>(packet->production_kind))) {
667 qCritical(
"handle_city_info() bad production_kind %d.",
668 packet->production_kind);
669 product.
kind = VUT_NONE;
672 static_cast<universals_n
>(packet->production_kind),
673 packet->production_value);
674 if (!universals_n_is_valid(product.
kind)) {
675 qCritical(
"handle_city_info() "
676 "production_kind %d with bad production_value %d.",
677 packet->production_kind, packet->production_value);
678 product.
kind = VUT_NONE;
682 if (
nullptr != pcity) {
685 if (
nullptr == ptile) {
687 city_list_remove(
invisible.cities, pcity);
690 pcity->
tile = pcenter;
692 pcity->
owner = powner;
698 pworked, _index, _x, _y)
701 if (
nullptr == worked_tiles) {
702 worked_tiles = tile_list_new();
704 tile_list_append(worked_tiles, pworked);
710 city_has_changed_owner =
true;
714 if (
nullptr == pcity) {
717 pcity->
id = packet->id;
719 update_descriptions =
true;
720 }
else if (pcity->
id != packet->id) {
721 qCritical(
"handle_city_info() city id %d != id %d.", pcity->
id,
724 }
else if (ptile != pcenter) {
725 qCritical(
"handle_city_info() city tile (%d, %d) != (%d, %d).",
730 (0 != strncmp(packet->name, pcity->
name,
sizeof(pcity->
name)));
732 while (trade_route_list_size(pcity->
routes) > packet->traderoute_count) {
735 trade_route_list_remove(pcity->
routes, proute);
738 trade_routes_changed =
true;
746 update_descriptions =
758 pcity->
client.full =
true;
780 qCritical(
"handle_city_info() "
781 "%d citizens not equal %d city size in \"%s\".",
787 if (
game.
info.citizen_nationality) {
789 for (i = 0; i < packet->nationalities_count; i++) {
791 packet->nation_citizens[i]);
796 pcity->
history = packet->history;
797 pcity->
client.culture = packet->culture;
798 pcity->
client.buy_cost = packet->buy_cost;
811 need_science_dialog_update =
true;
816 shield_stock_changed =
true;
823 production_changed =
true;
827 if ((city_is_new && VUT_UTYPE == product.
kind)
828 || (production_changed
830 || VUT_UTYPE == product.
kind))
832 || shield_stock_changed) {
833 need_units_dialog_update =
true;
839 pcity->
surplus[o] = packet->surplus[o];
840 pcity->
waste[o] = packet->waste[o];
842 pcity->
prod[o] = packet->prod[o];
844 pcity->
usage[o] = packet->usage[o];
848 #ifdef DONE_BY_create_city_virtual
860 pcity->
airlift = packet->airlift;
861 pcity->
did_buy = packet->did_buy;
869 if (!universals_n_is_valid(
870 static_cast<universals_n
>(packet->changed_from_kind))) {
871 qCritical(
"handle_city_info() bad changed_from_kind %d.",
872 packet->changed_from_kind);
873 product.
kind = VUT_NONE;
876 static_cast<universals_n
>(packet->changed_from_kind),
877 packet->changed_from_value);
878 if (!universals_n_is_valid(product.
kind)) {
879 qCritical(
"handle_city_info() bad changed_from_value %d.",
880 packet->changed_from_value);
881 product.
kind = VUT_NONE;
895 if (have && !city_is_new
899 need_economy_dialog_update |=
912 pcity->
client.walls = packet->walls;
913 pcity->
style = packet->style;
914 pcity->
capital = packet->capital;
915 if (packet->capital == CAPITAL_PRIMARY) {
920 pcity->
client.city_image = packet->city_image;
921 pcity->
steal = packet->steal;
928 || packet->diplomat_investigate;
931 popup, packet->diplomat_investigate);
933 if (city_is_new && !city_has_changed_owner) {
940 if (update_descriptions) {
947 if (pfocus_unit->homecity == pcity->
id) {
955 if (need_science_dialog_update) {
960 if (need_units_dialog_update) {
965 if (need_economy_dialog_update) {
973 if ((production_changed || shield_stock_changed)
975 dsend_packet_unit_get_actions(
982 && (trade_routes_changed
995 struct tile_list *worked_tiles,
bool is_new,
996 bool popup,
bool investigate)
998 if (
nullptr != worked_tiles) {
1003 tile_list_destroy(worked_tiles);
1008 city_list_prepend(powner->
cities, pcity);
1018 if (punit->homecity == pcity->
id) {
1043 if (pcity->
client.collecting_info_units_supported !=
nullptr) {
1047 unit_list_destroy(pcity->
client.info_units_present);
1048 pcity->
client.info_units_present =
1049 pcity->
client.collecting_info_units_present;
1050 pcity->
client.collecting_info_units_present =
nullptr;
1052 unit_list_destroy(pcity->
client.info_units_supported);
1053 pcity->
client.info_units_supported =
1054 pcity->
client.collecting_info_units_supported;
1055 pcity->
client.collecting_info_units_supported =
nullptr;
1060 unit_list_clear(pcity->
client.info_units_supported);
1061 unit_list_clear(pcity->
client.info_units_present);
1100 bool city_changed =
false;
1102 if (pcity ==
nullptr) {
1106 proute = trade_route_list_get(pcity->
routes, packet->index);
1107 if (proute ==
nullptr) {
1111 trade_route_list_append(pcity->
routes, proute);
1112 city_changed =
true;
1115 proute->
partner = packet->partner;
1116 proute->
value = packet->value;
1117 proute->
dir = packet->direction;
1133 bool city_has_changed_owner =
false;
1134 bool city_is_new =
false;
1135 bool name_changed =
false;
1136 bool update_descriptions =
false;
1139 struct tile *ptile =
nullptr;
1140 struct tile_list *worked_tiles =
nullptr;
1142 int radius_sq =
game.
info.init_city_radius_sq;
1149 if (
nullptr != pcity) {
1152 if (
nullptr == ptile) {
1154 city_list_remove(
invisible.cities, pcity);
1157 pcity->
tile = pcenter;
1159 pcity->
owner = powner;
1164 if (wtile->worked == pcity) {
1177 pworked, _index, _x, _y)
1180 if (
nullptr == worked_tiles) {
1181 worked_tiles = tile_list_new();
1183 tile_list_append(worked_tiles, pworked);
1190 city_has_changed_owner =
true;
1194 if (
nullptr == pcity) {
1197 pcity->
id = packet->id;
1200 }
else if (pcity->
id != packet->id) {
1201 qCritical(
"handle_city_short_info() city id %d != id %d.", pcity->
id,
1204 }
else if (
city_tile(pcity) != pcenter) {
1205 qCritical(
"handle_city_short_info() city tile (%d, %d) != (%d, %d).",
1210 (0 != strncmp(packet->name, pcity->
name,
sizeof(pcity->
name)));
1214 update_descriptions =
true;
1219 memset(pcity->
feel, 0,
sizeof(pcity->
feel));
1223 pcity->
client.full =
false;
1230 if (pcity->
client.occupied != packet->occupied) {
1231 pcity->
client.occupied = packet->occupied;
1232 update_descriptions =
true;
1234 pcity->
client.walls = packet->walls;
1235 pcity->
style = packet->style;
1236 pcity->
capital = packet->capital;
1237 if (packet->capital == CAPITAL_PRIMARY) {
1242 pcity->
client.city_image = packet->city_image;
1244 pcity->
client.happy = packet->happy;
1245 pcity->
client.unhappy = packet->unhappy;
1263 if (city_is_new && !city_has_changed_owner) {
1270 if (update_descriptions) {
1283 if (pcity ==
nullptr
1291 if (
tile_index(ptask_old->ptile) == packet->tile_id) {
1298 if (ptask ==
nullptr) {
1299 if (packet->activity == ACTIVITY_LAST) {
1303 worker_task_list_append(pcity->
task_reqs, ptask);
1306 if (packet->activity == ACTIVITY_LAST) {
1307 worker_task_list_remove(pcity->
task_reqs, ptask);
1313 if (ptask !=
nullptr) {
1315 ptask->
act = packet->activity;
1316 if (packet->tgt >= 0) {
1319 ptask->
tgt =
nullptr;
1321 ptask->
want = packet->want;
1333 game.
info.fragment_count = fragments;
1352 turn_gold_difference =
1396 || (
game.
info.phase_mode == PMT_PLAYERS_ALTERNATE
1398 || (
game.
info.phase_mode == PMT_TEAMS_ALTERNATE
1400 qCritical(
"handle_start_phase() illegal phase %d.", phase);
1429 pcity->client.colored =
false;
1435 punit->client.colored =
false;
1502 packet->event, packet->turn, packet->phase, packet->conn_id);
1518 packet->event, packet->turn, packet->phase, packet->conn_id);
1535 int minor_version,
int patch_version,
1538 if (emerg_version > 0) {
1539 qDebug(
"Server has version %d.%d.%d.%d%s", major_version, minor_version,
1540 patch_version, emerg_version, version_label);
1542 qDebug(
"Server has version %d.%d.%d%s", major_version, minor_version,
1543 patch_version, version_label);
1554 ||
event != E_BROADCAST_REPORT) {
1611 punit->
client.transported_by = -1;
1636 bool need_menus_update =
false;
1637 bool need_economy_report_update =
false;
1638 bool need_units_report_update =
false;
1639 bool repaint_unit =
false;
1640 bool repaint_city =
false;
1641 struct tile *old_tile =
nullptr;
1642 bool check_focus =
false;
1673 repaint_unit =
true;
1684 repaint_unit =
true;
1689 || punit->
client.transported_by != packet_unit->
client.transported_by
1690 || punit->
client.occupied != packet_unit->
client.occupied
1701 && (packet_unit->
activity != ACTIVITY_IDLE
1706 repaint_unit =
true;
1712 && punit->
activity == ACTIVITY_SENTRY
1713 && packet_unit->
activity == ACTIVITY_IDLE
1718 check_focus =
false;
1724 if (punit->
client.transported_by
1725 != packet_unit->
client.transported_by) {
1726 if (packet_unit->
client.transported_by == -1) {
1732 punit->
client.transported_by = packet_unit->
client.transported_by;
1735 if (punit->
client.occupied != packet_unit->
client.occupied) {
1740 need_menus_update =
true;
1767 need_menus_update =
true;
1782 repaint_city =
true;
1786 need_units_report_update =
true;
1789 if (punit->
name != packet_unit->
name) {
1795 need_menus_update =
true;
1799 if (punit->
hp != packet_unit->
hp) {
1801 punit->
hp = packet_unit->
hp;
1802 repaint_unit =
true;
1810 repaint_unit =
true;
1811 repaint_city =
true;
1812 if (ccity !=
nullptr && (ccity->
id != punit->
homecity)) {
1817 need_menus_update =
true;
1819 need_units_report_update =
true;
1838 if (ccity !=
nullptr) {
1841 bool new_occupied = (unit_list_size(ccity->
tile->
units) > 0);
1843 if (ccity->
client.occupied != new_occupied) {
1844 ccity->
client.occupied = new_occupied;
1851 repaint_city =
true;
1860 if (!ccity->
client.occupied) {
1861 ccity->
client.occupied =
true;
1868 repaint_city =
true;
1875 if (repaint_city || repaint_unit) {
1888 need_economy_report_update =
1920 punit = packet_unit;
1923 unit_list_prepend(
unit_owner(punit)->units, punit);
1924 unit_list_prepend(
unit_tile(punit)->units, punit);
1932 log_debug(
"New %s %s id %d (%d %d) hc %d %s",
1942 if (punit->
client.occupied) {
1945 if (aunit->client.transported_by == punit->
id) {
1946 fc_assert(aunit->transporter ==
nullptr);
1955 pcity->
client.occupied =
true;
1964 need_units_report_update =
true;
1970 if (punit->
client.transported_by != -1) {
1971 struct unit *ptrans =
1981 #ifdef DEBUG_TRANSPORT
1982 log_debug(
"load %s (ID: %d) onto %s (ID: %d)",
1986 log_debug(
"%s (ID: %d) is loaded onto %s (ID: %d)",
2010 && !
queen()->city_overlay->isVisible()) {
2014 if (need_menus_update) {
2019 if (need_economy_report_update) {
2022 if (need_units_report_update) {
2044 static int last_serial_num = 0;
2048 qCritical(
"Investigate city: unknown city id %d!",
2049 packet->info_city_id);
2061 pcity->
client.collecting_info_units_supported =
2063 pcity->
client.collecting_info_units_present =
2071 unit_list_append(pcity->
client.collecting_info_units_supported, punit);
2075 unit_list_append(pcity->
client.collecting_info_units_present, punit);
2083 qCritical(
"handle_unit_short_info() for own unit.");
2088 punit->
client.transported_by = -1;
2105 const char *ts_to_load;
2109 if (ts_to_load !=
nullptr && ts_to_load[0] !=
'\0') {
2132 _(
"Map topology and tileset incompatible."));
2156 bool update_aifill_button =
false, update_ai_skill_level =
false;
2158 if (
game.
info.aifill != pinfo->aifill) {
2159 update_aifill_button =
true;
2161 if (
game.
info.skill_level != pinfo->skill_level) {
2162 update_ai_skill_level =
true;
2165 if (
game.
info.is_edit_mode != pinfo->is_edit_mode) {
2175 _(
"This scenario may have manually set properties the editor "
2178 _(
"They won't be saved when scenario is saved "
2179 "from the editor."));
2187 #define VALIDATE(_count, _maximum, _string) \
2188 if (game.info._count > _maximum) { \
2189 qCritical("handle_game_info(): Too many " _string "; using %d of %d", \
2190 _maximum, game.info._count); \
2191 game.info._count = _maximum; \
2203 &&
game.
info.victory_conditions != pinfo->victory_conditions);
2212 if (update_aifill_button || update_ai_skill_level) {
2235 float last_turn_change_time)
2245 game.
tinfo.last_turn_change_time = last_turn_change_time;
2256 dsend_packet_player_change_government(&
client.
conn,
2267 dsend_packet_player_change_government(
2301 pconn->playing =
nullptr;
2325 bool is_new_nation =
false;
2326 bool turn_done_changed =
false;
2327 bool new_player =
false;
2329 struct player *pplayer, *my_player;
2341 if ((pplayer->
rgb ==
nullptr) != !pinfo->color_valid
2342 || (pinfo->color_valid
2343 && (pplayer->
rgb->
r != pinfo->color_red
2344 || pplayer->
rgb->
g != pinfo->color_green
2345 || pplayer->
rgb->
b != pinfo->color_blue))) {
2348 if (pinfo->color_valid) {
2349 prgbcolor =
rgbcolor_new(pinfo->color_red, pinfo->color_green,
2353 prgbcolor =
nullptr;
2364 pplayer->
client.color_changeable = pinfo->color_changeable;
2378 pplayer->
client.visible = pinfo->visible;
2395 pplayer->
is_male = pinfo->is_male;
2403 pplayer->
client.tech_upkeep = pinfo->tech_upkeep;
2411 for (i = 0; i <
ARRAY_SIZE(pinfo->real_embassy); i++) {
2412 if (pinfo->real_embassy[i]) {
2420 bool music_change =
false;
2424 music_change =
true;
2426 if (pplayer->
client.mood != pinfo->mood) {
2427 pplayer->
client.mood = pinfo->mood;
2428 music_change =
true;
2436 pplayer->
history = pinfo->history;
2437 pplayer->
client.culture = pinfo->culture;
2442 for (i = 0; i <
ARRAY_SIZE(pinfo->love); i++) {
2450 for (i = 0; i <
B_LAST; i++) {
2451 pplayer->
wonders[i] = pinfo->wonders[i];
2457 if (pplayer == my_player) {
2458 if (
is_ai(my_player)) {
2470 pplayer->
flags = pinfo->flags;
2474 turn_done_changed = (pplayer->
phase_done != pinfo->phase_done
2476 !=
BV_ISSET(pinfo->flags, PLRF_AI)));
2479 pplayer->
is_ready = pinfo->is_ready;
2481 pplayer->
is_alive = pinfo->is_alive;
2486 static_cast<ai_level
>(pinfo->ai_skill_level);
2489 game.
control.num_multipliers = pinfo->multip_count;
2505 if (pplayer == pconn->playing) {
2507 if (pconn->observer) {
2520 if (turn_done_changed) {
2537 if (is_new_nation) {
2562 bool tech_changed =
false;
2563 bool poptechup =
false;
2564 std::vector<Tech_type_id> gained_techs;
2566 int gained_techs_num = 0, i;
2567 enum tech_state newstate, oldstate;
2569 #ifdef FREECIV_DEBUG
2570 qDebug(
"Research nb %d inventions: %s", packet->id, packet->inventions);
2575 poptechup = (presearch->
researching != packet->researching
2576 || presearch->
tech_goal != packet->tech_goal);
2578 if (presearch->
future_tech == 0 && packet->future_tech > 0) {
2579 gained_techs[gained_techs_num++] =
A_FUTURE;
2583 presearch->
client.researching_cost = packet->researching_cost;
2585 presearch->
tech_goal = packet->tech_goal;
2586 presearch->
client.total_bulbs_prod = packet->total_bulbs_prod;
2590 newstate =
static_cast<tech_state
>(packet->inventions[advi] -
'0');
2593 if (newstate != oldstate) {
2594 if (TECH_KNOWN == newstate) {
2595 tech_changed =
true;
2597 gained_techs[gained_techs_num++] = advi;
2599 }
else if (TECH_KNOWN == oldstate) {
2600 tech_changed =
true;
2628 for (i = 0; i < gained_techs_num; i++) {
2653 bool need_players_dialog_update =
false;
2658 if (ds->
type != packet->type) {
2659 need_players_dialog_update =
true;
2666 && DS_ARMISTICE == packet->type) {
2673 if (punit->client.focus_status ==
FOCUS_WAIT) {
2676 if (punit->activity != ACTIVITY_IDLE) {
2684 ds->
type = packet->type;
2689 if (need_players_dialog_update) {
2693 if (need_players_dialog_update
2698 struct tile *tgt_tile =
nullptr;
2702 struct unit *tgt_unit;
2706 if (tgt_unit !=
nullptr && tgt_unit->
owner == plr1) {
2715 struct city *tgt_city;
2719 if (tgt_city !=
nullptr && tgt_city->
owner == plr1) {
2734 dsend_packet_unit_get_actions(
2751 bool preparing_client_state =
false;
2753 log_debug(
"conn_info id%d used%d est%d plr%d obs%d acc%d", pinfo->id,
2754 pinfo->used, pinfo->established, pinfo->player_num,
2755 pinfo->observer, (
int) pinfo->access_level);
2756 log_debug(
"conn_info \"%s\" \"%s\" \"%s\"", pinfo->username, pinfo->addr,
2762 qDebug(
"Server removed unknown connection %d", pinfo->id);
2769 struct player *pplayer =
nullptr;
2771 if (
nullptr != pslot) {
2776 qDebug(
"Server reports new connection %d %s", pinfo->id,
2789 log_packet(
"Server reports updated connection %d %s", pinfo->id,
2791 if (pplayer != pconn->
playing) {
2792 if (
nullptr != pconn->
playing) {
2801 pconn->
id = pinfo->id;
2808 pconn->
addr = pinfo->addr;
2823 preparing_client_state =
true;
2845 if (preparing_client_state) {
2856 const float *ping_time)
2870 if (id < 0 || id >=
game.
control.num_achievement_types) {
2871 qCritical(
"Received illegal achievement info %d",
id);
2935 ship->
fuel = p->fuel;
2942 ship->
mass = p->mass;
2971 bool known_changed =
false;
2972 bool tile_changed =
false;
2988 tile_changed =
true;
2989 switch (old_known) {
2995 if (
nullptr != pterrain ||
TILE_UNKNOWN == packet->known) {
2998 tile_changed =
false;
2999 qCritical(
"handle_tile_info() unknown terrain (%d, %d).",
3007 ptile->
extras = packet->extras;
3008 tile_changed =
true;
3011 tile_changed = tile_changed || (
tile_resource(ptile) != presource);
3018 tile_changed =
true;
3022 tile_changed =
true;
3025 if (packet->placing < 0) {
3026 if (ptile->
placing !=
nullptr) {
3027 tile_changed =
true;
3037 tile_changed =
true;
3047 if (
nullptr == pwork) {
3051 fc_snprintf(named,
sizeof(named),
"%06u", packet->worked);
3054 pwork->
id = packet->worked;
3057 city_list_prepend(
invisible.cities, pwork);
3061 }
else if (
nullptr ==
city_tile(pwork)) {
3063 if (
nullptr != powner &&
city_owner(pwork) != powner) {
3065 pwork->
owner = powner;
3085 if (oldwork &&
nullptr !=
city_tile(oldwork)) {
3108 tile_changed =
true;
3111 if (old_known != packet->known) {
3112 known_changed =
true;
3124 switch (packet->known) {
3140 qCritical(
"handle_tile_info() invalid known (%d).", packet->known);
3146 if (packet->spec_sprite[0] !=
'\0') {
3148 || strcmp(ptile->
spec_sprite, packet->spec_sprite) != 0) {
3151 tile_changed =
true;
3157 tile_changed =
true;
3166 qCritical(
"%p %d %s at (%d,%d) %s", punit, punit->id,
3173 unit_list_clear(ptile->
units);
3179 if (packet->label[0] ==
'\0') {
3180 if (ptile->
label !=
nullptr) {
3181 delete[] ptile->
label;
3182 ptile->
label =
nullptr;
3183 tile_changed =
true;
3185 }
else if (ptile->
label ==
nullptr
3186 || strcmp(packet->label, ptile->
label)) {
3188 tile_changed =
true;
3191 if (known_changed || tile_changed) {
3198 if (tile_changed || old_known != new_known) {
3225 game.
scenario.startpos_nations = packet->startpos_nations;
3226 game.
scenario.prevent_new_cities = packet->prevent_new_cities;
3232 game.
scenario.allow_ai_type_fallback = packet->allow_ai_type_fallback;
3266 #define VALIDATE(_count, _maximum, _string) \
3267 if (game.control._count > _maximum) { \
3268 qCritical("handle_ruleset_control(): Too many " _string \
3269 "; using %d of %d", \
3270 _maximum, game.control._count); \
3271 game.control._count = _maximum; \
3304 if (packet->preferred_tileset[0] !=
'\0') {
3316 if (packet->preferred_soundset[0] !=
'\0') {
3328 if (packet->preferred_musicset[0] !=
'\0') {
3351 len = qstrlen(packet->text);
3361 const struct packet_ruleset_description_part *packet)
3379 pextra->hiders = extra_type_list_new();
3383 extra_type_list_append(pextra->hiders, phider);
3387 pextra->bridged = extra_type_list_new();
3391 extra_type_list_append(pextra->bridged, pbridged);
3449 c->
flags = p->flags;
3479 for (i = 0; i < p->build_reqs_count; i++) {
3480 requirement_vector_append(&u->
build_reqs, p->build_reqs[i]);
3490 u->
flags = p->flags;
3491 u->
roles = p->roles;
3499 u->
cargo = p->cargo;
3505 if (p->veteran_levels == 0) {
3510 for (i = 0; i < p->veteran_levels; i++) {
3512 p->power_fact[i], p->move_bonus[i],
3513 p->base_raise_chance[i],
3514 p->work_raise_chance[i]);
3537 bonus->
flag = p->flag;
3538 bonus->
type = p->type;
3539 bonus->
value = p->value;
3540 bonus->
quiet = p->quiet;
3542 combat_bonus_list_append(u->
bonuses, bonus);
3550 const char *flagname;
3551 const char *helptxt;
3555 "Bad user flag %d.", p->id);
3557 if (p->name[0] ==
'\0') {
3563 if (p->helptxt[0] ==
'\0') {
3566 helptxt = p->helptxt;
3577 const struct packet_ruleset_unit_class_flag *p)
3579 const char *flagname;
3580 const char *helptxt;
3583 "Bad user flag %d.", p->id);
3585 if (p->name[0] ==
'\0') {
3591 if (p->helptxt[0] ==
'\0') {
3594 helptxt = p->helptxt;
3613 if (i < reqs_size &&
reqs[i].source.kind == VUT_ADVANCE) {
3651 if (p->tclass >= 0) {
3676 for (; i < p->research_reqs_count; i++) {
3677 requirement_vector_append(&a->
research_reqs, p->research_reqs[i]);
3691 == p->research_reqs_count);
3695 a->
flags = p->flags;
3721 const char *flagname;
3722 const char *helptxt;
3725 "Bad user flag %d.", p->id);
3727 if (p->name[0] ==
'\0') {
3733 if (p->helptxt[0] ==
'\0') {
3736 helptxt = p->helptxt;
3753 b->
genus = p->genus;
3757 for (i = 0; i < p->reqs_count; i++) {
3758 requirement_vector_append(&b->
reqs, p->reqs[i]);
3761 for (i = 0; i < p->obs_count; i++) {
3762 requirement_vector_append(&b->
obsolete_by, p->obs_reqs[i]);
3768 b->
flags = p->flags;
3774 #ifdef FREECIV_DEBUG
3779 log_debug(
" build_cost %3d", bdbg->build_cost);
3781 log_debug(
" sabotage %3d", bdbg->sabotage);
3782 if (
nullptr != bdbg->helptext) {
3783 for (
auto text : *bdbg->helptext) {
3784 log_debug(
" helptext %s", qUtf8Printable(text));
3805 pmul->
start = p->start;
3806 pmul->
stop = p->stop;
3807 pmul->
step = p->step;
3809 pmul->
offset = p->offset;
3810 pmul->
factor = p->factor;
3814 for (j = 0; j < p->reqs_count; j++) {
3815 requirement_vector_append(&pmul->
reqs, p->reqs[j]);
3834 for (j = 0; j < p->reqs_count; j++) {
3835 requirement_vector_append(&gov->
reqs, p->reqs[j]);
3852 const struct packet_ruleset_government_ruler_title *packet)
3860 packet->female_title);
3873 pterrain->
tclass =
static_cast<terrain_class
>(p->tclass);
3886 for (j = 0; j < p->num_resources; j++) {
3889 qCritical(
"handle_ruleset_terrain() "
3890 "Mismatched resource %d for terrain \"%s\".",
3894 pterrain->
resources[p->num_resources] =
nullptr;
3912 if (p->animal < 0) {
3913 pterrain->
animal =
nullptr;
3924 pterrain->
flags = p->flags;
3927 pterrain->
rgb =
rgbcolor_new(p->color_red, p->color_green, p->color_blue);
3939 const char *flagname;
3940 const char *helptxt;
3943 "Bad user flag %d.", p->id);
3945 if (p->name[0] ==
'\0') {
3951 if (p->helptxt[0] ==
'\0') {
3954 helptxt = p->helptxt;
3969 qCritical(
"Bad resource %d.", p->id);
3994 pextra->
category =
static_cast<extra_category
>(p->category);
3997 for (i = 0; i < EC_COUNT; i++) {
3999 pextra->
causes |= (1 << i);
4004 for (i = 0; i < ERM_COUNT; i++) {
4010 if (pextra->
causes == 0) {
4013 for (i = 0; i < EC_COUNT; i++) {
4035 if (!cbase && !croad && !cres) {
4041 for (i = 0; i < ERM_COUNT; i++) {
4055 for (i = 0; i < p->reqs_count; i++) {
4056 requirement_vector_append(&pextra->
reqs, p->reqs[i]);
4060 for (i = 0; i < p->rmreqs_count; i++) {
4061 requirement_vector_append(&pextra->
rmreqs, p->rmreqs[i]);
4066 for (i = 0; i < p->appearance_reqs_count; i++) {
4068 p->appearance_reqs[i]);
4073 for (i = 0; i < p->disappearance_reqs_count; i++) {
4075 p->disappearance_reqs[i]);
4098 pextra->
eus = p->eus;
4099 if (pextra->
eus == EUS_HIDDEN) {
4105 pextra->
flags = p->flags;
4118 const char *flagname;
4119 const char *helptxt;
4122 "Bad user flag %d.", p->id);
4124 if (p->name[0] ==
'\0') {
4130 if (p->helptxt[0] ==
'\0') {
4133 helptxt = p->helptxt;
4155 pbase->
flags = p->flags;
4168 for (i = 0; i < p->first_reqs_count; i++) {
4169 requirement_vector_append(&proad->
first_reqs, p->first_reqs[i]);
4184 proad->
compat = p->compat;
4186 proad->
flags = p->flags;
4201 for (i = 0; i < p->reqs_count; i++) {
4202 requirement_vector_append(&pgood->
reqs, p->reqs[i]);
4207 pgood->
to_pct = p->to_pct;
4209 pgood->
flags = p->flags;
4223 qCritical(
"handle_ruleset_action() the action id %d is out of range.",
4232 act->
quiet = p->quiet;
4250 const struct packet_ruleset_action_enabler *p)
4257 qCritical(
"handle_ruleset_action_enabler() the action %d "
4266 enabler->
action = p->enabled_action;
4268 for (i = 0; i < p->actor_reqs_count; i++) {
4269 requirement_vector_append(&enabler->
actor_reqs, p->actor_reqs[i]);
4273 for (i = 0; i < p->target_reqs_count; i++) {
4274 requirement_vector_append(&enabler->
target_reqs, p->target_reqs[i]);
4291 auto_perf->
cause = p->cause;
4293 for (i = 0; i < p->reqs_count; i++) {
4294 requirement_vector_append(&auto_perf->
reqs, p->reqs[i]);
4298 for (i = 0; i < p->alternatives_count; i++) {
4315 for (i = 0; i < p->reqs_count; i++) {
4316 requirement_vector_append(&pdis->
reqs, p->reqs[i]);
4336 pach->
type = p->type;
4337 pach->
unique = p->unique;
4338 pach->
value = p->value;
4349 if (pset !=
nullptr) {
4360 const struct packet_ruleset_terrain_control *p)
4373 const struct packet_ruleset_nation_sets *packet)
4377 for (i = 0; i < packet->nsets; i++) {
4381 packet->descriptions[i]);
4391 const struct packet_ruleset_nation_groups *packet)
4395 for (i = 0; i < packet->ngroups; i++) {
4401 pgroup->
hidden = packet->hidden[i];
4415 if (packet->translation_domain[0] !=
'\0') {
4416 size_t len = qstrlen(packet->translation_domain) + 1;
4423 packet->adjective, packet->rule_name);
4425 packet->noun_plural);
4429 for (i = 0; i < packet->leader_count; i++) {
4431 packet->leader_is_male[i]);
4435 pnation->
client.is_pickable =
false;
4437 pnation->
barb_type = packet->barbarian_type;
4439 if (
'\0' != packet->legend[0]) {
4446 for (i = 0; i < packet->nsets; i++) {
4449 if (
nullptr != pset) {
4450 nation_set_list_append(pnation->
sets, pset);
4452 qCritical(
"handle_ruleset_nation() \"%s\" have unknown set %d.",
4457 for (i = 0; i < packet->ngroups; i++) {
4460 if (
nullptr != pgroup) {
4461 nation_group_list_append(pnation->
groups, pgroup);
4463 qCritical(
"handle_ruleset_nation() \"%s\" have unknown group %d.",
4472 if (i < packet->init_techs_count) {
4473 pnation->
init_techs[i] = packet->init_techs[i];
4479 if (i < packet->init_units_count) {
4487 if (i < packet->init_buildings_count) {
4502 bool nationset_change)
4509 for (i = 0; i < ncount; i++) {
4540 for (i = 0; i < p->giver_reqs_count; i++) {
4541 requirement_vector_append(&info->
giver_reqs, p->giver_reqs[i]);
4545 for (i = 0; i < p->receiver_reqs_count; i++) {
4546 requirement_vector_append(&info->
receiver_reqs, p->receiver_reqs[i]);
4559 id = packet->style_id;
4561 "Bad citystyle %d.",
id);
4564 for (j = 0; j < packet->reqs_count; j++) {
4565 requirement_vector_append(&cs->
reqs, packet->reqs[j]);
4569 names_set(&cs->
name,
nullptr, packet->name, packet->rule_name);
4588 "Bad music_style %d.",
id);
4592 for (j = 0; j < packet->reqs_count; j++) {
4593 requirement_vector_append(&pmus->
reqs, packet->reqs[j]);
4617 if (i < packet->global_init_techs_count) {
4624 if (i < packet->global_init_buildings_count) {
4631 for (i = 0; i < packet->veteran_levels; i++) {
4633 packet->power_fact[i], packet->move_bonus[i],
4634 packet->base_raise_chance[i],
4635 packet->work_raise_chance[i]);
4640 rgbcolor_new(packet->background_red, packet->background_green,
4641 packet->background_blue);
4660 for (j = 0; j < p->reqs_count; j++) {
4661 requirement_vector_append(&s->
reqs, p->reqs[j]);
4683 bool other_asking =
false;
4687 if (other->client.asking_city_name) {
4688 other_asking =
true;
4692 punit->
client.asking_city_name =
true;
4694 if (!other_asking) {
4711 action_id action_type,
bool disturb_player)
4720 qCritical(
"handle_unit_action_answer() the action %d doesn't exist.",
4723 if (disturb_player) {
4735 if (disturb_player) {
4743 switch (
static_cast<enum gen_action
>(action_type)) {
4744 case ACTION_SPY_BRIBE_UNIT:
4746 if (disturb_player) {
4753 qCritical(
"Unimplemented: received background unit bribe cost.");
4757 if (disturb_player) {
4764 case ACTION_SPY_INCITE_CITY:
4765 case ACTION_SPY_INCITE_CITY_ESC:
4767 if (disturb_player) {
4774 qCritical(
"Unimplemented: received background city incite cost.");
4778 if (disturb_player) {
4785 case ACTION_UPGRADE_UNIT:
4794 qCritical(
"Received upgrade unit price but can't forward it.");
4798 log_debug(
"Server didn't respond to query.");
4799 if (disturb_player) {
4806 qCritical(
"handle_unit_action_answer() invalid action_type (%d).",
4808 if (disturb_player) {
4828 switch (
static_cast<enum gen_action
>(act)) {
4829 case ACTION_DISBAND_UNIT:
4830 case ACTION_FORTIFY:
4831 case ACTION_CONVERT:
4832 case ACTION_TRANSPORT_ALIGHT:
4833 case ACTION_TRANSPORT_BOARD:
4834 case ACTION_TRANSPORT_EMBARK:
4835 case ACTION_TRANSPORT_UNLOAD:
4836 case ACTION_TRANSPORT_DISEMBARK1:
4837 case ACTION_TRANSPORT_DISEMBARK2:
4840 case ACTION_USER_ACTION1:
4841 case ACTION_USER_ACTION2:
4842 case ACTION_USER_ACTION3:
4845 case ACTION_CAPTURE_UNITS:
4846 case ACTION_BOMBARD:
4847 case ACTION_BOMBARD2:
4848 case ACTION_BOMBARD3:
4850 case ACTION_NUKE_CITY:
4851 case ACTION_NUKE_UNITS:
4853 case ACTION_SUICIDE_ATTACK:
4854 case ACTION_CONQUER_CITY:
4855 case ACTION_CONQUER_CITY2:
4856 case ACTION_STRIKE_PRODUCTION:
4860 attack_action = act;
4866 case ACTION_ESTABLISH_EMBASSY:
4867 case ACTION_ESTABLISH_EMBASSY_STAY:
4868 case ACTION_SPY_INVESTIGATE_CITY:
4869 case ACTION_INV_CITY_SPEND:
4870 case ACTION_SPY_POISON:
4871 case ACTION_SPY_POISON_ESC:
4872 case ACTION_SPY_STEAL_GOLD:
4873 case ACTION_SPY_STEAL_GOLD_ESC:
4874 case ACTION_SPY_SPREAD_PLAGUE:
4875 case ACTION_SPY_SABOTAGE_CITY:
4876 case ACTION_SPY_SABOTAGE_CITY_ESC:
4877 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
4878 case ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC:
4879 case ACTION_SPY_SABOTAGE_CITY_PRODUCTION:
4880 case ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC:
4881 case ACTION_SPY_STEAL_TECH:
4882 case ACTION_SPY_STEAL_TECH_ESC:
4883 case ACTION_SPY_TARGETED_STEAL_TECH:
4884 case ACTION_SPY_TARGETED_STEAL_TECH_ESC:
4885 case ACTION_SPY_INCITE_CITY:
4886 case ACTION_SPY_INCITE_CITY_ESC:
4887 case ACTION_TRADE_ROUTE:
4888 case ACTION_MARKETPLACE:
4889 case ACTION_HELP_WONDER:
4890 case ACTION_SPY_BRIBE_UNIT:
4891 case ACTION_SPY_SABOTAGE_UNIT:
4892 case ACTION_SPY_SABOTAGE_UNIT_ESC:
4893 case ACTION_SPY_ATTACK:
4894 case ACTION_FOUND_CITY:
4895 case ACTION_JOIN_CITY:
4896 case ACTION_STEAL_MAPS:
4897 case ACTION_STEAL_MAPS_ESC:
4898 case ACTION_SPY_NUKE:
4899 case ACTION_SPY_NUKE_ESC:
4900 case ACTION_DESTROY_CITY:
4901 case ACTION_EXPEL_UNIT:
4902 case ACTION_RECYCLE_UNIT:
4903 case ACTION_HOME_CITY:
4904 case ACTION_UPGRADE_UNIT:
4905 case ACTION_PARADROP:
4906 case ACTION_AIRLIFT:
4907 case ACTION_HEAL_UNIT:
4908 case ACTION_TRANSFORM_TERRAIN:
4909 case ACTION_CULTIVATE:
4911 case ACTION_PILLAGE:
4912 case ACTION_CLEAN_POLLUTION:
4913 case ACTION_CLEAN_FALLOUT:
4917 case ACTION_IRRIGATE:
4921 case ACTION_STRIKE_BUILDING:
4933 return attack_action;
4946 struct tile *target_tile =
4955 const struct act_prob *act_probs = packet->action_probabilities;
4957 bool disturb_player = packet->disturb_player;
4961 if (actor_unit && (target_tile || target_city || target_unit)) {
4973 if (valid && disturb_player) {
4999 packet->target_tile_id, 0,
"");
5003 packet->target_city_id, 0,
"");
5007 packet->target_unit_id, 0,
"");
5011 packet->actor_unit_id, 0,
"");
5025 target_tile, target_extra, act_probs);
5027 }
else if (disturb_player) {
5038 target_tile, target_extra, act_probs);
5047 bv_imprs improvements,
action_id act_id,
5048 bool disturb_player)
5055 log_debug(
"Bad diplomat %d.", actor_id);
5057 if (disturb_player) {
5068 if (disturb_player) {
5086 if (disturb_player) {
5093 qCritical(
"Unimplemented: received background city building list.");
5097 if (disturb_player) {
5121 if (packet->winner) {
5134 const struct packet_player_attribute_chunk *packet)
5142 if (packet->offset + packet->chunk_length == packet->total_length) {
5169 log_debug(
"finish processing packet %d",
5191 log_debug(
"incoming packet={type=%d, size=%d}", packet_type,
size);
5198 int size,
int request_id)
5201 log_debug(
"outgoing packet={type=%d, size=%d, request_id=%d}", packet_type,
5263 bool changed =
false;
5266 if (
nullptr == ptile) {
5267 qCritical(
"%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5272 if (packet->removal) {
5286 if (packet->removal) {
5298 const struct packet_edit_startpos_full *packet)
5304 if (
nullptr == ptile) {
5305 qCritical(
"%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5310 if (
nullptr == psp) {
5311 qCritical(
"%s(): no start position at (%d, %d)", __FUNCTION__,
5344 "Got packet_vote_update for non-existant vote %d!",
5361 "Got a packet_vote_new for already existing "
5366 packet->percent_required, packet->flags);
5379 "Got packet_vote_resolve for non-existant vote %d!",
struct achievement * achievement_by_number(int id)
Return achievements of given id.
bool action_prob_possible(const struct act_prob probability)
Returns TRUE iff the given action probability belongs to an action that may be possible.
struct action_enabler * action_enabler_new()
Create a new action enabler.
void action_enabler_add(struct action_enabler *enabler)
Add an action enabler to the current ruleset.
struct action * action_by_number(action_id act_id)
Return the action with the given id.
bool action_id_exists(const action_id act_id)
Returns TRUE iff the specified action ID refers to a valid action.
void actions_rs_pre_san_gen()
Generate action related data based on the currently loaded ruleset.
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Returns action auto performer rule slot number num so it can be filled.
#define action_id_requires_details(act_id)
#define action_iterate_end
#define action_iterate(_act_)
#define action_id_get_target_kind(act_id)
void attribute_restore()
Recreate the attribute set from the player's attribute_block.
void audio_play_sound(const QString &tag, const QString &alt_tag)
Play an audio sample as suggested by sound tags.
void audio_restart(const QString &soundset_name, const QString &musicset_name)
Switch soundset.
void base_type_init(struct extra_type *pextra, int idx)
Initialize base_type structures.
struct base_type * base_by_number(const Base_type_id id)
Returns base_type entry for an ID value.
#define BV_SET_VAL(bv, bit, val)
bool BV_ISSET(const BV &bv, int bit)
#define BV_ARE_EQUAL(vec1, vec2)
bool has_capability(const char *cap, const char *capstr)
Wrapper for fc_has_capability() for nullptr terminated strings.
const char *const our_capability
void output_window_append(const struct ft_color color, const char *featured_text)
Add a line of text to the output ("chatline") window, like puts() would do it in the console.
void output_window_printf(const struct ft_color color, const char *format,...)
Add a line of text to the output ("chatline") window.
void citizens_nation_set(struct city *pcity, const struct player_slot *pslot, citizens count)
Set the number of citizens with the given nationality.
citizens citizens_count(const struct city *pcity)
Return the number of citizens in a city.
void citizens_init(struct city *pcity)
Initialise citizens data.
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
Returns the current squared radius of the city.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct citystyle * city_styles
void city_styles_alloc(int num)
Allocate memory for this amount of city styles.
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Removes an improvement (and its effects) from a city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
void city_size_add(struct city *pcity, int add)
Add a (positive or negative) value to the city size.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
bool city_unhappy(const struct city *pcity)
Return TRUE iff the city is unhappy.
bool city_happy(const struct city *pcity)
Return TRUE iff the city is happy.
void city_size_set(struct city *pcity, citizens size)
Set the city size.
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Adds an improvement (and its effects) to a city.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
void destroy_city_virtual(struct city *pcity)
Removes the virtual skeleton of a city.
void free_city_map_index()
Free memory allocated by generate_citymap_index.
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Create virtual skeleton for a city.
citizens city_size_get(const struct city *pcity)
Get the city size.
void city_production_caravan_shields_init()
Initialize the cache of what city production can use shields from caravans.
#define city_list_iterate(citylist, pcity)
#define output_type_iterate(output)
#define city_list_iterate_end
#define city_tile_iterate_skip_center_end
#define city_tile_iterate_skip_center(_radius_sq, _city_tile, _tile, _index, _x, _y)
#define output_type_iterate_end
bool city_dialog_is_open(struct city *pcity)
Return whether the dialog for the given city is open.
void refresh_unit_city_dialogs(struct unit *punit)
Update city dialogs when the given unit's status changes.
void popdown_city_dialog()
Closes the city overlay.
void generate_citydlg_dimensions()
Calculate the citydlg width and height.
void popup_city_dialog(struct city *pcity)
void refresh_city_dialog(struct city *pcity)
void city_report_dialog_update_city(struct city *pcity)
void city_report_dialog_update()
void add_city_remove(struct city *pcity)
void add_city_changed(struct city *pcity)
void add_city_new(struct city *pcity)
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
static update_queue * uq()
void processing_finished(int request_id)
enum client_states client_state()
Return current client state.
void start_turn_change_wait()
Start waiting of the server turn change activities.
void client_remove_cli_conn(struct connection *pconn)
Remove pconn from all connection lists in client, then free it.
bool client_has_player()
Either controlling or observing.
void set_miliseconds_to_turndone(int miliseconds)
Reset the number of seconds to turndone from an "authentic" source.
bool client_is_global_observer()
Returns whether client is global observer.
void set_server_busy(bool busy)
Sets if server is considered busy.
struct player * client_player()
Either controlling or observing.
bool can_client_issue_orders()
Returns TRUE iff the client can issue orders (such as giving unit commands).
void user_ended_turn()
Handle user ending his/her turn.
bool client_is_observer()
Returns whether client is observer.
bool can_client_change_view()
Return TRUE if the client can change the view; i.e.
void stop_turn_change_wait()
Server is responsive again.
void set_client_state(enum client_states newstate)
Change client state.
enum known_type client_tile_get_known(const struct tile *ptile)
A tile's "known" field is used by the server to store whether each player knows the tile.
void client_player_maps_reset()
Reset the private maps of all players.
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Creates a struct packet_generic_message packet and injects it via handle_chat_msg.
void client_player_init(struct player *pplayer)
Initialize a player on the client side.
void client_remove_city(struct city *pcity)
Remove city, client end version.
void flush_dirty_overview()
This module contains various general - mostly highlevel - functions used throughout the client.
struct nation_set * client_current_nation_set()
Returns the nation set in use.
void client_remove_unit(struct unit *punit)
Remove unit, client end version.
void unit_focus_set_status(struct player *pplayer)
Set focus status of all player units to FOCUS_AVAIL.
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Handles a chat or event message.
void send_client_wants_hack(const char *filename)
If the client is capable of 'wanting hack', then the server will send the client a filename in the pa...
bool is_server_running()
The general chain of events:
int get_next_request_id(int old_request_id)
Get next request id.
void conn_set_capability(struct connection *pconn, const char *capability)
Set the network capability string for 'pconn'.
struct connection * conn_by_number(int id)
Find connection by id, from game.all_connections.
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
void do_move_unit(struct unit *punit, struct unit *target_unit)
Called to have the client move a unit from one location to another, updating the graphics if necessar...
bool unit_is_in_focus(const struct unit *punit)
Return TRUE iff this unit is in focus.
std::vector< unit * > & get_units_in_focus()
Returns list of units currently in focus.
void action_selection_no_longer_in_progress(const int old_actor_id)
The action selection process is no longer in progres for the specified unit.
void action_decision_request(struct unit *actor_unit)
Request that the player makes a decision for the specified unit.
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Adjusts way combatants are displayed suitable for combat.
void unit_focus_update()
If there is no unit currently in focus, or if the current unit in focus should not be in focus,...
void unit_focus_set(struct unit *punit)
Sets the focus unit directly.
bool should_ask_server_for_actions(const struct unit *punit)
Returns TRUE iff the client should ask the server about what actions a unit can perform.
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Request an actor unit to do a specific action.
void unit_focus_urgent(struct unit *punit)
Store a priority focus unit.
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Change the battlegroup for this unit.
int get_num_units_in_focus()
Return the number of units currently in focus (0 or more).
void action_decision_clear_want(const int old_actor_id)
Have the server record that a decision no longer is wanted for the specified unit.
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Return TRUE iff a unit on this tile is in focus.
void clear_hover_state()
Clear current hover state (go to HOVER_NONE).
void unit_register_battlegroup(struct unit *punit)
Call this on new units to enter them in the battlegroup lists.
void auto_center_on_focus_unit()
Center on the focus unit, if off-screen and auto_center_on_unit is true.
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Send request for unit activity changing to server.
void action_selection_next_in_focus(const int old_actor_id)
Move on to the next unit in focus that needs an action decision.
int action_selection_target_extra(void)
Returns id of the target extra of the actions currently handled in action selection dialog when the a...
int action_selection_target_tile(void)
Returns id of the target tile of the actions currently handled in action selection dialog when the ac...
int action_selection_actor_unit(void)
Returns the id of the actor unit currently handled in action selection dialog when the action selecti...
bool handmade_scenario_warning()
Give a warning when user is about to edit scenario with manually set properties.
void popup_musicset_suggestion_dialog(void)
Ruleset (modpack) has suggested loading certain musicset.
void action_selection_close(void)
Closes the action selection dialog.
void races_update_pickable(bool nationset_change)
The server has changed the set of selectable nations.
int action_selection_target_city(void)
Returns id of the target city of the actions currently handled in action selection dialog when the ac...
void show_tech_gained_dialog(Tech_type_id tech)
Player has gained a new tech.
void popup_soundset_suggestion_dialog(void)
Ruleset (modpack) has suggested loading certain soundset.
void popdown_races_dialog(void)
Close the nation selection dialog.
void popup_tileset_suggestion_dialog(void)
Ruleset (modpack) has suggested loading certain tileset.
void popup_sabotage_dialog(struct unit *actor, struct city *tcity, const struct action *paction)
Popup a dialog asking a diplomatic unit if it wishes to sabotage the given enemy city.
void popup_bribe_dialog(struct unit *actor, struct unit *tunit, int cost, const struct action *paction)
Popup a dialog asking a diplomatic unit if it wishes to bribe the given enemy unit.
void popup_notify_dialog(const char *caption, const char *headline, const char *lines)
Popup a generic dialog to display some generic information.
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
Updates the action selection dialog with new information.
void popup_incite_dialog(struct unit *actor, struct city *tcity, int cost, const struct action *paction)
Popup a window asking a diplomatic unit if it wishes to incite the given enemy city.
void popup_connect_msg(const char *headline, const char *message)
Popup a dialog to display connection message from server.
void races_toggles_set_sensitive(void)
In the nation selection dialog, make already-taken nations unavailable.
void popup_action_selection(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
Popup a dialog that allows the player to select what action a unit should take.
void popup_combat_info(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran)
Popup detailed information about battle or save information for some kind of statistics.
int action_selection_target_unit(void)
Returns id of the target unit of the actions currently handled in action selection dialog when the ac...
void unit_select_dialog_update()
struct clause_info * clause_info_get(enum clause_type type)
Free memory associated with clause infos.
struct disaster_type * disaster_by_number(Disaster_type_id id)
Return disaster type of given id.
void editor_ruleset_changed()
Adjust editor for changed ruleset.
bool editor_is_active()
Returns TRUE if the client is in edit mode.
void recv_ruleset_effect(const struct packet_ruleset_effect *packet)
Receives a new effect.
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Show a dialog with player statistics at endgame.
void endgame_report_dialog_player(const struct packet_endgame_player *packet)
Received endgame report information about single player.
const char * get_event_tag(enum event_type event)
Returns a string for the sound to be used for this message type.
void update_start_page(void)
Update the start page.
#define MAX_DISASTER_TYPES
#define MAX_NUM_BUILDING_LIST
#define EC_NATURAL_DEFENSIVE
#define MAX_NUM_UNIT_LIST
#define MAX_ACHIEVEMENT_TYPES
#define MAX_NUM_TECH_LIST
#define IDENTITY_NUMBER_ZERO
const struct ft_color ftc_client
void game_ruleset_init()
Initialize the objects which will read from a ruleset.
void game_ruleset_free()
Frees all memory which in objects which are read from a ruleset.
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.
int current_turn_timeout()
Return timeout value for the current turn.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
void init_client_goto()
Called only by handle_map_info() in client/packhand.c.
struct government * government_of_player(const struct player *pplayer)
Return the government of a player.
struct government * government_by_number(const Government_type_id gov)
Return the government with the given index.
void governments_alloc(int num)
Allocate the governments.
struct ruler_title * government_ruler_title_new(struct government *pgovern, const struct nation_type *pnation, const char *ruler_male_title, const char *ruler_female_title)
Add a new ruler title for the nation.
Government_type_id government_number(const struct government *pgovern)
Return the government index.
void editgui_notify_object_created(int tag, int id)
Stub for editor function.
void editgui_notify_object_changed(int objtype, int object_id, bool removal)
Stub for editor function.
void editgui_refresh()
Stub for editor function.
void conn_list_dialog_update()
void boot_help_texts(const nation_set *nations_to_show, help_item *tileset_help)
pplayer may be nullptr.
void popdown_help_dialog(void)
Close the help dialog.
void idex_register_unit(struct world *iworld, struct unit *punit)
Register a unit into idex, with current punit->id.
void idex_unregister_city(struct world *iworld, struct city *pcity)
Remove a city from idex, with current pcity->id.
void idex_register_city(struct world *iworld, struct city *pcity)
Register a city into idex, with current pcity->id.
Impr_type_id improvement_count()
Return the number of improvements.
const char * improvement_rule_name(const struct impr_type *pimprove)
Return the (untranslated) rule name of the improvement.
void improvement_feature_cache_init()
Cache features of the improvement.
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
bool is_improvement_visible(const struct impr_type *pimprove)
Return TRUE if the improvement should be visible to others without spying.
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_msg(condition, message,...)
constexpr auto LOG_NORMAL
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
int startpos_number(const struct startpos *psp)
Returns the unique ID number for this start position.
void map_free(struct civ_map *fmap)
Frees the allocated memory of the map.
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Return squared distance between two tiles.
bool map_is_empty()
Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded.
struct startpos * map_startpos_get(const struct tile *ptile)
Returns the start position at the given tile, or nullptr if none exists there.
bool map_startpos_remove(struct tile *ptile)
Remove the start position at the given tile.
struct startpos * map_startpos_new(struct tile *ptile)
Create a new start position at the given tile and return it.
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Are (x1,y1) and (x2,y2) really the same when adjusted? This function might be necessary ALOT of place...
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Fills the start position with the nation information in the packet.
void map_init_topology()
map_init_topology needs to be called after map.topology_id is changed.
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Return the tile for the given index position.
struct terrain_misc terrain_control
void main_map_allocate()
Allocate main map and related global structures.
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
void update_turn_done_button_state()
Update the turn done button state.
struct city * city_workers_display
void upgrade_canvas_clipboard()
A newer technology may be available for units.
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
Popup a dialog to ask for the name of a new city.
void update_info_label(void)
Typically an info box is provided to tell the player about the state of their civilization.
void update_unit_info_label(const std::vector< unit * > &unit_list)
Update the information label which gives info on the current unit and the tile under the current unit...
void meswin_clear_older(int turn, int phase)
Clear all messages.
int utype_unknown_move_cost(const struct unit_type *utype)
This function calculates the movement cost to unknown tiles.
void init_move_fragments()
Call whenever terrain_control.move_fragments / SINGLE_MOVE changes.
struct multiplier * multiplier_by_number(Multiplier_type_id id)
Returns multiplier associated to given number.
Multiplier_type_id multiplier_count()
Return number of loaded multipliers in the ruleset.
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Returns multiplier index.
#define multipliers_iterate(_mul_)
#define multipliers_iterate_end
void start_style_music()
Start music suitable for current game situation.
void start_menu_music(const QString &tag, const QString &alt_tag)
Start menu music.
void play_single_track(const QString &tag)
Play single track before continuing normal style music.
static void name_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name)
static void names_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name, const char *rule_name)
struct nation_set * nation_set_by_number(int id)
Return the nation set with the given index.
struct nation_type * nation_by_number(const Nation_type_id nation)
Return the nation with the given index.
struct nation_type * nation_of_city(const struct city *pcity)
Return the nation of the player who owns the city.
int nation_group_index(const struct nation_group *pgroup)
Return the nation group index.
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Create a new leader for the nation.
int nation_set_index(const struct nation_set *pset)
Return the nation set index.
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
struct nation_group * nation_group_new(const char *name)
Add new group into the array of groups.
struct nation_type * nation_of_unit(const struct unit *punit)
Return the nation of the player who owns the unit.
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Return translated version of nation legend.
struct nation_group * nation_group_by_number(int id)
Return the nation group with the given index.
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Add new set into the array of nation sets.
void nations_alloc(int num)
Allocate space for the given number of nations.
client_options * gui_options
const char * tileset_name_for_topology(int topology_id)
Option framework wrapper for mapimg_get_format_list()
void calculate_overview_dimensions()
Called if the map size is know or changes.
QVector< QString > * packet_strvec_extract(const char *str)
void generic_handle_player_attribute_chunk(struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
Updates pplayer->attribute_block according to the given packet.
@ UNIT_INFO_CITY_SUPPORTED
void handle_ruleset_game(const struct packet_ruleset_game *packet)
Packet ruleset_game handler.
void handle_player_diplstate(const struct packet_player_diplstate *packet)
Packet player_diplstate handler.
void handle_conn_ping()
Reply to 'ping' packet with 'pong'.
static action_id auto_attack_act(const struct act_prob *act_probs)
Returns a possibly legal attack action iff it is the only interesting action that currently is legal.
void handle_ruleset_nation_sets(const struct packet_ruleset_nation_sets *packet)
Handle the list of nation sets, sent as part of the ruleset.
void handle_ruleset_nation(const struct packet_ruleset_nation *packet)
Handle initial ruleset nation info.
void handle_city_name_suggestion_info(int unit_id, const char *name)
Handle reply to our city name request.
void handle_nuke_tile_info(int tile)
The tile (x,y) has been nuked!
void handle_city_sabotage_list(int actor_id, int city_id, bv_imprs improvements, action_id act_id, bool disturb_player)
Handle list of potenttial buildings to sabotage.
void handle_processing_finished()
Handle request to stop processing packet.
void handle_ruleset_government_ruler_title(const struct packet_ruleset_government_ruler_title *packet)
Packet ruleset_government_ruler_title handler.
void handle_city_info(const struct packet_city_info *packet)
A city-info packet contains all information about a city.
void handle_conn_info(const struct packet_conn_info *pinfo)
Remove, add, or update dummy connection struct representing some connection to the server,...
void handle_vote_remove(int vote_no)
A vote no longer exists.
void handle_page_msg_part(const char *lines)
Page_msg part handler.
void handle_unit_combat_info(const struct packet_unit_combat_info *packet)
A combat packet.
void handle_ruleset_style(const struct packet_ruleset_style *p)
Handle a packet about a particular style.
void handle_unit_remove(int unit_id)
Handle a remove-unit packet, sent by the server to tell us any time a unit is no longer there.
void handle_vote_update(int vote_no, int yes, int no, int abstain, int num_voters)
Find and update the corresponding vote and refresh the GUI.
void handle_freeze_client()
We have received PACKET_FREEZE_CLIENT.
void handle_ruleset_multiplier(const struct packet_ruleset_multiplier *p)
Packet ruleset_multiplier handler.
void handle_player_info(const struct packet_player_info *pinfo)
Handle information about a player.
void handle_ruleset_extra(const struct packet_ruleset_extra *p)
Handle a packet about a particular extra type.
void handle_ruleset_action_auto(const struct packet_ruleset_action_auto *p)
Handle a packet about a particular action auto performer rule.
void handle_ruleset_unit_bonus(const struct packet_ruleset_unit_bonus *p)
Packet ruleset_unit_bonus handler.
void handle_start_phase(int phase)
Called by the network code when an start-phase packet is received.
void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
Sets the remaining turn time.
void handle_ruleset_terrain_control(const struct packet_ruleset_terrain_control *p)
Handle the terrain control ruleset packet sent by the server.
static struct unit * unpackage_short_unit(const struct packet_unit_short_info *packet)
Unpackage a short_unit_info packet.
void handle_end_phase()
Called by the network code when an end-phase packet is received.
void handle_play_music(const char *tag)
Play suitable music.
void handle_processing_started()
Handle request to start processing packet.
void handle_edit_object_created(int tag, int id)
Handle a notification from the server that an object was successfully created.
static void packhand_init()
Called only by handle_map_info() below.
static struct @141 invisible
void handle_ruleset_tech_class(const struct packet_ruleset_tech_class *p)
Packet ruleset_tech_class handler.
void handle_ruleset_control(const struct packet_ruleset_control *packet)
Take arrival of ruleset control packet to indicate that current allocated governments should be free'...
void handle_server_info(const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
Handle server info packet.
void handle_ruleset_nation_groups(const struct packet_ruleset_nation_groups *packet)
Handle the list of nation groups, sent as part of the ruleset.
void handle_traderoute_info(const struct packet_traderoute_info *packet)
A traderoute-info packet contains information about one end of a traderoute.
void handle_ruleset_effect(const struct packet_ruleset_effect *packet)
Add effect data to ruleset cache.
void handle_new_year(int year, int fragments, int turn)
Handle turn and year advancement.
void handle_rulesets_ready()
Received packet indicating that all rulesets have now been received.
void handle_research_info(const struct packet_research_info *packet)
Receive a research info packet.
void handle_ruleset_goods(const struct packet_ruleset_goods *p)
Handle a packet about a particular goods type.
void handle_unit_info(const struct packet_unit_info *packet)
Packet unit_info.
void handle_ruleset_city(const struct packet_ruleset_city *packet)
Handle city style packet.
void handle_ruleset_unit_class(const struct packet_ruleset_unit_class *p)
Packet ruleset_unit_class handler.
void handle_server_shutdown()
Handle server shutdown.
void handle_ruleset_government(const struct packet_ruleset_government *p)
Packet ruleset_government handler.
void handle_ruleset_terrain_flag(const struct packet_ruleset_terrain_flag *p)
Packet ruleset_terrain_flag handler.
void handle_connect_msg(const char *message)
Handle a connect message packet.
void packhand_free()
Called below, and by client/client_main.c client_game_free()
void handle_tile_info(const struct packet_tile_info *packet)
Packet tile_info handler.
void handle_ruleset_action(const struct packet_ruleset_action *p)
Handle a packet about a particular action.
void handle_achievement_info(int id, bool gained, bool first)
Received package about gaining an achievement.
void handle_unit_bombard_info(int attacker_unit_id, int target_tile_id)
A bombardment packet.
void handle_scenario_description(const char *description)
Received packet containing description of current scenario.
void play_sound_for_event(enum event_type type)
Plays sound associated with event.
static struct @142 page_msg_report
void handle_edit_startpos(const struct packet_edit_startpos *packet)
Handle start position creation/removal.
static int unpack_tech_req(const enum tech_req r_num, const int reqs_size, const struct requirement *reqs, struct advance *a, int i)
Unpack a traditional tech req from a standard requirement vector (that still is in the network serial...
void handle_city_short_info(const struct packet_city_short_info *packet)
A city-short-info packet is sent to tell us about any cities we can't see the internals of.
void handle_endgame_player(const struct packet_endgame_player *packet)
Pass endgame report about single player.
void handle_ruleset_resource(const struct packet_ruleset_resource *p)
Handle a packet about a particular terrain resource.
void handle_ruleset_tech(const struct packet_ruleset_tech *p)
Packet ruleset_tech handler.
void handle_team_name_info(int team_id, const char *team_name)
The name of team 'team_id'.
void handle_calendar_info(const struct packet_calendar_info *pcalendar)
Packet calendar_info handler.
void set_government_choice(struct government *government)
Sets the target government.
void handle_ruleset_disaster(const struct packet_ruleset_disaster *p)
Handle a packet about a particular disaster type.
static bool handle_unit_packet_common(struct unit *packet_unit)
Called to do basic handling for a unit_info or short_unit_info packet.
void handle_ruleset_unit_class_flag(const struct packet_ruleset_unit_class_flag *p)
Packet ruleset_unit_class_flag handler.
void handle_server_join_reply(bool you_can_join, const char *message, const char *capability, const char *challenge_file, int conn_id)
After we send a join packet to the server we receive a reply.
void handle_ruleset_summary(const struct packet_ruleset_summary *packet)
Ruleset summary.
void handle_page_msg(const char *caption, const char *headline, enum event_type event, int len, int parts)
Page_msg header handler.
void handle_edit_startpos_full(const struct packet_edit_startpos_full *packet)
Handle start position internal information.
void handle_conn_ping_info(int connections, const int *conn_id, const float *ping_time)
Handles a conn_ping_info packet from the server.
static bool spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Ideally the client should let the player choose which type of modules and components to build,...
void handle_player_remove(int playerno)
Handle a notification that the player slot identified by 'playerno' has become unused.
void handle_end_turn()
Called when end-turn packet is received.
void handle_endgame_report(const struct packet_endgame_report *packet)
Pass the header information about things be displayed in a gui-specific endgame dialog.
void handle_early_chat_msg(const struct packet_early_chat_msg *packet)
Handle an early message packet.
void handle_ruleset_clause(const struct packet_ruleset_clause *p)
Handle a packet about a particular clause.
void handle_ruleset_road(const struct packet_ruleset_road *p)
Handle a packet about a particular road type.
void handle_unit_actions(const struct packet_unit_actions *packet)
Handle reply to possible actions.
void handle_ruleset_music(const struct packet_ruleset_music *packet)
Handle music style packet.
void handle_ruleset_base(const struct packet_ruleset_base *p)
Handle a packet about a particular base type.
void notify_about_incoming_packet(struct connection *pc, int packet_type, int size)
Notify interested parties about incoming packet.
void handle_city_remove(int city_id)
Handles a remove-city packet, used by the server to tell us any time a city is no longer there.
void handle_chat_msg(const struct packet_chat_msg *packet)
Handle a message packet.
static void city_packet_common(struct city *pcity, struct tile *pcenter, struct player *powner, struct tile_list *worked_tiles, bool is_new, bool popup, bool investigate)
A helper function for handling city-info and city-short-info packets.
void handle_player_attribute_chunk(const struct packet_player_attribute_chunk *packet)
Packet player_attribute_chunk handler.
void handle_vote_new(const struct packet_vote_new *packet)
Create a new vote and add it to the queue.
void handle_set_topology(int topology_id)
Server requested topology change.
void handle_scenario_info(const struct packet_scenario_info *packet)
Received packet containing info about current scenario.
static struct unit * unpackage_unit(const struct packet_unit_info *packet)
Unpackage the unit information into a newly allocated unit structure.
void handle_ruleset_extra_flag(const struct packet_ruleset_extra_flag *p)
Packet ruleset_extra_flag handler.
void notify_about_outgoing_packet(struct connection *pc, int packet_type, int size, int request_id)
Notify interested parties about outgoing packet.
#define VALIDATE(_count, _maximum, _string)
struct city_list * cities
void handle_ruleset_tech_flag(const struct packet_ruleset_tech_flag *p)
Packet ruleset_tech_flag handler.
void handle_nation_availability(int ncount, const bool *is_pickable, bool nationset_change)
Handle nation availability info.
void handle_spaceship_info(const struct packet_spaceship_info *p)
Packet spaceship_info handler.
void handle_begin_turn()
Called when begin-turn packet is received.
void handle_ruleset_specialist(const struct packet_ruleset_specialist *p)
Handle info about a single specialist.
void handle_unit_short_info(const struct packet_unit_short_info *packet)
Receive a short_unit info packet.
void handle_ruleset_unit_flag(const struct packet_ruleset_unit_flag *p)
Packet ruleset_unit_flag handler.
void handle_thaw_client()
We have received PACKET_THAW_CLIENT.
QString forced_tileset_name
void handle_ruleset_building(const struct packet_ruleset_building *p)
Packet ruleset_building handler.
void handle_map_info(int xsize, int ysize, int topology_id)
Receive information about the map size and topology from the server.
static bool update_improvement_from_packet(struct city *pcity, struct impr_type *pimprove, bool have_impr)
Updates a city's list of improvements from packet data.
void handle_ruleset_unit(const struct packet_ruleset_unit *p)
Packet ruleset_unit handler.
void handle_ruleset_terrain(const struct packet_ruleset_terrain *p)
Packet ruleset_terrain handler.
void handle_unit_action_answer(int actor_id, int target_id, int cost, action_id action_type, bool disturb_player)
Handle the requested follow up question about an action.
void handle_ruleset_action_enabler(const struct packet_ruleset_action_enabler *p)
Handle a packet about a particular action enabler.
void handle_ruleset_achievement(const struct packet_ruleset_achievement *p)
Handle a packet about a particular achievement type.
void handle_game_info(const struct packet_game_info *pinfo)
Packet game_info handler.
struct player * placeholder
void handle_vote_resolve(int vote_no, bool passed)
Update the vote's status and refresh the GUI.
void start_revolution()
Begin a revolution by telling the server to start it.
void handle_worker_task(const struct packet_worker_task *packet)
Handle worker task assigned to the city.
void handle_ruleset_description_part(const struct packet_ruleset_description_part *packet)
Next part of ruleset description.
void handle_ruleset_trade(const struct packet_ruleset_trade *p)
Handle a packet about a particular trade route type.
pageGame * queen()
Return game instandce.
void set_client_page(enum client_pages page)
enum client_pages get_client_page()
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
If the specified player owns the unit with the specified id, return pointer to the unit struct.
struct player_slot * player_slot_by_number(int player_id)
Return the possibly unused and uninitialized player slot.
bool player_slot_is_used(const struct player_slot *pslot)
Returns TRUE is this slot is "used" i.e.
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.
void player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Set the player's color.
int player_index(const struct player *pplayer)
Return the player index.
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
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 can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the player can see units in the city.
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the player can see the city's internals.
struct player * player_new(struct player_slot *pslot)
Creates a new player for the slot.
void player_destroy(struct player *pplayer)
Destroys and remove a player from the game.
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)
void start_turn()
New turn callback.
void multipliers_dialog_update()
void science_report_dialog_popup(bool raise)
Display the science report.
void science_report_dialog_update()
void economy_report_dialog_update()
void units_report_dialog_update()
void science_report_dialog_redraw(void)
Resize and redraw the requirement tree.
struct universal universal_by_number(const enum universals_n kind, const int value)
Combine values into a universal structure.
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Return TRUE iff the two sources are equivalent.
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Set research knowledge about tech to given state.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
struct research * research_by_number(int number)
Returns the research for the given index.
void research_update(struct research *presearch)
Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements ful...
#define research_players_iterate(_presearch, _pplayer)
#define research_players_iterate_end
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
struct rgbcolor * rgbcolor_new(int r, int g, int b)
Allocate new rgbcolor structure.
void road_integrators_cache_init()
Initialize the road integrators cache.
void road_type_init(struct extra_type *pextra, int idx)
Initialize road_type structures.
struct road_type * road_by_number(Road_type_id id)
Return road type of given id.
void script_client_signal_emit(const char *signal_name,...)
Invoke all the callback functions attached to a given signal.
static struct connection connections[MAX_NUM_CONNECTIONS]
bool next_spaceship_component(struct player *pplayer, struct player_spaceship *ship, struct spaceship_component *fill)
Find (default) place for next spaceship component.
void refresh_spaceship_dialog(struct player *pplayer)
Refresh (update) the spaceship dialog for the given player.
struct specialist * specialist_by_number(const Specialist_type_id id)
Return the specialist pointer for the given number.
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define DEFAULT_SPECIALIST
enum achievement_type type
struct name_translation name
struct requirement_vector reqs
enum action_auto_perf_cause cause
action_id alternatives[MAX_NUM_ACTIONS]
struct requirement_vector actor_reqs
struct requirement_vector target_reqs
bool actor_consuming_always
enum action_sub_target_kind sub_target_kind
enum action_result result
char ui_name[MAX_LEN_NAME]
enum action_actor_kind actor_kind
enum action_target_kind target_kind
struct requirement_vector research_reqs
struct tech_class * tclass
struct advance * require[AR_SIZE]
struct name_translation name
char graphic_str[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
QVector< QString > * helptext
enum base_gui_type gui_type
struct worker_task_list * task_reqs
struct city::@15::@18 client
struct built_status built[B_LAST]
int last_turns_shield_surplus
enum capital_type capital
bv_city_options city_options
struct trade_route_list * routes
struct universal production
int unhappy_penalty[O_LAST]
char name[MAX_LEN_CITYNAME]
int before_change_shields
citizens feel[CITIZEN_LAST][FEELING_LAST]
citizens specialists[SP_MAX]
struct universal changed_from
struct unit_list * units_supported
struct requirement_vector reqs
char citizens_graphic[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
struct name_translation name
char graphic[MAX_LEN_NAME]
char citizens_graphic_alt[MAX_LEN_NAME]
struct rgbcolor * plr_bg_color
struct packet_scenario_description scenario_desc
struct packet_ruleset_control control
struct civ_game::@28::@31 client
struct conn_list * est_connections
int global_init_techs[MAX_NUM_TECH_LIST]
struct packet_game_info info
int global_init_buildings[MAX_NUM_BUILDING_LIST]
struct packet_scenario_info scenario
char * ruleset_description
struct conn_list * all_connections
struct civ_game::@27 rgame
struct packet_timeout_info tinfo
struct veteran_system * veteran
struct packet_calendar_info calendar
struct government * default_government
struct government * government_during_revolution
struct requirement_vector receiver_reqs
struct requirement_vector giver_reqs
bool sound_bell_at_new_turn
bool autoaccept_tileset_suggestion
bool autoaccept_musicset_suggestion
bool draw_city_productions
bool draw_city_trade_routes
bool autoaccept_soundset_suggestion
int smooth_combat_step_msec
bool auto_center_on_combat
bool popup_attack_actions
enum unit_type_flag_id flag
enum combat_bonus_type type
enum cmdlevel access_level
char username[MAX_LEN_NAME]
struct connection::@55::@60 client
struct socket_packet_buffer * send_buffer
char capability[MAX_LEN_CAPSTR]
struct socket_packet_buffer * buffer
struct name_translation name
struct requirement_vector reqs
bv_disaster_effects effects
struct requirement_vector reqs
QVector< QString > * helptext
struct name_translation name
struct requirement_vector reqs
char graphic_alt[MAX_LEN_NAME]
Government_type_id item_number
QVector< QString > * helptext
struct name_translation name
char graphic_str[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
struct requirement_vector obsolete_by
char soundtag_alt[MAX_LEN_NAME]
struct requirement_vector reqs
struct name_translation name
QVector< QString > * helptext
char soundtag[MAX_LEN_NAME]
struct requirement_vector reqs
QVector< QString > * helptext
struct name_translation name
struct requirement_vector reqs
Functions for handling the nations.
struct name_translation name
int init_buildings[MAX_NUM_BUILDING_LIST]
struct nation_group_list * groups
struct name_translation noun_plural
struct nation_set_list * sets
char flag_graphic_str[MAX_LEN_NAME]
struct name_translation adjective
char flag_graphic_alt[MAX_LEN_NAME]
std::array< unit_type *, MAX_NUM_UNIT_LIST > init_units
enum barbarian_type barb_type
char * translation_domain
struct nation_type::@48::@51 client
struct nation_style * style
int init_techs[MAX_NUM_TECH_LIST]
government * init_government
enum ai_level skill_level
enum barbarian_type barbarian_type
int love[MAX_NUM_PLAYER_SLOTS]
bv_spaceship_structure structure
enum spaceship_state state
struct city_list * cities
struct player_ai ai_common
struct player::@65::@68 client
struct government * target_government
char username[MAX_LEN_NAME]
struct government * government
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
bv_player gives_shared_vision
struct player_score score
int multipliers[MAX_NUM_MULTIPLIERS]
struct nation_style * style
int multipliers_target[MAX_NUM_MULTIPLIERS]
struct research::@71::@73 client
struct requirement_vector first_reqs
enum road_move_mode move_mode
int tile_incr_const[O_LAST]
enum spaceship_place_type type
struct requirement_vector reqs
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
struct name_translation name
QVector< QString > * helptext
struct name_translation abbreviation
struct name_translation name
struct extra_type ** resources
bv_unit_classes native_to
struct name_translation name
struct terrain * irrigation_result
QVector< QString > * helptext
const struct unit_type * animal
struct terrain * mining_result
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
enum terrain_class tclass
int road_output_incr_pct[O_LAST]
struct terrain * transform_result
struct player * extras_owner
struct extra_type * placing
enum traderoute_bonus_type bonus_type
enum traderoute_illegal_cancelling cancelling
struct goods_type * goods
enum hut_behavior hut_behavior
QVector< QString > * helptext
struct name_translation name
bv_unit_class_flags flags
struct unit_class * uclass
struct unit_type::@82 adv
struct requirement_vector build_reqs
QVector< QString > * helptext
char graphic_alt[MAX_LEN_NAME]
char sound_move_alt[MAX_LEN_NAME]
struct veteran_system * veteran
const struct unit_type * obsoleted_by
struct advance * require_advance
char graphic_str[MAX_LEN_NAME]
char sound_move[MAX_LEN_NAME]
char sound_fight_alt[MAX_LEN_NAME]
struct name_translation name
bv_unit_classes disembarks
const struct unit_type * converted_to
char sound_fight[MAX_LEN_NAME]
struct combat_bonus_list * bonuses
enum action_decision action_decision_want
enum unit_activity activity
struct unit::@76::@78 client
struct extra_type * changed_from_target
struct extra_type * activity_target
enum unit_activity changed_from
struct player * nationality
struct goods_type * carrying
struct tile * action_decision_tile
const struct unit_type * utype
enum server_side_agent ssa_controller
struct music_style * music_style_by_number(int id)
Return music style of given id.
void styles_alloc(int count)
Initialise styles structures.
struct nation_style * style_by_number(int id)
Return style of given id.
void music_styles_alloc(int count)
Initialise music styles structures.
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
size_t fc_strlcat(char *dest, const char *src, size_t n)
fc_strlcat() provides utf-8 version of (non-standard) function strlcat() It is intended as more user-...
#define sz_strlcpy(dest, src)
void team_add_player(struct player *pplayer, struct team *pteam)
Set a player to a team.
int team_count()
Return the current number of teams.
struct team * team_new(struct team_slot *tslot)
Creates a new team for the slot.
struct team_slot * team_slot_by_number(int team_id)
Return the possibly unused and uninitialized team slot.
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
Set the name defined in the ruleset for this slot.
void set_user_tech_flag_name(enum tech_flag_id id, const char *name, const char *helptxt)
Sets user defined name for tech flag.
struct tech_class * tech_class_by_number(const int idx)
Return the tech_class for the given index.
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
Tech_type_id advance_count()
Return the number of advances/technologies.
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
Terrain_type_id terrain_count()
Return the number of terrains.
struct terrain * terrain_by_number(const Terrain_type_id type)
Return the terrain for the given terrain index.
const char * terrain_rule_name(const struct terrain *pterrain)
Return the (untranslated) rule name of the terrain.
struct resource_type * resource_type_init(struct extra_type *pextra)
Initialize resource_type structure.
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Sets user defined name for terrain flag.
#define MAX_RESOURCE_TYPES
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
Set the given terrain at the specified tile.
void tile_set_owner(struct tile *ptile, struct player *pplayer, struct tile *claimer)
Set the owner of a tile (may be nullptr).
bool tile_set_label(struct tile *ptile, const char *label)
Sets label for tile.
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Set the given resource at the specified tile.
void tile_set_worked(struct tile *ptile, struct city *pcity)
Set the city/worker on the tile (may be nullptr).
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_resource(_tile)
#define tile_list_iterate(tile_list, ptile)
#define tile_terrain(_tile)
#define tile_list_iterate_end
#define tile_owner(_tile)
bool tilespec_reread(const QString &name, bool game_fully_initialized)
Read a new tilespec in from scratch.
void tileset_setup_unit_type(struct tileset *t, struct unit_type *ut)
Set unit_type sprite value; should only happen after tilespec_load_tiles().
const char * tileset_basename(const struct tileset *t)
Return the name of the given tileset.
void tileset_setup_government(struct tileset *t, struct government *gov)
Set government sprite value; should only happen after tilespec_load_tiles().
void tileset_setup_specialist_type(struct tileset *t, Specialist_type_id id)
Setup the graphics for specialist types.
void tileset_setup_tile_type(struct tileset *t, const struct terrain *pterrain)
Set tile_type sprite values; should only happen after tilespec_load_tiles().
void tileset_player_init(struct tileset *t, struct player *pplayer)
Setup tiles for one player using the player color.
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Indicate whether a unit is to be drawn with a surrounding city outline under current conditions.
void tileset_setup_impr_type(struct tileset *t, struct impr_type *pimprove)
Set improvement_type sprite value; should only happen after tilespec_load_tiles().
void tileset_setup_tech_type(struct tileset *t, struct advance *padvance)
Set tech_type sprite value; should only happen after tilespec_load_tiles().
void tileset_setup_city_tiles(struct tileset *t, int style)
Set city tiles sprite values; should only happen after tilespec_load_tiles().
void tileset_setup_extra(struct tileset *t, struct extra_type *pextra)
Set extra sprite values; should only happen after tilespec_load_tiles().
void finish_loading_sprites(struct tileset *t)
Frees any internal buffers which are created by load_sprite.
void tileset_error(struct tileset *t, QtMsgType level, const char *format,...)
Called when ever there's problem in ruleset/tileset compatibility.
help_item * tileset_help(const struct tileset *t)
Creates the help item for the given tileset.
void tilespec_reread_frozen_refresh(const QString &name)
Read a new tilespec in from scratch.
void tileset_setup_nation_flag(struct tileset *t, struct nation_type *nation)
Set nation flag sprite value; should only happen after tilespec_load_tiles().
void tileset_ruleset_reset(struct tileset *t)
Reset tileset data specific to ruleset.
#define MAX_NUM_CITIZEN_SPRITES
struct goods_type * goods_by_number(Goods_type_id id)
Return goods type of given id.
int city_num_trade_routes(const struct city *pcity)
Return number of trade route city has.
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
Get trade route settings related to type.
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Load pcargo onto ptrans.
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool unit_transport_unload(struct unit *pcargo)
Unload pcargo from ptrans.
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Returns the list of cargo units.
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
void unit_tile_set(struct unit *punit, struct tile *ptile)
Set the tile location of the unit.
bool unit_transported(const struct unit *pcargo)
Returns TRUE iff the unit is transported.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
void set_unit_class_caches(struct unit_class *pclass)
Set caches for unit class.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
struct unit_type * utype_by_number(const Unit_type_id id)
Return a pointer for the unit type struct for the given unit type id.
void set_unit_move_type(struct unit_class *puclass)
Set move_type for unit class.
void set_unit_type_caches(struct unit_type *ptype)
Set caches for unit types.
struct veteran_system * veteran_system_new(int count)
Allocate new veteran system structure with given veteran level count.
void veteran_system_definition(struct veteran_system *vsystem, int level, const char *vlist_name, int vlist_power, int vlist_move, int vlist_raise, int vlist_wraise)
Fill veteran level in given veteran system with given information.
void unit_type_action_cache_set(struct unit_type *ptype)
Cache if any action may be possible for a unit of the type putype given the property tested for.
struct unit_class * uclass_by_number(const Unit_Class_id id)
Returns unit class pointer for an ID value.
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Sets user defined name for unit class flag.
const char * unit_name_translation(const struct unit *punit)
Return the (translated) name of the unit.
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Sets user defined name for unit flag.
#define UCF_LAST_USER_FLAG
#define unit_class_iterate(_p)
#define UTYF_LAST_USER_FLAG
#define unit_type_iterate(_p)
#define unit_class_iterate_end
#define unit_type_iterate_end
void players_dialog_update(void)
void put_nuke_mushroom_pixmaps(struct tile *ptile)
Animate the nuke explosion at map(x, y).
bool tile_visible_mapcanvas(struct tile *ptile)
Return TRUE iff the given map position has a tile visible on the map canvas.
void mapdeco_init()
Called when we receive map dimensions.
void refresh_tile_mapcanvas(const tile *ptile, bool full_refresh)
Refreshes a single tile on the map canvas.
void animate_unit_explosion(const tile *location)
Draws an explosion animation on the given sprite.
void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile, bool full_refresh)
Refreshes a single city on the map canvas.
void update_city_description(struct city *pcity)
Update the city description for the given city.
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh)
Refreshes a single unit on the map canvas.
void link_marks_decrease_turn_counters()
Clear all visible links.
void decrease_unit_hp_smooth(struct unit *punit0, int hp0, struct unit *punit1, int hp1)
This function is called to decrease a unit's HP smoothly in battle when combat_animation is turned on...
enum topo_comp_lvl tileset_map_topo_compatible(int topology_id, struct tileset *tset)
Are the topology and tileset compatible?
void update_map_canvas_visible()
Schedules an update of (only) the visible part of the map at the next unqueue_mapview_update().
void close_intel_dialog(struct player *p)
Close an intelligence dialog for the given player.
void update_intel_dialog(struct player *p)
Update the intelligence dialog for the given player.
#define vision_layer_iterate(v)
#define vision_layer_iterate_end
void voteinfo_queue_delayed_remove(int vote_no)
Remove the vote with number 'vote_no' after a small amount of time so that the user can see that it w...
struct voteinfo * voteinfo_queue_find(int vote_no)
Find the voteinfo record corresponding to the given vote number.
void voteinfo_queue_add(int vote_no, const char *user, const char *desc, int percent_required, int flags)
Create a new voteinfo record and place it in the queue.
void voteinfo_gui_update(void)
Refresh all vote related GUI widgets.
#define worker_task_list_iterate(tasklist, ptask)
#define worker_task_list_iterate_end
void worklist_copy(struct worklist *dst, const struct worklist *src)
Copy contents from worklist src to worklist dst.
void worklist_init(struct worklist *pwl)
Initialize a worklist to be empty.