1 #ifndef _obchunk_hpp
2 #define _obchunk_hpp 1
3 
4 #include "chunk.hpp"
5 
6 #include "chnktype.hpp"
7 #include "mishchnk.hpp"
8 
9 
10 // object flags
11 
12 #define OBJECT_FLAG_BASE_OBJECT 0x0000100
13 #define OBJECT_FLAG_MODULE_OBJECT 0x0000200
14 #define OBJECT_FLAG_PLACED_OBJECT 0x0000400
15 
16 // Note these flags have to correspond with the ones used by ed_ob_type
17 // and AVP generator flags
18 
19 #define OBJECT_FLAG_AVPGAMEMODEMARINE 	0x00000800
20 #define OBJECT_FLAG_AVPGAMEMODEALIEN 		0x00001000
21 #define OBJECT_FLAG_AVPGAMEMODEPREDATOR	0x00002000
22 
23 #define OBJECT_FLAG_PLATFORMLOADSET			0x00004000
24 #define OBJECT_FLAG_PCLOAD 							0x00008000
25 #define OBJECT_FLAG_PSXLOAD 						0x00010000
26 #define OBJECT_FLAG_SATURNLOAD 					    0x00020000
27 
28 #define OBJECT_FLAG_NOTDIFFICULTY1 					0x00100000
29 #define OBJECT_FLAG_NOTDIFFICULTY2 					0x00200000
30 #define OBJECT_FLAG_NOTDIFFICULTY3 					0x00400000
31 
32 
33 class Shape_Chunk;
34 class Shape_Header_Chunk;
35 class Object_Header_Chunk;
36 
37 // flags structure
38 
39 struct object_flags
40 {
41 	unsigned int locked : 1;
42 // add more flags here as they are needed
43 };
44 
45 
46 class VModule_Array_Chunk;
47 
48 class Object_Chunk : public Lockable_Chunk_With_Children
49 {
50 public:
51 
52 	// constructor from buffer
53 	Object_Chunk (Chunk_With_Children * parent,const char *, size_t);
54 
55 	// constructor from data
56 
57 	Object_Chunk (Chunk_With_Children * parent, ChunkObject &obj);
58 
59 	// destructor
60 	virtual ~Object_Chunk();
61 
62 	const ChunkObject object_data;
63 
64 	Shape_Chunk * get_assoc_shape();
65 
66 	BOOL assoc_with_shape (Shape_Chunk *);
67 
68 	BOOL deassoc_with_shape (Shape_Chunk *);
69 
70 	Object_Header_Chunk * get_header();
71 
72 	BOOL inc_v_no();
73 
74 	BOOL same_and_updated(Object_Chunk &);
75 
76 	BOOL assoc_with_shape_no(File_Chunk *);
77 
78 	void update_my_chunkobject (ChunkObject &);
79 
80 	// functions for the locking functionality
81 
82 	BOOL file_equals (HANDLE &);
83 	const char * get_head_id();
84 	void set_lock_user(char *);
85 
86 	virtual void post_input_processing();
87 
88 	VModule_Array_Chunk * get_vmod_chunk();
89 
90 	// destroy object needs to go through all the other
91 	// objects and delete itself from the VMAC
92 
93 	void destroy(File_Chunk *);
94 
95 	ObjectID CalculateID();
96 
97 	//program_object_index can be set by the program using the chunks , so you can find where
98 	//the object has been put.
99 	//I need it so that I can find out which module each object has been put into.
100 	int program_object_index;
101 
102 private:
103 
104 	friend class File_Chunk;
105 	friend class Object_Header_Chunk;
106 
107 	ChunkObject * object_data_store;
108 
109 };
110 
111 ///////////////////////////////////////////////
112 
113 class Object_Header_Chunk : public Chunk
114 {
115 public:
116 	// constructor from buffer
117 	Object_Header_Chunk (Chunk_With_Children * parent, const char * pdata, size_t psize);
118 	virtual size_t size_chunk ();
119 
120 	virtual BOOL output_chunk (HANDLE &);
121 
122 	virtual void fill_data_block (char * data_start);
123 
124 	const ChunkObject * const object_data;
125 
126 	virtual void prepare_for_output();
127 
get_lockuser()128 	const char * get_lockuser()
129 	{
130 		return lock_user;
131 	}
132 
133 	int flags;
134 
135 private:
136 
137 	friend class Object_Chunk;
138 	friend class Shape_Header_Chunk;
139 	friend class RIF_File_Chunk;
140 	friend class File_Chunk;
141 
142 	friend class Environment;
143 
144 	char lock_user[17];
145 	int version_no;
146 
147 	int shape_id_no;
148 
149 	Shape_Chunk * associated_shape;
150 
151 
152 
153 	// constructor from data
154 	Object_Header_Chunk (Object_Chunk * parent);
155 
156 };
157 
158 
159 ///////////////////////////////////////////////
160 
161 
162 // automatically constructed when Object_Chunks are constructed from
163 // data
164 
165 class Object_Interface_Data_Chunk : public Chunk_With_Children
166 {
167 public:
168 	// constructor from buffer
169 	Object_Interface_Data_Chunk (Chunk_With_Children * parent,const char *, size_t);
170 private:
171 
172 	friend class Object_Chunk;
173 
174 
175 
176 	// constructor from Object_Chunks
177 	Object_Interface_Data_Chunk (Object_Chunk * parent);
178 
179 };
180 
181 ///////////////////////////////////////////////
182 
183 class Object_Notes_Chunk : public Chunk
184 {
185 public:
186 
187 	Object_Notes_Chunk (Chunk_With_Children * parent,
188 									 const char * _data, size_t _data_size);
189 
190 
191 	virtual ~Object_Notes_Chunk ();
192 
size_chunk()193 	virtual size_t size_chunk ()
194 	{
195 		chunk_size = (data_size + 12);
196 		chunk_size += (4-chunk_size%4)%4;
197 		return chunk_size;
198 	}
199 
200 	virtual BOOL output_chunk (HANDLE &);
201 
202 	virtual void fill_data_block (char * data_start);
203 
204 	const size_t data_size;
205 	const char * const data;
206 
207 private:
208 
209 	char * data_store;
210 
211 };
212 
213 ///////////////////////////////////////////////
214 
215 class Object_Module_Data_Chunk : public Chunk_With_Children
216 {
217 public:
218 
219 	// constructor from Object_Chunks
Object_Module_Data_Chunk(Object_Chunk * parent)220 	Object_Module_Data_Chunk (Object_Chunk * parent)
221 	: Chunk_With_Children (parent, "MODULEDT")
222 	{}
223 	// constructor from buffer
224 	Object_Module_Data_Chunk (Chunk_With_Children * parent,const char *, size_t);
225 
226 private:
227 
228 	friend class Object_Chunk;
229 	friend class AI_Module_Master_Chunk;
230 	friend class AI_Module_Slave_Chunk;
231 	// constructor from buffer
232 	Object_Module_Data_Chunk (Object_Chunk * parent,const char *, size_t);
233 
234 };
235 
236 ///////////////////////////////////////////////
237 
238 class VModule_Array_Chunk : public Chunk
239 {
240 public:
241 
242 	VModule_Array_Chunk (Object_Module_Data_Chunk * parent, VMod_Arr_Item * vma, int num_in_vma);
243 	VModule_Array_Chunk (Chunk_With_Children* parent, const char * vmdata, size_t vmsize);
244 	~VModule_Array_Chunk ();
245 
246 	int num_array_items;
247 
248 	VMod_Arr_Item * vmod_array;
249 
250 	virtual void fill_data_block (char *);
251 	virtual size_t size_chunk ();
252 
253 private:
254 
255 	friend class Object_Module_Data_Chunk;
256 
257 
258 };
259 
260 
261 ///////////////////////////////////////////////
262 
263 #if 0
264 class Adjacent_Modules_Chunk : public Chunk
265 {
266 public:
267 
268 	Adjacent_Modules_Chunk(Object_Module_Data_Chunk * parent, List<Adjacent_Module> aml)
269 	: Chunk (parent, "ADJMDLST"), adjacent_modules_list (aml)
270 	{}
271 
272 	List<Adjacent_Module> adjacent_modules_list;
273 
274 	virtual void fill_data_block (char *);
275 	virtual size_t size_chunk ();
276 
277 
278 private:
279 
280 	friend class Object_Module_Data_Chunk;
281 
282 	Adjacent_Modules_Chunk(Object_Module_Data_Chunk * parent, const char * data, size_t size);
283 
284 };
285 #endif
286 
287 //a replacement for adjacent_modules_chunk
288 #define AdjacentModuleFlag_EntryPointSetByHand 0x00000001
289 #define AdjacentModuleFlag_InsideAdjacentModule 0x00000002
290 #define AdjacentModuleFlag_AdjacentModuleInsideMe 0x00000004
291 #define AdjacentModuleFlag_Vertical 0x00000008
292 
293 class Adjacent_Module_Entry_Points_Chunk : public Chunk
294 {
295 public:
296 
Adjacent_Module_Entry_Points_Chunk(Object_Module_Data_Chunk * parent,List<Adjacent_Module> aml)297 	Adjacent_Module_Entry_Points_Chunk(Object_Module_Data_Chunk * parent, List<Adjacent_Module> aml)
298 	: Chunk (parent, "ADJMDLEP"), adjacent_modules_list (aml)
299 	{}
300 	Adjacent_Module_Entry_Points_Chunk(Chunk_With_Children * parent, const char * data, size_t size);
301 	List<Adjacent_Module> adjacent_modules_list;
302 
303 	virtual void fill_data_block (char *);
304 	virtual size_t size_chunk ();
305 
306 
307 private:
308 
309 	friend class Object_Module_Data_Chunk;
310 
311 
312 
313 };
314 
315 
316 ///////////////////////////////////////////////
317 
318 class Module_Flag_Chunk : public Chunk
319 {
320 public:
321 	Module_Flag_Chunk(Object_Module_Data_Chunk * parent);
322 	Module_Flag_Chunk(Chunk_With_Children* parent, const char * data, size_t );
323 
324 	virtual void fill_data_block(char*);
size_chunk()325 	virtual size_t size_chunk()
326 	{return chunk_size=20;}
327 
328 	int Flags;
329 	int spare;
330 private:
331 	friend class Object_Module_Data_Chunk;
332 
333 
334 
335 };
336 ///////////////////////////////////////////////
337 
338 class Module_Zone_Chunk : public Chunk
339 {
340 public:
341 	Module_Zone_Chunk(Object_Module_Data_Chunk * parent);
342 	Module_Zone_Chunk(Chunk_With_Children* parent, const char * data, size_t );
343 
344 	virtual void fill_data_block(char*);
size_chunk()345 	virtual size_t size_chunk()
346 	{return chunk_size=20;}
347 
348 	int Zone;
349 	int spare;
350 private:
351 	friend class Object_Module_Data_Chunk;
352 };
353 
354 
355 ///////////////////////////////////////////////
356 class Module_Acoustics_Chunk : public Chunk
357 {
358 public:
359 	Module_Acoustics_Chunk(Object_Module_Data_Chunk * parent);
360 	Module_Acoustics_Chunk(Chunk_With_Children* parent, const char * data, size_t );
361 
362 	virtual void fill_data_block(char*);
size_chunk()363 	virtual size_t size_chunk()
364 	{return chunk_size=24;}
365 
366 	int env_index;
367 	float reverb;
368 	int spare;
369 private:
370 	friend class Object_Module_Data_Chunk;
371 
372 
373 
374 };
375 ///////////////////////////////////////////////
376 
377 class Object_Project_Data_Chunk : public Chunk_With_Children
378 {
379 public:
380 
381 	// constructor from Object_Chunks
Object_Project_Data_Chunk(Object_Chunk * parent)382 	Object_Project_Data_Chunk (Object_Chunk * parent)
383 	: Chunk_With_Children (parent, "OBJPRJDT")
384 	{}
385 	// constructor from buffer
386 	Object_Project_Data_Chunk (Chunk_With_Children * const parent,const char *,const size_t);
387 private:
388 
389 	friend class Object_Chunk;
390 
391 
392 
393 };
394 
395 
396 
397 ///////////////////////////////////////////////
398 
399 
400 
401 struct ChunkTrackSection
402 {
403 
404 	ChunkQuat quat_start;
405 	ChunkQuat quat_end;
406 
407 	ChunkVectorInt pivot_start;
408 	ChunkVectorInt pivot_end;
409 
410 	ChunkVectorInt object_offset;
411 
412 	int time_for_section;
413 
414 	int spare;
415 
416 
417 };
418 
419 #define TrackFlag_Loop 0x00000001
420 #define TrackFlag_PlayingAtStart 0x00000002
421 #define TrackFlag_LoopBackAndForth 0x00000004
422 #define TrackFlag_UseTrackSmoothing 0x00000008
423 #define TrackFlag_QuatProblemSorted 0x80000000
424 
425 class Object_Track_Chunk2 : public Chunk
426 {
427 public:
428 
429 	Object_Track_Chunk2 (Object_Chunk * parent);
430 	Object_Track_Chunk2 (Chunk_With_Children * parent,const char *, size_t);
431 
432 	~Object_Track_Chunk2();
433 
434 	int num_sections;
435 	ChunkTrackSection * sections;
436 
437 	int flags;
438 	int timer_start;
439 
440 	virtual void fill_data_block (char *);
441 	virtual size_t size_chunk ();
442 
443 private:
444 
445 	friend class Object_Chunk;
446 
447 
448 };
449 
450 #define TrackSoundFlag_Loop 0x00000001
451 class Object_Track_Sound_Chunk : public Chunk
452 {
453 	public :
454 
455 	Object_Track_Sound_Chunk(Chunk_With_Children* parent);
456 	Object_Track_Sound_Chunk (Chunk_With_Children * const parent,const char *, size_t const);
457 	~Object_Track_Sound_Chunk();
458 
459 	size_t size_chunk ();
460 	void fill_data_block (char * data_start);
461 
462 	char* wav_name;
463 	unsigned long inner_range;
464 	unsigned long outer_range;
465 	int max_volume;
466 	int	pitch;
467 	int flags;
468 	int index;
469 
470 };
471 
472 ///////////////////////////////////////////////
473 
474 
475 struct AltObjectLocation
476 {
477 	ChunkVectorInt position;
478 	ChunkQuat orientation;
479 	int spare1,spare2;
480 };
481 
482 
483 //chunk for storing list of possible alternate locations for an object
484 //use for placed objects and generators and possibly sounds
485 class Object_Alternate_Locations_Chunk : public Chunk
486 {
487 public :
488 	Object_Alternate_Locations_Chunk(Chunk_With_Children* parent,const char* data, size_t);
489 	Object_Alternate_Locations_Chunk(Chunk_With_Children* parent);
490 	~Object_Alternate_Locations_Chunk();
491 
492 	void fill_data_block(char* data);
493 	size_t size_chunk();
494 
495 	int num_locations;
496 	AltObjectLocation* locations;
497 
498 	int group; //objects with the same group (other than 0) share the same die roll
499 
500 	int spare2;
501 };
502 
503 #endif
504