2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, 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:
48 static s_char *head_meanwhile(int val);
49 static s_char *head_describe(struct histstr *hp, int what);
50 static int head_printscoop(struct histstr (*hist)[MAXNOC], natid ano,
52 static int head_findscoop(struct histstr (*hist)[MAXNOC],
53 register natid maxcnum, natid *ano, natid *vno);
59 register struct histstr *hp;
60 register natid maxcnum;
66 struct histstr hist[MAXNOC][MAXNOC];
71 struct nstr_item nstr;
75 natp = getnatp(player->cnum);
76 if (player->argp[1] != 0 && *player->argp[1] != 0) {
77 news_per = days(atoi(player->argp[1]));
78 if (news_per > days(3))
81 /* replaced the following line with the one under it to
82 * fix headlines which never change.
83 * 3/3/90 bailey@math-cs.kent.edu
85 /* news_per = natp->nat_newstim; */
86 news_per = now - natp->nat_newstim;
87 pr("\n -=[ EMPIRE NEWS ]=-\n");
88 pr("::::::::::::::::::::::::::::::::::::::::::::::::::\n");
89 pr("! \"All the news that fits, we print.\" !\n");
90 pr("::::::::::::::::::::::::::::::::::::::::::::::::::\n");
91 pr(" %s", ctime(&now));
93 memset(hist, 0, sizeof(hist));
94 snxtitem_all(&nstr, EF_NEWS);
96 while (nxtitem(&nstr, (s_char *)&news)) {
97 news_age = now - news.nws_when;
98 if (news_age > news_per)
100 if (news.nws_ano == news.nws_vno)
102 if ((i = rpt[(int)news.nws_vrb].r_good_will) == 0)
104 if (news_age > (news_per / 2))
105 hist[news.nws_ano][news.nws_vno].h_past += i;
107 hist[news.nws_ano][news.nws_vno].h_recent += i;
108 if (maxcnum < news.nws_ano)
109 maxcnum = news.nws_ano;
110 if (maxcnum < news.nws_vno)
111 maxcnum = news.nws_vno;
113 for (n = 0; n < 5; n++) {
114 if ((scoop = head_findscoop(hist, maxcnum, &actor, &victim)) < 10)
116 severity = head_printscoop(hist, actor, victim);
117 hp = &hist[actor][victim];
118 severity = hp->h_recent - hp->h_past;
119 if (severity <= -scoop / 2 || severity >= scoop / 2) {
120 pr("\t%s\n", head_meanwhile(severity));
121 (void)head_printscoop(hist, victim, actor);
125 pr("\nRelative calm prevails.\n");
130 head_printscoop(struct histstr (*hist)[MAXNOC], natid ano, natid vno)
132 register struct histstr *hp;
135 hp = &hist[ano][vno];
136 severity = abs(hp->h_past) > abs(hp->h_recent) ? 1 : 0;
137 severity += (hp->h_past >= 0) ? 2 : 0;
138 severity += (hp->h_recent >= 0) ? 4 : 0;
139 pr(head_describe(hp, severity), cname(ano), cname(vno));
147 head_meanwhile(int val)
153 return "On the other hand";
155 return "At the same time";
164 head_describe(struct histstr *hp, int what)
171 if (hp->h_recent > hp->h_past / 2)
172 cp = "Bad relations between %s and %s worsen!";
174 cp = "Carnage wrought by %s on %s continues unabated!";
177 if (hp->h_recent < -16)
178 cp = "%s agression against %s has lessened slightly";
180 cp = "Peace talks may occur between %s & %s";
183 if (hp->h_recent < -16) {
185 cp = " ! WAR ! Reversal of prior %s -- %s relations";
186 else if (hp->h_recent >= -25)
187 cp = "VIOLENCE ERUPTS! -- %s wages war on %s";
189 cp = "%s wreaks havoc on %s!";
191 cp = "Breakdown in communication between %s & %s";
194 cp = "FLASH! %s turns on former ally, %s!";
197 cp = "%s \"makes friends\" with %s";
200 if (hp->h_past >= -25)
201 cp = "%s seems to have forgotten earlier disagreement with %s";
203 cp = "Tensions ease as %s attacks on %s seem at an end";
206 cp = "%s good deeds further growing alliance with %s";
209 if (hp->h_recent - hp->h_past < 12)
210 cp = "Honeymoon appears to be over between %s & %s";
212 cp = "Friendly relations between %s & %s have cooled";
219 * returns 9 if no scoops were found
223 head_findscoop(struct histstr (*hist)[MAXNOC], register natid maxcnum,
224 natid *ano, natid *vno)
226 register struct histstr *hp;
237 for (i = 1; i < maxcnum; i++) {
238 for (j = 1; j < maxcnum; j++) {
240 k = abs(hp->h_recent / 2);
246 k = abs(hp->h_recent - hp->h_past);