]> git.pond.sub.org Git - empserver/commitdiff
Optimize sendmessage() use of getnatp()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 5 Feb 2011 10:17:40 +0000 (11:17 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 13 Feb 2011 15:06:23 +0000 (16:06 +0100)
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

index 87a1e605c5ab0b3f965355c15428f08746293ee5..f16e8c4d87aa341d069bb938ea671313128baabf 100644 (file)
@@ -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)) {