Clean up confusing control flow in sendmessage()
The second patch hunk fixes a latent bug. Before, rejected deity flashes led to a bogus "not logged on" message, now they lead to a "not accepting" message. But deity flashes can't be rejected, so this doesn't matter.
This commit is contained in:
parent
e21f5035cb
commit
5eeac45b8d
1 changed files with 26 additions and 22 deletions
|
@ -129,21 +129,24 @@ sendmessage(struct natstr *us, struct natstr *to, char *message, int verbose)
|
||||||
continue;
|
continue;
|
||||||
if (player == other)
|
if (player == other)
|
||||||
continue;
|
continue;
|
||||||
if (to && other->cnum != to->nat_cnum)
|
if (to) {
|
||||||
|
/* flash */
|
||||||
|
if (other->cnum != to->nat_cnum)
|
||||||
continue;
|
continue;
|
||||||
if (to)
|
|
||||||
wto = to;
|
wto = to;
|
||||||
else {
|
} else {
|
||||||
|
/* wall */
|
||||||
wto = getnatp(other->cnum);
|
wto = getnatp(other->cnum);
|
||||||
if (CANT_HAPPEN(!wto))
|
if (CANT_HAPPEN(!wto))
|
||||||
continue;
|
continue;
|
||||||
}
|
if (!player->god && getrel(wto, player->cnum) != ALLIED)
|
||||||
if (!to && !player->god && getrel(wto, player->cnum) != ALLIED)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (!player->god && !(wto->nat_flags & NF_FLASH)) {
|
if (!player->god && !(wto->nat_flags & NF_FLASH)) {
|
||||||
rejected++;
|
rejected++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
if (to)
|
if (to)
|
||||||
pr_flash(other, "FLASH from %s (#%d) @ %02d:%02d%s\n",
|
pr_flash(other, "FLASH from %s (#%d) @ %02d:%02d%s\n",
|
||||||
|
@ -160,23 +163,24 @@ sendmessage(struct natstr *us, struct natstr *to, char *message, int verbose)
|
||||||
sent++;
|
sent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->god) {
|
|
||||||
if (to) {
|
if (to) {
|
||||||
if (!sent)
|
/* flash */
|
||||||
pr("%s is not logged on\n", to->nat_cnam);
|
if (player->god || getrel(to, player->cnum) == ALLIED) {
|
||||||
} else if (sent)
|
/* Can see TO logged in anyway, so it's okay to tell */
|
||||||
pr("Broadcast sent to %d players\n", sent);
|
|
||||||
else
|
|
||||||
pr("No-one is logged in\n");
|
|
||||||
}
|
|
||||||
if (to && !player->god && getrel(to, player->cnum) == ALLIED) {
|
|
||||||
/* If they are allied with us, we would normally see that
|
|
||||||
* they are logged in anyway, so just tell us */
|
|
||||||
if (rejected)
|
if (rejected)
|
||||||
pr("%s is not accepting flashes\n", to->nat_cnam);
|
pr("%s is not accepting flashes\n", to->nat_cnam);
|
||||||
else if (!sent) {
|
else if (!sent) {
|
||||||
pr("%s is not logged on\n", to->nat_cnam);
|
pr("%s is not logged on\n", to->nat_cnam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* wall */
|
||||||
|
if (player->god) {
|
||||||
|
if (sent)
|
||||||
|
pr("Broadcast sent to %d players\n", sent);
|
||||||
|
else
|
||||||
|
pr("No-one is logged in\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue