2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2014, 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);
67 if (ship.shp_name[0] != 0) {
70 pr(" %s\n", ship.shp_name);
75 pr("%s: No ship(s)\n", player->argp[1]);
77 pr("%s: No ship(s)\n", "");
80 pr("%d ship%s\n", count, splur(count));
85 cmd_unsail_ship(struct nstr_item *nstr)
90 while (nxtitem(nstr, &ship)) {
91 if (!player->owner || ship.shp_own == 0)
93 if (ship.shp_path[0]) {
94 pr("Ship #%d unsailed\n", ship.shp_uid);
97 putship(ship.shp_uid, &ship);
104 cmd_sail_ship(struct nstr_item *nstr)
108 char navpath[MAX_PATH_LEN];
110 while (nxtitem(nstr, &ship)) {
111 if (!player->owner || ship.shp_own == 0)
114 pr("Ship #%d at %s\n", ship.shp_uid,
115 xyas(ship.shp_x, ship.shp_y, player->cnum));
116 cp = getpath(navpath, player->argp[2],
117 ship.shp_x, ship.shp_y, 0, 0, MOB_SAIL);
120 if (!check_ship_ok(&ship))
122 strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 1);
123 ship.shp_mission = 0;
124 putship(ship.shp_uid, &ship);
133 struct nstr_item nstr;
136 pr("The SAIL option is not enabled, so this command is not valid.\n");
139 if (!snxtitem(&nstr, EF_SHIP, player->argp[1], NULL))
141 cp = player->argp[2];
142 if (*player->argp[0] == 'u' || (cp && !strcmp(cp, "-")))
143 return cmd_unsail_ship(&nstr);
144 if (cp && *cp == 'q')
145 return show_sail(&nstr);
146 return cmd_sail_ship(&nstr);