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