2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * flash.c: Flash a message to another player
30 * Known contributors to this file:
35 #if defined(Rel4) || defined(_WIN32)
55 us = getnatp(player->cnum);
56 if ((tocn = natarg(player->argp[1], "to which country? ")) < 0)
58 if (!(to = getnatp((natid)tocn))) {
59 pr("Bad country number\n");
63 if (us->nat_stat & STAT_GOD) {
64 /* We are gods, we can flash anyone */
65 } else if (us->nat_stat == VIS) {
66 /* We are a visitor. We can only flash the gods. :) */
67 if (!(to->nat_stat & STAT_GOD)) {
68 pr("Visitors can only flash the gods.\n");
72 /* Ok, we are a normal country, can we flash them? */
73 if ((!(to->nat_stat & STAT_GOD)) &&
74 (getrel(to, player->cnum) < FRIENDLY)) {
75 pr("%s is not a deity or friendly with us.\n", to->nat_cnam);
80 if (player->argp[2]) {
81 for (sp = &player->combuf[0]; *sp && *sp != ' '; ++sp) ;
82 for (++sp; *sp && *sp != ' '; ++sp) ;
83 sprintf(buf, ":%s", sp);
84 sendmessage(us, to, buf, 1);
86 sendmessage(us, to, "...", 1);
87 while (getstring("> ", buf)) {
90 sendmessage(us, to, buf, 0);
92 sendmessage(us, to, "<EOT>", 0);
104 us = getnatp(player->cnum);
105 if (player->argp[1]) {
106 for (sp = &player->combuf[0]; *sp && *sp != ' '; ++sp) ;
107 for (++sp; *sp && *sp != ' '; ++sp) ;
108 sprintf(buf, ":%s", sp);
109 sendmessage(us, 0, buf, 1);
111 sendmessage(us, 0, "...", 1);
112 while (getstring("> ", buf)) {
115 sendmessage(us, 0, buf, 0);
117 sendmessage(us, 0, "<EOT>", 0);
123 sendmessage(struct natstr *us, struct natstr *to, char *message,
126 struct player *other;
134 for (p = message; 0 != (c = *p); p++) {
138 if (strlen(message) > 60) {
139 s_char c = message[60];
141 sendmessage(us, to, message, oneshot);
143 sendmessage(us, to, &message[60], 0);
147 tm = localtime(&now);
148 for (other = player_next(0); other != 0; other = player_next(other)) {
149 if (to && other->cnum != to->nat_cnum)
151 if (!(wto = getnatp(other->cnum)))
153 if (!to && !player->god && getrel(wto, player->cnum) != ALLIED)
155 if (!player->god && !(wto->nat_flags & NF_FLASH))
161 pr_flash(other, "FLASH from %s (#%d) @ %02d:%02d%s\n",
162 us->nat_cnam, us->nat_cnum, tm->tm_hour,
163 tm->tm_min, message);
165 pr_flash(other, "BROADCAST from %s (#%d) @ %02d:%02d%s\n",
166 us->nat_cnam, us->nat_cnum, tm->tm_hour,
167 tm->tm_min, message);
170 pr_flash(other, "%s (#%d): %s\n",
171 us->nat_cnam, us->nat_cnum, message);
172 player_wakeup(other);
178 pr("Flash sent to %s\n", to->nat_cnam);
180 pr("%s is not logged on\n", to->nat_cnam);
182 pr("Broadcast sent to %d players\n", sent);
184 pr("No-one is logged in\n");
186 if (to && !player->god) {
187 /* If they are allied with us, we would normally see that
188 * they are logged in anyway, so just tell us */
189 if ((getrel(to, player->cnum) == ALLIED) && !sent) {
190 if (to->nat_flags & NF_FLASH)
191 pr("%s is not logged on\n", to->nat_cnam);
193 pr("%s is not accepting flashes\n", to->nat_cnam);