121 enum extra_rmcause rmcause);
219 focus.erase(std::remove(focus.begin(), focus.end(), punit), focus.end());
352 "Unit %d started action selection before unit %d was done",
356 dsend_packet_unit_get_actions(
367 return std::find(focus.begin(), focus.end(), punit) != focus.end();
390 return list.empty() ? nullptr :
list.front();
411 bool auto_center_enabled =
true;
460 if (punit->
activity != ACTIVITY_IDLE
481 bool focus_changed =
false;
495 focus_changed =
true;
519 if (
nullptr != punit) {
597 && (punit->moves_left > 0 ||
unit_type_get(punit)->move_rate == 0)
599 && punit->ssa_controller == SSA_NONE) {
619 struct unit *candidate =
nullptr;
636 if (punit->ssa_controller == SSA_NONE) {
644 struct tile *focus_tile =
656 }
else if (
nullptr == focus_tile || focus_tile ==
unit_tile(punit)) {
660 }
else if (
nullptr == candidate) {
666 if (
nullptr != candidate) {
677 if (
nullptr == candidate) {
684 if (punit->client.focus_status ==
FOCUS_WAIT) {
735 if ((punit->activity == ACTIVITY_IDLE || punit->activity == ACTIVITY_GOTO
737 && punit->moves_left > 0 && !punit->done_moving
738 && punit->ssa_controller == SSA_NONE) {
751 struct unit *panyowned =
nullptr, *panyother =
nullptr,
752 *ptptother =
nullptr;
755 if (unit_list_size(ptile->units) == 0) {
806 }
else if (!panyowned) {
813 }
else if (!panyother) {
820 return (panyowned ? panyowned : (ptptother ? ptptother : panyother));
829 static QTimer blink_timer;
830 blink_timer.setSingleShot(
true);
834 if (!blink_timer.isActive()) {
837 blink_timer.start(blink_time);
847 return blink_time - blink_timer.remainingTime();
859 static QTimer blink_timer;
860 blink_timer.setSingleShot(
true);
861 const double blink_time = 500;
866 if (!blink_timer.isActive()) {
867 int is_waiting = 0, is_moving = 0;
872 if (opt !=
nullptr) {
875 blocking_mode =
false;
880 if ((pplayer->is_connected || blocking_mode)
882 if (pplayer->phase_done) {
891 if (is_moving == 1 && is_waiting > 0) {
894 blink_timer.start(blink_time);
896 return blink_time - blink_timer.remainingTime();
930 "Decision taken for %d but selection is for %d.",
950 dsend_packet_unit_sscs_set(&
client.
conn, old_actor_id, USSDT_UNQUEUE,
1002 if (focus.empty()) {
1010 for (
const auto punit : focus) {
1022 _(
"Only %s can do %s."), qUtf8Printable(roles),
1038 sub_tgt_id, act_id, last_order);
1055 const struct tile *ptile)
1057 return std::any_of(units.begin(), units.end(), [&](
const auto *
unit) {
1058 return is_attack_unit(unit) && can_unit_attack_tile(unit, ptile);
1069 struct unit *punit =
nullptr;
1070 struct city *pcity =
nullptr;
1110 }
else if (
nullptr != pcity && pcity->
client.full) {
1171 enum unit_activity activity)
1175 if (punit->activity == activity) {
1190 const struct unit *punit,
1191 const struct player *pplayer,
int rec)
1193 int activity_mc = 0;
1212 if (single_mc < 0) {
1216 activity_mc += single_mc;
1222 if (punit !=
nullptr) {
1226 }
else if (pplayer !=
nullptr) {
1245 const struct unit *punit)
1254 .kind = VUT_TERRAIN,
1285 case ACTIVITY_GEN_ROAD: {
1306 return build_time >= 0;
1309 case ACTIVITY_IRRIGATE:
1347 && (activity == ACTIVITY_GEN_ROAD
1348 || activity == ACTIVITY_IRRIGATE))) {
1367 struct unit *plast =
nullptr;
1371 _(
"Only transporter units can be unloaded."));
1380 if (pcargo->activity == ACTIVITY_SENTRY) {
1412 finder.set_constraint(
1413 std::make_unique<freeciv::tile_known_constraint>(
client_player()));
1415 if (
auto path = finder.find_path(
1417 auto steps = path->steps();
1418 int hp = steps.empty() ?
unit->
hp : steps.back().health;
1421 auto sentry = steps.back();
1424 sentry.order.activity = ACTIVITY_SENTRY;
1428 steps.push_back(sentry);
1432 if (!steps.empty()) {
1433 auto packet = packet_unit_orders{};
1434 packet.unit_id =
unit->
id;
1435 packet.dest_tile = steps.back().location->index;
1437 packet.repeat =
false;
1438 packet.vigilant =
false;
1442 packet.length = steps.size();
1443 for (std::size_t i = 0; i < steps.size(); ++i) {
1444 packet.orders[i] = steps[i].order;
1449 send_packet_unit_orders(&
client.
conn, &packet);
1465 if (punit->activity == ACTIVITY_SENTRY
1488 const struct player *pplayer;
1489 const struct tile *ptile;
1490 QSet<const struct tile *> tile_table;
1491 QSet<const struct unit_type *> type_table;
1492 QSet<Continent_id> cont_table;
1498 const auto punit_first = punits.front();
1507 for (
const auto punit : punits) {
1514 tile_table.insert(ptile);
1521 for (
const auto *hash_tile : tile_table) {
1564 int sub_tgt,
const char *
name)
1571 dsend_packet_unit_do_action(&
client.
conn, actor_id, target_id, sub_tgt,
1608 dsend_packet_city_name_suggestion_req(&
client.
conn, punit->
id);
1620 struct packet_unit_orders p;
1630 memset(&p, 0,
sizeof(p));
1635 p.unit_id = punit->
id;
1641 p.orders[0].dir =
static_cast<direction8
>(dir);
1642 p.orders[0].activity = ACTIVITY_LAST;
1662 struct packet_unit_orders p;
1663 struct tile *dest_tile;
1685 memset(&p, 0,
sizeof(p));
1690 p.unit_id = punit->
id;
1698 p.orders[0].dir =
static_cast<direction8
>(dir);
1699 p.orders[0].activity = ACTIVITY_LAST;
1722 enum unit_activity act,
1732 if (tgt ==
nullptr) {
1733 dsend_packet_unit_change_activity(&
client.
conn, punit->
id, act,
1736 dsend_packet_unit_change_activity(&
client.
conn, punit->
id, act,
1760 int last_request_id_used;
1771 if (punit ==
nullptr) {
1776 if (data->
alt == -1) {
1780 _(
"Unable to get rid of %s."),
1790 next->
alt = data->
alt - 1;
1907 enum server_side_agent agent)
1910 dsend_packet_unit_server_side_agent_set(&
client.
conn, punit->
id, agent);
1924 _(
"Only settler units can be put into auto mode."));
1977 && pcargo->
activity == ACTIVITY_SENTRY) {
1996 if (
action == ACTION_TRADE_ROUTE) {
1998 }
else if (
action == ACTION_HELP_WONDER) {
2001 qCritical(
"request_unit_caravan_action() Bad action (%d)",
action);
2012 struct tile *offender =
nullptr;
2014 if (
units.empty()) {
2017 for (
const auto punit :
units) {
2029 _(
"Click on a tile to paradrop to it."));
2036 _(
"Only paratrooper units can do this."));
2047 if (focus.empty()) {
2068 if (punit->
activity != ACTIVITY_SENTRY
2079 if (punit->
activity != ACTIVITY_FORTIFYING
2094 bv_extras pspossible;
2114 if (target !=
nullptr) {
2268 for (
auto punit :
units) {
2284 if (punit->activity != ACTIVITY_IDLE) {
2290 punit->client.focus_status = new_status;
2307 bool was_teleported, do_animation;
2313 if (!was_teleported && punit->
activity != ACTIVITY_SENTRY
2321 && punit->
activity != ACTIVITY_GOTO
2322 && punit->
activity != ACTIVITY_SENTRY
2336 unit_list_remove(src_tile->
units, punit);
2351 }
else if (do_animation) {
2362 unit_list_prepend(dst_tile->
units, punit);
2401 dsend_packet_unit_sscs_set(&
client.
conn, punit->
id, USSDT_QUEUE,
2414 bool maybe_goto =
false;
2424 for (
const auto punit : units) {
2464 dsend_packet_city_make_specialist(&
client.
conn, near_pcity->
id,
2467 dsend_packet_city_make_worker(&
client.
conn, near_pcity->
id,
2484 }
else if (!near_pcity && unit_list_size(ptile->
units) == 0
2487 }
else if (!near_pcity && unit_list_size(ptile->
units) == 1
2489 struct unit *punit = unit_list_get(ptile->
units, 0);
2504 }
else if (!near_pcity && unit_list_size(ptile->
units) > 0) {
2528 int listsize = unit_list_size(ptile->
units);
2529 struct unit *panytransporter =
nullptr, *panymovesea =
nullptr,
2530 *panysea =
nullptr, *panymoveland =
nullptr,
2531 *panyland =
nullptr, *panymoveunit =
nullptr,
2532 *panyunit =
nullptr;
2540 if (listsize == 0) {
2542 }
else if (listsize == 1) {
2543 struct unit *punit = unit_list_get(ptile->
units, 0);
2569 if (punit->moves_left > 0) {
2571 }
else if (!panytransporter) {
2572 panytransporter = punit;
2577 if (punit->moves_left > 0) {
2579 panymovesea = punit;
2581 }
else if (!panysea) {
2587 if (punit->moves_left > 0) {
2590 }
else if (!panymoveland) {
2591 panymoveland = punit;
2593 }
else if (!panyland) {
2597 if (punit->moves_left > 0) {
2598 panymovesea = punit;
2604 if (punit->moves_left > 0 && !panymoveunit) {
2605 panymoveunit = punit;
2614 if (panytransporter) {
2615 return panytransporter;
2616 }
else if (panymovesea) {
2618 }
else if (panysea) {
2620 }
else if (panymoveunit) {
2621 return panymoveunit;
2622 }
else if (panyunit) {
2627 return panymoveland;
2628 }
else if (panyland) {
2630 }
else if (panymovesea) {
2632 }
else if (panysea) {
2634 }
else if (panymoveunit) {
2635 return panymoveunit;
2636 }
else if (panyunit) {
2662 _(
"Didn't find a route to the destination!"));
2684 _(
"Didn't find a route to the destination!"));
2700 _(
"Didn't find a route to the destination!"));
2755 _(
"Oh my! You seem to have no capital!"));
2824 dsend_packet_unit_sscs_set(&
client.
conn, punit->
id, USSDT_QUEUE,
2869 _(
"Click on a tile to do %s against it."),
2881 _(
"Click on a tile to act against it. "
2882 "Press 'd' again to act against own tile."));
2913 struct unit *pnext_focus =
nullptr, *plast;
2918 pnext_focus = plast;
3067 enum extra_rmcause rmcause)
3212 if (punit->client.asking_city_name) {
3217 punit->client.asking_city_name =
false;
3232 punit->client.asking_city_name =
false;
struct act_prob action_prob_self(const struct unit *actor_unit, const action_id act_id)
Get the actor unit's probability of successfully performing the chosen action on itself.
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 act_prob action_prob_vs_city(const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
Get the actor unit's probability of successfully performing the chosen action on the target city.
struct act_prob action_prob_vs_unit(const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
Get the actor unit's probability of successfully performing the chosen action on the target unit.
struct act_prob action_prob_vs_tile(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
Get the actor unit's probability of successfully performing the chosen action on the target tile.
struct act_prob action_prob_vs_units(const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
Get the actor unit's probability of successfully performing the chosen action on all units at the tar...
const QString action_name_translation(const struct action *action)
Get the action name used when displaying the action in the UI.
const QString action_id_name_translation(action_id act_id)
Get the action name used when displaying the action in the UI.
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.
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
#define action_id_get_role(act_id)
#define action_id_get_target_kind(act_id)
#define action_id_has_result_safe(act_id, result)
void audio_play_sound(const QString &tag, const QString &alt_tag)
Play an audio sample as suggested by sound tags.
struct extra_type * base_extra_get(const struct base_type *pbase)
Return extra that base is.
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
Get best gui_type base for given parameters.
struct city * is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
Is there an enemy city on this tile?
bool city_base_to_city_map(int *city_map_x, int *city_map_y, const struct city *const pcity, const struct tile *map_tile)
Finds the city map coordinate for a given map position and a city.
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Returns TRUE when a tile is available to be worked, or the city itself is currently working the tile ...
struct city * is_any_city_dialog_open()
void refresh_unit_city_dialogs(struct unit *punit)
Update city dialogs when the given unit's status changes.
void popup_city_dialog(struct city *pcity)
A path finding destination that accepts any allied city.
A path is a succession of moves and actions to go from one location to another.
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
static update_queue * uq()
void connect_processing_finished_full(int request_id, uq_callback_t cb, void *data, uq_free_fn_t free_func)
enum client_states client_state()
Return current client state.
bool is_server_busy()
Returns if server is considered busy at the moment.
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 send_turn_done()
Send information about player having finished his/her turn to server.
bool can_client_change_view()
Return TRUE if the client can change the view; i.e.
enum direction8 gui_to_map_dir(enum direction8 gui_dir)
Convert the given GUI direction into a map direction.
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 flush_dirty_overview()
This module contains various general - mostly highlevel - functions used throughout the client.
bool can_units_do_connect(const std::vector< unit * > &units, enum unit_activity activity, struct extra_type *tgt)
Returns TRUE if any of the units can do the connect activity.
static bool can_ask_server_for_actions()
Returns TRUE iff it is OK to ask the server about what actions a unit can perform.
void request_toggle_city_productions()
Toggle display of city productions.
void request_unit_airlift(struct unit *punit, struct city *pcity)
Send unit airlift request to server.
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...
void request_unit_non_action_move(struct unit *punit, struct tile *dest_tile)
Order a unit to move to a neighboring tile without performing an action.
void request_toggle_city_output()
Toggle display of worker output of cities on the map.
void key_unit_plant()
Handle user 'plant' input.
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 key_unit_paradrop()
Handle user 'paradrop' input.
void key_unit_goto()
Handle user 'unit goto' input.
void request_units_wait(const std::vector< unit * > &units)
Set units in list to waiting focus and advance focus.
void key_unit_homecity()
Handle user 'change homecity' input.
void request_unit_fortify(struct unit *punit)
Try to fortify unit.
void request_unit_caravan_action(struct unit *punit, action_id action)
Send request to do caravan action - establishing traderoute or helping in wonder building - to server...
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.
enum unit_orders goto_last_order
void request_unit_wakeup(struct unit *punit)
(RP:) un-sentry all my own sentried units on punit's tile
void key_city_names_toggle()
Handle user 'toggle city names display' input.
void action_decision_request(struct unit *actor_unit)
Request that the player makes a decision for the specified unit.
void key_unit_fallout()
Handle user 'clean fallout' input.
void key_unit_mine()
Handle user 'build mine' input.
void key_unit_done()
Handle user 'unit done' input.
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Adjusts way combatants are displayed suitable for combat.
int check_recursive_road_connect(struct tile *ptile, const struct extra_type *pextra, const struct unit *punit, const struct player *pplayer, int rec)
Fill orders to build recursive roads.
void request_toggle_city_trade_routes()
Toggle display of city trade routes.
void request_toggle_map_grid()
Toggle display of grid lines on the map.
static int action_selection_in_progress_for
static void do_disband_alternative(void *p)
Try to disband a unit using actions ordered by preference.
void key_unit_wait()
Handle user 'wait' input.
void unit_focus_update()
If there is no unit currently in focus, or if the current unit in focus should not be in focus,...
unit * find_visible_unit(const ::tile *ptile)
Return a pointer to a visible unit, if there is one.
void key_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Handle user pressing key for 'Connect' command.
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Send a request to the server that the cargo be loaded into the transporter.
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Handles everything when the user clicked a tile.
static void key_unit_extra(enum unit_activity act, enum extra_cause cause)
Handle user extra building input of given type.
void key_unit_auto_settle()
Call to request (from the server) that the focus unit is put into autosettler mode.
void control_init()
Called only by client_game_init() in client/client_main.c.
static struct unit * punit_attacking
void key_unit_irrigate()
Handle user 'irrigate' input.
void unit_focus_add(struct unit *punit)
Adds this unit to the list of units in focus.
void key_city_trade_routes_toggle()
Handle client request to toggle drawing of trade route information by the city name for cities visibl...
void key_unit_wakeup_others()
Handle user 'wakeup others' input.
void unit_focus_set(struct unit *punit)
Sets the focus unit directly.
struct unit * request_unit_unload_all(struct unit *punit)
Returns one of the unit of the transporter which can have focus next.
static void do_unit_act_sel_vs(struct tile *ptile)
An action selection dialog for the selected units against the specified tile is wanted.
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Do a goto with an order at the end (or ORDER_LAST).
void key_center_capital()
Center the mapview on the player's named capital, or print a failure message.
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Paradrop to a location.
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.
struct extra_type * connect_tgt
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 key_map_native_toggle()
Toggle native tiles on the mapview on/off based on a keypress.
void request_unit_disband(struct unit *punit)
Send request to disband unit to server.
static struct unit_list * previous_focus
void request_unit_autosettlers(const struct unit *punit)
Call to request (from the server) that the settler unit is put into autosettler mode.
void request_unit_pillage(struct unit *punit)
Send pillage request to server.
void unit_focus_urgent(struct unit *punit)
Store a priority focus unit.
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Return whether the unit can connect with given activity (or with any activity if activity arg is set ...
void request_unit_change_homecity(struct unit *punit)
Send request to change unit homecity to server.
void request_unit_patrol()
Either start new patrol route planning, or add waypoint to current one.
void key_unit_transform()
Handle user 'transform unit' input.
void request_unit_move_done()
Set focus units to FOCUS_DONE state.
void request_toggle_map_native()
Toggle display of native tiles on the map.
void key_unit_unload_all()
Handle user 'unload all' input.
void request_unit_unload(struct unit *pcargo)
Send a request to the server that the cargo be unloaded from its current transporter.
void key_unit_sentry()
Handle user 'sentry' input.
static auto current_focus
static void client_disband_unit_data_destroy(void *p)
Destroy the client disband unit data.
void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent)
Call to request (from the server) that the unit is put under the control of the specified server side...
void request_action_details(action_id action, int actor_id, int target_id)
Request data for follow up questions about an action the unit can perform.
static struct unit * quickselect(struct tile *ptile, enum quickselect_type qtype)
Quickselecting a unit is normally done with [control] left, right click, for the current tile.
void request_unit_paradrop(const std::vector< unit * > &units)
Have the player select what tile to paradrop to.
enum unit_activity connect_activity
void request_toggle_city_growth()
Toggle display of city growth (turns-to-grow)
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Send request for unit activity changing to server.
void key_city_productions_toggle()
Handle user 'toggle city production display' input.
void set_auto_center_enabled(bool enabled)
Allows disabling automatic map recentering.
void request_unit_build_city(struct unit *punit)
Player pressed 'b' or otherwise instructed unit to build or add to city.
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Change the battlegroup for this unit.
void key_unit_auto_explore()
Handle user 'autoexplore' input.
static struct unit_list * urgent_focus_queue
void key_map_grid_toggle()
Handle user 'toggle map grid' input.
void key_cancel_action()
The 'Escape' key.
void key_city_buycost_toggle()
Toggles the showing of the buy cost of the current production in the city descriptions.
void key_unit_convert()
Unit convert key pressed or respective menu entry selected.
void control_free()
Called only by client_game_free() in client/client_main.c.
void key_unit_move(enum direction8 gui_dir)
Move the focus unit in the given direction.
static int disband_unit_alternatives[3]
void request_unit_select(const std::vector< unit * > &punits, enum unit_select_type_mode seltype, enum unit_select_location_mode selloc)
Select all units based on the given list of units and the selection modes.
void key_unit_action_select()
Handle user 'Do...' input.
int get_num_units_in_focus()
Return the number of units currently in focus (0 or more).
void key_recall_previous_focus_unit()
Recall the previous focus unit(s).
void request_center_focus_unit()
Center to focus unit.
void key_unit_patrol()
Handle user 'patrol' input.
void key_city_output_toggle()
Toggle drawing of city output produced by workers of the city.
int blink_turn_done_button()
Blink the turn done button (if necessary).
void request_unit_sentry(struct unit *punit)
Try to sentry unit.
static struct unit * punit_defending
static bool can_units_attack_at(const std::vector< unit * > &units, const struct tile *ptile)
Return TRUE if at least one of the units can do an attack at the tile.
void key_unit_fortify()
Handle user 'fortify' input.
enum cursor_hover_state hover_state
void request_unit_connect(enum unit_activity activity, struct extra_type *tgt)
Prompt player for entering destination point for unit connect (e.g.
void clear_unit_orders(struct unit *punit)
Clear all orders for the given unit.
static void key_unit_clean(enum unit_activity act, enum extra_rmcause rmcause)
Handle user extra cleaning input of given type.
void key_unit_cultivate()
Handle user 'cultivate' input.
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.
void do_unit_connect(struct tile *ptile, enum unit_activity activity, struct extra_type *tgt)
"Connect" to the given location.
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Return TRUE iff a unit on this tile is in focus.
void key_end_turn()
Handle user 'end turn' input.
void do_unit_patrol_to(struct tile *ptile)
Patrol to a location.
void request_toggle_city_buycost()
Toggle display of city buycost.
void finish_city(struct tile *ptile, const char *name)
All units ready to build city to the tile should now proceed.
static struct unit * punit_moving
static bool is_activity_on_tile(struct tile *ptile, enum unit_activity activity)
Return TRUE if there are any units doing the activity on the tile.
static bool can_be_irrigated(const struct tile *ptile, const struct unit *punit)
Can tile be irrigated by given unit? Unit can be nullptr to check if any settler type unit of any pla...
void key_city_outlines_toggle()
Toggle drawing of city outlines.
void set_hover_state(const std::vector< unit * > &units, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Enter the given hover state.
static struct unit_list * battlegroups[MAX_NUM_BATTLEGROUPS]
void unit_focus_advance()
This function may be called from packhand.c, via unit_focus_update(), as a result of packets indicati...
void key_unit_action_select_tgt()
Have the user select what action the unit(s) in focus should perform to the targets at the tile the u...
void request_move_unit_direction(struct unit *punit, int dir)
This function is called whenever the player pressed an arrow key.
static void current_focus_append(struct unit *punit)
Add unit to list of units currently in focus.
void request_toggle_city_outlines()
Toggle display of city outlines on the map.
static struct tile * find_a_focus_unit_tile_to_center_on()
Finds a single focus unit that we can center on.
static struct tile * hover_tile
void unit_focus_set_and_select(struct unit *punit)
The only difference is that here we draw the "cross".
void request_unit_convert(struct unit *punit)
Sends unit convert packet.
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 request_units_return()
Return-and-recover for a particular unit.
static void focus_units_changed()
Do various updates required when the set of units in focus changes.
void control_mouse_cursor(struct tile *ptile)
Determines which mouse cursor should be used, according to hover_state, and the information gathered ...
void request_toggle_map_borders()
Toggle display of national borders on the map.
void wakeup_sentried_units(struct tile *ptile)
Wakes all owned sentried units on tile.
void auto_center_on_focus_unit()
Center on the focus unit, if off-screen and auto_center_on_unit is true.
void key_unit_pillage()
Handle user 'pillage' input.
void key_unit_fortress()
Handle user 'build base of class fortress' input.
static void store_previous_focus()
Store the focus unit(s).
void request_unit_upgrade(struct unit *punit)
Send request to upgrade unit to server.
void control_unit_killed(struct unit *punit)
Called when a unit is killed; this removes it from the control lists.
void request_toggle_city_names()
Toggle display of city names.
void cancel_city(struct tile *ptile)
Do not build city after all.
static void ask_server_for_actions(struct unit *punit)
Ask the server about what actions punit may be able to perform against it's stored target tile.
struct unit * head_of_units_in_focus()
Return head of focus units list.
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Send request for unit activity changing to server.
static struct unit * find_best_focus_candidate(bool accept_current)
Find the nearest available unit for focus, excluding any current unit in focus unless "accept_current...
action_id goto_last_action
void key_map_borders_toggle()
Toggle map borders on the mapview on/off based on a keypress.
void do_unit_goto(struct tile *ptile)
Finish the goto mode and let the units stored in goto_map_list move to a given location.
void key_city_growth_toggle()
Toggles the "show city growth turns" option by passing off the request to another function....
void action_selection_next_in_focus(const int old_actor_id)
Move on to the next unit in focus that needs an action decision.
void key_unit_airbase()
Handle user 'build base of class airbase' input.
int blink_active_unit()
Blink the active unit (if necessary).
unit_select_location_mode
int action_selection_actor_unit(void)
Returns the id of the actor unit currently handled in action selection dialog when the action selecti...
void unit_select_dialog_popup(struct tile *ptile)
Popup a dialog window to select units on a particular tile.
void action_selection_close(void)
Closes the action selection dialog.
void action_selection_no_longer_in_progress_gui_specific(int actor_id)
Let the non shared client code know that the action selection process no longer is in progress for th...
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Popup a dialog asking the unit which improvement they would like to pillage.
bool request_transport(struct unit *pcargo, struct tile *ptile)
Unit wants to get into some transport on given tile.
#define IDENTITY_NUMBER_ZERO
const struct ft_color ftc_client
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.
bool goto_pop_waypoint()
Returns whether there were any waypoint popped (we don't remove the initial position)
void send_patrol_route()
Send the current patrol route (i.e., the one generated via HOVER_STATE) to the server.
void enter_goto_state(const std::vector< unit * > &units)
Enter the goto state: activate, prepare PF-template and add the initial part.
bool goto_is_active()
Is goto state active?
void send_goto_route()
Send the current goto route (i.e., the one generated via HOVER_STATE) to the server.
void goto_add_waypoint()
Inserts a waypoint at the end of the current goto line.
bool is_valid_goto_draw_line(struct tile *dest_tile)
Puts a line to dest_tile on the map according to the current goto_map.
bool can_unit_move_now(const struct unit *punit)
Returns if unit can move now.
void send_connect_route(enum unit_activity activity, struct extra_type *tgt)
Send the current connect route (i.e., the one generated via HOVER_STATE) to the server.
void goto_unit_killed(struct unit *punit)
Called from control_unit_killed() in client/control.c.
bool is_valid_goto_destination(const struct tile *ptile)
Determines if a goto to the destination tile is allowed.
void exit_goto_state()
Tidy up and deactivate goto state.
void request_orders_cleared(struct unit *punit)
Send a packet to the server to request that the current orders be cleared.
void free_client_goto()
Called above, and by control_done() in client/control.c.
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Check whether city is under governor control, and fill parameter if it is.
void real_focus_units_changed()
Called when the set of units in focus (get_units_in_focus()) changes.
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
int get_direction_for_step(const struct civ_map *nmap, const struct tile *start_tile, const struct tile *end_tile)
Return the direction which is needed for a step on the map from (start_x, start_y) to (end_x,...
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
Are two tiles adjacent to each other.
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...
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Topology function to find the vector which has the minimum "real" distance between the map positions ...
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Step from the given tile in the given direction.
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
#define iterate_outward_end
struct city * city_workers_display
bool keyboardless_goto_button_down
bool keyboardless_goto_active
struct tile * keyboardless_goto_start_tile
void create_line_at_mouse_pos()
Draw a goto or patrol line at the current mouse position.
void debug_tile(tile *t)
Callback to set the tile being debugged.
void update_turn_done_button(bool do_restore)
If do_restore is false it should change the turn button style (to draw the user's attention to it).
void put_cross_overlay_tile(struct tile *ptile)
Draw a cross-hair overlay on a tile.
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 update_mouse_cursor(enum cursor_type new_cursor_type)
Update the mouse cursor.
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "exist" at this location.
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "survive" at this location.
const struct option_set * server_optset
client_options * gui_options
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Returns the option corresponding of the name in this option set.
bool option_bool_get(const struct option *poption)
Returns the current value of this boolean option.
pageGame * queen()
Return game instandce.
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 city * player_primary_capital(const struct player *pplayer)
Locate the player's primary capital city, (nullptr Otherwise)
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.
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
bool are_reqs_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement_vector *reqs, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement(s) to see if they are active on the given target.
bool player_can_build_road(const struct road_type *proad, const struct player *pplayer, const struct tile *ptile)
Tells if player can build road to tile with suitable unit.
bool can_build_road(struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Tells if unit can build road on tile.
struct city::@15::@18 client
enum capital_type capital
struct packet_game_info info
bool enable_cursor_changes
bool draw_city_productions
int smooth_move_unit_msec
bool auto_center_on_automated
bool draw_city_trade_routes
bool unit_selection_clears_orders
bool popup_last_move_to_allied
struct connection::@55::@60 client
The base class for options.
struct player::@65::@68 client
struct terrain * irrigation_result
enum action_decision action_decision_want
enum unit_activity activity
struct unit::@76::@78 client
struct tile * action_decision_tile
enum server_side_agent ssa_controller
struct extra_type * get_preferred_pillage(bv_extras extras)
Returns the highest-priority (best) extra to be pillaged from the terrain set.
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Time to complete the extra building activity on the given terrain.
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Adds extra to tile.
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
Returns TRUE if the given tile has a road of given type on it.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
int get_focus_unit_toggle_timeout(const struct tileset *t)
Return the amount of time between calls to toggle_focus_unit_state.
void toggle_focus_unit_state(struct tileset *t)
Toggle/increment the focus unit state.
void focus_unit_in_combat(struct tileset *t)
Setup tileset for showing combat where focus unit participates.
const struct unit_type * utype
int get_transporter_occupancy(const struct unit *ptrans)
Return how many units are in the transport.
struct unit * transporter_for_unit(const struct unit *pcargo)
Find the best transporter at the given location for the unit.
bool can_unit_paradrop(const struct unit *punit)
Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airb...
struct unit * is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non-allied unit on this tile?
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool is_military_unit(const struct unit *punit)
Military units are capable of enforcing martial law.
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Return TRUE iff the given unit could be loaded into the transporter if we moved there.
bool can_unit_do_autosettlers(const struct unit *punit)
Return whether the unit can be put in auto-settler mode.
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlle...
bool can_unit_do_activity_targeted(const struct unit *punit, enum unit_activity activity, struct extra_type *target)
Return whether the unit can do the targeted activity at its current location.
int get_transporter_capacity(const struct unit *punit)
Return the number of units the transporter can hold (or 0).
bool can_unit_do_activity(const struct unit *punit, enum unit_activity activity)
Return TRUE iff the unit can do the given untargeted activity at its current location.
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.
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Return TRUE iff the given unit can be unloaded from its current transporter.
bool unit_has_orders(const struct unit *punit)
Return TRUE iff the unit is following client-side orders.
#define MAX_NUM_BATTLEGROUPS
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_both_iterate_end
#define unit_list_both_iterate(unitlist, plink, punit)
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Return move type of the unit type.
bool utype_may_act_at_all(const struct unit_type *putype)
Return TRUE iff units of this type can do actions controlled by generalized (ruleset defined) action ...
bool role_units_translations(QString &astr, int flag, bool alts)
Return a string with all the names of units with this flag.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
const char * unit_name_translation(const struct unit *punit)
Return the (translated) name of the unit.
struct tile * get_center_tile_mapcanvas()
Finds the current center tile of the mapcanvas.
void move_unit_map_canvas(struct unit *punit, struct tile *src_tile, int dx, int dy)
Animates punit's "smooth" move from (x0, y0) to (x0+dx, y0+dy).
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.
bool tile_visible_and_not_on_border_mapcanvas(struct tile *ptile)
Return TRUE iff the given map position has a tile visible within the interior of the map canvas.
void update_map_canvas_visible()
Schedules an update of (only) the visible part of the map at the next unqueue_mapview_update().