1 #ifndef OPENMW_ESM_DEFS_H
2 #define OPENMW_ESM_DEFS_H
3
4 #include <stdint.h>
5
6 #include <osg/Vec3f>
7
8 namespace ESM
9 {
10
11 struct TimeStamp
12 {
13 float mHour;
14 int mDay;
15 };
16
17 struct EpochTimeStamp
18 {
19 float mGameHour;
20 int mDay;
21 int mMonth;
22 int mYear;
23 };
24
25 // Pixel color value. Standard four-byte rr,gg,bb,aa format.
26 typedef uint32_t Color;
27
28 enum Specialization
29 {
30 SPC_Combat = 0,
31 SPC_Magic = 1,
32 SPC_Stealth = 2
33 };
34
35 enum RangeType
36 {
37 RT_Self = 0,
38 RT_Touch = 1,
39 RT_Target = 2
40 };
41
42 #pragma pack(push)
43 #pragma pack(1)
44
45 // Position and rotation
46 struct Position
47 {
48 float pos[3];
49
50 // In radians
51 float rot[3];
52
asVec3ESM::Position53 osg::Vec3f asVec3() const
54 {
55 return osg::Vec3f(pos[0], pos[1], pos[2]);
56 }
57
asRotationVec3ESM::Position58 osg::Vec3f asRotationVec3() const
59 {
60 return osg::Vec3f(rot[0], rot[1], rot[2]);
61 }
62 };
63 #pragma pack(pop)
64
operator ==(const Position & left,const Position & right)65 bool inline operator== (const Position& left, const Position& right) noexcept
66 {
67 return left.pos[0] == right.pos[0] &&
68 left.pos[1] == right.pos[1] &&
69 left.pos[2] == right.pos[2] &&
70 left.rot[0] == right.rot[0] &&
71 left.rot[1] == right.rot[1] &&
72 left.rot[2] == right.rot[2];
73 }
74
operator !=(const Position & left,const Position & right)75 bool inline operator!= (const Position& left, const Position& right) noexcept
76 {
77 return left.pos[0] != right.pos[0] ||
78 left.pos[1] != right.pos[1] ||
79 left.pos[2] != right.pos[2] ||
80 left.rot[0] != right.rot[0] ||
81 left.rot[1] != right.rot[1] ||
82 left.rot[2] != right.rot[2];
83 }
84
85 template <int a, int b, int c, int d>
86 struct FourCC
87 {
88 static constexpr unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
89 };
90
91 enum RecNameInts
92 {
93 // format 0 / legacy
94 REC_ACTI = FourCC<'A','C','T','I'>::value,
95 REC_ALCH = FourCC<'A','L','C','H'>::value,
96 REC_APPA = FourCC<'A','P','P','A'>::value,
97 REC_ARMO = FourCC<'A','R','M','O'>::value,
98 REC_BODY = FourCC<'B','O','D','Y'>::value,
99 REC_BOOK = FourCC<'B','O','O','K'>::value,
100 REC_BSGN = FourCC<'B','S','G','N'>::value,
101 REC_CELL = FourCC<'C','E','L','L'>::value,
102 REC_CLAS = FourCC<'C','L','A','S'>::value,
103 REC_CLOT = FourCC<'C','L','O','T'>::value,
104 REC_CNTC = FourCC<'C','N','T','C'>::value,
105 REC_CONT = FourCC<'C','O','N','T'>::value,
106 REC_CREA = FourCC<'C','R','E','A'>::value,
107 REC_CREC = FourCC<'C','R','E','C'>::value,
108 REC_DIAL = FourCC<'D','I','A','L'>::value,
109 REC_DOOR = FourCC<'D','O','O','R'>::value,
110 REC_ENCH = FourCC<'E','N','C','H'>::value,
111 REC_FACT = FourCC<'F','A','C','T'>::value,
112 REC_GLOB = FourCC<'G','L','O','B'>::value,
113 REC_GMST = FourCC<'G','M','S','T'>::value,
114 REC_INFO = FourCC<'I','N','F','O'>::value,
115 REC_INGR = FourCC<'I','N','G','R'>::value,
116 REC_LAND = FourCC<'L','A','N','D'>::value,
117 REC_LEVC = FourCC<'L','E','V','C'>::value,
118 REC_LEVI = FourCC<'L','E','V','I'>::value,
119 REC_LIGH = FourCC<'L','I','G','H'>::value,
120 REC_LOCK = FourCC<'L','O','C','K'>::value,
121 REC_LTEX = FourCC<'L','T','E','X'>::value,
122 REC_MGEF = FourCC<'M','G','E','F'>::value,
123 REC_MISC = FourCC<'M','I','S','C'>::value,
124 REC_NPC_ = FourCC<'N','P','C','_'>::value,
125 REC_NPCC = FourCC<'N','P','C','C'>::value,
126 REC_PGRD = FourCC<'P','G','R','D'>::value,
127 REC_PROB = FourCC<'P','R','O','B'>::value,
128 REC_RACE = FourCC<'R','A','C','E'>::value,
129 REC_REGN = FourCC<'R','E','G','N'>::value,
130 REC_REPA = FourCC<'R','E','P','A'>::value,
131 REC_SCPT = FourCC<'S','C','P','T'>::value,
132 REC_SKIL = FourCC<'S','K','I','L'>::value,
133 REC_SNDG = FourCC<'S','N','D','G'>::value,
134 REC_SOUN = FourCC<'S','O','U','N'>::value,
135 REC_SPEL = FourCC<'S','P','E','L'>::value,
136 REC_SSCR = FourCC<'S','S','C','R'>::value,
137 REC_STAT = FourCC<'S','T','A','T'>::value,
138 REC_WEAP = FourCC<'W','E','A','P'>::value,
139
140 // format 0 - saved games
141 REC_SAVE = FourCC<'S','A','V','E'>::value,
142 REC_JOUR_LEGACY = FourCC<0xa4,'U','O','R'>::value, // "\xa4UOR", rather than "JOUR", little oversight when magic numbers were
143 // calculated by hand, needs to be supported for older files now
144 REC_JOUR = FourCC<'J','O','U','R'>::value,
145 REC_QUES = FourCC<'Q','U','E','S'>::value,
146 REC_GSCR = FourCC<'G','S','C','R'>::value,
147 REC_PLAY = FourCC<'P','L','A','Y'>::value,
148 REC_CSTA = FourCC<'C','S','T','A'>::value,
149 REC_GMAP = FourCC<'G','M','A','P'>::value,
150 REC_DIAS = FourCC<'D','I','A','S'>::value,
151 REC_WTHR = FourCC<'W','T','H','R'>::value,
152 REC_KEYS = FourCC<'K','E','Y','S'>::value,
153 REC_DYNA = FourCC<'D','Y','N','A'>::value,
154 REC_ASPL = FourCC<'A','S','P','L'>::value,
155 REC_ACTC = FourCC<'A','C','T','C'>::value,
156 REC_MPRJ = FourCC<'M','P','R','J'>::value,
157 REC_PROJ = FourCC<'P','R','O','J'>::value,
158 REC_DCOU = FourCC<'D','C','O','U'>::value,
159 REC_MARK = FourCC<'M','A','R','K'>::value,
160 REC_ENAB = FourCC<'E','N','A','B'>::value,
161 REC_CAM_ = FourCC<'C','A','M','_'>::value,
162 REC_STLN = FourCC<'S','T','L','N'>::value,
163 REC_INPU = FourCC<'I','N','P','U'>::value,
164
165 // format 1
166 REC_FILT = FourCC<'F','I','L','T'>::value,
167 REC_DBGP = FourCC<'D','B','G','P'>::value ///< only used in project files
168 };
169
170 /// Common subrecords
171 enum SubRecNameInts
172 {
173 SREC_DELE = ESM::FourCC<'D','E','L','E'>::value,
174 SREC_NAME = ESM::FourCC<'N','A','M','E'>::value
175 };
176
177 }
178 #endif
179