2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * sail.c: Set sail path for leaders
30 * Known contributors to this file:
48 show_sail(struct nstr_item *nstr)
53 while (nxtitem(nstr, &ship)) {
54 if (!player->owner || ship.shp_own == 0)
59 pr("shp# ship type x,y ");
60 pr("mobil mobquota follows path\n");
63 pr("%3d ", ship.shp_own);
64 pr("%4d ", ship.shp_uid);
65 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
66 prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
67 pr("%3d ", ship.shp_mobil);
68 pr(" %3d ", ship.shp_mobquota);
69 pr(" %3d ", ship.shp_follow);
70 if (ship.shp_path[0]) {
72 } else if ((ship.shp_autonav & AN_AUTONAV)) {
76 if (ship.shp_name[0] != 0) {
79 pr(" %s\n", ship.shp_name);
84 pr("%s: No ship(s)\n", player->argp[1]);
86 pr("%s: No ship(s)\n", "");
89 pr("%d ship%s\n", count, splur(count));
94 cmd_unsail_ship(struct nstr_item *nstr)
99 while (nxtitem(nstr, &ship)) {
100 if (!player->owner || ship.shp_own == 0)
102 if (ship.shp_path[0]) {
103 pr("Ship #%d unsailed\n", ship.shp_uid);
105 ship.shp_path[0] = 0;
106 putship(ship.shp_uid, &ship);
113 cmd_sail_ship(struct nstr_item *nstr)
117 char navpath[MAX_PATH_LEN];
119 while (!player->aborted && nxtitem(nstr, &ship)) {
120 if (!player->owner || ship.shp_own == 0)
122 if ((ship.shp_autonav & AN_AUTONAV) &&
123 !(ship.shp_autonav & AN_STANDBY)) {
124 pr("Ship #%d has other orders!\n", ship.shp_uid);
128 pr("Ship #%d at %s\n", ship.shp_uid,
129 xyas(ship.shp_x, ship.shp_y, ship.shp_own));
130 cp = getpath(navpath, player->argp[2],
131 ship.shp_x, ship.shp_y, 0, 0, P_SAILING);
132 if (!check_ship_ok(&ship))
134 if (!player->aborted) {
135 strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2);
136 ship.shp_mission = 0;
137 putship(ship.shp_uid, &ship);
147 struct nstr_item nstr;
150 pr("The SAIL option is not enabled, so this command is not valid.\n");
153 if (!snxtitem(&nstr, EF_SHIP, player->argp[1]))
155 cp = player->argp[2];
156 if ((*player->argp[0] == 'q') /*qsail command */ ||(cp && *cp == 'q')) {
157 return show_sail(&nstr);
158 } else if (*player->argp[0] == 'u' /*unsail command */
159 || (cp && *cp == '-')) {
160 return cmd_unsail_ship(&nstr);
162 return cmd_sail_ship(&nstr);