2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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 * head.c: Print headlines of the Empire News
30 * Known contributors to this file:
50 static s_char *head_meanwhile(int val);
51 static s_char *head_describe(struct histstr *hp, int what);
52 static int head_printscoop(struct histstr (*hist)[MAXNOC], natid ano,
54 static int head_findscoop(struct histstr (*hist)[MAXNOC],
55 register natid maxcnum, natid *ano, natid *vno);
61 register struct histstr *hp;
62 register natid maxcnum;
68 struct histstr hist[MAXNOC][MAXNOC];
73 struct nstr_item nstr;
77 natp = getnatp(player->cnum);
78 if (player->argp[1] != 0 && *player->argp[1] != 0) {
79 news_per = days(atoi(player->argp[1]));
80 if (news_per > days(3))
83 /* replaced the following line with the one under it to
84 * fix headlines which never change.
85 * 3/3/90 bailey@math-cs.kent.edu
87 /* news_per = natp->nat_newstim; */
88 news_per = now - natp->nat_newstim;
89 pr("\n -=[ EMPIRE NEWS ]=-\n");
90 pr("::::::::::::::::::::::::::::::::::::::::::::::::::\n");
91 pr("! \"All the news that fits, we print.\" !\n");
92 pr("::::::::::::::::::::::::::::::::::::::::::::::::::\n");
93 pr(" %s", ctime(&now));
95 memset(hist, 0, sizeof(hist));
96 snxtitem_all(&nstr, EF_NEWS);
98 while (nxtitem(&nstr, &news)) {
99 news_age = now - news.nws_when;
100 if (news_age > news_per)
102 if (news.nws_ano == news.nws_vno)
104 if ((i = rpt[(int)news.nws_vrb].r_good_will) == 0)
106 if (news_age > (news_per / 2))
107 hist[news.nws_ano][news.nws_vno].h_past += i;
109 hist[news.nws_ano][news.nws_vno].h_recent += i;
110 if (maxcnum < news.nws_ano)
111 maxcnum = news.nws_ano;
112 if (maxcnum < news.nws_vno)
113 maxcnum = news.nws_vno;
115 for (n = 0; n < 5; n++) {
116 if ((scoop = head_findscoop(hist, maxcnum, &actor, &victim)) < 10)
118 severity = head_printscoop(hist, actor, victim);
119 hp = &hist[actor][victim];
120 severity = hp->h_recent - hp->h_past;
121 if (severity <= -scoop / 2 || severity >= scoop / 2) {
122 pr("\t%s\n", head_meanwhile(severity));
123 (void)head_printscoop(hist, victim, actor);
127 pr("\nRelative calm prevails.\n");
132 head_printscoop(struct histstr (*hist)[MAXNOC], natid ano, natid vno)
134 register struct histstr *hp;
137 hp = &hist[ano][vno];
138 severity = abs(hp->h_past) > abs(hp->h_recent) ? 1 : 0;
139 severity += (hp->h_past >= 0) ? 2 : 0;
140 severity += (hp->h_recent >= 0) ? 4 : 0;
141 pr(head_describe(hp, severity), cname(ano), cname(vno));
149 head_meanwhile(int val)
155 return "On the other hand";
157 return "At the same time";
166 head_describe(struct histstr *hp, int what)
173 if (hp->h_recent > hp->h_past / 2)
174 cp = "Bad relations between %s and %s worsen!";
176 cp = "Carnage wrought by %s on %s continues unabated!";
179 if (hp->h_recent < -16)
180 cp = "%s agression against %s has lessened slightly";
182 cp = "Peace talks may occur between %s & %s";
185 if (hp->h_recent < -16) {
187 cp = " ! WAR ! Reversal of prior %s -- %s relations";
188 else if (hp->h_recent >= -25)
189 cp = "VIOLENCE ERUPTS! -- %s wages war on %s";
191 cp = "%s wreaks havoc on %s!";
193 cp = "Breakdown in communication between %s & %s";
196 cp = "FLASH! %s turns on former ally, %s!";
199 cp = "%s \"makes friends\" with %s";
202 if (hp->h_past >= -25)
203 cp = "%s seems to have forgotten earlier disagreement with %s";
205 cp = "Tensions ease as %s attacks on %s seem at an end";
208 cp = "%s good deeds further growing alliance with %s";
211 if (hp->h_recent - hp->h_past < 12)
212 cp = "Honeymoon appears to be over between %s & %s";
214 cp = "Friendly relations between %s & %s have cooled";
221 * returns 9 if no scoops were found
225 head_findscoop(struct histstr (*hist)[MAXNOC], register natid maxcnum,
226 natid *ano, natid *vno)
228 register struct histstr *hp;
239 for (i = 1; i < maxcnum; i++) {
240 for (j = 1; j < maxcnum; j++) {
242 k = abs(hp->h_recent / 2);
248 k = abs(hp->h_recent - hp->h_past);