1 #ifndef __STRUCTURE_INTERNAL_H
2 #define __STRUCTURE_INTERNAL_H
3 
4 //
5 // If you wish to use the structure database functions, include
6 // structure_extern.h, not structure.h!
7 //
8 
9 #include "Types.h"
10 
11 // A few words about the overall structure scheme:
12 //
13 // Large structures are split into multiple sections,
14 // one for each tile.
15 //
16 // Each section is treated as a separate object,
17 // except that it does NOT record information about
18 // hit points, but instead stores a pointer to the
19 // base object (section).
20 //
21 // Each section has a line of sight profile.  These
22 // profiles are split into 5 in each horizontal direction
23 // and 4 vertically, forming 100 "cubes".  In real
24 // world terms, each section represents a volume
25 // with a height of 8 feet (and width and length
26 // of what?)
27 //
28 // It is important to note that the vertical
29 // position of each section is measured in individual
30 // cubes (rather than, as it were, groups of 4 vertical
31 // cubes)
32 
33 #define PROFILE_X_SIZE 5
34 #define PROFILE_Y_SIZE 5
35 #define PROFILE_Z_SIZE 4
36 
37 // these values should be compared for less than rather than less
38 // than or equal to
39 #define STRUCTURE_ON_GROUND 0
40 #define STRUCTURE_ON_ROOF PROFILE_Z_SIZE
41 #define STRUCTURE_ON_GROUND_MAX PROFILE_Z_SIZE
42 #define STRUCTURE_ON_ROOF_MAX PROFILE_Z_SIZE * 2
43 
44 typedef UINT8 PROFILE[PROFILE_X_SIZE][PROFILE_Y_SIZE];
45 
46 extern UINT8 AtHeight[PROFILE_Z_SIZE];
47 
48 // MAP_ELEMENT may get later:
49 // PROFILE *		CombinedLOSProfile;
50 // PROFILE *		CombinedProtectionProfile;
51 //
52 // LEVELNODE gets a pointer to a STRUCTURE or
53 // a union between its soldier pointer and a
54 // STRUCTURE pointer
55 
56 // if (fFlags & STRUCTURE_BASE_TILE)
57 // then the structure is the "base" of the object
58 // and its hitpoint value is the one for the object
59 //
60 //    vv       generic flags for all structures
61 //    vvv      type flags
62 //
63 
64 // how to handle explodable structures
65 
66 enum StructureFlags
67 {
68 	// NOT used in DB structures
69 	STRUCTURE_BASE_TILE     = 0x00000001,
70 	STRUCTURE_OPEN          = 0x00000002,
71 	STRUCTURE_OPENABLE      = 0x00000004,
72 
73 	STRUCTURE_MOBILE        = 0x00000010,
74 	/* STRUCTURE_PASSABLE is set for each structure instance where the tile flag
75 	 * TILE_PASSABLE is set */
76 	STRUCTURE_PASSABLE      = 0x00000020,
77 	STRUCTURE_EXPLOSIVE     = 0x00000040,
78 	STRUCTURE_TRANSPARENT   = 0x00000080,
79 
80 	STRUCTURE_GENERIC       = 0x00000100,
81 	STRUCTURE_TREE          = 0x00000200,
82 	STRUCTURE_FENCE         = 0x00000400,
83 	STRUCTURE_WIREFENCE     = 0x00000800,
84 
85 	STRUCTURE_HASITEMONTOP  = 0x00001000, // ATE: struct has item on top of it
86 	STRUCTURE_SPECIAL       = 0x00002000,
87 	STRUCTURE_LIGHTSOURCE   = 0x00004000,
88 	STRUCTURE_VEHICLE       = 0x00008000,
89 
90 	STRUCTURE_WALL          = 0x00010000,
91 	STRUCTURE_WALLNWINDOW   = 0x00020000,
92 	STRUCTURE_SLIDINGDOOR   = 0x00040000,
93 	STRUCTURE_DOOR          = 0x00080000,
94 
95 	/* a "multi" structure (as opposed to multitiled) is composed of multiple
96 	 * graphics & structures */
97 	STRUCTURE_MULTI         = 0x00100000,
98 	STRUCTURE_CAVEWALL      = 0x00200000,
99 	STRUCTURE_DDOOR_LEFT    = 0x00400000,
100 	STRUCTURE_DDOOR_RIGHT   = 0x00800000,
101 
102 	STRUCTURE_NORMAL_ROOF   = 0x01000000,
103 	STRUCTURE_SLANTED_ROOF  = 0x02000000,
104 	STRUCTURE_TALL_ROOF     = 0x04000000,
105 	STRUCTURE_SWITCH        = 0x08000000,
106 
107 	STRUCTURE_ON_LEFT_WALL  = 0x10000000,
108 	STRUCTURE_ON_RIGHT_WALL = 0x20000000,
109 	STRUCTURE_CORPSE        = 0x40000000,
110 	STRUCTURE_PERSON        = 0x80000000,
111 
112 // Combination flags
113 	STRUCTURE_ANYFENCE      = 0x00000C00,
114 	STRUCTURE_ANYDOOR       = 0x00CC0000,
115 	STRUCTURE_OBSTACLE      = 0x00008F00,
116 	STRUCTURE_WALLSTUFF     = 0x00CF0000,
117 	STRUCTURE_BLOCKSMOVES   = 0x00208F00,
118 	STRUCTURE_TYPE_DEFINED  = 0x8FEF8F00,
119 	STRUCTURE_ROOF          = 0x07000000
120 };
121 ENUM_BITSET(StructureFlags)
122 
123 #define TILE_ON_ROOF						0x01
124 #define TILE_PASSABLE						0x02
125 
126 struct DB_STRUCTURE_TILE
127 {
128 	INT16			sPosRelToBase;  // "single-axis"
129 	INT8			bXPosRelToBase;
130 	INT8			bYPosRelToBase;
131 	PROFILE		Shape;					// 25 bytes
132 	UINT8			fFlags;
133 	UINT8			ubVehicleHitLocation;
134 	BYTE			bUnused[1]; // XXX HACK000B
135 }; // 32 bytes
136 
137 #define BASE_TILE 0
138 
139 #define NO_PARTNER_STRUCTURE 0
140 
141 struct DB_STRUCTURE
142 {
143 	UINT8								ubArmour;
144 	UINT8								ubHitPoints;
145 	UINT8								ubDensity;
146 	UINT8								ubNumberOfTiles;
147 	UINT32							fFlags;
148 	UINT16							usStructureNumber;
149 	UINT8								ubWallOrientation;
150 	INT8								bDestructionPartner; // >0 = debris number (bDP - 1), <0 = partner graphic
151 	INT8								bPartnerDelta; // opened/closed version, etc... 0 for unused
152 	INT8								bZTileOffsetX;
153 	INT8								bZTileOffsetY;
154 	BYTE								bUnused[1]; // XXX HACK000B
155 }; // 16 bytes
156 
157 struct DB_STRUCTURE_REF
158 {
159 	DB_STRUCTURE * 												pDBStructure;
160 	DB_STRUCTURE_TILE **									ppTile; // dynamic array
161 }; // 8 bytes
162 
163 struct STRUCTURE
164 {
165 	STRUCTURE*                    pPrev;
166 	STRUCTURE*                    pNext;
167 	INT16													sGridNo;
168 	UINT16												usStructureID;
169 	const DB_STRUCTURE_REF*       pDBStructureRef;
170 	union
171 	{
172 		struct
173 		{
174 			UINT8											ubHitPoints;
175 			UINT8											ubLockStrength;
176 		};
177 		struct
178 		{
179 			INT16											sBaseGridNo;
180 		};
181 	}; // 2 bytes
182 	INT16													sCubeOffset;// height of bottom of object in profile "cubes"
183 	UINT32												fFlags; // need to have something to indicate base tile/not
184 	PROFILE *											pShape;
185 	UINT8													ubWallOrientation;
186 	UINT8													ubVehicleHitLocation;
187 	UINT8													ubStructureHeight; // if 0, then unset; otherwise stores height of structure when last calculated
188 	UINT8													ubUnused[1]; // XXX HACK000B
189 }; // 32 bytes
190 
191 struct STRUCTURE_FILE_REF
192 {
193 	STRUCTURE_FILE_REF* pPrev;
194 	STRUCTURE_FILE_REF* pNext;
195 	AuxObjectData*      pAuxData;
196 	RelTileLoc*         pTileLocData;
197 	UINT8*              pubStructureData;
198 	DB_STRUCTURE_REF*   pDBStructureRef; // dynamic array
199 	UINT16              usNumberOfStructures;
200 	UINT16              usNumberOfStructuresStored;
201 }; // 24 bytes
202 
203 #define STRUCTURE_FILE_CONTAINS_AUXIMAGEDATA		0x01
204 #define STRUCTURE_FILE_CONTAINS_STRUCTUREDATA		0x02
205 
206 #endif
207