-
Notifications
You must be signed in to change notification settings - Fork 1
/
rdl.hpp
67 lines (57 loc) · 1.62 KB
/
rdl.hpp
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
#ifndef RDL_HPP_GUARD
#define RDL_HPP_GUARD
//===----------------------------------------------------------------------===//
//
// The Descent map loader
//
// NAME : Rdl
// PURPOSE : Providing a decoder and wrapper for the Descent .RDL format.
// COPYRIGHT : (c) 2011 Sean Donnellan. All Rights Reserved.
// AUTHORS : Sean Donnellan ([email protected])
// DESCRIPTION : A decoder for the RDL file format that is used by Parallax
// Software in the computer game, Descent.
//
// The file format is as follows:
//
// - Magic number which is 4 bytes and corresponding to the
// string "LVLP"
//
// - TODO: Document the rest of the format.
//
//===----------------------------------------------------------------------===//
#include <vector>
#ifdef _MSC_VER
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#else
#include <stdint.h>
#include <stddef.h>
#endif
struct Cube;
struct RdlHeader;
struct Vertex
{
double x;
double y;
double z;
};
class RdlReader
{
// TODO: Write one that takes a file as well.
public:
RdlReader(const std::vector<uint8_t>& Data);
bool IsValid() const;
// Returns true if magic header is correct.
std::vector<Vertex> Vertices() const;
std::vector<Cube> Cubes() const;
private:
size_t CubeOffset() const;
// The index of the first cube in the file.
const std::vector<uint8_t>& myData;
const RdlHeader* const myHeader;
};
#endif