/********************************************************************** Freeciv - Copyright (C) 2001 - Raimar Falke This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ***********************************************************************/ #ifndef FC__CLIENT_AGENTS_GOTO_AGENT_H #define FC__CLIENT_AGENTS_GOTO_AGENT_H /* * The goto agent computes the optimal path for a goto. * * TODO: * - air units aren't tested * - units won't attack */ /* * Maximal number of steps in a path. */ #define MAX_PATH_LENGTH 100 struct ga_path { /* * Is this path a valid. Is set to 0 if there was no path found. */ short int found_a_valid; /* * Number of positions used in the array "positions". */ short int positions_used; struct ga_position { /* * x, y, turn and remaining_move_points describe a position in * place and time. */ short int x, y, turn, remaining_move_points; short int direction_for_next_position; } positions[MAX_PATH_LENGTH + 1]; }; /* * Takes a "struct ga_path *" and returns the last position as a * "struct ga_position *". */ #define LAST_POSITION(_ppath_) (&((_ppath_)->positions[(_ppath_)->positions_used-1])) /* * Opaque type. */ typedef struct ga_map *ga_map_t; /* * Called once per start of the client. */ void ga_init(void); /* * Returns a map which can be used to query for paths. The origin is * the current position of the unit. */ ga_map_t ga_get_map(int unit_id); /* * Tries to find a path in the given map to the given destination * position. The path will be written in the given struct ga_path. * Caller should test path->found_a_valid. ga_get_path_from_map will * not change anything. */ void ga_get_path_from_map(ga_map_t map, int dest_x, int dest_y, struct ga_path *path); /* * After usage the map should be destroyed. */ void ga_destroy_map(ga_map_t map); /* * ga_get_path is a one shot version. It combines ga_get_map, * ga_get_path_from_map and ga_destroy_map. */ void ga_get_path(int unit_id, int dest_x,int dest_y,struct ga_path *path); /* * Will move the given unit using the given path. */ void ga_apply_path(int unit_id, struct ga_path *path); /* * Revokes ga_apply_path. */ void ga_cancel_action(int unit_id); int ga_is_agent_moving_unit(int unit_id); void ga_print_path(char *msg, struct ga_path *path); void ga_show_report(void); #endif