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_map(coord curx, coord cury, char *arg);
52 static int tran_nuke(void);
53 static int tran_plane(void);
61 what = getstarg(player->argp[1], "transport what (nuke or plane): ",
67 else if (*what == 'p')
80 struct nstr_item nstr;
83 struct sctstr endsect;
87 if (!snxtitem(&nstr, EF_NUKE, player->argp[2]))
89 while (nxtitem(&nstr, &nuke)) {
93 if (nuke.nuk_plane >= 0) {
94 pr("%s is armed and can't be transported\n", prnuke(&nuke));
101 if (nuke.nuk_x != srcx || nuke.nuk_y != srcy) {
102 pr("All nukes must be in the same sector.\n");
106 weight += nchr[type].n_weight;
113 if (!getsect(srcx, srcy, §) || !player->owner) {
114 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
117 if (!military_control(§)) {
118 pr("Military control required to move nukes.\n");
122 mcost = move_ground(§, &endsect, weight,
123 player->argp[3], tran_map, 0, &dam);
127 dstx = endsect.sct_x;
128 dsty = endsect.sct_y;
129 snxtitem_rewind(&nstr);
130 while (nxtitem(&nstr, &nuke)) {
136 nuke.nuk_mission = 0;
137 putnuke(nuke.nuk_uid, &nuke);
140 pr("Total movement cost = %d\n", mcost);
142 pr("No mobility used\n");
143 getsect(srcx, srcy, §);
144 sect.sct_mobil -= mcost;
145 if (sect.sct_mobil < 0)
159 struct nstr_item nstr;
162 struct sctstr endsect;
166 if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
169 * First do some sanity checks: make sure that they are all in the,
170 * same sector, not on ships, owned, etc.
171 * No one could seriously want to move planes in parallel from
174 while (nxtitem(&nstr, &plane)) {
177 type = plane.pln_type;
178 if (plane.pln_ship >= 0) {
179 pr("%s is at sea and can't be transported\n", prplane(&plane));
181 } else if (plane.pln_harden != 0) {
182 pr("%s has been hardened and can't be transported\n",
185 } else if ((plane.pln_flags & PLN_LAUNCHED) &&
186 (plchr[type].pl_flags & P_O)) {
187 pr("%s is in space and can't be transported\n",
195 if (plane.pln_x != srcx || plane.pln_y != srcy) {
196 pr("All planes must be in the same sector.\n");
200 weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
207 if (!getsect(srcx, srcy, §) || !player->owner) {
208 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
211 if (!military_control(§)) {
212 pr("Military control required to move planes.\n");
216 mcost = move_ground(§, &endsect, weight,
217 player->argp[3], tran_map, 0, &dam);
222 dstx = endsect.sct_x;
223 dsty = endsect.sct_y;
224 snxtitem_rewind(&nstr);
225 while (nxtitem(&nstr, &plane)) {
229 planedamage(&plane, dam);
232 plane.pln_mission = 0;
233 putplane(plane.pln_uid, &plane);
236 pr("Total movement cost = %d\n", mcost);
238 pr("No mobility used\n");
239 getsect(srcx, srcy, §);
240 sect.sct_mobil -= mcost;
241 if (sect.sct_mobil < 0)
248 * Pretty tacky, but it works.
249 * If more commands start doing this, then
250 * rewrite map to do the right thing.
254 tran_map(coord curx, coord cury, char *arg)
256 player->argp[0] = "map";
257 player->argp[1] = arg;
258 player->argp[2] = NULL;
259 player->condarg = NULL;