#include "prototypes.h"
#include "server.h"
-int
+void
setrel(natid us, natid them, int rel)
{
- struct natstr *mynp;
- struct natstr *themnp;
- char *myname = cname(us);
- char *themname;
+ struct natstr *mynp = getnatp(us);
+ struct natstr *themnp = getnatp(them);
int oldrel;
char *whichway;
int n_up = 0;
int n_down = 0;
char *addendum = NULL;
- if (rel < AT_WAR)
+ if (CANT_HAPPEN(rel < AT_WAR))
rel = AT_WAR;
- if (rel > ALLIED)
+ if (CANT_HAPPEN(rel > ALLIED))
rel = ALLIED;
- if (!(mynp = getnatp(us)))
- return RET_FAIL;
- if (!(themnp = getnatp(them)))
- return RET_FAIL;
- if ((oldrel = getrel(mynp, them)) == rel)
- return RET_FAIL;
- themname = cname(them);
+ if (CANT_HAPPEN(!mynp || !themnp))
+ return;
+ if (us == them)
+ return;
+ oldrel = relations_with(us, them);
+ if (oldrel == rel)
+ return;
if (rel > oldrel)
whichway = "upgraded";
else
if (addendum && us == player->cnum && !update_running)
pr("%s\n", addendum);
mpr(us, "Diplomatic relations with %s %s to \"%s\".\n",
- themname, whichway, relates[rel]);
+ cname(them), whichway, relates[rel]);
if (!(getrejects(us, themnp) & REJ_TELE))
mpr(them,
"Country %s (#%d) has %s their relations with you to \"%s\"!\n",
- myname, us, whichway, relates[rel]);
+ cname(us), us, whichway, relates[rel]);
putrel(mynp, them, rel);
putnat(mynp);
}
if (opt_HIDDEN)
setcont(them, us, FOUND_TELE);
-
- return RET_OK;
}
-int
+void
setcont(natid us, natid them, int contact)
{
- struct natstr *np;
+ struct natstr *np = getnatp(us);
- if (!(np = getnatp(us)))
- return 0;
+ if (CANT_HAPPEN(!np))
+ return;
putcontact(np, them, contact);
putnat(np);
- return 1;
}
-int
+void
setrej(natid us, natid them, int how, int what)
{
- struct natstr *np;
+ struct natstr *np = getnatp(us);
- if (!(np = getnatp(us)))
- return 0;
+ if (CANT_HAPPEN(!np))
+ return;
putreject(np, them, how, what);
putnat(np);
- return 1;
}