summaryrefslogtreecommitdiff
path: root/src/win95/obchunk.hpp
blob: 29233f8cafbff8e624a4c5e708f3dad802b3edfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
#ifndef _obchunk_hpp
#define _obchunk_hpp 1

#include "chunk.hpp"

#include "chnktype.hpp"
#include "mishchnk.hpp"


// object flags

#define OBJECT_FLAG_BASE_OBJECT 0x0000100
#define OBJECT_FLAG_MODULE_OBJECT 0x0000200
#define OBJECT_FLAG_PLACED_OBJECT 0x0000400

// Note these flags have to correspond with the ones used by ed_ob_type
// and AVP generator flags

#define OBJECT_FLAG_AVPGAMEMODEMARINE 	0x00000800
#define OBJECT_FLAG_AVPGAMEMODEALIEN 		0x00001000
#define OBJECT_FLAG_AVPGAMEMODEPREDATOR	0x00002000

#define OBJECT_FLAG_PLATFORMLOADSET			0x00004000
#define OBJECT_FLAG_PCLOAD 							0x00008000
#define OBJECT_FLAG_PSXLOAD 						0x00010000
#define OBJECT_FLAG_SATURNLOAD 					    0x00020000

#define OBJECT_FLAG_NOTDIFFICULTY1 					0x00100000
#define OBJECT_FLAG_NOTDIFFICULTY2 					0x00200000
#define OBJECT_FLAG_NOTDIFFICULTY3 					0x00400000


class Shape_Chunk;
class Shape_Header_Chunk;
class Object_Header_Chunk;

// flags structure

struct object_flags
{
	unsigned int locked : 1;
// add more flags here as they are needed
};


class VModule_Array_Chunk;

class Object_Chunk : public Lockable_Chunk_With_Children
{
public:

	// constructor from buffer
	Object_Chunk (Chunk_With_Children * parent,const char *, size_t);

	// constructor from data

	Object_Chunk (Chunk_With_Children * parent, ChunkObject &obj);

	// destructor
	virtual ~Object_Chunk();

	const ChunkObject object_data;

	Shape_Chunk * get_assoc_shape();

	BOOL assoc_with_shape (Shape_Chunk *);

	BOOL deassoc_with_shape (Shape_Chunk *);

	Object_Header_Chunk * get_header();

	BOOL inc_v_no();

	BOOL same_and_updated(Object_Chunk &);
	
	BOOL assoc_with_shape_no(File_Chunk *);
	
	void update_my_chunkobject (ChunkObject &);
	
	// functions for the locking functionality

	BOOL file_equals (HANDLE &);
	const char * get_head_id();
	void set_lock_user(char *);

	virtual void post_input_processing();

	VModule_Array_Chunk * get_vmod_chunk();
	
	// destroy object needs to go through all the other
	// objects and delete itself from the VMAC
	
	void destroy(File_Chunk *);
	
	ObjectID CalculateID();

	//program_object_index can be set by the program using the chunks , so you can find where
	//the object has been put.
	//I need it so that I can find out which module each object has been put into.
	int program_object_index;

private:
	
	friend class File_Chunk;
	friend class Object_Header_Chunk;

	ChunkObject * object_data_store;

};

///////////////////////////////////////////////
	
class Object_Header_Chunk : public Chunk
{
public:
	// constructor from buffer
	Object_Header_Chunk (Chunk_With_Children * parent, const char * pdata, size_t psize);	
	virtual size_t size_chunk ();

	virtual BOOL output_chunk (HANDLE &);

	virtual void fill_data_block (char * data_start);

	const ChunkObject * const object_data;

	virtual void prepare_for_output();

	const char * get_lockuser()
	{
		return lock_user;
	}

	int flags;

private:

	friend class Object_Chunk;
	friend class Shape_Header_Chunk;
	friend class RIF_File_Chunk;
	friend class File_Chunk;

	friend class Environment;
	
	char lock_user[17];
	int version_no;

	int shape_id_no;

	Shape_Chunk * associated_shape;



	// constructor from data
	Object_Header_Chunk (Object_Chunk * parent);

};


///////////////////////////////////////////////


// automatically constructed when Object_Chunks are constructed from
// data

class Object_Interface_Data_Chunk : public Chunk_With_Children
{
public:
	// constructor from buffer
	Object_Interface_Data_Chunk (Chunk_With_Children * parent,const char *, size_t);
private:

	friend class Object_Chunk;



	// constructor from Object_Chunks
	Object_Interface_Data_Chunk (Object_Chunk * parent);

};

///////////////////////////////////////////////

class Object_Notes_Chunk : public Chunk
{
public:

	Object_Notes_Chunk (Chunk_With_Children * parent,
									 const char * _data, size_t _data_size);


	virtual ~Object_Notes_Chunk ();

	virtual size_t size_chunk ()
	{
		chunk_size = (data_size + 12);
		chunk_size += (4-chunk_size%4)%4;
		return chunk_size;
	}

	virtual BOOL output_chunk (HANDLE &);

	virtual void fill_data_block (char * data_start);

	const size_t data_size;
	const char * const data;
	
private:

	char * data_store;

};

///////////////////////////////////////////////

class Object_Module_Data_Chunk : public Chunk_With_Children
{
public:

	// constructor from Object_Chunks
	Object_Module_Data_Chunk (Object_Chunk * parent)
	: Chunk_With_Children (parent, "MODULEDT")
	{}
	// constructor from buffer
	Object_Module_Data_Chunk (Chunk_With_Children * parent,const char *, size_t);

private:

	friend class Object_Chunk;
	friend class AI_Module_Master_Chunk; 
	friend class AI_Module_Slave_Chunk; 
	// constructor from buffer
	Object_Module_Data_Chunk (Object_Chunk * parent,const char *, size_t);
	
};

///////////////////////////////////////////////

class VModule_Array_Chunk : public Chunk
{
public:
	
	VModule_Array_Chunk (Object_Module_Data_Chunk * parent, VMod_Arr_Item * vma, int num_in_vma);
	VModule_Array_Chunk (Chunk_With_Children* parent, const char * vmdata, size_t vmsize);
	~VModule_Array_Chunk ();
	
	int num_array_items;
	
	VMod_Arr_Item * vmod_array;
	
	virtual void fill_data_block (char *);
	virtual size_t size_chunk ();

private:

	friend class Object_Module_Data_Chunk;


};


///////////////////////////////////////////////

#if 0
class Adjacent_Modules_Chunk : public Chunk
{
public:

	Adjacent_Modules_Chunk(Object_Module_Data_Chunk * parent, List<Adjacent_Module> aml)
	: Chunk (parent, "ADJMDLST"), adjacent_modules_list (aml)
	{}

	List<Adjacent_Module> adjacent_modules_list;

	virtual void fill_data_block (char *);
	virtual size_t size_chunk ();

	
private:

	friend class Object_Module_Data_Chunk;
	
	Adjacent_Modules_Chunk(Object_Module_Data_Chunk * parent, const char * data, size_t size);
	
};
#endif

//a replacement for adjacent_modules_chunk
#define AdjacentModuleFlag_EntryPointSetByHand 0x00000001
#define AdjacentModuleFlag_InsideAdjacentModule 0x00000002
#define AdjacentModuleFlag_AdjacentModuleInsideMe 0x00000004
#define AdjacentModuleFlag_Vertical 0x00000008

class Adjacent_Module_Entry_Points_Chunk : public Chunk
{
public:

	Adjacent_Module_Entry_Points_Chunk(Object_Module_Data_Chunk * parent, List<Adjacent_Module> aml)
	: Chunk (parent, "ADJMDLEP"), adjacent_modules_list (aml)
	{}
	Adjacent_Module_Entry_Points_Chunk(Chunk_With_Children * parent, const char * data, size_t size);
	List<Adjacent_Module> adjacent_modules_list;

	virtual void fill_data_block (char *);
	virtual size_t size_chunk ();

	
private:

	friend class Object_Module_Data_Chunk;
	

	
};


///////////////////////////////////////////////

class Module_Flag_Chunk : public Chunk
{
public:
	Module_Flag_Chunk(Object_Module_Data_Chunk * parent);
	Module_Flag_Chunk(Chunk_With_Children* parent, const char * data, size_t );
	
	virtual void fill_data_block(char*);
	virtual size_t size_chunk()
	{return chunk_size=20;}

	int Flags;
	int spare;
private:
	friend class Object_Module_Data_Chunk;
	

	
};
///////////////////////////////////////////////

class Module_Zone_Chunk : public Chunk
{
public:
	Module_Zone_Chunk(Object_Module_Data_Chunk * parent);
	Module_Zone_Chunk(Chunk_With_Children* parent, const char * data, size_t );
	
	virtual void fill_data_block(char*);
	virtual size_t size_chunk()
	{return chunk_size=20;}

	int Zone;
	int spare;
private:
	friend class Object_Module_Data_Chunk;
};


///////////////////////////////////////////////
class Module_Acoustics_Chunk : public Chunk
{
public:
	Module_Acoustics_Chunk(Object_Module_Data_Chunk * parent);
	Module_Acoustics_Chunk(Chunk_With_Children* parent, const char * data, size_t );
	
	virtual void fill_data_block(char*);
	virtual size_t size_chunk()
	{return chunk_size=24;}

	int env_index; 
	float reverb;
	int spare;
private:
	friend class Object_Module_Data_Chunk;
	


};
///////////////////////////////////////////////

class Object_Project_Data_Chunk : public Chunk_With_Children
{
public:

	// constructor from Object_Chunks
	Object_Project_Data_Chunk (Object_Chunk * parent)
	: Chunk_With_Children (parent, "OBJPRJDT")
	{}
	// constructor from buffer
	Object_Project_Data_Chunk (Chunk_With_Children * const parent,const char *,const size_t);
private:

	friend class Object_Chunk;

	

};



///////////////////////////////////////////////



struct ChunkTrackSection
{

	ChunkQuat quat_start;
	ChunkQuat quat_end;
	
	ChunkVectorInt pivot_start;
	ChunkVectorInt pivot_end;
	
	ChunkVectorInt object_offset;

	int time_for_section;

	int spare;


};

#define TrackFlag_Loop 0x00000001
#define TrackFlag_PlayingAtStart 0x00000002
#define TrackFlag_LoopBackAndForth 0x00000004
#define TrackFlag_UseTrackSmoothing 0x00000008
#define TrackFlag_QuatProblemSorted 0x80000000

class Object_Track_Chunk2 : public Chunk
{
public:

	Object_Track_Chunk2 (Object_Chunk * parent);
	Object_Track_Chunk2 (Chunk_With_Children * parent,const char *, size_t);

	~Object_Track_Chunk2();
	
	int num_sections;
	ChunkTrackSection * sections;

	int flags;
	int timer_start;
 
	virtual void fill_data_block (char *);
	virtual size_t size_chunk ();
	
private:

	friend class Object_Chunk;
	
	
};

#define TrackSoundFlag_Loop 0x00000001
class Object_Track_Sound_Chunk : public Chunk
{
	public :
	
	Object_Track_Sound_Chunk(Chunk_With_Children* parent);
	Object_Track_Sound_Chunk (Chunk_With_Children * const parent,const char *, size_t const);
	~Object_Track_Sound_Chunk();
	
	size_t size_chunk ();
	void fill_data_block (char * data_start);
	
	char* wav_name;
	unsigned long inner_range;
	unsigned long outer_range;
	int max_volume;
	int	pitch;
	int flags;
	int index;	

};

///////////////////////////////////////////////


struct AltObjectLocation 
{
	ChunkVectorInt position;
	ChunkQuat orientation;
	int spare1,spare2;
};


//chunk for storing list of possible alternate locations for an object
//use for placed objects and generators and possibly sounds
class Object_Alternate_Locations_Chunk : public Chunk
{
public :
	Object_Alternate_Locations_Chunk(Chunk_With_Children* parent,const char* data, size_t);	
	Object_Alternate_Locations_Chunk(Chunk_With_Children* parent);
	~Object_Alternate_Locations_Chunk();

	void fill_data_block(char* data);
	size_t size_chunk();
	
	int num_locations;
	AltObjectLocation* locations;

	int group; //objects with the same group (other than 0) share the same die roll

	int spare2;
};

#endif