Oops on invalid arguments in setrel(), setcont(), setrej()

Before, they recovered silently.
This commit is contained in:
Markus Armbruster 2011-02-05 09:28:05 +01:00
parent 89bc9c4d5b
commit a302bde1fb

View file

@ -44,8 +44,8 @@
int int
setrel(natid us, natid them, int rel) setrel(natid us, natid them, int rel)
{ {
struct natstr *mynp; struct natstr *mynp = getnatp(us);
struct natstr *themnp; struct natstr *themnp = getnatp(them);
char *myname = cname(us); char *myname = cname(us);
char *themname; char *themname;
int oldrel; int oldrel;
@ -54,13 +54,11 @@ setrel(natid us, natid them, int rel)
int n_down = 0; int n_down = 0;
char *addendum = NULL; char *addendum = NULL;
if (rel < AT_WAR) if (CANT_HAPPEN(rel < AT_WAR))
rel = AT_WAR; rel = AT_WAR;
if (rel > ALLIED) if (CANT_HAPPEN(rel > ALLIED))
rel = ALLIED; rel = ALLIED;
if (!(mynp = getnatp(us))) if (CANT_HAPPEN(!mynp || !themnp))
return RET_FAIL;
if (!(themnp = getnatp(them)))
return RET_FAIL; return RET_FAIL;
if ((oldrel = getrel(mynp, them)) == rel) if ((oldrel = getrel(mynp, them)) == rel)
return RET_FAIL; return RET_FAIL;
@ -118,9 +116,9 @@ setrel(natid us, natid them, int rel)
int int
setcont(natid us, natid them, int contact) setcont(natid us, natid them, int contact)
{ {
struct natstr *np; struct natstr *np = getnatp(us);
if (!(np = getnatp(us))) if (CANT_HAPPEN(!np))
return 0; return 0;
putcontact(np, them, contact); putcontact(np, them, contact);
putnat(np); putnat(np);
@ -130,9 +128,9 @@ setcont(natid us, natid them, int contact)
int int
setrej(natid us, natid them, int how, int what) setrej(natid us, natid them, int how, int what)
{ {
struct natstr *np; struct natstr *np = getnatp(us);
if (!(np = getnatp(us))) if (CANT_HAPPEN(!np))
return 0; return 0;
putreject(np, them, how, what); putreject(np, them, how, what);
putnat(np); putnat(np);