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