2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * sail.c: Set sail path for leaders
29 * Known contributors to this file:
41 show_sail(struct nstr_item *nstr)
46 while (nxtitem(nstr, &ship)) {
47 if (!player->owner || ship.shp_own == 0)
52 pr("shp# ship type x,y ");
53 pr("mobil mobquota follows path\n");
56 pr("%3d ", ship.shp_own);
57 pr("%4d ", ship.shp_uid);
58 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
59 prxy("%4d,%-4d ", ship.shp_x, ship.shp_y);
60 pr("%3d ", ship.shp_mobil);
61 pr(" %3d ", ship.shp_mobquota);
62 pr(" %3d ", ship.shp_follow);
63 if (ship.shp_path[0]) {
64 pr("%s", ship.shp_path);
65 } else if ((ship.shp_autonav & AN_AUTONAV)) {
69 if (ship.shp_name[0] != 0) {
72 pr(" %s\n", ship.shp_name);
77 pr("%s: No ship(s)\n", player->argp[1]);
79 pr("%s: No ship(s)\n", "");
82 pr("%d ship%s\n", count, splur(count));
87 cmd_unsail_ship(struct nstr_item *nstr)
92 while (nxtitem(nstr, &ship)) {
93 if (!player->owner || ship.shp_own == 0)
95 if (ship.shp_path[0]) {
96 pr("Ship #%d unsailed\n", ship.shp_uid);
99 putship(ship.shp_uid, &ship);
106 cmd_sail_ship(struct nstr_item *nstr)
110 char navpath[MAX_PATH_LEN];
112 while (nxtitem(nstr, &ship)) {
113 if (!player->owner || ship.shp_own == 0)
115 if ((ship.shp_autonav & AN_AUTONAV) &&
116 !(ship.shp_autonav & AN_STANDBY)) {
117 pr("Ship #%d has other orders!\n", ship.shp_uid);
121 pr("Ship #%d at %s\n", ship.shp_uid,
122 xyas(ship.shp_x, ship.shp_y, player->cnum));
123 cp = getpath(navpath, player->argp[2],
124 ship.shp_x, ship.shp_y, 0, 0, MOB_SAIL);
127 if (!check_ship_ok(&ship))
129 strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 1);
130 ship.shp_mission = 0;
131 putship(ship.shp_uid, &ship);
140 struct nstr_item nstr;
143 pr("The SAIL option is not enabled, so this command is not valid.\n");
146 if (!snxtitem(&nstr, EF_SHIP, player->argp[1], NULL))
148 cp = player->argp[2];
149 if (*player->argp[0] == 'u' || (cp && !strcmp(cp, "-")))
150 return cmd_unsail_ship(&nstr);
151 if (cp && *cp == 'q')
152 return show_sail(&nstr);
153 return cmd_sail_ship(&nstr);