OpenMoHAA
0.82.1
Loading...
Searching...
No Matches
short3.h
1
/*
2
===========================================================================
3
Copyright (C) 2015 the OpenMoHAA team
4
5
This file is part of OpenMoHAA source code.
6
7
OpenMoHAA source code is free software; you can redistribute it
8
and/or modify it under the terms of the GNU General Public License as
9
published by the Free Software Foundation; either version 2 of the License,
10
or (at your option) any later version.
11
12
OpenMoHAA source code is distributed in the hope that it will be
13
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with OpenMoHAA source code; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
===========================================================================
21
*/
22
23
// short3.h : 3-byte sized integer
24
25
#ifndef __Q_MATH_H__
26
#define __Q_MATH_H__
27
28
#pragma pack(1)
29
30
typedef
struct
short3_data
{
31
unsigned
short
highmid;
32
unsigned
char
low;
33
} short3_data_t;
34
35
#pragma pack()
36
37
class
short3
38
{
39
private
:
40
short3_data_t data;
41
42
protected
:
43
int
get()
const
{
return
data.highmid | (data.low << 16); }
44
45
void
set(
int
value)
46
{
47
data.highmid = value & 0xFFFF;
48
data.low = value >> 16;
49
}
50
51
public
:
52
operator
int(
void
)
const
{
return
get(); }
53
54
short3() {}
55
56
short3(
int
value) { set(value); }
57
58
short3 operator-(
void
)
const
;
59
short3 operator~(
void
)
const
;
60
61
short3 operator+(
int
b)
const
;
62
short3 operator-(
int
b)
const
;
63
short3 operator*(
int
b)
const
;
64
short3 operator/(
int
b)
const
;
65
short3 operator%(
int
b)
const
;
66
short3 operator|(
int
b)
const
;
67
short3 operator&(
int
b)
const
;
68
short3 operator^(
int
b)
const
;
69
short3 operator<<(
int
b)
const
;
70
short3 operator>>(
int
b)
const
;
71
72
short3 operator++(
int
);
73
short3 operator--(
int
);
74
75
short3& operator++();
76
short3& operator--();
77
78
short3& operator=(
int
b);
79
short3& operator+=(
int
b);
80
short3& operator-=(
int
b);
81
short3& operator*=(
int
b);
82
short3& operator/=(
int
b);
83
short3& operator%=(
int
b);
84
85
short3& operator|=(
int
b);
86
short3& operator&=(
int
b);
87
short3& operator^=(
int
b);
88
89
short3& operator<<=(
int
b);
90
short3& operator>>=(
int
b);
91
92
bool
operator!(
void
) {
return
!get(); };
93
94
bool
operator==(
int
b) {
return
get() == b; };
95
96
bool
operator!=(
int
b) {
return
get() != b; };
97
98
bool
operator<=(
int
b) {
return
get() <= b; };
99
100
bool
operator>=(
int
b) {
return
get() >= b; };
101
102
bool
operator<(
int
b) {
return
get() < b; };
103
104
bool
operator>(
int
b) {
return
get() > b; };
105
106
bool
operator==(short3& b) {
return
get() == b.get(); };
107
108
bool
operator!=(short3& b) {
return
get() != b.get(); };
109
110
bool
operator<=(short3& b) {
return
get() <= b.get(); };
111
112
bool
operator>=(short3& b) {
return
get() >= b.get(); };
113
114
bool
operator<(short3& b) {
return
get() < b.get(); };
115
116
bool
operator>(short3& b) {
return
get() > b.get(); };
117
};
118
119
class
unsigned_short3
:
public
short3
120
{
121
public
:
122
operator
unsigned
int(
void
)
const
{
return
get(); }
123
};
124
125
inline
short3
short3::operator-()
const
126
{
127
return
short3
(-get());
128
}
129
130
inline
short3
short3::operator~()
const
131
{
132
return
short3(~get());
133
}
134
135
inline
short3
short3::operator+(
int
b)
const
136
{
137
return
short3(get() + b);
138
}
139
140
inline
short3
short3::operator-(
int
b)
const
141
{
142
return
short3(get() - b);
143
}
144
145
inline
short3
short3::operator*(
int
b)
const
146
{
147
return
short3(get() * b);
148
}
149
150
inline
short3
short3::operator/(
int
b)
const
151
{
152
return
short3(get() / b);
153
}
154
155
inline
short3
short3::operator%(
int
b)
const
156
{
157
return
short3(get() % b);
158
}
159
160
inline
short3
short3::operator|(
int
b)
const
161
{
162
return
short3(get() | b);
163
}
164
165
inline
short3
short3::operator&(
int
b)
const
166
{
167
return
short3(get() & b);
168
}
169
170
inline
short3
short3::operator^(
int
b)
const
171
{
172
return
short3(get() ^ b);
173
}
174
175
inline
short3
short3::operator<<(
int
b)
const
176
{
177
return
short3(get() << b);
178
}
179
180
inline
short3
short3::operator>>(
int
b)
const
181
{
182
return
short3(get() >> b);
183
}
184
185
inline
short3
short3::operator++(
int
)
186
{
187
short3 result = *
this
;
188
set(get() + 1);
189
return
result;
190
}
191
192
inline
short3
short3::operator--(
int
)
193
{
194
short3 result = *
this
;
195
set(get() - 1);
196
return
result;
197
}
198
199
inline
short3
& short3::operator++()
200
{
201
set(get() + 1);
202
return
*
this
;
203
}
204
205
inline
short3
& short3::operator--()
206
{
207
set(get() - 1);
208
return
*
this
;
209
}
210
211
inline
short3
& short3::operator=(
int
b)
212
{
213
set(b);
214
return
*
this
;
215
}
216
217
inline
short3
& short3::operator+=(
int
b)
218
{
219
set(get() + b);
220
return
*
this
;
221
}
222
223
inline
short3
& short3::operator-=(
int
b)
224
{
225
set(get() - b);
226
return
*
this
;
227
}
228
229
inline
short3
& short3::operator/=(
int
b)
230
{
231
set(get() / b);
232
return
*
this
;
233
}
234
235
inline
short3
& short3::operator*=(
int
b)
236
{
237
set(get() * b);
238
return
*
this
;
239
}
240
241
inline
short3
& short3::operator%=(
int
b)
242
{
243
set(get() % b);
244
return
*
this
;
245
}
246
247
inline
short3
& short3::operator|=(
int
b)
248
{
249
set(get() | b);
250
return
*
this
;
251
}
252
253
inline
short3
& short3::operator&=(
int
b)
254
{
255
set(get() % b);
256
return
*
this
;
257
}
258
259
inline
short3
& short3::operator^=(
int
b)
260
{
261
set(get() ^ b);
262
return
*
this
;
263
}
264
265
inline
short3
& short3::operator<<=(
int
b)
266
{
267
set(get() << b);
268
return
*
this
;
269
}
270
271
inline
short3
& short3::operator>>=(
int
b)
272
{
273
set(get() >> b);
274
return
*
this
;
275
}
276
277
#endif
/* __Q_MATH_H__ */
short3
Definition
short3.h:38
unsigned_short3
Definition
short3.h:120
short3_data
Definition
short3.h:30
code
qcommon
short3.h
Generated by
1.13.2