]> git.pond.sub.org Git - empserver/blob - src/lib/subs/distrea.c
Update copyright notice.
[empserver] / src / lib / subs / distrea.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2004, 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 "file.h"
39 #include "prototypes.h"
40
41 int
42 distrea(int n, register struct trtstr *tp)
43 {
44     register int i;
45     int acond;
46     int bcond;
47     int cond;
48     time_t now;
49
50     if (tp->trt_status == TS_FREE)
51         return 0;
52     if (tp->trt_cna != player->cnum &&
53         tp->trt_cnb != player->cnum && !player->god)
54         return 0;
55     (void)time(&now);
56     if (now > tp->trt_exp) {
57         tp->trt_status = TS_FREE;
58         if (!puttre(n, tp)) {
59             pr("Couldn't save treaty; get help!\n");
60             return 0;
61         }
62         pr("Treaty #%d expired %s", n, ctime(&tp->trt_exp));
63         return 0;
64     }
65     pr("\n      * * *  Empire Treaty #%d  * * *\n", n);
66     if (tp->trt_status == TS_PROPOSED)
67         pr("(proposed)\n");
68     pr("between %s and ", cname(tp->trt_cna));
69     pr("%s  expires %s", cname(tp->trt_cnb), ctime(&tp->trt_exp));
70     pr("%24.24s terms", cname(tp->trt_cna));
71     pr(" - %s terms\n", cname(tp->trt_cnb));
72     for (i = 0; 0 != (cond = tchr[i].t_cond); i++) {
73         acond = tp->trt_acond & cond;
74         bcond = tp->trt_bcond & cond;
75         if (acond | bcond) {
76             if (acond)
77                 pr("%30s", tchr[i].t_name);
78             else
79                 pr("%30s", "");
80             if (bcond)
81                 pr(" - %s\n", tchr[i].t_name);
82             else
83                 pr(" -\n");
84         }
85     }
86     return 1;
87 }