/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* Dave Pare, 1986, 1989
* Steve McClure, 1998-2000
* Ron Koenderink, 2005
- * Markus Armbruster, 2005
+ * Markus Armbruster, 2005-2007
*/
/*
#include <config.h>
-#include <string.h>
-#include <fcntl.h>
-#include <ctype.h>
#include <stdarg.h>
-#include "proto.h"
-#include "misc.h"
-#include "player.h"
-#include "nat.h"
+#include <stdlib.h>
+#include "com.h"
#include "empio.h"
#include "file.h"
-#include "com.h"
-#include "tel.h"
-#include "server.h"
+#include "misc.h"
+#include "nat.h"
+#include "player.h"
+#include "proto.h"
#include "prototypes.h"
+#include "server.h"
+#include "tel.h"
static void pr_player(struct player *pl, int id, char *buf);
static void upr_player(struct player *pl, int id, char *buf);
* Send C_FLASH text to everyone.
* Format text to send using printf-style FORMAT and optional
* arguments. It is assumed to be plain ASCII.
+ * Prefix text it with a header suitable for broadcast from deity.
* Initiate an output queue flush, but do not wait for it to complete.
*/
void
pr_wall(char *format, ...)
{
+ time_t now;
+ struct tm *tm;
char buf[4096]; /* UTF-8 */
+ int n;
struct player *p;
va_list ap;
+ time(&now);
+ tm = localtime(&now);
+ n = sprintf(buf, "BROADCAST from %s @ %02d:%02d: ",
+ getnatp(0)->nat_cnam, tm->tm_hour, tm->tm_min);
+
va_start(ap, format);
- (void)vsprintf(buf, format, ap);
+ (void)vsprintf(buf + n, format, ap);
va_end(ap);
for (p = player_next(0); p; p = player_next(p)) {
if (p->state != PS_PLAYING)
newline = strrchr(buf, '\n') ? 1 : 0;
strcat(longline[cn], buf);
if (newline) {
- if (update_pending || (cn && cn != player->cnum))
+ if (update_running || (cn && cn != player->cnum))
typed_wu(0, cn, longline[cn], TEL_BULLETIN);
else
pr_player(player, C_DATA, longline[cn]);
(void)vsprintf(buf, format, ap);
va_end(ap);
if (cn) {
- if (update_pending || cn != player->cnum)
+ if (update_running || cn != player->cnum)
typed_wu(0, cn, buf, TEL_BULLETIN);
else
pr_player(player, C_DATA, buf);