]> git.pond.sub.org Git - empserver/blob - include/plane.h
e94f67944055b1ac602096d1892d0d39b0df1fe8
[empserver] / include / plane.h
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2009, 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  *  plane.h: Definitions for planes and plane types
29  *
30  *  Known contributors to this file:
31  *     Dave Pare, 1986
32  *     Ken Stevens, 1995
33  *     Steve McClure, 1998
34  *     Markus Armbruster, 2004-2008
35  */
36
37 #ifndef PLANE_H
38 #define PLANE_H
39
40 #include <time.h>
41 #include "queue.h"
42 #include "types.h"
43
44 #define PLN_TYPE_MAX    46
45 #define PLANE_MINEFF    10
46
47 struct plnstr {
48     /* initial part must match struct empobj */
49     short ef_type;
50     short pln_uid;              /* plane unit id */
51     unsigned pln_seqno;
52     time_t pln_timestamp;       /* Last time this plane was touched */
53     natid pln_own;              /* owning country */
54     coord pln_x;                /* plane x-y */
55     coord pln_y;
56     signed char pln_type;       /* index in plchr[] */
57     signed char pln_effic;      /* actually "training" */
58     signed char pln_mobil;      /* plane mobility */
59     unsigned char pln_off;      /* repairs stopped? */
60     short pln_tech;             /* plane's tech level */
61     char pln_wing;              /* like fleet */
62     coord pln_opx;              /* Op sector coords */
63     coord pln_opy;              /* Op sector coords */
64     short pln_mission;          /* mission code */
65     short pln_radius;           /* mission radius */
66     /* end of part matching struct empobj */
67     unsigned char pln_range;    /* total distance, not radius */
68     short pln_ship;             /* pointer to carrier */
69     short pln_land;             /* pointer to carrier */
70     signed char pln_harden;     /* for missiles */
71     signed char pln_flags;      /* State of the plane */
72     short pln_access;           /* Last tick mob was updated (MOB_ACCESS) */
73     float pln_theta;            /* position in orbital sine wave */
74 };
75
76 #define PLN_LAUNCHED    bit(0)  /* Flying (satellite: in orbit) */
77 #define PLN_SYNCHRONOUS bit(1)  /* A satellite in geo-synchronous orbit */
78 #define PLN_AIRBURST    bit(2)  /* Airburst the nuke we're armed with */
79
80 struct plchrstr {
81     char *pl_name;              /* full name of type of plane */
82     int pl_lcm;                 /* costs to build */
83     int pl_hcm;
84     int pl_cost;
85     int pl_tech;                /* tech needed to build */
86     int pl_acc;                 /* bombing accuracy (higher the better) */
87     int pl_load;                /* bomb load, also for carrying cargo */
88     int pl_att;                 /* air-air attack/defense strengths */
89     int pl_def;
90     int pl_range;               /* how many sectors it can fly */
91     int pl_crew;                /* number of mil to crew it */
92     int pl_fuel;                /* fuel consumption */
93     int pl_stealth;             /* how stealthy is it? */
94     int pl_flags;               /* description of capability */
95     signed char pl_type;        /* index in plchr[] */
96 };
97
98 #define P_B     bit(0)          /* bombing factor only for bombing */
99 #define P_T     bit(1)          /* tactical bombing ability */
100 #define P_F     bit(2)          /* interceptor/escort */
101 #define P_C     bit(3)          /* bombing factor for transport only */
102 #define P_V     bit(4)          /* vtol ability */
103 #define P_M     bit(5)          /* missile, used only once, can't be intercepted */
104 #define P_L     bit(6)          /* light plane, lands on carriers */
105 #define P_S     bit(7)          /* Spy ability */
106 #define P_I     bit(8)          /* Imaging ability (advanced spying) */
107 #define P_O     bit(9)          /* Orbital ability (a satellite) */
108 #define P_X     bit(10)         /* Stealth ability */
109 #define P_N     bit(11)         /* Nuclear RV interceptor (abm) */
110 #define P_H     bit(12)         /* Half stealthy */
111 #define P_E     bit(13)         /* extra light */
112 #define P_K     bit(14)         /* chopper */
113 #define P_A     bit(15)         /* ASW (Anti-Sub Warfare) */
114 #define P_P     bit(16)         /* paradropping */
115 #define P_ESC   bit(17)         /* escort */
116 #define P_MINE  bit(18)         /* can lay mines */
117 #define P_SWEEP bit(19)         /* can sweep mines */
118 #define P_MAR   bit(20)         /* missile can hit ships */
119
120 #define PM_R    bit(0)          /* Recon mission */
121 #define PM_S    bit(1)          /* Mine-sweeping mission */
122
123         /* internal to "fly" module -- really shouldn't be here */
124
125 struct plist {
126     struct emp_qelem queue;     /* list of planes */
127     int bombs;                  /* bombs carried for bombing mission */
128     int misc;                   /* amount of random item being transported */
129     struct plchrstr *pcp;       /* pointer to desc of plane */
130     struct plnstr plane;        /* struct plane */
131 };
132
133 #define getplane(n, p) ef_read(EF_PLANE, (n), (p))
134 #define putplane(n, p) ef_write(EF_PLANE, (n), (p))
135 #define getplanep(n) ((struct plnstr *)ef_ptr(EF_PLANE, (n)))
136
137 extern struct plchrstr plchr[PLN_TYPE_MAX + 2];
138
139 struct shiplist {
140     short uid;
141     struct shiplist *next;
142 };
143
144 /* Work required for building 100% */
145 #define PLN_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
146
147 extern int pl_att(struct plchrstr *, int);
148 extern int pl_def(struct plchrstr *, int);
149 extern int pl_acc(struct plchrstr *, int);
150 extern int pl_range(struct plchrstr *, int);
151 extern int pl_load(struct plchrstr *, int);
152 extern int pln_att(struct plnstr *);
153 extern int pln_def(struct plnstr *);
154 extern int pln_acc(struct plnstr *);
155 extern int pln_range_max(struct plnstr *);
156 extern int pln_load(struct plnstr *);
157
158 /* src/lib/common/cargo.c */
159 extern void pln_carrier_change(struct plnstr *, int, int, int);
160 extern int pln_first_on_ship(struct shpstr *);
161 extern int pln_first_on_land(struct lndstr *);
162 extern int pln_next_on_unit(int);
163
164 /* src/lib/subs/aircombat.c */
165 extern int ac_flak_dam(int, int, int);
166 extern void ac_encounter(struct emp_qelem *, struct emp_qelem *, coord,
167                          coord, char *, int);
168
169 /* src/lib/subs/aswplnsubs.c */
170 extern int on_shiplist(short, struct shiplist *);
171 extern void add_shiplist(short, struct shiplist **);
172 extern void free_shiplist(struct shiplist **);
173 extern void print_shiplist(struct shiplist *);
174
175 #endif