/*
* 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-2011, 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,
* 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/>.
*
* ---
*
* Dave Pare, 1986, 1989
* Steve McClure, 1998-2000
* Ron Koenderink, 2005
- * Markus Armbruster, 2005-2009
+ * Markus Armbruster, 2005-2011
*/
/*
#include "com.h"
#include "empio.h"
#include "file.h"
+#include "journal.h"
#include "misc.h"
#include "nat.h"
#include "player.h"
#include "prototypes.h"
#include "server.h"
#include "tel.h"
+#include "xy.h"
static void pr_player(struct player *pl, int id, char *buf);
static void upr_player(struct player *pl, int id, char *buf);
if (p->curid >= 0) {
io_puts(p->iop, "\n");
+ journal_output(p, p->curid, "\n");
p->curid = -1;
}
va_start(ap, format);
char *bp;
int len;
+ journal_output(pl, id, buf);
+
bp = buf;
while (*bp != '\0') {
if (pl->curid != -1 && pl->curid != id) {
char printbuf[2];
char ch;
+ journal_output(pl, id, buf);
+
printbuf[0] = '\0';
printbuf[1] = '\0';
/*
* Send script execute request FILE to the current player.
- * REDIR is UTF-8, but non-ASCII characters can occur only if the
+ * FILE is UTF-8, but non-ASCII characters can occur only if the
* player sent them. Therefore, it is also user text.
*/
void
pr(format, xrel(np, x), yrel(np, y));
}
-/*
- * Print to country CN similar to printf().
- * Use printf-style FORMAT with the optional arguments.
- * Output is buffered until a newline arrives.
- * If CN is the current player and we're not in the update, print just
- * like pr(). Else print into a bulletin.
- * Because printing like pr() requires normal text, and bulletins
- * require user text, only plain ASCII is allowed.
- */
-void
-PR(int cn, char *format, ...)
-{
- /* XXX should really do this on a per-nation basis */
- static char longline[MAXNOC][512];
- int newline;
- va_list ap;
- char buf[1024];
-
- va_start(ap, format);
- (void)vsprintf(buf, format, ap);
- va_end(ap);
- newline = strrchr(buf, '\n') ? 1 : 0;
- strcat(longline[cn], buf);
- if (newline) {
- if (update_running || (cn && cn != player->cnum))
- typed_wu(0, cn, longline[cn], TEL_BULLETIN);
- else
- pr_player(player, C_DATA, longline[cn]);
- longline[cn][0] = '\0';
- }
-}
-
-/*
- * Print the current time in ctime() format to country CN.
- * If CN is the current player and we're not in the update, print just
- * like prdate(). Else print into a bulletin.
- */
-void
-PRdate(natid cn)
-{
- time_t now;
-
- (void)time(&now);
- PR(cn, ctime(&now));
-}
-
/*
* Sound the current player's bell.
*/
}
/*
- * Print to country CN similar to printf().
- * Use printf-style FORMAT with the optional arguments.
+ * Print complete lines to country CN similar to printf().
+ * Use printf-style FORMAT with the optional arguments. FORMAT must
+ * end with '\n'.
* If CN is zero, don't print anything.
* Else, if CN is the current player and we're not in the update,
* print just like pr(). Else print into a bulletin.
char buf[4096];
va_list ap;
+ CANT_HAPPEN(!format[0] || format[strlen(format) - 1] != '\n');
if (!cn)
return;
va_start(ap, format);
(void)vsprintf(buf, format, ap);
va_end(ap);
if (update_running || cn != player->cnum)
- typed_wu(0, cn, buf, TEL_BULLETIN);
+ wu(0, cn, "%s", buf);
else
pr_player(player, C_DATA, buf);
}
; /* ignore funny control */
else if (ch > 0x7f) {
*p++ = '?'; /* replace non-ASCII */
- while ((*src++ & 0xc0) == 0x80) ;
+ while ((*src & 0xc0) == 0x80)
+ src++;
} else
*p++ = ch;
}