2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2016, 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 * tran.c: Transport nuclear devices and planes
29 * Known contributors to this file:
31 * Markus Armbruster, 2006-2011
41 static int tran_pmap(coord, coord, char *, char *);
42 static int tran_nmap(coord, coord, char *, char *);
43 static int tran_nuke(void);
44 static int tran_plane(void);
52 what = getstarg(player->argp[1], "transport what (nuke or plane): ",
58 else if (*what == 'p')
71 struct nstr_item nstr;
74 struct sctstr endsect;
78 if (!snxtitem(&nstr, EF_NUKE, player->argp[2], NULL))
80 while (nxtitem(&nstr, &nuke)) {
84 if (nuke.nuk_plane >= 0) {
85 pr("%s is armed and can't be transported\n", prnuke(&nuke));
92 if (nuke.nuk_x != srcx || nuke.nuk_y != srcy) {
93 pr("All nukes must be in the same sector.\n");
97 weight += nchr[type].n_weight;
104 if (!getsect(srcx, srcy, §) || !player->owner) {
105 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
108 if (!military_control(§)) {
109 pr("Military control required to move nukes.\n");
113 mcost = move_ground(§, &endsect, weight,
114 player->argp[3], tran_nmap, 0, &dam);
118 dstx = endsect.sct_x;
119 dsty = endsect.sct_y;
120 snxtitem_rewind(&nstr);
121 while (nxtitem(&nstr, &nuke)) {
127 nuke.nuk_mission = 0;
128 putnuke(nuke.nuk_uid, &nuke);
131 pr("Total movement cost = %d\n", mcost);
133 pr("No mobility used\n");
134 getsect(srcx, srcy, §);
135 if (sect.sct_mobil >= mcost)
136 sect.sct_mobil -= mcost;
151 struct nstr_item nstr;
154 struct sctstr endsect;
158 if (!snxtitem(&nstr, EF_PLANE, player->argp[2], NULL))
161 * First do some sanity checks: make sure that they are all in the,
162 * same sector, not on ships, owned, etc.
163 * No one could seriously want to move planes in parallel from
166 while (nxtitem(&nstr, &plane)) {
169 type = plane.pln_type;
170 if (plane.pln_ship >= 0) {
171 pr("%s is stowed on ship #%d, and can't be transported\n",
172 prplane(&plane), plane.pln_ship);
174 } else if (plane.pln_land >= 0) {
175 pr("%s is stowed on land #%d, and can't be transported\n",
176 prplane(&plane), plane.pln_land);
178 } else if (plane.pln_harden != 0) {
179 pr("%s has been hardened and can't be transported\n",
182 } else if (pln_is_in_orbit(&plane)) {
183 pr("%s is in space and can't be transported\n",
191 if (plane.pln_x != srcx || plane.pln_y != srcy) {
192 pr("All planes must be in the same sector.\n");
196 weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
203 if (!getsect(srcx, srcy, §) || !player->owner) {
204 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
207 if (!military_control(§)) {
208 pr("Military control required to move planes.\n");
212 mcost = move_ground(§, &endsect, weight,
213 player->argp[3], tran_pmap, 0, &dam);
218 dstx = endsect.sct_x;
219 dsty = endsect.sct_y;
220 snxtitem_rewind(&nstr);
221 while (nxtitem(&nstr, &plane)) {
225 planedamage(&plane, dam);
228 plane.pln_mission = 0;
229 putplane(plane.pln_uid, &plane);
232 pr("Total movement cost = %d\n", mcost);
234 pr("No mobility used\n");
235 getsect(srcx, srcy, §);
236 if (sect.sct_mobil >= mcost)
237 sect.sct_mobil -= mcost;
245 * Pretty tacky, but it works.
246 * If more commands start doing this, then
247 * rewrite map to do the right thing.
251 tran_pmap(coord curx, coord cury, char *arg1, char *arg2)
253 return display_region_map(0, EF_PLANE, curx, cury, arg1, arg2);
257 tran_nmap(coord curx, coord cury, char *arg1, char *arg2)
259 return display_region_map(0, EF_NUKE, curx, cury, arg1, arg2);