2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 of the License, or
9 * (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * rej.c: Various relations setting routines
29 * Known contributors to this file:
31 * Markus Armbruster, 2005-2016
40 #include "prototypes.h"
44 setrel(natid us, natid them, int rel)
46 struct natstr *mynp = getnatp(us);
47 struct natstr *themnp = getnatp(them);
52 char *addendum = NULL;
54 if (CANT_HAPPEN(rel < AT_WAR))
56 if (CANT_HAPPEN(rel > ALLIED))
58 if (CANT_HAPPEN(!mynp || !themnp))
62 oldrel = relations_with(us, them);
66 whichway = "upgraded";
68 whichway = "downgraded";
70 addendum = "Congratulations!";
72 } else if (rel == FRIENDLY) {
74 n_down = N_DOWN_FRIENDLY;
75 } else if (rel == NEUTRAL) {
77 n_down = N_DOWN_NEUTRAL;
78 } else if (rel == HOSTILE) {
79 addendum = "Another cold war...";
81 n_down = N_DOWN_HOSTILE;
82 } else if (rel < HOSTILE) {
83 addendum = "Declaration made (give 'em hell).";
87 if (addendum && us == player->cnum && !update_running)
89 mpr(us, "Diplomatic relations with %s %s to \"%s\".\n",
90 cname(them), whichway, relates[rel]);
91 if (mynp->nat_stat == STAT_GOD || !(getrejects(us, themnp) & REJ_TELE))
93 "Country %s has %s their relations with you to \"%s\"!\n",
94 prnat(mynp), whichway, relates[rel]);
96 putrel(mynp, them, rel);
100 if (oldrel == ALLIED)
101 nreport(us, N_DIS_ALLY, them, 1);
102 else if (oldrel < HOSTILE && rel >= HOSTILE)
103 nreport(us, N_DIS_WAR, them, 1);
105 nreport(us, n_up, them, 1);
107 nreport(us, n_down, them, 1);
110 setcont(them, us, FOUND_TELE);
114 setcont(natid us, natid them, int contact)
116 struct contactstr *conp = getcontactp(us);
118 if (CANT_HAPPEN(!conp))
121 if (CANT_HAPPEN(contact < 0))
123 if (CANT_HAPPEN(contact > 255))
126 if (!opt_LOSE_CONTACT)
128 if (conp->con_contact[them] < contact) {
129 conp->con_contact[them] = contact;
135 setrej(natid us, natid them, int how, int what)
137 struct natstr *np = getnatp(us);
139 if (CANT_HAPPEN(!np))
142 np->nat_rejects[them] |= what;
144 np->nat_rejects[them] &= ~what;