Freeciv-3.3
|
#include <string.h>
#include "log.h"
#include "mem.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "packets.h"
#include "pf_tools.h"
#include "road.h"
#include "unit.h"
#include "unitlist.h"
#include "client_main.h"
#include "control.h"
#include "mapview_g.h"
#include "goto.h"
#include "mapctrl_common.h"
#include "speclist.h"
Go to the source code of this file.
Data Structures | |
struct | part |
struct | goto_map |
Variables | |
static struct goto_map_list * | goto_maps = nullptr |
static bool | goto_warned = FALSE |
static struct tile * | goto_destination = nullptr |
#define goto_map_list_iterate_end LIST_ITERATE_END |
#define goto_map_unit_iterate_end } goto_map_list_iterate_end; |
Add a part. Depending on the num of already existing parts the start of the new part is either the unit position (for the first part) or the destination of the last part (not the first part).
Definition at line 439 of file goto.c.
Referenced by enter_goto_state(), and goto_add_waypoint().
Enter the goto state: activate, prepare PF-template and add the initial part.
Definition at line 1011 of file goto.c.
Referenced by patrol_here_callback(), request_unit_connect(), request_unit_goto(), request_unit_patrol(), and mr_menu::slot_delayed_goto().
Tidy up and deactivate goto state.
Definition at line 1033 of file goto.c.
Referenced by paradrop_here_callback(), patrol_here_callback(), set_hover_state(), and map_view::shortcut_pressed().
|
static |
Fill pathfinding parameter for adding a new part.
Definition at line 408 of file goto.c.
Referenced by add_part(), and update_last_part().
Called above, and by control_done() in client/control.c.
Definition at line 163 of file goto.c.
Referenced by control_free(), and init_client_goto().
Return the number of MP needed to do the connect activity at this position. A negative number means it's impossible.
Definition at line 620 of file goto.c.
Referenced by get_connect_irrig(), get_connect_road(), goto_fill_parameter_full(), goto_get_turns(), and goto_tile_state().
|
static |
PF jumbo callback for the cost of a connect by irrigation. Here we are only interested in how long it will take to irrigate the path.
param->data should contain the result of get_activity_rate(punit) / 10.
Definition at line 808 of file goto.c.
Referenced by goto_fill_parameter_full().
|
static |
PF jumbo callback for the cost of a connect by road. In road-connect mode we are concerned with (1) the number of steps of the resulting path (2) (the tie-breaker) time to build the path (travel plus activity time). In rail-connect the priorities are reversed.
param->data should contain the result of get_activity_rate(punit).
Definition at line 698 of file goto.c.
Referenced by goto_fill_parameter_full().
|
static |
PF callback to get the path with the minimal number of steps (out of all shortest paths).
Definition at line 561 of file goto.c.
Referenced by goto_fill_parameter_base().
|
static |
PF callback to prohibit going into the unknown. Also makes sure we don't plan our route through enemy city/tile.
Definition at line 571 of file goto.c.
Referenced by goto_fill_parameter_base().
|
static |
PF callback for caravans. Caravans doesn't go into the unknown and don't attack enemy units but enter enemy cities.
Definition at line 593 of file goto.c.
Referenced by goto_fill_parameter_base().
Inserts a waypoint at the end of the current goto line.
Definition at line 489 of file goto.c.
Referenced by request_unit_connect(), request_unit_goto(), and request_unit_patrol().
|
static |
Fill the PF parameter with the correct client-goto values. See also goto_fill_parameter_full().
Definition at line 898 of file goto.c.
Referenced by goto_fill_parameter_full(), path_to_nearest_allied_city(), send_attack_tile(), send_goto_tile(), send_rally_tile(), and tile_before_end_path().
|
static |
Fill the PF parameter with the correct client-goto values. The storage behind "connect_speed" must remain valid for the lifetime of the pf_map.
Note that you must call this function only if the 'hover_state' is set, and we are in goto mode (usually, this function is only called from enter_goto_state()).
See also goto_fill_parameter_base().
Definition at line 931 of file goto.c.
Referenced by enter_goto_state().
Return the path length (in turns). WARNING: not useful for determining paths of scattered groups.
Definition at line 1079 of file goto.c.
Referenced by get_unit_info_label_text2().
Is goto state active?
Definition at line 1070 of file goto.c.
Referenced by do_unit_goto(), enter_goto_state(), exit_goto_state(), fill_sprite_array(), goto_add_waypoint(), goto_fill_parameter_full(), goto_get_turns(), goto_pop_waypoint(), goto_tile_state(), goto_unit_killed(), is_valid_goto_draw_line(), request_unit_connect(), request_unit_goto(), request_unit_patrol(), send_connect_route(), send_goto_route(), send_patrol_route(), map_view::shortcut_pressed(), map_view::shortcut_released(), and unit_actions::update_actions().
Free an existing goto map.
Definition at line 122 of file goto.c.
Referenced by exit_goto_state(), free_client_goto(), and goto_unit_killed().
Returns the unit associated with the goto map.
Definition at line 139 of file goto.c.
Referenced by add_part(), and fill_parameter_part().
Returns whether there were any waypoint popped (we don't remove the initial position)
Definition at line 528 of file goto.c.
Referenced by key_cancel_action().
bool goto_tile_state | ( | const struct tile * | ptile, |
enum goto_tile_state * | state, | ||
int * | turns, | ||
bool * | waypoint | ||
) |
Called from control_unit_killed() in client/control.c
Definition at line 1051 of file goto.c.
Referenced by control_unit_killed().
Called only by handle_map_info() in client/packhand.c.
Definition at line 153 of file goto.c.
Referenced by handle_map_info().
|
static |
When building a road or a railroad, we don't want to go next to nonallied cities
Definition at line 677 of file goto.c.
Referenced by get_connect_irrig(), and get_connect_road().
Determines if a goto to the destination tile is allowed.
Definition at line 180 of file goto.c.
Referenced by control_mouse_cursor().
Puts a line to dest_tile on the map according to the current goto_map. If there is no route to the dest then don't draw anything.
Definition at line 1350 of file goto.c.
Referenced by do_unit_connect(), do_unit_goto(), do_unit_patrol_to(), overview_update_line(), and update_line().
|
static |
Creates orders for a path as a goto or patrol route.
Definition at line 1399 of file goto.c.
Referenced by send_path_orders(), and send_rally_path_orders().
|
static |
PF callback to prohibit going into the unknown (conditionally). Also makes sure we don't plan to attack anyone.
Definition at line 882 of file goto.c.
Referenced by goto_fill_parameter_base().
|
static |
Returns TRUE if it is certain that the order must be performed from an adjacent tile.
Definition at line 1869 of file goto.c.
Referenced by send_goto_route().
|
static |
Fill orders to build recursive roads.
Definition at line 1694 of file goto.c.
Referenced by order_recursive_roads(), and send_connect_route().
|
static |
Returns TRUE if the order preferably should be performed from an adjacent tile.
This function doesn't care if a direction is required or just possible. Use order_demands_direction() for that.
Definition at line 1820 of file goto.c.
Referenced by send_goto_route().
Find the path to the nearest (fastest to reach) allied city for the unit, or nullptr if none is reachable.
Definition at line 2007 of file goto.c.
Referenced by request_unit_return().
Remove the last part, erasing the corresponding path segment.
Definition at line 471 of file goto.c.
Referenced by goto_map_free(), and goto_pop_waypoint().
Send a packet to the server to request that the current orders be cleared.
Definition at line 1377 of file goto.c.
Referenced by clear_unit_orders().
Change the drawn path to a size of 0 steps by setting it to the start position.
Definition at line 395 of file goto.c.
Referenced by remove_last_part(), and update_last_part().
Send orders for the unit to move it to the arbitrary tile and attack everything it approaches. Returns FALSE if no path is found.
Definition at line 1639 of file goto.c.
Referenced by mr_menu::slot_execute_orders().
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.
Definition at line 1733 of file goto.c.
Referenced by do_unit_connect().
Send an arbitrary goto path for the unit to the server.
Definition at line 1548 of file goto.c.
Referenced by request_unit_return(), send_goto_route(), and send_goto_tile().
Send the current goto route (i.e., the one generated via HOVER_STATE) to the server. The route might involve more than one part, if waypoints were used. FIXME: danger paths are not supported.
Definition at line 1894 of file goto.c.
Referenced by do_unit_goto(), and key_unit_action_select_tgt().
Send orders for the unit to move it to the arbitrary tile. Returns FALSE if no path is found.
Definition at line 1569 of file goto.c.
Referenced by goto_dialog::go_to_city(), goto_city_callback(), goto_cmd_callback(), goto_here_callback(), and mr_menu::slot_autocaravan().
|
static |
Send a path as a goto or patrol route to the server.
Definition at line 1492 of file goto.c.
Referenced by send_attack_tile(), send_goto_path(), and send_patrol_route().
Send the current patrol route (i.e., the one generated via HOVER_STATE) to the server.
Definition at line 1666 of file goto.c.
Referenced by do_unit_patrol_to().
|
static |
Send an arbitrary rally path for the city to the server.
Definition at line 1557 of file goto.c.
Referenced by send_rally_tile().
|
static |
Send a path as a goto or patrol rally orders to the server.
Definition at line 1523 of file goto.c.
Referenced by send_rally_path().
Send rally orders for the city to move new units to the arbitrary tile. Returns FALSE if no path is found for the currently produced unit type.
Definition at line 1593 of file goto.c.
Referenced by rally_set_tile(), and map_view::shortcut_pressed().
Finds penultimate tile on path for given unit going to ptile
Definition at line 2036 of file goto.c.
Referenced by mr_menu::find_last_unit_pos().
Change the destination of the last part to the given location. If a path cannot be found, the destination is set to the start. Return TRUE when the new path is valid.
Definition at line 259 of file goto.c.
Referenced by goto_pop_waypoint(), is_valid_goto_draw_line(), and reset_last_part().
Definition at line 103 of file goto.c.
Referenced by exit_goto_state(), free_client_goto(), goto_add_waypoint(), goto_get_turns(), goto_tile_state(), is_valid_goto_destination(), and is_valid_goto_draw_line().
|
static |
Definition at line 91 of file goto.c.
Referenced by enter_goto_state(), exit_goto_state(), free_client_goto(), goto_add_waypoint(), goto_get_turns(), goto_is_active(), goto_pop_waypoint(), goto_tile_state(), goto_unit_killed(), init_client_goto(), is_valid_goto_draw_line(), send_connect_route(), send_goto_route(), and send_patrol_route().
Definition at line 92 of file goto.c.
Referenced by enter_goto_state(), exit_goto_state(), free_client_goto(), and update_last_part().