unsigned char nws_vrb; /* action (verb) */
natid nws_vno; /* "victim" country # */
signed char nws_ntm; /* number of times */
+ short nws_duration; /* last time at nws_when + nws_duration */
time_t nws_when; /* time of action */
};
{"action", fldoff(nws_vrb), NSC_UCHAR, 0, NULL, EF_NEWS_CHR, 0},
{"victim", fldoff(nws_vno), NSC_NATID, 0, NULL, EF_NATION, 0},
{"times", fldoff(nws_ntm), NSC_CHAR, 0, NULL, EF_BAD, 0},
+ {"duration", fldoff(nws_duration), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"time", fldoff(nws_when), NSC_TIME, 0, NULL, EF_BAD, 0},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
#undef CURSTR
struct newscache *np;
int i;
int oldslot;
- time_t oldtime;
+ time_t oldtime, dur;
time_t now = time(NULL);
oldslot = -1;
}
if (np->news.nws_vrb == 0)
continue;
- if ((now - np->news.nws_when) > minutes(5))
+ dur = now - np->news.nws_when;
+ if (dur > minutes(5))
continue;
if (np->news.nws_vrb == event && np->news.nws_vno == victim &&
np->news.nws_ntm + times <= 127) {
np->news.nws_ntm += times;
+ np->news.nws_duration = dur;
return np;
}
}
np = &cache[actor][oldslot];
ef_blank(EF_NEWS, news_tail, &np->news);
np->news.nws_ano = actor;
- np->news.nws_vno = victim;
- np->news.nws_when = now;
np->news.nws_vrb = event;
+ np->news.nws_vno = victim;
np->news.nws_ntm = times;
+ np->news.nws_duration = 0;
+ np->news.nws_when = now;
np->id = news_tail++;
return np;
}