From e21f5035cb955a975e3b119ea86692862caa2329 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 5 Feb 2011 11:17:40 +0100 Subject: [PATCH] Optimize sendmessage() use of getnatp() Don't call it when its value must be TO anyway. While there, oops when it fails instead of recovering silently. --- src/lib/commands/flash.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/commands/flash.c b/src/lib/commands/flash.c index 87a1e605..f16e8c4d 100644 --- a/src/lib/commands/flash.c +++ b/src/lib/commands/flash.c @@ -131,8 +131,13 @@ sendmessage(struct natstr *us, struct natstr *to, char *message, int verbose) continue; if (to && other->cnum != to->nat_cnum) continue; - if (!(wto = getnatp(other->cnum))) - continue; + if (to) + wto = to; + else { + wto = getnatp(other->cnum); + if (CANT_HAPPEN(!wto)) + continue; + } if (!to && !player->god && getrel(wto, player->cnum) != ALLIED) continue; if (!player->god && !(wto->nat_flags & NF_FLASH)) {