]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/nreport.c
Record news more compactly
[empserver] / src / lib / subs / nreport.c
index 522888f252827813eb82c12867223305e6ccf94e..cfb5641bdac625c3bc75d2f378125a7258b26fc9 100644 (file)
@@ -117,7 +117,6 @@ delete_old_news(void)
     for (j = 0; getnews(i + j, &news); j++) {
        if (news.nws_vrb == 0)
            break;
-       ef_set_uid(EF_NEWS, &news, j);
        putnews(j, &news);
     }
     CANT_HAPPEN(i + j != news_tail);
@@ -161,7 +160,7 @@ ncache(int actor, int event, int victim, int times)
     struct newscache *np;
     int i;
     int oldslot;
-    time_t oldtime;
+    time_t oldtime, dur;
     time_t now = time(NULL);
 
     oldslot = -1;
@@ -174,11 +173,13 @@ ncache(int actor, int event, int victim, int times)
        }
        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;
        }
     }
@@ -189,10 +190,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->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;
 }