2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2005, 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:
46 show_sail(struct nstr_item *nstr)
51 while (nxtitem(nstr, (s_char *)&ship)) {
52 if (!player->owner || ship.shp_own == 0)
54 if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
55 pr("bad ship type %d (#%d)\n", ship.shp_type, nstr->cur);
61 pr("shp# ship type x,y ");
62 pr("mobil mobquota follows path\n");
65 pr("%3d ", ship.shp_own);
66 pr("%4d ", ship.shp_uid);
67 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
68 prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
69 pr("%3d ", ship.shp_mobil);
70 pr(" %3d ", ship.shp_mobquota);
71 pr(" %3d ", ship.shp_follow);
72 if (ship.shp_path[0]) {
74 } else if ((ship.shp_autonav & AN_AUTONAV)) {
79 if (ship.shp_name[0] != 0) {
82 pr(" %s\n", ship.shp_name);
88 pr("%s: No ship(s)\n", player->argp[1]);
90 pr("%s: No ship(s)\n", "");
93 pr("%d ship%s\n", count, splur(count));
98 cmd_unsail_ship(struct nstr_item *nstr)
103 while (nxtitem(nstr, (s_char *)&ship)) {
104 if (!player->owner || ship.shp_own == 0)
106 if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
107 pr("bad ship type %d (#%d)\n", ship.shp_type, nstr->cur);
110 if (ship.shp_path[0]) {
111 pr("Ship #%d unsailed\n", ship.shp_uid);
113 ship.shp_path[0] = 0;
114 putship(ship.shp_uid, &ship);
121 cmd_sail_ship(struct nstr_item *nstr)
125 char navpath[MAX_PATH_LEN];
127 while (!player->aborted && nxtitem(nstr, (s_char *)&ship)) {
128 if (!player->owner || ship.shp_own == 0)
130 if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
131 pr("bad ship type %d (#%d)\n", ship.shp_type, nstr->cur);
134 if ((ship.shp_autonav & AN_AUTONAV) &&
135 !(ship.shp_autonav & AN_STANDBY)) {
136 pr("Ship #%d has other orders!\n", ship.shp_uid);
140 pr("Ship #%d at %s\n", ship.shp_uid,
141 xyas(ship.shp_x, ship.shp_y, ship.shp_own));
142 cp = getpath(navpath, player->argp[2],
143 ship.shp_x, ship.shp_y, 0, 0, 0, P_SAILING);
144 if (!check_ship_ok(&ship))
146 if (!player->aborted) {
147 strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2);
148 ship.shp_mission = 0;
149 putship(ship.shp_uid, &ship);
159 struct nstr_item nstr;
162 pr("The SAIL option is not enabled, so this command is not valid.\n");
165 if (!snxtitem(&nstr, EF_SHIP, player->argp[1]))
167 cp = player->argp[2];
168 if ((*player->argp[0] == 'q') /*qsail command */ ||(cp && *cp == 'q')) {
169 return (show_sail(&nstr));
170 } else if (*player->argp[0] == 'u' /*unsail command */
171 || (cp && *cp == '-')) {
172 return (cmd_unsail_ship(&nstr));
174 return (cmd_sail_ship(&nstr));