]> git.pond.sub.org Git - empserver/blob - src/lib/commands/reje.c
146369479c887f374a36196802497365b053a7d0
[empserver] / src / lib / commands / reje.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 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  *  reje.c: Refuse telegrams/annos/treaties/loans from countries
29  * 
30  *  Known contributors to this file:
31  *     
32  */
33
34 #include <config.h>
35
36 #include "misc.h"
37 #include "player.h"
38 #include "nat.h"
39 #include "file.h"
40 #include "xy.h"
41 #include "nsc.h"
42 #include "commands.h"
43 #include "optlist.h"
44
45 int
46 reje(void)
47 {
48     register s_char *p;
49     int rel;
50     int do_undo;
51     struct natstr nat;
52     struct nstr_item ni;
53     s_char buf[1024];
54
55     if ((p = getstarg(player->argp[1], "reject or accept? ", buf)) == 0)
56         return RET_SYN;
57     switch (*p) {
58     case 'r':
59         do_undo = 1;
60         break;
61     case 'a':
62         do_undo = 0;
63         break;
64     default:
65         pr("That's not one of the choices!\n");
66         return RET_SYN;
67     }
68     if ((p =
69          getstarg(player->argp[2],
70                   "mail, treaties, loans, or announcements? ", buf)) == 0)
71         return RET_SYN;
72     switch (*p) {
73     case 'a':
74         rel = REJ_ANNO;
75         break;
76     case 'l':
77         rel = REJ_LOAN;
78         break;
79     case 'm':
80         rel = REJ_TELE;
81         break;
82     case 't':
83         rel = REJ_TREA;
84         break;
85     default:
86         pr("That's not one of the choices!\n");
87         return RET_SYN;
88     }
89     if (!snxtitem(&ni, EF_NATION, player->argp[3]))
90         return RET_SYN;
91     while (nxtitem(&ni, &nat)) {
92         if (nat.nat_stat == STAT_GOD) {
93             pr("You may not reject/accept stuff from %s\nbecause they are a deity.\n", nat.nat_cnam);
94             continue;
95         }
96         if (nat.nat_stat == STAT_UNUSED)
97             continue;
98         switch (rel) {
99         case REJ_ANNO:
100             pr("%s annos from %s\n",
101                (do_undo == 1 ? "Rejecting" : "Accepting"), nat.nat_cnam);
102             break;
103         case REJ_LOAN:
104             pr("%s loans from %s\n",
105                (do_undo == 1 ? "Rejecting" : "Accepting"), nat.nat_cnam);
106             break;
107         case REJ_TELE:
108             pr("%s teles from %s\n",
109                (do_undo == 1 ? "Rejecting" : "Accepting"), nat.nat_cnam);
110             break;
111         case REJ_TREA:
112             pr("%s treaties from %s\n",
113                (do_undo == 1 ? "Rejecting" : "Accepting"), nat.nat_cnam);
114             break;
115         }
116         setrej(player->cnum, (natid)ni.cur, do_undo, rel);
117     }
118     return RET_OK;
119 }