]> git.pond.sub.org Git - empserver/blob - src/lib/commands/lost.c
Indented with src/scripts/indent-emp.
[empserver] / src / lib / commands / lost.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  lost.c: List lost items
29  * 
30  *  Known contributors to this file:
31  *     Steve McClure, 1997
32  */
33
34 #include "player.h"
35 #include "nat.h"
36 #include "nsc.h"
37 #include "file.h"
38 #include "lost.h"
39 #include "optlist.h"
40 #include "commands.h"
41
42 int
43 lost(void)
44 {
45     int nlost;
46     struct nstr_item ni;
47     struct loststr lost;
48     time_t now;
49
50     if (!player->argp[1]) {
51         if (!snxtitem(&ni, EF_LOST, "*"))
52             return RET_SYN;
53     } else {
54         if (!snxtitem(&ni, EF_LOST, player->argp[1]))
55             return RET_SYN;
56     }
57
58     prdate();
59     nlost = 0;
60     time(&now);
61     pr("DUMP LOST ITEMS %d\n", now);
62     if (player->god)
63         pr("owner ");
64     pr("type id x y timestamp\n");
65     while (nxtitem(&ni, (s_char *)&lost)) {
66         if (lost.lost_owner == 0)
67             continue;
68         if (lost.lost_owner != player->cnum && !player->god)
69             continue;
70         if (player->god)
71             pr("%d ", lost.lost_owner);
72         pr("%d %d ", lost.lost_type, lost.lost_id);
73         prxy("%d %d ", lost.lost_x, lost.lost_y, player->cnum);
74         pr("%d\n", lost.lost_timestamp);
75         nlost++;
76     }
77     if (nlost == 0) {
78         if (player->argp[1])
79             pr("%s: Nothing lost.\n", player->argp[1]);
80         else
81             pr("%s: Nothing lost.\n", "");
82     } else
83         pr("%d lost item%s.\n", nlost, splur(nlost));
84     return RET_OK;
85 }