]> git.pond.sub.org Git - empserver/blob - src/lib/subs/aswplnsubs.c
Do not include var.h where no longer needed. Clean up register keywords in these...
[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 "sect.h"
38 #include "ship.h"
39 #include "nsc.h"
40 #include "nat.h"
41 #include "path.h"
42 #include "file.h"
43 #include "queue.h"
44 #include "plane.h"
45 #include <fcntl.h>
46 #include <ctype.h>
47 #include "prototypes.h"
48
49 int
50 have_looked(u_char uid, struct shiplook *head)
51 {
52     struct shiplook *s;
53
54     s = head;
55     if (s->uid == -1)
56         return 0;
57
58     while (s != ((struct shiplook *)0)) {
59         if (s->uid == uid)
60             return s->looked;
61         s = s->next;
62     }
63
64     return 0;
65 }
66
67 int
68 have_found(u_char uid, struct shiplook *head)
69 {
70     struct shiplook *s;
71
72     s = head;
73     if (s->uid == -1)
74         return 0;
75
76     while (s != ((struct shiplook *)0)) {
77         if (s->uid == uid)
78             return s->found;
79         s = s->next;
80     }
81
82     return 0;
83 }
84
85 void
86 set_have_looked(u_char uid, struct shiplook *head)
87 {
88     struct shiplook *s, *s2;
89
90     s = head;
91     if (s->uid == -1) {
92         s->uid = uid;
93         s->looked = 1;
94         s->found = 0;
95         s->next = (struct shiplook *)0;
96     }
97
98     while (s != ((struct shiplook *)0)) {
99         if (s->uid == uid) {
100             s->looked = 1;
101             return;
102         }
103         s2 = s;
104         s = s->next;
105     }
106
107     s = (struct shiplook *)malloc(sizeof(struct shiplook));
108     memset(s, 0, sizeof(struct shiplook));
109     s2->next = s;
110     s->uid = uid;
111     s->looked = 1;
112     s->next = (struct shiplook *)0;
113 }
114
115 void
116 set_have_found(u_char uid, struct shiplook *head)
117 {
118     struct shiplook *s, *s2;
119
120     s = head;
121     if (s->uid == -1) {
122         s->uid = uid;
123         s->looked = 0;
124         s->found = 1;
125         s->next = (struct shiplook *)0;
126     }
127
128
129     while (s != ((struct shiplook *)0)) {
130         if (s->uid == uid) {
131             s->found = 1;
132             return;
133         }
134         s2 = s;
135         s = s->next;
136     }
137
138     s = (struct shiplook *)malloc(sizeof(struct shiplook));
139     memset(s, 0, sizeof(struct shiplook));
140     s2->next = s;
141     s->uid = uid;
142     s->found = 1;
143     s->next = (struct shiplook *)0;
144 }
145
146 int
147 print_found(struct shiplook *head)
148 {
149     struct shiplook *s;
150     int first;
151     struct mchrstr *mp;
152     struct shpstr ship;
153
154     s = head;
155     first = 1;
156     if (s->uid == -1)
157         return 0;
158
159     while (s != ((struct shiplook *)0)) {
160         getship(s->uid, &ship);
161         mp = &mchr[(int)ship.shp_type];
162         if (first) {
163             pr(" #          player->owner           eff        type\n");
164             first = 0;
165         }
166         pr("(#%3d) %10.10s  %12.12s  %s\n", ship.shp_uid,
167            cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
168         s = s->next;
169     }
170
171     return 1;
172 }