]> git.pond.sub.org Git - empserver/blob - src/lib/commands/show.c
Update copyright notice
[empserver] / src / lib / commands / show.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  *  show.c: Give info on empire objects, planes, boats, nukes, etc.
29  *
30  *  Known contributors to this file:
31  *     Julian Onions, 1988
32  *     Steve McClure, 1997
33  */
34
35 #include <config.h>
36
37 #include "commands.h"
38 #include "nuke.h"
39 #include "optlist.h"
40
41 int
42 show(void)
43 {
44     char *p;
45     void (*cfunc)(int);
46     void (*sfunc)(int);
47     void (*bfunc)(int);
48     struct natstr *natp;
49     int tlev;
50     char buf[1024];
51     int rlev;
52
53 again:
54     p = getstarg(player->argp[1], "Show what ('?' to list options)? ", buf);
55     if (!p || !*p)
56         return RET_SYN;
57     if (*p == '?') {
58         pr("bridge, item, land, news, nuke, plane, sect, ship, product, tower, updates\n");
59         goto again;
60     }
61
62     natp = getnatp(player->cnum);
63     rlev = (int)(1.25 * natp->nat_level[NAT_RLEV]);
64
65     if (!player->argp[3]) {
66         tlev = (int)(1.25 * natp->nat_level[NAT_TLEV]);
67         if (player->god)
68             tlev = 1000;
69     } else {
70         tlev = (int)atoi(player->argp[3]);
71         if (tlev > (int)(1.25 * natp->nat_level[NAT_TLEV]) && !player->god)
72             tlev = (int)(1.25 * natp->nat_level[NAT_TLEV]);
73     }
74     if (player->god)
75         rlev = 1000;
76     switch (*p) {
77     case 'b':
78         show_bridge(99999);
79         return RET_OK;
80     case 't':
81         show_tower(99999);
82         return RET_OK;
83     case 'i':
84         show_item(99999);
85         return RET_OK;
86     case 'n':
87         if (*(p + 1) == 'e') {
88             show_news(99999);
89             return RET_OK;
90         }
91         if (drnuke_const > MIN_DRNUKE_CONST)
92             tlev = ((rlev / drnuke_const) > tlev ? tlev :
93                     (rlev / drnuke_const));
94         bfunc = show_nuke_build;
95         cfunc = show_nuke_capab;
96         sfunc = show_nuke_stats;
97         break;
98     case 'l':
99         bfunc = show_land_build;
100         sfunc = show_land_stats;
101         cfunc = show_land_capab;
102         break;
103     case 'p':
104         if (p[1] == 'r') {
105             show_product(99999);
106             return RET_OK;
107         }
108         bfunc = show_plane_build;
109         sfunc = show_plane_stats;
110         cfunc = show_plane_capab;
111         break;
112     case 's':
113         if (*(p + 1) == 'e') {
114             bfunc = show_sect_build;
115             sfunc = show_sect_stats;
116             cfunc = show_sect_capab;
117         } else {
118             bfunc = show_ship_build;
119             sfunc = show_ship_stats;
120             cfunc = show_ship_capab;
121         }
122         break;
123     case 'u':
124         show_updates(player->argp[2] ? atoi(player->argp[2]) : 8);
125         return RET_OK;
126     default:
127         return RET_SYN;
128     }
129
130     p = getstarg(player->argp[2],
131                  "Build, stats, or capability data (b,s,c)? ", buf);
132     if (!p || !*p)
133         return RET_SYN;
134     pr("Printing for tech level '%d'\n", tlev);
135     if (*p == 'B' || *p == 'b')
136         bfunc(tlev);
137     else if (*p == 'C' || *p == 'c')
138         cfunc(tlev);
139     else if (*p == 'S' || *p == 's')
140         sfunc(tlev);
141     else
142         return RET_SYN;
143     return RET_OK;
144 }