]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/flash.c
commands: Rename the command functions
[empserver] / src / lib / commands / flash.c
index d1aaa2d097733bec1b0c85dbd15329df8de6e8f2..4f95cde1b67fe61a17032f4e5be601af9741beb9 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -31,7 +30,7 @@
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
  *     Ron Koenderink, 2005
- *     Markus Armbruster, 2004-2009
+ *     Markus Armbruster, 2004-2013
  */
 
 #include <config.h>
@@ -42,7 +41,7 @@ static int chat(struct natstr *, char *);
 static int sendmessage(struct natstr *, char *, int);
 
 int
-flash(void)
+c_flash(void)
 {
     struct natstr *us;
     struct natstr *to;
@@ -63,7 +62,8 @@ flash(void)
        }
     } else {
        /* Ok, we are a normal country, can we flash them? */
-       if (to->nat_stat != STAT_GOD && getrel(to, player->cnum) < FRIENDLY) {
+       if (to->nat_stat != STAT_GOD
+           && relations_with(tocn, player->cnum) < FRIENDLY) {
            pr("%s is not a deity or friendly with us.\n", to->nat_cnam);
            return RET_SYN;
        }
@@ -73,15 +73,15 @@ flash(void)
 }
 
 int
-wall(void)
+c_wall(void)
 {
     return chat(NULL, player->comtail[1]);
 }
 
 /*
- * Send flash message(s) from US to TO.
- * Null TO broadcasts to all.
- * MESSAGE is UTF-8.  If it is null, prompt for messages interactively.
+ * Send flash message(s) to @to.
+ * Null @to broadcasts to all.
+ * @message is UTF-8.  If it is null, prompt for messages interactively.
  * Return RET_OK.
  */
 static int
@@ -107,11 +107,11 @@ chat(struct natstr *to, char *message)
 }
 
 /*
- * Send flash message MESSAGE from US to TO.
- * MESSAGE is UTF-8.
- * Null TO broadcasts to all.
- * A header identifying US is prepended to the message.  It is more
- * verbose if VERBOSE.
+ * Send flash message @message to @to.
+ * @message is UTF-8.
+ * Null @to broadcasts to all.
+ * A header identifying the player is prepended to the message.  It is
+ * more verbose if @verbose.
  */
 static int
 sendmessage(struct natstr *to, char *message, int verbose)
@@ -127,8 +127,6 @@ sendmessage(struct natstr *to, char *message, int verbose)
     for (other = player_next(NULL); other; other = player_next(other)) {
        if (other->state != PS_PLAYING)
            continue;
-       if (player == other)
-           continue;
        if (to) {
            /* flash */
            if (other->cnum != to->nat_cnum)
@@ -136,10 +134,13 @@ sendmessage(struct natstr *to, char *message, int verbose)
            wto = to;
        } else {
            /* wall */
+           if (player == other)
+               continue;
            wto = getnatp(other->cnum);
            if (CANT_HAPPEN(!wto))
                continue;
-           if (!player->god && getrel(wto, player->cnum) != ALLIED)
+           if (!player->god
+               && relations_with(other->cnum, player->cnum) != ALLIED)
                continue;
        }
        if (!player->god && !(wto->nat_flags & NF_FLASH)) {
@@ -149,23 +150,24 @@ sendmessage(struct natstr *to, char *message, int verbose)
 
        if (verbose)
            if (to)
-               pr_flash(other, "FLASH from %s (#%d) @ %02d:%02d%s\n",
-                        cname(player->cnum), player->cnum, tm->tm_hour,
-                        tm->tm_min, message);
+               pr_flash(other, "FLASH from %s @ %02d:%02d%s\n",
+                        prnatid(player->cnum),
+                        tm->tm_hour, tm->tm_min, message);
            else
-               pr_flash(other, "BROADCAST from %s (#%d) @ %02d:%02d%s\n",
-                        cname(player->cnum), player->cnum, tm->tm_hour,
-                        tm->tm_min, message);
+               pr_flash(other, "BROADCAST from %s @ %02d:%02d%s\n",
+                        prnatid(player->cnum),
+                        tm->tm_hour, tm->tm_min, message);
 
        else
-           pr_flash(other, "%s (#%d): %s\n",
-                    cname(player->cnum), player->cnum, message);
+           pr_flash(other, "%s: %s\n",
+                    prnatid(player->cnum), message);
        sent++;
     }
 
     if (to) {
        /* flash */
-       if (player->god || getrel(to, player->cnum) == ALLIED) {
+       if (player->god
+           || relations_with(to->nat_cnum, player->cnum) == ALLIED) {
            /* Can see TO logged in anyway, so it's okay to tell */
            if (rejected)
                pr("%s is not accepting flashes\n", to->nat_cnam);