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);
51 char *addendum = NULL;
53 if (CANT_HAPPEN(rel < AT_WAR))
55 if (CANT_HAPPEN(rel > ALLIED))
57 if (CANT_HAPPEN(!mynp))
61 oldrel = relations_with(us, them);
65 whichway = "upgraded";
67 whichway = "downgraded";
69 addendum = "Congratulations!";
71 } else if (rel == FRIENDLY) {
73 n_down = N_DOWN_FRIENDLY;
74 } else if (rel == NEUTRAL) {
76 n_down = N_DOWN_NEUTRAL;
77 } else if (rel == HOSTILE) {
78 addendum = "Another cold war...";
80 n_down = N_DOWN_HOSTILE;
81 } else if (rel < HOSTILE) {
82 addendum = "Declaration made (give 'em hell).";
86 if (addendum && us == player->cnum && !update_running)
88 mpr(us, "Diplomatic relations with %s %s to \"%s\".\n",
89 cname(them), whichway, relates[rel]);
90 if (nat_accepts(them, us, REJ_TELE))
92 "Country %s has %s their relations with you to \"%s\"!\n",
93 prnat(mynp), whichway, relates[rel]);
95 putrel(mynp, them, rel);
100 nreport(us, N_DIS_ALLY, them, 1);
101 else if (oldrel < HOSTILE && rel >= HOSTILE)
102 nreport(us, N_DIS_WAR, them, 1);
104 nreport(us, n_up, them, 1);
106 nreport(us, n_down, them, 1);
109 setcont(them, us, FOUND_TELE);
113 setcont(natid us, natid them, int contact)
115 struct contactstr *conp = getcontactp(us);
117 if (CANT_HAPPEN(!conp))
120 if (CANT_HAPPEN(contact < 0))
122 if (CANT_HAPPEN(contact > 255))
125 if (!opt_LOSE_CONTACT)
127 if (conp->con_contact[them] < contact) {
128 conp->con_contact[them] = contact;
134 setrej(natid us, natid them, int reject, enum rej_comm what)
136 struct rejectstr *rejp = getrejectp(us);
138 if (CANT_HAPPEN(!rejp))
141 rejp->rej_rejects[them] |= bit(what);
143 rejp->rej_rejects[them] &= ~bit(what);