]> git.pond.sub.org Git - empserver/blob - src/lib/subs/aswplnsubs.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / subs / aswplnsubs.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2006, 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 files README, COPYING and CREDITS in the root of the source
23  *  tree for related information and legal notices.  It is expected
24  *  that future projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  aswplnsubs.c: Various subroutines used for ASW planes
29  * 
30  *  Known contributors to this file:
31  *  Ron Koenderink, 2004
32  *     
33  */
34
35 #include <config.h>
36
37 #include <stdlib.h>
38 #include "misc.h"
39 #include "file.h"
40 #include "ship.h"
41 #include "plane.h"
42 #include "prototypes.h"
43
44 int
45 on_shiplist(short uid, struct shiplist *head)
46 {
47     struct shiplist *s;
48
49     s = head;
50     while (s != NULL) {
51         if (s->uid == uid)
52             return 1;
53         s = s->next;
54     }
55     return 0;
56 }
57
58 void
59 add_shiplist(short uid, struct shiplist **head)
60 {
61     struct shiplist *s, *s2;
62
63     s = *head;
64     s2 = NULL;
65
66     while (s != NULL) {
67         if (s->uid == uid) {
68             return;
69         }
70         s2 = s;
71         s = s->next;
72     }
73
74     s = malloc(sizeof(struct shiplist));
75     if (s2 != NULL) 
76         s2->next = s;
77     else
78         *head = s;
79     s->uid = uid;
80     s->next = NULL;
81 }
82
83 void
84 free_shiplist(struct shiplist **head)
85 {
86     struct shiplist *s, *s2;
87
88     s = *head;
89
90     while (s != NULL) {
91         s2 = s;
92         s = s->next;
93         free(s2);
94     }
95     *head = NULL;
96 }
97
98 void
99 print_shiplist(struct shiplist *head)
100 {
101     struct shiplist *s;
102     int first;
103     struct mchrstr *mp;
104     struct shpstr ship;
105
106     s = head;
107     first = 1;
108
109     while (s != NULL) {
110         getship(s->uid, &ship);
111         mp = &mchr[(int)ship.shp_type];
112         if (first) {
113             pr(" #          player->owner           eff        type\n");
114             first = 0;
115         }
116         pr("(#%3d) %10.10s  %12.12s  %s\n", ship.shp_uid,
117            cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
118         s = s->next;
119     }
120 }