Skip to content

Commit 6ff0720

Browse files
author
nitrocaster
committed
Move level structure definitions to common headers.
1 parent dbb05c0 commit 6ff0720

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+125
-198
lines changed

src/Layers/xrRender/Light_DB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "StdAfx.h"
22
#include "Common/_d3d_extensions.h"
3-
#include "xrEngine/xrLevel.h"
3+
#include "Common/LevelStructure.hpp"
44
#include "xrEngine/IGame_Persistent.h"
55
#include "xrEngine/Environment.h"
66
#include "utils/xrLC_Light/R_light.h"

src/Layers/xrRender/r__sector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "stdafx.h"
66
#include "r__sector.h"
7-
#include "xrEngine/xrLevel.h"
7+
#include "Common/LevelStructure.hpp"
88
#include "xrEngine/xr_object.h"
99
#include "FBasicVisual.h"
1010
#include "xrEngine/IGame_Persistent.h"

src/Layers/xrRenderPC_R1/FStaticRender_Loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "stdafx.h"
22
#include "Layers/xrRender/FBasicVisual.h"
33
#include "xrCore/FMesh.hpp"
4-
#include "xrEngine/xrLevel.h"
4+
#include "Common/LevelStructure.hpp"
55
#include "xrEngine/x_ray.h"
66
#include "xrEngine/IGame_Persistent.h"
77
#include "xrCore/stream_reader.h"

src/Layers/xrRenderPC_R2/r2_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "Layers/xrRender/ResourceManager.h"
44
#include "Layers/xrRender/FBasicVisual.h"
55
#include "xrCore/FMesh.hpp"
6-
#include "xrEngine/xrLevel.h"
6+
#include "Common/LevelStructure.hpp"
77
#include "xrEngine/x_ray.h"
88
#include "xrEngine/IGame_Persistent.h"
99
#include "xrCore/stream_reader.h"

src/Layers/xrRenderPC_R3/r3_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "Layers/xrRender/ResourceManager.h"
44
#include "Layers/xrRender/FBasicVisual.h"
55
#include "xrCore/FMesh.hpp"
6-
#include "xrEngine/xrLevel.h"
6+
#include "Common/LevelStructure.hpp"
77
#include "xrEngine/x_ray.h"
88
#include "xrEngine/IGame_Persistent.h"
99
#include "xrCore/stream_reader.h"

src/Layers/xrRenderPC_R4/r4_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "Layers/xrRender/ResourceManager.h"
44
#include "Layers/xrRender/FBasicVisual.h"
55
#include "xrCore/FMesh.hpp"
6-
#include "xrEngine/xrLevel.h"
6+
#include "Common/LevelStructure.hpp"
77
#include "xrEngine/x_ray.h"
88
#include "xrEngine/IGame_Persistent.h"
99
#include "xrCore/stream_reader.h"

src/common/GUID.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
#include "xrCore/xrCore.h"
3+
4+
class xrGUID
5+
{
6+
public:
7+
u64 g[2];
8+
9+
ICF bool operator== (const xrGUID &that) const
10+
{ return g[0]==that.g[0] && g[1]==that.g[1]; }
11+
12+
ICF bool operator!= (const xrGUID &that) const
13+
{ return !(*this==that); }
14+
15+
ICF void LoadLTX(CInifile &ini, const char *section, const char *name)
16+
{
17+
string128 buff;
18+
g[0] = ini.r_u64(section, strconcat(sizeof(buff), buff, name, "_g0"));
19+
g[1] = ini.r_u64(section, strconcat(sizeof(buff), buff, name, "_g1"));
20+
}
21+
22+
ICF void SaveLTX(CInifile &ini, const char *section, const char *name)
23+
{
24+
string128 buff;
25+
ini.w_u64(section, strconcat(sizeof(buff), buff, name, "_g0"), g[0]);
26+
ini.w_u64(section, strconcat(sizeof(buff), buff, name, "_g1"), g[1]);
27+
}
28+
};
Lines changed: 55 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,6 @@
1-
#ifndef xrLevelH
2-
#define xrLevelH
3-
41
#pragma once
52

6-
struct xrGUID
7-
{
8-
u64 g[2];
9-
10-
ICF bool operator== (const xrGUID& o) const
11-
{
12-
return ((g[0] == o.g[0]) && (g[1] == o.g[1]));
13-
}
14-
15-
ICF bool operator!= (const xrGUID& o) const
16-
{
17-
return !(*this == o);
18-
}
19-
ICF void LoadLTX(CInifile& ini, LPCSTR section, LPCSTR name)
20-
{
21-
string128 buff;
22-
23-
g[0] = ini.r_u64(section, strconcat(sizeof(buff), buff, name, "_g0"));
24-
g[1] = ini.r_u64(section, strconcat(sizeof(buff), buff, name, "_g1"));
25-
}
26-
27-
ICF void SaveLTX(CInifile& ini, LPCSTR section, LPCSTR name)
28-
{
29-
string128 buff;
30-
31-
ini.w_u64(section, strconcat(sizeof(buff), buff, name, "_g0"), g[0]);
32-
ini.w_u64(section, strconcat(sizeof(buff), buff, name, "_g1"), g[1]);
33-
}
34-
};
3+
#include "Common/GUID.hpp"
354

365
enum fsL_Chunks
376
{
@@ -47,28 +16,30 @@ enum fsL_Chunks
4716
fsL_SWIS = 11, //* - collapse info, usually for trees
4817
fsL_forcedword = 0xFFFFFFFF
4918
};
19+
5020
enum fsESectorChunks
5121
{
5222
fsP_Portals = 1, // - portal polygons
53-
fsP_Root, // - geometry root
23+
fsP_Root = 2, // - geometry root
5424
fsP_forcedword = u32(-1)
5525
};
26+
5627
enum fsSLS_Chunks
5728
{
5829
fsSLS_Description = 1, // Name of level
59-
fsSLS_ServerState,
30+
fsSLS_ServerState = 2,
6031
fsSLS_forcedword = u32(-1)
6132
};
6233

6334
enum EBuildQuality
6435
{
6536
ebqDraft = 0,
66-
ebqHigh,
67-
ebqCustom,
37+
ebqHigh = 1,
38+
ebqCustom = 2,
6839
ebq_force_u16 = u16(-1)
6940
};
7041

71-
#pragma pack(push,8)
42+
#pragma pack(push, 8)
7243
struct hdrLEVEL
7344
{
7445
u16 XRLC_version;
@@ -94,15 +65,17 @@ struct hdrNODES
9465
};
9566
#pragma pack(pop)
9667

97-
#pragma pack(push,1)
68+
#pragma pack(push, 1)
9869
#pragma pack(1)
9970
#ifndef _EDITOR
10071
class NodePosition
10172
{
10273
u8 data[5];
10374

10475
ICF void xz(u32 value) { CopyMemory(data, &value, 3); }
105-
ICF void y(u16 value) { CopyMemory(data + 3, &value, 2); }
76+
77+
ICF void y(u16 value) { CopyMemory(data+3, &value, 2); }
78+
10679
public:
10780
ICF u32 xz() const
10881
{
@@ -130,47 +103,37 @@ struct NodeCompressed
130103
{
131104
public:
132105
u8 data[12];
133-
private:
134106

107+
private:
135108
ICF void link(u8 link_index, u32 value)
136109
{
137110
value &= 0x007fffff;
138111
switch (link_index)
139112
{
140113
case 0:
141-
{
142-
value |= (*(u32*)data) & 0xff800000;
114+
value |= *(u32*)data & 0xff800000;
143115
CopyMemory(data, &value, sizeof(u32));
144116
break;
145-
}
146117
case 1:
147-
{
148118
value <<= 7;
149-
value |= (*(u32*)(data + 2)) & 0xc000007f;
150-
CopyMemory(data + 2, &value, sizeof(u32));
119+
value |= *(u32*)(data+2) & 0xc000007f;
120+
CopyMemory(data+2, &value, sizeof(u32));
151121
break;
152-
}
153122
case 2:
154-
{
155123
value <<= 6;
156-
value |= (*(u32*)(data + 5)) & 0xe000003f;
157-
CopyMemory(data + 5, &value, sizeof(u32));
124+
value |= *(u32*)(data+5) & 0xe000003f;
125+
CopyMemory(data+5, &value, sizeof(u32));
158126
break;
159-
}
160127
case 3:
161-
{
162128
value <<= 5;
163-
value |= (*(u32*)(data + 8)) & 0xf000001f;
164-
CopyMemory(data + 8, &value, sizeof(u32));
129+
value |= *(u32*)(data+8) & 0xf000001f;
130+
CopyMemory(data+8, &value, sizeof(u32));
165131
break;
166132
}
167-
}
168133
}
169134

170135
ICF void light(u8 value)
171-
{
172-
data[10] |= value << 4;
173-
}
136+
{ data[10] |= value << 4; }
174137

175138
public:
176139
struct SCover
@@ -184,19 +147,14 @@ struct NodeCompressed
184147
{
185148
switch (index)
186149
{
187-
case 0:
188-
return(cover0);
189-
case 1:
190-
return(cover1);
191-
case 2:
192-
return(cover2);
193-
case 3:
194-
return(cover3);
195-
default:
196-
NODEFAULT;
150+
case 0: return cover0;
151+
case 1: return cover1;
152+
case 2: return cover2;
153+
case 3: return cover3;
154+
default: NODEFAULT;
197155
}
198156
#ifdef DEBUG
199-
return (u8(-1));
157+
return u8(-1);
200158
#endif
201159
}
202160
};
@@ -239,47 +197,37 @@ struct NodeCompressed6
239197
{
240198
public:
241199
u8 data[11];
242-
private:
243200

201+
private:
244202
ICF void link(u8 link_index, u32 value)
245203
{
246204
value &= 0x001fffff;
247205
switch (link_index)
248206
{
249-
case 0 :
250-
{
251-
value |= (*(u32*)data) & 0xffe00000;
207+
case 0:
208+
value |= *(u32*)data & 0xffe00000;
252209
CopyMemory(data, &value, sizeof(u32));
253210
break;
254-
}
255-
case 1 :
256-
{
211+
case 1:
257212
value <<= 5;
258-
value |= (*(u32*)(data + 2)) & 0xfc00001f;
259-
CopyMemory(data + 2, &value, sizeof(u32));
213+
value |= *(u32*)(data+2) & 0xfc00001f;
214+
CopyMemory(data+2, &value, sizeof(u32));
260215
break;
261-
}
262-
case 2 :
263-
{
216+
case 2:
264217
value <<= 2;
265-
value |= (*(u32*)(data + 5)) & 0xff800003;
266-
CopyMemory(data + 5, &value, sizeof(u32));
218+
value |= *(u32*)(data+5) & 0xff800003;
219+
CopyMemory(data+5, &value, sizeof(u32));
267220
break;
268-
}
269-
case 3 :
270-
{
221+
case 3:
271222
value <<= 7;
272-
value |= (*(u32*)(data + 7)) & 0xf000007f;
273-
CopyMemory(data + 7, &value, sizeof(u32));
223+
value |= *(u32*)(data+7) & 0xf000007f;
224+
CopyMemory(data+7, &value, sizeof(u32));
274225
break;
275226
}
276-
}
277227
}
278228

279229
ICF void light(u8 value)
280-
{
281-
data[10] |= value << 4;
282-
}
230+
{ data[10] |= value << 4; }
283231

284232
public:
285233
u16 cover0 : 4;
@@ -293,44 +241,32 @@ struct NodeCompressed6
293241
{
294242
switch (index)
295243
{
296-
case 0 :
297-
return ((*(u32*)data) & 0x001fffff);
298-
case 1 :
299-
return (((*(u32*)(data + 2)) >> 5) & 0x001fffff);
300-
case 2 :
301-
return (((*(u32*)(data + 5)) >> 2) & 0x001fffff);
302-
case 3 :
303-
return (((*(u32*)(data + 7)) >> 7) & 0x001fffff);
304-
default :
305-
NODEFAULT;
244+
case 0: return *(u32*)data & 0x001fffff;
245+
case 1: return (*(u32*)(data+2) >> 5) & 0x001fffff;
246+
case 2: return (*(u32*)(data+5) >> 2) & 0x001fffff;
247+
case 3: return (*(u32*)(data+7) >> 7) & 0x001fffff;
248+
default: NODEFAULT;
306249
}
307250
#ifdef DEBUG
308-
return (0);
251+
return 0;
309252
#endif
310253
}
311254

312255
ICF u8 light() const
313-
{
314-
return (data[10] >> 4);
315-
}
256+
{ return data[10] >> 4; }
316257

317258
ICF u16 cover(u8 index) const
318259
{
319260
switch (index)
320261
{
321-
case 0 :
322-
return(cover0);
323-
case 1 :
324-
return(cover1);
325-
case 2 :
326-
return(cover2);
327-
case 3 :
328-
return(cover3);
329-
default :
330-
NODEFAULT;
262+
case 0: return cover0;
263+
case 1: return cover1;
264+
case 2: return cover2;
265+
case 3: return cover3;
266+
default: NODEFAULT;
331267
}
332268
#ifdef DEBUG
333-
return (u8(-1));
269+
return u8(-1);
334270
#endif
335271
}
336272

@@ -346,16 +282,14 @@ struct SNodePositionOld
346282
u16 y;
347283
s16 z;
348284
};
349-
#pragma pack (pop)
285+
#pragma pack(pop)
350286

351287
#ifdef _EDITOR
352288
typedef SNodePositionOld NodePosition;
353289
#endif
354290

355-
const u32 XRCL_CURRENT_VERSION = 18; //17; // input
291+
const u32 XRCL_CURRENT_VERSION = 18; // input
356292
const u32 XRCL_PRODUCTION_VERSION = 14; // output
357293
const u32 CFORM_CURRENT_VERSION = 4;
358294
const u32 MAX_NODE_BIT_COUNT = 23;
359295
const u32 XRAI_CURRENT_VERSION = 10;
360-
361-
#endif // xrLevelH

0 commit comments

Comments
 (0)