/
p_mapdata.h
343 lines (274 loc) · 9.85 KB
/
p_mapdata.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
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
/**\file p_mapdata.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2011 Daniel Swanson <danij@dengine.net>
*
* 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
*/
/**
* Playsim Data Structures, Macros and Constants.
*
* These are internal to Doomsday. The games have no direct access to
* this data.
*/
#ifndef LIBDENG_PLAY_DATA_H
#define LIBDENG_PLAY_DATA_H
#if defined(__JDOOM__) || defined(__JHERETIC__) || defined(__JHEXEN__)
# error "Attempted to include internal Doomsday p_mapdata.h from a game"
#endif
#include "dd_share.h"
#include "dam_main.h"
#include "rend_bias.h"
#include "m_nodepile.h"
#include "m_vector.h"
#define GET_VERTEX_IDX(vtx) ( (int) ((vtx) - vertexes) )
#define GET_LINE_IDX(li) ( (int) ((li) - lineDefs) )
#define GET_SIDE_IDX(si) ( (int) ((si) - sideDefs) )
#define GET_SECTOR_IDX(sec) ( (int) ((sec) - sectors) )
#define GET_SUBSECTOR_IDX(sub) ( (int) ((sub) - ssectors) )
#define GET_SEG_IDX(seg) ( (int) ((seg) - segs) )
#define GET_NODE_IDX(nd) ( (int) ((nd) - nodes) )
// Return the index of plane within a sector's planes array.
#define GET_PLANE_IDX(pln) ( (int) ((pln) - (pln)->sector->planes[0]) )
#define VERTEX_PTR(i) (&vertexes[i])
#define SEG_PTR(i) (&segs[i])
#define SECTOR_PTR(i) (§ors[i])
#define SUBSECTOR_PTR(i) (&ssectors[i])
#define NODE_PTR(i) (&nodes[i])
#define LINE_PTR(i) (&lineDefs[i])
#define SIDE_PTR(i) (&sideDefs[i])
// Node flags.
#define NF_SUBSECTOR 0x80000000
// Runtime map data objects, such as vertices, sectors, and subsectors all
// have this header as their first member. This makes it possible to treat
// an unknown map data pointer as a runtime_mapdata_header_t* and determine
// its type. Note that this information is internal to the engine.
typedef struct runtime_mapdata_header_s {
int type; // One of the DMU type constants.
} runtime_mapdata_header_t;
typedef struct fvertex_s {
float pos[2];
} fvertex_t;
typedef struct shadowcorner_s {
float corner;
struct sector_s* proximity;
float pOffset;
float pHeight;
} shadowcorner_t;
typedef struct edgespan_s {
float length;
float shift;
} edgespan_t;
typedef struct linkmobj_s {
struct mobj_s* mobj;
struct linkmobj_s* prev;
struct linkmobj_s* next;
} linkmobj_t;
typedef struct linkpolyobj_s {
struct polyobj_s* polyobj;
struct linkpolyobj_s* prev;
struct linkpolyobj_s* next;
} linkpolyobj_t;
typedef struct watchedplanelist_s {
uint num, maxNum;
struct plane_s** list;
} watchedplanelist_t;
typedef struct surfacelistnode_s {
void* data;
struct surfacelistnode_s* next;
} surfacelistnode_t;
typedef struct surfacelist_s {
uint num;
surfacelistnode_t* head;
} surfacelist_t;
/**
* Stores the data pertaining to vertex lighting for a worldmap, surface.
*/
typedef struct biassurface_s {
uint updated;
uint size;
vertexillum_t* illum; // [size]
biastracker_t tracker;
biasaffection_t affected[MAX_BIAS_AFFECTED];
struct biassurface_s* next;
} biassurface_t;
typedef void* blockmap_t;
#include "p_polyob.h"
#include "p_maptypes.h"
// Game-specific, map object type definitions.
typedef struct {
int identifier;
char* name;
valuetype_t type;
} mapobjprop_t;
typedef struct {
int identifier;
char* name;
uint numProps;
mapobjprop_t* props;
} gamemapobjdef_t;
// Map objects.
typedef struct {
uint idx;
valuetype_t type;
uint valueIdx;
} customproperty_t;
typedef struct {
uint elmIdx;
uint numProps;
customproperty_t* props;
} gamemapobj_t;
typedef struct {
uint num;
gamemapobjdef_t* def;
gamemapobj_t** objs;
} gamemapobjlist_t;
// Map value databases.
typedef struct {
valuetype_t type;
uint numElms;
void* data;
} valuetable_t;
typedef struct {
uint numTables;
valuetable_t** tables;
} valuedb_t;
typedef struct {
gamemapobjlist_t* objLists;
valuedb_t db;
} gameobjdata_t;
/**
* The map data arrays are accessible globally inside the engine.
*/
extern Uri* mapUri;
extern uint numVertexes;
extern vertex_t* vertexes;
extern uint numSegs;
extern seg_t* segs;
extern uint numSectors;
extern sector_t* sectors;
extern uint numSSectors;
extern subsector_t* ssectors;
extern uint numNodes;
extern node_t* nodes;
extern uint numLineDefs;
extern linedef_t* lineDefs;
extern uint numSideDefs;
extern sidedef_t* sideDefs;
extern watchedplanelist_t* watchedPlaneList;
extern surfacelist_t* movingSurfaceList;
extern surfacelist_t* decoratedSurfaceList;
extern surfacelist_t* glowingSurfaceList;
extern float mapGravity;
typedef struct gamemap_s {
Uri* uri;
char uniqueId[256];
float bBox[4];
uint numVertexes;
vertex_t* vertexes;
uint numSegs;
seg_t* segs;
uint numSectors;
sector_t* sectors;
uint numSSectors;
subsector_t* ssectors;
uint numNodes;
node_t* nodes;
uint numLineDefs;
linedef_t* lineDefs;
uint numSideDefs;
sidedef_t* sideDefs;
uint numPolyObjs;
polyobj_t** polyObjs;
gameobjdata_t gameObjData;
linkpolyobj_t** polyBlockMap;
watchedplanelist_t watchedPlaneList;
surfacelist_t movingSurfaceList;
surfacelist_t decoratedSurfaceList;
surfacelist_t glowingSurfaceList;
blockmap_t* blockMap;
blockmap_t* ssecBlockMap;
nodepile_t mobjNodes, lineNodes; // All kinds of wacky links.
nodeindex_t* lineLinks; // Indices to roots.
float globalGravity; // Gravity for the current map.
int ambientLightLevel; // Ambient lightlevel for the current map.
} gamemap_t;
gamemap_t* P_GetCurrentMap(void);
void P_SetCurrentMap(gamemap_t* map);
/**
* This ID is the name of the lump tag that marks the beginning of map
* data, e.g. "MAP03" or "E2M8".
*/
const Uri* P_MapUri(gamemap_t* map);
/// @return The 'unique' identifier of the map.
const char* P_GetUniqueMapId(gamemap_t* map);
void P_GetMapBounds(gamemap_t* map, float* min, float* max);
int P_GetMapAmbientLightLevel(gamemap_t* map);
const char* P_GenerateUniqueMapId(const char* mapId);
/**
* Is there a known map referenced by @a uri and if so, is it available for loading?
*
* @param Uri identifying the map to be searched for.
* @return @c true= A known and loadable map.
*/
boolean P_MapExists(const char* uri);
/**
* Retrieve the name of the source file containing the map referenced by @a uri
* if known and available for loading.
*
* @param Uri identifying the map to be searched for.
* @return Fully qualified (i.e., absolute) path to the source file.
*/
const char* P_MapSourceFile(const char* uri);
/**
* Begin the process of loading a new map.
*
* @param uri Uri identifying the map to be loaded.
* @return @c true, if the map was loaded successfully.
*/
boolean P_LoadMap(const char* uri);
void P_PolyobjChanged(polyobj_t* po);
void P_RegisterUnknownTexture(const char* name, boolean planeTex);
void P_PrintMissingTextureList(void);
void P_FreeBadTexList(void);
/// To be called to initialize the game map object defs.
void P_InitGameMapObjDefs(void);
/// To be called to free all memory allocated for the map obj defs.
void P_ShutdownGameMapObjDefs(void);
void P_InitGameMapObjDefs(void);
void P_ShutdownGameMapObjDefs(void);
boolean P_RegisterMapObj(int identifier, const char* name);
boolean P_RegisterMapObjProperty(int identifier, int propIdentifier,
const char* propName, valuetype_t type);
gamemapobjdef_t* P_GetGameMapObjDef(int identifier, const char *objName,
boolean canCreate);
void P_DestroyGameMapObjDB(gameobjdata_t* moData);
void P_AddGameMapObjValue(gameobjdata_t* moData, gamemapobjdef_t* gmoDef,
uint propIdx, uint elmIdx, valuetype_t type,
void* data);
gamemapobj_t* P_GetGameMapObj(gameobjdata_t* moData, gamemapobjdef_t* def,
uint elmIdx, boolean canCreate);
uint P_CountGameMapObjs(int identifier);
byte P_GetGMOByte(int identifier, uint elmIdx, int propIdentifier);
short P_GetGMOShort(int identifier, uint elmIdx, int propIdentifier);
int P_GetGMOInt(int identifier, uint elmIdx, int propIdentifier);
fixed_t P_GetGMOFixed(int identifier, uint elmIdx, int propIdentifier);
angle_t P_GetGMOAngle(int identifier, uint elmIdx, int propIdentifier);
float P_GetGMOFloat(int identifier, uint elmIdx, int propIdentifier);
#endif /* LIBDENG_PLAY_DATA_H */