/
ded.h
245 lines (177 loc) · 6.73 KB
/
ded.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
/** @file defs/ded.h Definition namespace.
*
* @authors Copyright © 2003-2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2014 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, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef LIBDOOMSDAY_DEFINITION_DATABASE_H
#define LIBDOOMSDAY_DEFINITION_DATABASE_H
#include <vector>
#include <de/libcore.h>
#include <de/Vector>
#include <de/Record>
#include "../uri.h"
#include "dedtypes.h"
#include "dedregister.h"
// Version 6 does not require semicolons.
#define DED_VERSION 6
/**
* The ded_t structure encapsulates all the data one definition file can contain. This is
* only an internal representation of the data. An ASCII version is written and read by
* DED_Write() and DED_Read() routines.
*
* It is VERY important not to sort the data arrays in any way: the index numbers are
* important. The Game DLL must be recompiled with the new constants if the order of the
* array items changes.
*/
struct LIBDOOMSDAY_PUBLIC ded_s
{
de::Record names; ///< Namespace where definition values are stored.
int version; // DED version number.
ded_flags_t modelFlags; // Default values for models.
float modelScale;
float modelOffset;
// Flag values (for all types of data).
//DEDArray<ded_flag_t> flags;
DEDRegister flags;
// Episodes.
DEDRegister episodes;
// Map object information.
DEDArray<ded_mobj_t> mobjs;
// States.
DEDArray<ded_state_t> states;
// Sprites.
DEDArray<ded_sprid_t> sprites;
// Lights.
DEDArray<ded_light_t> lights;
// Materials.
DEDArray<ded_material_t> materials;
// Models.
//typedef std::vector<ded_model_t> Models;
//Models models;
DEDRegister models;
// Skies.
//DEDArray<ded_sky_t> skies;
DEDRegister skies;
// Sounds.
DEDArray<ded_sound_t> sounds;
// Music.
//DEDArray<ded_music_t> music;
DEDRegister musics;
// Map information.
//DEDArray<ded_mapinfo_t> mapInfo;
DEDRegister mapInfos;
// Text.
DEDArray<ded_text_t> text;
// Aural environments for textures.
DEDArray<ded_tenviron_t> textureEnv;
// Free-from string values.
DEDArray<ded_value_t> values;
// Detail texture assignments.
DEDArray<ded_detailtexture_t> details;
// Particle generators.
DEDArray<ded_ptcgen_t> ptcGens;
// Finales.
DEDArray<ded_finale_t> finales;
// Decorations.
DEDArray<ded_decor_t> decorations;
// Reflections.
DEDArray<ded_reflection_t> reflections;
// Animation/Precache groups for textures.
DEDArray<ded_group_t> groups;
// XG line types.
DEDArray<ded_linetype_t> lineTypes;
// XG sector types.
DEDArray<ded_sectortype_t> sectorTypes;
// Composite fonts.
DEDArray<ded_compositefont_t> compositeFonts;
public:
/**
* Constructor initializes everything to zero.
*/
ded_s();
void clear();
int addFlag(char const *id, int value);
int addEpisode();
int addMapInfo();
int addModel();
int addMusic();
int addSky();
//ded_flag_t *getFlag(char const *flag) const;
int evalFlags2(char const *ptr) const;
int getTextNumForName(const char* name) const;
ded_material_t *findMaterialDef(de::Uri const &uri) const;
ded_material_t *getMaterial(char const *uriCString) const;
int getMobjNum(char const *id) const;
int getMobjNumForName(char const *name) const;
char const *getMobjName(int num) const;
int getStateNum(de::String const &id) const;
int getStateNum(char const *id) const;
int getEpisodeNum(de::String const &id) const;
int getMapInfoNum(de::Uri const &uri) const;
int getModelNum(char const *id) const;
int getSkyNum(char const *id) const;
int getSoundNum(char const *id) const;
/**
* Looks up a sound using @a name key.
* @param name Sound name.
* @return If the name is not found, returns the NULL sound index (zero).
*/
int getSoundNumForName(char const *name) const;
int getMusicNum(char const *id) const;
ded_value_t *getValueById(char const *id) const;
ded_value_t *getValueByUri(de::Uri const &uri) const;
ded_compositefont_t *findCompositeFontDef(de::Uri const &uri) const;
ded_compositefont_t *getCompositeFont(char const *uriCString) const;
protected:
void release();
DENG2_NO_ASSIGN(ded_s)
DENG2_NO_COPY (ded_s)
};
typedef ded_s ded_t;
#ifdef __cplusplus
extern "C" {
#endif
// Routines for managing DED files:
int DED_AddMobj(ded_t* ded, char const* idStr);
int DED_AddState(ded_t* ded, char const* id);
int DED_AddSprite(ded_t* ded, char const* name);
int DED_AddLight(ded_t* ded, char const* stateID);
LIBDOOMSDAY_PUBLIC int DED_AddMaterial(ded_t* ded, char const* uri);
LIBDOOMSDAY_PUBLIC int DED_AddMaterialLayerStage(ded_material_layer_t *ml);
int DED_AddMaterialDecorationStage(ded_material_decoration_t *li);
//int DED_AddSky(ded_t* ded, char const* id);
int DED_AddSound(ded_t* ded, char const* id);
//LIBDOOMSDAY_PUBLIC int DED_AddMusic(ded_t* ded, char const* id);
//int DED_AddMapInfo(ded_t* ded, char const* uri);
int DED_AddText(ded_t* ded, char const* id);
int DED_AddTextureEnv(ded_t* ded, char const* id);
int DED_AddValue(ded_t *ded, char const* id);
int DED_AddDetail(ded_t* ded, char const* lumpname);
int DED_AddPtcGen(ded_t* ded, char const* state);
int DED_AddPtcGenStage(ded_ptcgen_t* gen);
int DED_AddFinale(ded_t* ded);
int DED_AddDecoration(ded_t* ded);
int DED_AddReflection(ded_t* ded);
int DED_AddGroup(ded_t* ded);
int DED_AddGroupMember(ded_group_t* grp);
int DED_AddSectorType(ded_t* ded, int id);
int DED_AddLineType(ded_t* ded, int id);
int DED_AddCompositeFont(ded_t* ded, char const* uri);
int DED_AddCompositeFontMapCharacter(ded_compositefont_t* font);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // LIBDOOMSDAY_DEFINITION_DATABASE_H