1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; either version 2 of the License, or
5  *  (at your option) any later version.
6  *
7  *  This program is distributed in the hope that it will be useful,
8  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *  GNU General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */
16 
17 #ifndef UQM_GRPINFO_H_
18 #define UQM_GRPINFO_H_
19 
20 #include "port.h"
21 #include "libs/compiler.h"
22 #include "displist.h"
23 #include "libs/gfxlib.h"
24 		// for POINT
25 #include <assert.h>
26 
27 #if defined(__cplusplus)
28 extern "C" {
29 #endif
30 
31 // XXX: Needed to maintain savegame compatibility
32 #define NUM_SAVED_BATTLE_GROUPS 64
33 
34 typedef HLINK HIPGROUP;
35 
36 typedef struct
37 {
38 	// LINK elements; must be first
39 	HIPGROUP pred;
40 	HIPGROUP succ;
41 
42 	UWORD group_counter;
43 	BYTE race_id;
44 	BYTE sys_loc;
45 	BYTE task;  // AKA mission
46 	BYTE in_system;
47 			// a simple != 0 flag
48 			// In older savegames this will be >1, because
49 			//   CloneShipFragment was used to spawn groups,
50 			//   and it set this to crew_level values
51 
52 	BYTE dest_loc;
53 	BYTE orbit_pos;
54 			/* Also: saved prev dest_loc before intercept call,
55 			 *   restored to dest_loc on all-clear */
56 	BYTE group_id;
57 	POINT loc;
58 
59 	FRAME melee_icon;
60 } IP_GROUP;
61 
62 enum
63 {
64 	IN_ORBIT = 0,
65 	EXPLORE,
66 	FLEE,
67 	ON_STATION,
68 
69 	IGNORE_FLAGSHIP = 1 << 2,
70 	REFORM_GROUP = 1 << 3
71 };
72 #define MAX_REVOLUTIONS 5
73 
74 #define STATION_RADIUS 1600
75 #define ORBIT_RADIUS 2400
76 
77 static inline IP_GROUP *
LockIpGroup(const QUEUE * pq,HIPGROUP h)78 LockIpGroup (const QUEUE *pq, HIPGROUP h)
79 {
80 	assert (GetLinkSize (pq) == sizeof (IP_GROUP));
81 	return (IP_GROUP *) LockLink (pq, h);
82 }
83 
84 #define UnlockIpGroup(pq, h)  UnlockLink (pq, h)
85 #define FreeIpGroup(pq, h)    FreeLink (pq, h)
86 
87 extern HIPGROUP BuildGroup (QUEUE *pDstQueue, BYTE race_id);
88 
89 #if defined(__cplusplus)
90 }
91 #endif
92 
93 #endif /* UQM_GRPINFO_H_ */
94