]> git.pond.sub.org Git - empserver/blob - src/lib/subs/aswplnsubs.c
Cleanup #includes of (mostly a long time) unused header files.
[empserver] / src / lib / subs / aswplnsubs.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2004, 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  *  aswplnsubs.c: Various subroutines used for ASW planes
29  * 
30  *  Known contributors to this file:
31  *     
32  */
33
34 #include "misc.h"
35 #include "player.h"
36 #include "xy.h"
37 #include "ship.h"
38 #include "nsc.h"
39 #include "nat.h"
40 #include "path.h"
41 #include "file.h"
42 #include "plane.h"
43 #include <fcntl.h>
44 #include <ctype.h>
45 #include "prototypes.h"
46
47 int
48 have_looked(u_char uid, struct shiplook *head)
49 {
50     struct shiplook *s;
51
52     s = head;
53     if (s->uid == -1)
54         return 0;
55
56     while (s != ((struct shiplook *)0)) {
57         if (s->uid == uid)
58             return s->looked;
59         s = s->next;
60     }
61
62     return 0;
63 }
64
65 int
66 have_found(u_char uid, struct shiplook *head)
67 {
68     struct shiplook *s;
69
70     s = head;
71     if (s->uid == -1)
72         return 0;
73
74     while (s != ((struct shiplook *)0)) {
75         if (s->uid == uid)
76             return s->found;
77         s = s->next;
78     }
79
80     return 0;
81 }
82
83 void
84 set_have_looked(u_char uid, struct shiplook *head)
85 {
86     struct shiplook *s, *s2;
87
88     s = head;
89     if (s->uid == -1) {
90         s->uid = uid;
91         s->looked = 1;
92         s->found = 0;
93         s->next = (struct shiplook *)0;
94     }
95
96     while (s != ((struct shiplook *)0)) {
97         if (s->uid == uid) {
98             s->looked = 1;
99             return;
100         }
101         s2 = s;
102         s = s->next;
103     }
104
105     s = (struct shiplook *)malloc(sizeof(struct shiplook));
106     memset(s, 0, sizeof(struct shiplook));
107     s2->next = s;
108     s->uid = uid;
109     s->looked = 1;
110     s->next = (struct shiplook *)0;
111 }
112
113 void
114 set_have_found(u_char uid, struct shiplook *head)
115 {
116     struct shiplook *s, *s2;
117
118     s = head;
119     if (s->uid == -1) {
120         s->uid = uid;
121         s->looked = 0;
122         s->found = 1;
123         s->next = (struct shiplook *)0;
124     }
125
126
127     while (s != ((struct shiplook *)0)) {
128         if (s->uid == uid) {
129             s->found = 1;
130             return;
131         }
132         s2 = s;
133         s = s->next;
134     }
135
136     s = (struct shiplook *)malloc(sizeof(struct shiplook));
137     memset(s, 0, sizeof(struct shiplook));
138     s2->next = s;
139     s->uid = uid;
140     s->found = 1;
141     s->next = (struct shiplook *)0;
142 }
143
144 int
145 print_found(struct shiplook *head)
146 {
147     struct shiplook *s;
148     int first;
149     struct mchrstr *mp;
150     struct shpstr ship;
151
152     s = head;
153     first = 1;
154     if (s->uid == -1)
155         return 0;
156
157     while (s != ((struct shiplook *)0)) {
158         getship(s->uid, &ship);
159         mp = &mchr[(int)ship.shp_type];
160         if (first) {
161             pr(" #          player->owner           eff        type\n");
162             first = 0;
163         }
164         pr("(#%3d) %10.10s  %12.12s  %s\n", ship.shp_uid,
165            cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
166         s = s->next;
167     }
168
169     return 1;
170 }