Expire lost items at the update instead of continuously

Replace thread DeleteItems running delete_lostitems() by simple
function delete_old_lostitems(), and call it from update_main().
This commit is contained in:
Markus Armbruster 2008-09-10 07:30:48 -04:00
parent b72fd20674
commit 7441e2499f
6 changed files with 21 additions and 71 deletions

View 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);
}
}

View file

@ -173,6 +173,7 @@ update_main(void)
unit_cargo_init();
delete_old_announcements();
delete_old_news();
delete_old_lostitems();
/* Clear all the telegram flags */
for (cn = 0; cn < MAXNOC; cn++)
clear_telegram_is_new(cn);