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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * tran.c: Transport nuclear devices and planes
30 * Known contributors to this file:
32 * Markus Armbruster, 2006
51 static int tran_pmap(coord curx, coord cury, char *arg);
52 static int tran_nmap(coord curx, coord cury, char *arg);
53 static int tran_nuke(void);
54 static int tran_plane(void);
62 what = getstarg(player->argp[1], "transport what (nuke or plane): ",
68 else if (*what == 'p')
81 struct nstr_item nstr;
84 struct sctstr endsect;
88 if (!snxtitem(&nstr, EF_NUKE, player->argp[2]))
90 while (nxtitem(&nstr, &nuke)) {
94 if (nuke.nuk_plane >= 0) {
95 pr("%s is armed and can't be transported\n", prnuke(&nuke));
102 if (nuke.nuk_x != srcx || nuke.nuk_y != srcy) {
103 pr("All nukes must be in the same sector.\n");
107 weight += nchr[type].n_weight;
114 if (!getsect(srcx, srcy, §) || !player->owner) {
115 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
118 if (!military_control(§)) {
119 pr("Military control required to move nukes.\n");
123 mcost = move_ground(§, &endsect, weight,
124 player->argp[3], tran_nmap, 0, &dam);
128 dstx = endsect.sct_x;
129 dsty = endsect.sct_y;
130 snxtitem_rewind(&nstr);
131 while (nxtitem(&nstr, &nuke)) {
137 nuke.nuk_mission = 0;
138 putnuke(nuke.nuk_uid, &nuke);
141 pr("Total movement cost = %d\n", mcost);
143 pr("No mobility used\n");
144 getsect(srcx, srcy, §);
145 sect.sct_mobil -= mcost;
146 if (sect.sct_mobil < 0)
160 struct nstr_item nstr;
163 struct sctstr endsect;
167 if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
170 * First do some sanity checks: make sure that they are all in the,
171 * same sector, not on ships, owned, etc.
172 * No one could seriously want to move planes in parallel from
175 while (nxtitem(&nstr, &plane)) {
178 type = plane.pln_type;
179 if (plane.pln_ship >= 0) {
180 pr("%s is at sea and can't be transported\n", prplane(&plane));
182 } else if (plane.pln_harden != 0) {
183 pr("%s has been hardened and can't be transported\n",
186 } else if ((plane.pln_flags & PLN_LAUNCHED) &&
187 (plchr[type].pl_flags & P_O)) {
188 pr("%s is in space and can't be transported\n",
196 if (plane.pln_x != srcx || plane.pln_y != srcy) {
197 pr("All planes must be in the same sector.\n");
201 weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
208 if (!getsect(srcx, srcy, §) || !player->owner) {
209 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
212 if (!military_control(§)) {
213 pr("Military control required to move planes.\n");
217 mcost = move_ground(§, &endsect, weight,
218 player->argp[3], tran_pmap, 0, &dam);
223 dstx = endsect.sct_x;
224 dsty = endsect.sct_y;
225 snxtitem_rewind(&nstr);
226 while (nxtitem(&nstr, &plane)) {
230 planedamage(&plane, dam);
233 plane.pln_mission = 0;
234 putplane(plane.pln_uid, &plane);
237 pr("Total movement cost = %d\n", mcost);
239 pr("No mobility used\n");
240 getsect(srcx, srcy, §);
241 sect.sct_mobil -= mcost;
242 if (sect.sct_mobil < 0)
249 * Pretty tacky, but it works.
250 * If more commands start doing this, then
251 * rewrite map to do the right thing.
255 tran_pmap(coord curx, coord cury, char *arg)
257 return display_region_map("pmap", curx, cury, arg);
261 tran_nmap(coord curx, coord cury, char *arg)
263 return display_region_map("nmap", curx, cury, arg);