]> git.pond.sub.org Git - empserver/blob - src/lib/commands/sate.c
Update copyright notice
[empserver] / src / lib / commands / sate.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
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.
10  *
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.
15  *
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
19  *
20  *  ---
21  *
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.
25  *
26  *  ---
27  *
28  *  sate.c: Do satellite maps/reports.
29  *
30  *  Known contributors to this file:
31  *     Edward M. Rynes Esq, 1988
32  *     Ken Stevens, 1995
33  *     Steve McClure, 1998-2000
34  */
35
36 #include <config.h>
37
38 #include <ctype.h>
39 #include "commands.h"
40 #include "optlist.h"
41 #include "plane.h"
42
43 int
44 sate(void)
45 {
46     static int sct_shp_or_lnd[] = { EF_SECTOR, EF_SHIP, EF_LAND, EF_BAD };
47     double tech;
48     int pln_uid;
49     struct plnstr plane;
50     int type = EF_BAD;
51
52     if (!player->argp[1] ||
53         !*player->argp[1] ||
54         !isdigit(*player->argp[1]) ||
55         (pln_uid = atoi(player->argp[1])) < 0)
56         return RET_SYN;
57
58     if (!getplane(pln_uid, &plane)) {
59         pr("No such plane\n");
60         return RET_FAIL;
61     }
62
63     if (plane.pln_own != player->cnum && !player->god) {
64         pr("You don't own plane #%d\n", pln_uid);
65         return RET_FAIL;
66     }
67
68     if (!pln_is_in_orbit(&plane)) {
69         pr("%s isn't in orbit\n", prplane(&plane));
70         return RET_FAIL;
71     }
72     if (plane.pln_mobil < plane_mob_max) {
73         pr("%s doesn't have enough mobility (needs %d)\n",
74            prplane(&plane), plane_mob_max);
75         return RET_FAIL;
76     }
77     if (player->argp[2]) {
78         type = ef_byname_from(player->argp[2], sct_shp_or_lnd);
79         if (type < 0) {
80             return RET_SYN;
81         }
82     }
83
84     if (plchr[(int)plane.pln_type].pl_flags & P_S)
85         pr("Satellite Spy Report:\n");
86     else
87         pr("Satellite Map Report:\n");
88     pr("%s at ", prplane(&plane));
89     tech = techfact(plane.pln_tech, 20.0);
90     satmap(plane.pln_x, plane.pln_y, plane.pln_effic,
91            (int)tech, plchr[(int)plane.pln_type].pl_flags, type);
92
93     return RET_OK;
94 }