/
id1map.h
121 lines (100 loc) · 3.65 KB
/
id1map.h
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
/**
* @file id1map.h @ingroup wadmapconverter
*
* @authors Copyright © 2007-2012 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef __WADMAPCONVERTER_ID1MAP_H__
#define __WADMAPCONVERTER_ID1MAP_H__
#include "doomsday.h"
#include "dd_types.h"
#include "maplumpinfo.h"
#include "id1map_datatypes.h"
#include "id1map_load.h"
#include "id1map_util.h"
#include <vector>
#include <list>
/// Material dictionary groups.
typedef enum materialdictgroup_e {
MG_PLANE = 0,
MG_WALL
} MaterialDictGroup;
typedef std::vector<mline_t> Lines;
typedef std::vector<mside_t> Sides;
typedef std::vector<msector_t> Sectors;
typedef std::vector<mthing_t> Things;
typedef std::vector<surfacetint_t> SurfaceTints;
typedef std::list<mpolyobj_t> Polyobjs;
typedef std::list<uint> LineList;
class Id1Map
{
public:
Id1Map();
~Id1Map();
int load(MapLumpInfo* lumpInfos[NUM_MAPLUMP_TYPES]);
void analyze(void);
int transfer(void);
MaterialDictId addMaterialToDictionary(const char* name, MaterialDictGroup group);
private:
inline const Str* findMaterialInDictionary(MaterialDictId id)
{
return StringPool_String(materials, id);
}
bool loadVertexes(Reader* reader, uint numElements);
bool loadLineDefs(Reader* reader, uint numElements);
bool loadSideDefs(Reader* reader, uint numElements);
bool loadSectors(Reader* reader, uint numElements);
bool loadThings(Reader* reader, uint numElements);
bool loadSurfaceTints(Reader* reader, uint numElements);
/**
* Create a temporary polyobj.
*/
mpolyobj_t* createPolyobj(LineList& lineList, int tag, int sequenceType,
int16_t anchorX, int16_t anchorY);
/**
* @param lineList @c NULL, will cause IterFindPolyLines to count
* the number of lines in the polyobj.
*/
void collectPolyobjLinesWorker(LineList& lineList, coord_t x, coord_t y);
void collectPolyobjLines(LineList& lineList, Lines::iterator lineIt);
/**
* Find all linedefs marked as belonging to a polyobject with the given tag
* and attempt to create a polyobject from them.
*
* @param tag Line tag of linedefs to search for.
*
* @return @c true = successfully created polyobj.
*/
bool findAndCreatePolyobj(int16_t tag, int16_t anchorX, int16_t anchorY);
void findPolyobjs(void);
void transferVertexes(void);
void transferSectors(void);
void transferLinesAndSides(void);
void transferSurfaceTints(void);
void transferPolyobjs(void);
void transferThings(void);
private:
uint numVertexes;
coord_t* vertexes; ///< Array of vertex coords [v0:X, vo:Y, v1:X, v1:Y, ..]
Lines lines;
Sides sides;
Sectors sectors;
Things things;
SurfaceTints surfaceTints;
Polyobjs polyobjs;
StringPool* materials; ///< Material dictionary.
};
#endif /* __WADMAPCONVERTER_ID1MAP_H__ */