]> git.pond.sub.org Git - empserver/blob - src/lib/commands/rang.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / commands / rang.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2006, 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  *  rang.c: Edit range of plane/land unit
29  * 
30  *  Known contributors to this file:
31  *     Jeff Bailey
32  */
33
34 #include <config.h>
35
36 #include "misc.h"
37 #include "player.h"
38 #include "plane.h"
39 #include "land.h"
40 #include "nsc.h"
41 #include "file.h"
42 #include "commands.h"
43
44 int
45 range(void)
46 {
47     struct nstr_item np;
48     struct plnstr plane;
49     int i;
50     s_char *p;
51     s_char buf[1024];
52
53     if (!snxtitem(&np, EF_PLANE, player->argp[1]))
54         return RET_SYN;
55     while (nxtitem(&np, &plane)) {
56         if (!player->owner || plane.pln_own == 0)
57             continue;
58         p = getstarg(player->argp[2], "New range? ", buf);
59         if (!check_plane_ok(&plane))
60             return RET_SYN;
61         if (!p || (i = atoi(p)) < 0)
62             continue;
63         plane.pln_range = (plane.pln_range_max < i) ?
64             plane.pln_range_max : i;
65         pr("Plane %d range changed to %d\n", plane.pln_uid,
66            plane.pln_range);
67
68         putplane(plane.pln_uid, &plane);
69     }
70
71     return RET_OK;
72 }
73
74 int
75 lrange(void)
76 {
77     struct nstr_item np;
78     struct lndstr land;
79     struct lchrstr *lcp;
80     int i;
81     char *p;
82     char prompt[128];
83     char buf[1024];
84
85     if (!snxtitem(&np, EF_LAND, player->argp[1]))
86         return RET_SYN;
87     while (nxtitem(&np, &land)) {
88         if (!player->owner || land.lnd_own == 0)
89             continue;
90         lcp = &lchr[(int)land.lnd_type];
91         sprintf(prompt, "New range for %s? ", prland(&land));
92         if ((p = getstarg(player->argp[2], prompt, buf)) == 0)
93             return RET_SYN;
94         if (!check_land_ok(&land))
95             return RET_SYN;
96         if ((i = atoi(p)) < 0)
97             continue;
98         land.lnd_rad_max = (i < land.lnd_rad) ? i : land.lnd_rad;
99         pr("%s reaction radius changed to %d\n", prland(&land),
100            land.lnd_rad_max);
101         putland(land.lnd_uid, &land);
102     }
103
104     return RET_OK;
105 }