Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[6b9f61]: area.h Maximize Restore History

Download this file

area.h    493 lines (470 with data), 10.3 kB

  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
// area.h: interface for the Carea class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_AREA_H__C975A46B_7D3C_433C_8F35_9582A94DEF85__INCLUDED_)
#define AFX_AREA_H__C975A46B_7D3C_433C_8F35_9582A94DEF85__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "structs.h"
#include <io.h>
class Carea
{
private:
int fhandlea, fhandlew;
long maxlena, maxlenw;
long fullsizea, fullsizew;
long startpointa, startpointw;
public:
//.wed
bool m_night;
bool wedchanged, wedavailable;
wed_header wedheader;
wed_secondary_header secheader;
int polyoffset;
int overlaycount, overlaytilecount, overlaytileidxcount;
int weddoorcount, doortileidxcount, doorpolygoncount;
int wallgroupidxcount;
int wallpolygoncount; //this is the count of the wallpolygons
int polygonidxcount; //this is the size of the wallgroup index table
int wedvertexcount;
wed_overlay *overlayheaders;
wed_tilemap *overlaytileheaders;
wed_door *weddoorheaders;
short *doortileindices;
short *overlaytileindices;
wed_polyidx *wallgroupindices;
wed_polygon *doorpolygonheaders;
wed_polygon *wallpolygonheaders;
short *polygonindices; //wallgroup polygon indices
area_vertex *wedvertices; //a wed vertex is the same as an area vertex (POINTS)
unsigned short m_width, m_height;
unsigned char *searchmap;
unsigned char *lightmap;
unsigned char *heightmap;
bool changedmap[3];
COLORREF lmpal[256];
COLORREF srpal[16];
COLORREF htpal[16];
//.area
int revision;
area_header header;
area_song songheader;
area_int intheader;
iwd2_header iwd2header;
int actorcount;
int triggercount;
int spawncount;
int entrancecount;
int containercount;
int itemcount;
int ambientcount;
int animcount;
int vertexcount;
int variablecount;
int doorcount;
int mapnotecount;
int tilecount;
int exploredsize;
area_actor *actorheaders;
area_trigger *triggerheaders;
area_spawn *spawnheaders;
area_entrance *entranceheaders;
area_container *containerheaders;
area_item *itemheaders;
area_ambient *ambientheaders;
area_anim *animheaders;
area_vertex *vertexheaders;
CMyPtrList vertexheaderlist;
CMyPtrList wedvertexheaderlist;
CMyPtrList doortilelist;
area_variable *variableheaders;
area_door *doorheaders;
area_mapnote *mapnoteheaders;
pst_area_mapnote *pstmapnoteheaders;
area_tile *tileheaders;
char *explored;
char **credatapointers;
Carea();
virtual ~Carea();
void new_area();
int RemoveDoorPolygon(int first);
int AddWedDoor(CString doorid);
int RemoveWedDoor(char *doorid);
int DefaultAreaOverlays();
int WriteAreaToFile(int fh, int calculate);
int WriteWedToFile(int fh);
int WriteMap(const char *suffix, unsigned char *pixels, COLORREF *pal, int palsize);
int ReadActorData();
void ConvertFromPstMapnote();
void ConvertToPstMapnote();
int ReadAreaFromFile(int fh, long ml);
int getotc(int overlay);
int getfoti(int overlay);
int getotic(int overlay);
int ReadMap(const char *Suffix, unsigned char *&Storage, COLORREF *Palette, int size);
int ReadWedFromFile(int fh, long ml);
int CheckDestination(int fh, long ml, CString entryname);
int FillDestination(int fh, long ml, CComboBox *cb);
CString RetrieveMosRef(int fh);
bool WedChanged()
{
int i;
for(i=0;i<3;i++) if(changedmap[i]) return true;
return wedchanged;
}
bool WedAvailable() { return wedavailable; }
void MirrorMap(unsigned char *poi);
void RecalcBox(int pos, wed_polygon *header, area_vertex *vertices);
//int VertexOrder(area_vertex *wedvertex, int count);
int ConvertOffsetToIndex(int polyoffset);
// int ConsolidateVertices();
// int ConsolidateDoortiles();
inline void KillMaps()
{
if(searchmap)
{
delete [] searchmap;
searchmap=NULL;
}
if(lightmap)
{
delete [] lightmap;
lightmap=NULL;
}
if(heightmap)
{
delete [] heightmap;
heightmap=NULL;
}
}
inline void KillOverlays()
{
if(overlayheaders)
{
delete[] overlayheaders;
overlayheaders=NULL;
}
overlaycount=0;
}
inline void KillOverlaytiles()
{
if(overlaytileheaders)
{
delete[] overlaytileheaders;
overlaytileheaders=NULL;
}
overlaytilecount=0;
}
inline void KillOverlayindices()
{
if(overlaytileindices)
{
delete[] overlaytileindices;
overlaytileindices=NULL;
}
overlaytileidxcount=0;
}
inline void KillWeddoors()
{
if(weddoorheaders)
{
delete[] weddoorheaders;
weddoorheaders=NULL;
}
weddoorcount=0;
}
inline void KillDoortiles()
{
if(doortileindices)
{
delete[] doortileindices;
doortileindices=NULL;
}
doortileidxcount=0;
}
inline void KillDoorpolygons()
{
if(doorpolygonheaders)
{
delete[] doorpolygonheaders;
doorpolygonheaders=NULL;
}
doorpolygoncount=0;
}
inline void KillWallgroups()
{
if(wallgroupindices)
{
delete[] wallgroupindices;
wallgroupindices=NULL;
}
wallgroupidxcount=0;
}
inline void KillWallgrouppolygons()
{
if(wallpolygonheaders)
{
delete[] wallpolygonheaders;
wallpolygonheaders=NULL;
}
wallpolygoncount=0;
}
inline void KillPolygonindices()
{
if(polygonindices)
{
delete[] polygonindices;
polygonindices=NULL;
}
polygonidxcount=0;
}
inline void KillWedvertices()
{
if(wedvertices)
{
delete[] wedvertices;
wedvertices=NULL;
}
wedvertexcount=0;
}
/* these will be in lists now
inline void KillWallgroupvertices()
{
if(wallgroupvertices)
{
delete[] wallgroupvertices;
wallgroupvertices=NULL;
}
wallgroupvertexcount=0;
}
inline void KillDoorvertices()
{
if(doorvertices)
{
delete[] doorvertices;
doorvertices=NULL;
}
doorvertexcount=0;
}
*/
inline void KillActors()
{
KillCreDataPointers();
if(actorheaders)
{
delete[] actorheaders;
actorheaders=NULL;
}
actorcount=0;
}
inline void KillCreDataPointers()
{
if(credatapointers)
{
int i;
for(i=0;i<actorcount;i++)
{
if(credatapointers[i])
{
delete [] credatapointers[i];
credatapointers[i]=NULL;
}
}
delete [] credatapointers;
credatapointers=NULL;
}
}
inline void KillTriggers()
{
if(triggerheaders)
{
delete[] triggerheaders;
triggerheaders=NULL;
}
triggercount=0;
}
inline void KillSpawns()
{
if(spawnheaders)
{
delete[] spawnheaders;
spawnheaders=NULL;
}
spawncount=0;
}
inline void KillEntrances()
{
if(entranceheaders)
{
delete[] entranceheaders;
entranceheaders=NULL;
}
entrancecount=0;
}
inline void KillContainers()
{
if(containerheaders)
{
delete[] containerheaders;
containerheaders=NULL;
}
containercount=0;
}
inline void KillItems()
{
if(itemheaders)
{
delete[] itemheaders;
itemheaders=NULL;
}
itemcount=0;
}
inline void KillAmbients()
{
if(ambientheaders)
{
delete[] ambientheaders;
ambientheaders=NULL;
}
ambientcount=0;
}
inline void KillAnimations()
{
if(animheaders)
{
delete[] animheaders;
animheaders=NULL;
}
animcount=0;
}
inline void KillVariables()
{
if(variableheaders)
{
delete[] variableheaders;
variableheaders=NULL;
}
variablecount=0;
}
inline void KillDoors()
{
if(doorheaders)
{
delete[] doorheaders;
doorheaders=NULL;
}
doorcount=0;
}
inline void KillMapnotes()
{
if(mapnoteheaders)
{
delete[] mapnoteheaders;
mapnoteheaders=NULL;
}
if(pstmapnoteheaders)
{
delete[] pstmapnoteheaders;
pstmapnoteheaders=NULL;
}
mapnotecount=0;
}
inline void KillTiles()
{
if(tileheaders)
{
delete[] tileheaders;
tileheaders=NULL;
}
tilecount=0;
}
inline void KillVertices()
{
if(vertexheaders)
{
delete[] vertexheaders;
vertexheaders=NULL;
}
vertexcount=0;
}
inline void KillDoorTileList()
{
int i;
void *poi;
i=doortilelist.GetCount();
while(i--)
{
poi=doortilelist.RemoveHead();
if(poi) delete [] poi;
}
}
inline void KillWedVertexList()
{
int i;
void *poi;
i=wedvertexheaderlist.GetCount();
while(i--)
{
poi=wedvertexheaderlist.RemoveHead();
if(poi) delete [] poi;
}
}
inline void KillVertexList()
{
int i;
void *poi;
i=vertexheaderlist.GetCount();
while(i--)
{
poi=vertexheaderlist.RemoveHead();
if(poi) delete [] poi;
}
}
inline void KillExplored()
{
if(explored)
{
delete [] explored;
explored=NULL;
}
exploredsize=0;
}
void ShiftVertex(long id, int count, POINTS &point);
void FlipVertex(long id, int count, int width);
void FlipWedVertex(long id, int count, int width);
void FlipDoorTile(long id, int count, int width);
int RecalcBoundingBoxes();
private:
int adjust_actpointa(long offset);
int adjust_actpointw(long offset);
void MergeVertex(long &offset, int count);
void MergeWedVertex(long &offset, int count);
void MergeDoortile(short &offset, int count);
int ImplodeVertices();
int ImplodeWedVertices();
int ImplodeDoortiles();
void HandleVertex(long offset, int count);
void HandleWedVertex(long offset, int count);
void HandleDoortile(long offset, int count);
int ExplodeVertices();
int ExplodeWedVertices();
int ExplodeDoorTiles();
inline long myseeka(long pos)
{
return lseek(fhandlea, pos+startpointa,SEEK_SET)-startpointa;
}
inline long myseekw(long pos)
{
return lseek(fhandlew, pos+startpointw,SEEK_SET)-startpointw;
}
inline long actpointa()
{
return tell(fhandlea)-startpointa;
}
inline long actpointw()
{
return tell(fhandlew)-startpointw;
}
};
#endif // !defined(AFX_AREA_H__C975A46B_7D3C_433C_8F35_9582A94DEF85__INCLUDED_)