Author: sveinung Date: Wed Dec 30 13:28:38 2015 New Revision: 31264 URL: http://svn.gna.org/viewcvs/freeciv?rev=31264&view=rev Log: client goto: add send_attack_tile().
Add the new function send_attack_tile(). It orders a unit to try to reach a specified tile. The unit will act against anything in its path (because it uses the ORDER_ACTION_MOVE order for all moves). The tile must be reachable the same turn. Dangers and refuel points are ignored. Patch by mir3x <mir3x> See patch #6741 Modified: trunk/client/goto.c trunk/client/goto.h Modified: trunk/client/goto.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/goto.c?rev=31264&r1=31263&r2=31264&view=diff ============================================================================== --- trunk/client/goto.c (original) +++ trunk/client/goto.c Wed Dec 30 13:28:38 2015 @@ -1344,8 +1344,9 @@ Send a path as a goto or patrol route to the server. **************************************************************************/ static void send_path_orders(struct unit *punit, struct pf_path *path, - bool repeat, bool vigilant, - struct unit_order *final_order) + bool repeat, bool vigilant, + enum unit_orders orders, + struct unit_order *final_order) { struct packet_unit_orders p; int i; @@ -1388,7 +1389,7 @@ p.action[i] = ACTION_COUNT; log_goto_packet(" packet[%d] = wait: %d,%d", i, TILE_XY(old_tile)); } else { - p.orders[i] = ORDER_MOVE; + p.orders[i] = orders; p.dir[i] = get_direction_for_step(old_tile, new_tile); p.activity[i] = ACTIVITY_LAST; p.target[i] = EXTRA_NONE; @@ -1445,7 +1446,7 @@ void send_goto_path(struct unit *punit, struct pf_path *path, struct unit_order *final_order) { - send_path_orders(punit, path, FALSE, FALSE, final_order); + send_path_orders(punit, path, FALSE, FALSE, ORDER_MOVE, final_order); } /**************************************************************************** @@ -1472,6 +1473,32 @@ } } +/**************************************************************************** + Send orders for the unit to move it to the arbitrary tile and attack + everything it approaches. Returns FALSE if no path is found. +****************************************************************************/ +bool send_attack_tile(struct unit *punit, struct tile *ptile) +{ + struct pf_parameter parameter; + struct pf_map *pfm; + struct pf_path *path; + + goto_fill_parameter_base(¶meter, punit); + parameter.move_rate = 0; + parameter.is_pos_dangerous = NULL; + parameter.get_moves_left_req = NULL; + pfm = pf_map_new(¶meter); + path = pf_map_path(pfm, ptile); + pf_map_destroy(pfm); + + if (path) { + send_path_orders(punit, path, false, false, ORDER_ACTION_MOVE, NULL); + pf_path_destroy(path); + return TRUE; + } + return FALSE; +} + /************************************************************************** Send the current patrol route (i.e., the one generated via HOVER_STATE) to the server. @@ -1494,7 +1521,7 @@ } path = pf_path_concat(path, goto_map->patrol.return_path); - send_path_orders(punit, path, TRUE, TRUE, NULL); + send_path_orders(punit, path, TRUE, TRUE, ORDER_MOVE, NULL); pf_path_destroy(path); } goto_map_unit_iterate_end; Modified: trunk/client/goto.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/goto.h?rev=31264&r1=31263&r2=31264&view=diff ============================================================================== --- trunk/client/goto.h (original) +++ trunk/client/goto.h Wed Dec 30 13:28:38 2015 @@ -52,6 +52,7 @@ void send_goto_path(struct unit *punit, struct pf_path *path, struct unit_order *last_order); bool send_goto_tile(struct unit *punit, struct tile *ptile); +bool send_attack_tile(struct unit *punit, struct tile *ptile); void send_patrol_route(void); void send_goto_route(void); void send_connect_route(enum unit_activity activity, _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits