]> git.pond.sub.org Git - empserver/blob - src/lib/commands/show.c
Import of Empire 4.2.12
[empserver] / src / lib / commands / show.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, 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  *  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 "misc.h"
36 #include "player.h"
37 #include "nat.h"
38 #include "file.h"
39 #include "deity.h"
40 #include "optlist.h"
41 #include "subs.h"
42 #include "commands.h"
43
44 int
45 show(void)
46 {
47         s_char   *p;
48         void     (*cfunc)(int);
49         void     (*sfunc)(int);
50         void     (*bfunc)(int);
51         struct  natstr *natp;
52         int     tlev;
53         s_char  buf[1024];
54         extern  float drnuke_const;
55         int     rlev;
56
57         if (!(p = getstarg(player->argp[1], "Describe what (plane, nuke, bridge, ship, sect, land unit, tower)? ", buf)) || !*p)
58                 return RET_SYN;
59
60         natp = getnatp (player->cnum);
61         rlev = (int) (1.25 * natp->nat_level[NAT_RLEV]);
62
63         if (!player->argp[3]) {
64             tlev = (int) (1.25 * natp->nat_level[NAT_TLEV]);
65             if (player->god)
66                 tlev = 1000;
67         } else {
68             tlev = (int)atoi(player->argp[3]);
69             if (tlev > (int)(1.25 * natp->nat_level[NAT_TLEV]) && !player->god)
70                 tlev = (int) (1.25 * natp->nat_level[NAT_TLEV]);
71         }
72         if (player->god)
73             rlev = 1000;
74         pr("Printing for tech level '%d'\n", tlev);
75         switch (*p) {
76         case 'b':
77                 show_bridge(99999);
78                 return RET_OK;
79         case 't':
80                 show_tower(99999);
81                 return RET_OK;
82         case 'n':
83                 if (opt_DRNUKE)
84                         tlev = ((rlev/drnuke_const) > tlev ? tlev :
85                                 (rlev/drnuke_const));
86                 bfunc = show_nuke_build;
87                 cfunc = show_nuke_capab;
88                 sfunc = show_nuke_stats;
89                 break;
90         case 'l':
91                 bfunc = show_land_build;
92                 sfunc = show_land_stats;
93                 cfunc = show_land_capab;
94                 break;
95         case 'p':
96                 bfunc = show_plane_build;
97                 sfunc = show_plane_stats;
98                 cfunc = show_plane_capab;
99                 break;
100         case 's':
101                 if (*(p+1) == 'e'){
102                         bfunc = show_sect_build;
103                         sfunc = show_sect_stats;
104                         cfunc = show_sect_capab;
105                 }else{
106                         bfunc = show_ship_build;
107                         sfunc = show_ship_stats;
108                         cfunc = show_ship_capab;
109                 }
110                 break;
111         default:
112                 return RET_SYN;
113         }
114         if (!(p = getstarg(player->argp[2], "Build, stats, or capability data (b,s,c)? ", buf)) || !*p)
115                 return RET_SYN;
116         if (*p == 'B' || *p == 'b')
117                 (*bfunc) (tlev);
118         else if (*p == 'C' || *p == 'c')
119                 (*cfunc) (tlev);
120         else if (*p == 'S' || *p == 's')
121                 (*sfunc) (tlev);
122         return RET_OK;
123 }