]> 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-2005, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  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 "misc.h"
37 #include "player.h"
38 #include "xy.h"
39 #include "plane.h"
40 #include "nsc.h"
41 #include "file.h"
42 #include "nat.h"
43 #include "commands.h"
44 #include "optlist.h"
45
46 int
47 sate(void)
48 {
49     double tech;
50     int pln_uid;
51     struct plnstr plane;
52     int type = EF_BAD;
53
54     if (!player->argp[1] ||
55         !*player->argp[1] ||
56         !isdigit(*player->argp[1]) ||
57         (pln_uid = atoi(player->argp[1])) < 0)
58         return RET_SYN;
59
60     if (!getplane(pln_uid, &plane)) {
61         pr("No such plane\n");
62         return RET_FAIL;
63     }
64
65     if (plane.pln_own != player->cnum && !player->god) {
66         pr("You don't own plane #%d\n", pln_uid);
67         return RET_FAIL;
68     }
69
70     if (!(plane.pln_flags & PLN_LAUNCHED)) {
71         pr("%s isn't in orbit\n", prplane(&plane));
72         return RET_FAIL;
73     }
74     if (plane.pln_mobil < plane_mob_max) {
75         pr("%s doesn't have enough mobility (needs %d)\n",
76            prplane(&plane), plane_mob_max);
77         return RET_FAIL;
78     }
79     if (player->argp[2]) {
80         switch (*player->argp[2]) {
81         case 'l':
82             type = EF_LAND;
83             break;
84         case 's':
85             if (*(player->argp[2] + 1) == 'e')
86                 type = EF_SECTOR;
87             else
88                 type = EF_SHIP;
89             break;
90         default:
91             return RET_SYN;
92         }
93     }
94
95     if (plchr[(int)plane.pln_type].pl_flags & P_S)
96         pr("Satellite Spy Report:\n");
97     else
98         pr("Satellite Map Report:\n");
99     pr("%s at ", prplane(&plane));
100     tech = techfact(plane.pln_tech, 20.0);
101     satmap(plane.pln_x, plane.pln_y, plane.pln_effic,
102            (int)tech, plchr[(int)plane.pln_type].pl_flags, type);
103
104     return RET_OK;
105 }