]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/lostsub.c
Expire lost items at the update instead of continuously
[empserver] / src / lib / subs / lostsub.c
index b254f8ab448004618d0c2f4b79bd292846a337b5..427ec5a5625a7da35f86b2ce53ef18fc9b1a6470 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "file.h"
 #include "lost.h"
+#include "misc.h"
+#include "optlist.h"
 
 static int findlost(short, natid, short, coord, coord, int);
 
@@ -118,3 +120,20 @@ findlost(short type, natid owner, short id, coord x, coord y, int free)
 
     return -1;
 }
+
+void
+delete_old_lostitems(void)
+{
+    time_t expiry_time = time(NULL) - hours(lost_keep_hours);
+    struct loststr lost;
+    int i;
+
+    for (i = 0; getlost(i, &lost); i++) {
+       if (!lost.lost_owner)
+           continue;
+       if (lost.lost_timestamp >= expiry_time)
+           continue;
+       lost.lost_owner = 0;
+       putlost(i, &lost);
+    }
+}