Use relations_with() for US==THEM || getrel(NP, THEM)
Replace patterns like "US == THEM || getrel(NP, THEM)...", where NP is known to be getnatp(US), by "relations_with(US, THEM)...". No functional change. Adds a few calls to getnatp() hidden in relations_with(), though. Keeping that optimized isn't worth it.
This commit is contained in:
parent
928e9a4cc3
commit
bdf63bc5fa
3 changed files with 6 additions and 7 deletions
|
@ -68,7 +68,7 @@ coun_list(struct natstr *natp)
|
||||||
if (getplayer(cn)
|
if (getplayer(cn)
|
||||||
&& (player->god
|
&& (player->god
|
||||||
|| natp->nat_stat == STAT_GOD
|
|| natp->nat_stat == STAT_GOD
|
||||||
|| cn == player->cnum || getrel(natp, player->cnum) == ALLIED))
|
|| relations_with(cn, player->cnum) == ALLIED))
|
||||||
pr(" Now logged on ");
|
pr(" Now logged on ");
|
||||||
else if (player->god) {
|
else if (player->god) {
|
||||||
if (natp->nat_last_login == 0)
|
if (natp->nat_last_login == 0)
|
||||||
|
|
|
@ -63,8 +63,8 @@ flash(void)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Ok, we are a normal country, can we flash them? */
|
/* Ok, we are a normal country, can we flash them? */
|
||||||
if (to->nat_stat != STAT_GOD && tocn != player->cnum
|
if (to->nat_stat != STAT_GOD
|
||||||
&& getrel(to, player->cnum) < FRIENDLY) {
|
&& relations_with(tocn, player->cnum) < FRIENDLY) {
|
||||||
pr("%s is not a deity or friendly with us.\n", to->nat_cnam);
|
pr("%s is not a deity or friendly with us.\n", to->nat_cnam);
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,8 @@ sendmessage(struct natstr *to, char *message, int verbose)
|
||||||
|
|
||||||
if (to) {
|
if (to) {
|
||||||
/* flash */
|
/* flash */
|
||||||
if (player->god || to->nat_cnum == player->cnum
|
if (player->god
|
||||||
|| getrel(to, player->cnum) == ALLIED) {
|
|| relations_with(to->nat_cnum, player->cnum) == ALLIED) {
|
||||||
/* Can see TO logged in anyway, so it's okay to tell */
|
/* Can see TO logged in anyway, so it's okay to tell */
|
||||||
if (rejected)
|
if (rejected)
|
||||||
pr("%s is not accepting flashes\n", to->nat_cnam);
|
pr("%s is not accepting flashes\n", to->nat_cnam);
|
||||||
|
|
|
@ -67,8 +67,7 @@ orig(void)
|
||||||
cnum = natarg(p, NULL);
|
cnum = natarg(p, NULL);
|
||||||
if (!(np = getnatp(cnum)))
|
if (!(np = getnatp(cnum)))
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!player->god && player->cnum != cnum
|
if (!player->god && relations_with(cnum, player->cnum) != ALLIED) {
|
||||||
&& getrel(np, player->cnum) != ALLIED) {
|
|
||||||
pr("Country %s is not allied with you!\n", np->nat_cnam);
|
pr("Country %s is not allied with you!\n", np->nat_cnam);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue