]> git.pond.sub.org Git - empserver/commitdiff
New news selector duration
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 31 Dec 2009 08:17:54 +0000 (09:17 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 19 Jan 2010 07:21:55 +0000 (08:21 +0100)
Backed by new struct nwsstr member nws_duration.  Time between first
and last occurence of the news recorded in this item, in seconds.

include/news.h
src/lib/common/nsc.c
src/lib/subs/nreport.c

index 24554f096c32da24e3fa7b93404e994d21c10993..54d7ef9f09b3f5cbf60d415ae983e32a0cb35eba 100644 (file)
@@ -55,6 +55,7 @@ struct nwsstr {
     unsigned char nws_vrb;     /* action (verb) */
     natid nws_vno;             /* "victim" country # */
     signed char nws_ntm;       /* number of times */
     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 */
 };
 
     time_t nws_when;           /* time of action */
 };
 
index 462007982e307b6d2ddf53363c430cc7dcc6184e..eb0348ee9574905790bcc065c2011ea6c26a844a 100644 (file)
@@ -475,6 +475,7 @@ struct castr news_ca[] = {
     {"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},
     {"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
     {"time", fldoff(nws_when), NSC_TIME, 0, NULL, EF_BAD, 0},
     {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
 #undef CURSTR
index 522888f252827813eb82c12867223305e6ccf94e..2d92aa8a132ebbfe5604605c956c6dd8783813d4 100644 (file)
@@ -161,7 +161,7 @@ ncache(int actor, int event, int victim, int times)
     struct newscache *np;
     int i;
     int oldslot;
     struct newscache *np;
     int i;
     int oldslot;
-    time_t oldtime;
+    time_t oldtime, dur;
     time_t now = time(NULL);
 
     oldslot = -1;
     time_t now = time(NULL);
 
     oldslot = -1;
@@ -174,11 +174,13 @@ ncache(int actor, int event, int victim, int times)
        }
        if (np->news.nws_vrb == 0)
            continue;
        }
        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;
            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;
        }
     }
            return np;
        }
     }
@@ -189,10 +191,11 @@ ncache(int actor, int event, int victim, int times)
     np = &cache[actor][oldslot];
     ef_blank(EF_NEWS, news_tail, &np->news);
     np->news.nws_ano = actor;
     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_vrb = event;
+    np->news.nws_vno = victim;
     np->news.nws_ntm = times;
     np->news.nws_ntm = times;
+    np->news.nws_duration = 0;
+    np->news.nws_when = now;
     np->id = news_tail++;
     return np;
 }
     np->id = news_tail++;
     return np;
 }