]> git.pond.sub.org Git - empserver/blob - src/lib/subs/distrea.c
Indented with src/scripts/indent-emp.
[empserver] / src / lib / subs / distrea.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  *  distrea.c: Display treaty information
29  * 
30  *  Known contributors to this file:
31  *     
32  */
33
34 #include "misc.h"
35 #include "player.h"
36 #include "treaty.h"
37 #include "nat.h"
38 #include "deity.h"
39 #include "file.h"
40 #include "prototypes.h"
41
42 int
43 distrea(int n, register struct trtstr *tp)
44 {
45     register int i;
46     int acond;
47     int bcond;
48     int cond;
49     time_t now;
50
51     if (tp->trt_status == TS_FREE)
52         return 0;
53     if (tp->trt_cna != player->cnum &&
54         tp->trt_cnb != player->cnum && !player->god)
55         return 0;
56     (void)time(&now);
57     if (now > tp->trt_exp) {
58         if (!ef_lock(EF_TREATY)) {
59             pr("Can't lock treaty file; get help!\n");
60             return 0;
61         }
62         tp->trt_status = TS_FREE;
63         if (!puttre(n, tp)) {
64             pr("Couldn't save treaty; get help!\n");
65             (void)ef_unlock(EF_TREATY);
66             return 0;
67         }
68         (void)ef_unlock(EF_TREATY);
69         pr("Treaty #%d expired %s", n, ctime(&tp->trt_exp));
70         return 0;
71     }
72     pr("\n      * * *  Empire Treaty #%d  * * *\n", n);
73     if (tp->trt_status == TS_PROPOSED)
74         pr("(proposed)\n");
75     pr("between %s and ", cname(tp->trt_cna));
76     pr("%s  expires %s", cname(tp->trt_cnb), ctime(&tp->trt_exp));
77     pr("%24.24s terms", cname(tp->trt_cna));
78     pr(" - %s terms\n", cname(tp->trt_cnb));
79     for (i = 0; 0 != (cond = tchr[i].t_cond); i++) {
80         acond = tp->trt_acond & cond;
81         bcond = tp->trt_bcond & cond;
82         if (acond | bcond) {
83             if (acond)
84                 pr("%30s", tchr[i].t_name);
85             else
86                 pr("%30s", "");
87             if (bcond)
88                 pr(" - %s\n", tchr[i].t_name);
89             else
90                 pr(" -\n");
91         }
92     }
93     return 1;
94 }