/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*
* ---
*
- * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- * related information and legal notices. It is expected that any future
- * projects/authors will amend these files as needed.
+ * See files README, COPYING and CREDITS in the root of the source
+ * tree for related information and legal notices. It is expected
+ * that future projects/authors will amend these files as needed.
*
* ---
*
* news.c: Show current Empire news
- *
+ *
* Known contributors to this file:
- *
+ *
*/
-#include "misc.h"
-#include "player.h"
-#include "nat.h"
-#include "news.h"
-#include "file.h"
-#include "xy.h"
-#include "nsc.h"
-#include "deity.h"
+#include <config.h>
+
#include "commands.h"
+#include "news.h"
#include "optlist.h"
-static void preport(register struct nwsstr *np);
+static void preport(struct nwsstr *np);
int
news(void)
short k;
int sectors_were_taken = 0;
natid i, j;
- s_char num[128];
- s_char *verb;
+ char num[128];
+ char *verb;
+ if (!snxtitem(&nstr, EF_NEWS, "*", NULL))
+ return RET_SYN;
memset(page_has_news, 0, sizeof(page_has_news));
memset(sectors_taken, 0, sizeof(sectors_taken));
- (void)head();
(void)time(&now);
natp = getnatp(player->cnum);
then = natp->nat_newstim;
- if (!opt_HIDDEN) {
- if (player->argp[1] != 0 && isdigit(*player->argp[1])) {
- delta = days(atoi(player->argp[1]));
- then = now - delta;
+ if (player->argp[1]) {
+ /*
+ * We want to hide events before contact. Proper solution
+ * would be to timestamp the contact. Cheesy approximation:
+ * disable old news.
+ */
+ if (opt_HIDDEN && !player->god) {
+ pr("Sorry, argument doesn't work with HIDDEN enabled\n");
+ return RET_FAIL;
}
+ delta = days(atoi(player->argp[1]));
+ then = now - delta;
}
natp->nat_newstim = now;
-/* if (then < now - days(3))
- then = now - days(3);
-*/
- snxtitem(&nstr, EF_NEWS, "*");
+ head();
pr("\nThe details of Empire news since %s", ctime(&then));
- while (nxtitem(&nstr, (s_char *)&nws)) {
+ while (nxtitem(&nstr, &nws)) {
+ if (!nws.nws_vrb || CANT_HAPPEN(nws.nws_vrb > N_MAX_VERB))
+ continue;
if (nws.nws_when < then)
continue;
if (opt_HIDDEN) {
for (page = 1; page <= N_MAX_PAGE; page++) {
if (!page_has_news[page])
continue;
- pr("\n\t === %s ===\n", page_headings[page]);
+ pr("\n\t === %s ===\n", page_headings[page].name);
snxtitem_rewind(&nstr);
- while (nxtitem(&nstr, (s_char *)&nws)) {
+ while (nxtitem(&nstr, &nws)) {
+ if (CANT_HAPPEN(nws.nws_vrb > N_MAX_VERB))
+ continue;
if (rpt[(int)nws.nws_vrb].r_newspage != page)
continue;
if (nws.nws_when < then)
}
static void
-preport(register struct nwsstr *np)
+preport(struct nwsstr *np)
{
- register s_char *cp;
- register int i;
- s_char buf[255];
- s_char num[128];
- s_char *ptr;
+ char *cp;
+ int i;
+ char buf[255];
+ char num[128];
+ char *ptr;
cp = buf;
sprintf(buf, "%-16.16s ", ctime(&np->nws_when));
strcpy(cp, cname(np->nws_ano));
cp += strlen(cp);
*cp++ = ' ';
- if (np->nws_vrb < 1 || np->nws_vrb > N_MAX_VERB)
- np->nws_vrb = 0;
sprintf(cp, rpt[(int)np->nws_vrb].r_newstory[random() % NUM_RPTS],
cname(np->nws_vno));
cp += strlen(cp);
sprintf(cp, " %s times", ptr);
cp += strlen(cp);
}
- if (*buf >= 'a' && *buf <= 'z')
- *buf += 'A' - 'a';
if (cp - buf > 80) {
for (i = 80; --i > 60;)
if (buf[i] == ' ')