2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2009, 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-2009
43 static int tran_pmap(coord curx, coord cury, char *arg);
44 static int tran_nmap(coord curx, coord cury, char *arg);
45 static int tran_nuke(void);
46 static int tran_plane(void);
54 what = getstarg(player->argp[1], "transport what (nuke or plane): ",
60 else if (*what == 'p')
73 struct nstr_item nstr;
76 struct sctstr endsect;
80 if (!snxtitem(&nstr, EF_NUKE, player->argp[2], NULL))
82 while (nxtitem(&nstr, &nuke)) {
86 if (nuke.nuk_plane >= 0) {
87 pr("%s is armed and can't be transported\n", prnuke(&nuke));
94 if (nuke.nuk_x != srcx || nuke.nuk_y != srcy) {
95 pr("All nukes must be in the same sector.\n");
99 weight += nchr[type].n_weight;
106 if (!getsect(srcx, srcy, §) || !player->owner) {
107 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
110 if (!military_control(§)) {
111 pr("Military control required to move nukes.\n");
115 mcost = move_ground(§, &endsect, weight,
116 player->argp[3], tran_nmap, 0, &dam);
120 dstx = endsect.sct_x;
121 dsty = endsect.sct_y;
122 snxtitem_rewind(&nstr);
123 while (nxtitem(&nstr, &nuke)) {
129 nuke.nuk_mission = 0;
130 putnuke(nuke.nuk_uid, &nuke);
133 pr("Total movement cost = %d\n", mcost);
135 pr("No mobility used\n");
136 getsect(srcx, srcy, §);
137 if (sect.sct_mobil >= mcost)
138 sect.sct_mobil -= mcost;
153 struct nstr_item nstr;
156 struct sctstr endsect;
160 if (!snxtitem(&nstr, EF_PLANE, player->argp[2], NULL))
163 * First do some sanity checks: make sure that they are all in the,
164 * same sector, not on ships, owned, etc.
165 * No one could seriously want to move planes in parallel from
168 while (nxtitem(&nstr, &plane)) {
171 type = plane.pln_type;
172 if (plane.pln_ship >= 0) {
173 pr("%s is at sea and can't be transported\n", prplane(&plane));
175 } else if (plane.pln_harden != 0) {
176 pr("%s has been hardened and can't be transported\n",
179 } else if (pln_is_in_orbit(&plane)) {
180 pr("%s is in space and can't be transported\n",
188 if (plane.pln_x != srcx || plane.pln_y != srcy) {
189 pr("All planes must be in the same sector.\n");
193 weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
200 if (!getsect(srcx, srcy, §) || !player->owner) {
201 pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
204 if (!military_control(§)) {
205 pr("Military control required to move planes.\n");
209 mcost = move_ground(§, &endsect, weight,
210 player->argp[3], tran_pmap, 0, &dam);
215 dstx = endsect.sct_x;
216 dsty = endsect.sct_y;
217 snxtitem_rewind(&nstr);
218 while (nxtitem(&nstr, &plane)) {
222 planedamage(&plane, dam);
225 plane.pln_mission = 0;
226 putplane(plane.pln_uid, &plane);
229 pr("Total movement cost = %d\n", mcost);
231 pr("No mobility used\n");
232 getsect(srcx, srcy, §);
233 if (sect.sct_mobil >= mcost)
234 sect.sct_mobil -= mcost;
242 * Pretty tacky, but it works.
243 * If more commands start doing this, then
244 * rewrite map to do the right thing.
248 tran_pmap(coord curx, coord cury, char *arg)
250 return display_region_map(0, EF_PLANE, curx, cury, arg);
254 tran_nmap(coord curx, coord cury, char *arg)
256 return display_region_map(0, EF_NUKE, curx, cury, arg);