26 #ifndef SAGA2_TCOORDS_H 27 #define SAGA2_TCOORDS_H 29 #include "common/savefile.h" 30 #include "common/memstream.h" 34 enum facingDirections {
46 typedef uint8 Direction;
51 void set(
int nu,
int nv,
int nz) {
112 return a.u == b.u && a.v == b.v && a.z == b.z;
116 return a.u != b.u || a.v != b.v || a.z != b.z;
126 #include "common/pack-start.h" 139 TilePoint(int16 nu, int16 nv, int16 nz) { u = nu; v = nv; z = nz; }
161 {
return TilePoint( (int16) (a.u + b.u), (int16) (a.v + b.v), (int16) (a.z + b.z) ); }
164 {
return TilePoint( (int16) (-a.u), (int16) (-a.v), (int16) (-a.z) ); }
167 {
return TilePoint( (int16) (a.u - b.u), (int16) (a.v - b.v), (int16) (a.z - b.z) ); }
170 {
return TilePoint( (int16) (a.u * (int16)b), (int16) (a.v * (int16)b), (int16) (a.z * (int16)b) ); }
173 {
return TilePoint( (int16) (a.u / (int16)b), (int16) (a.v / (int16)b), (int16) (a.z / (int16)b) ); }
176 {
return TilePoint( (int16) (a.u >> (int16)b), (int16) (a.v >> (int16)b), (int16) (a.z >> (int16)b) ); }
179 {
return TilePoint( (int16) (a.u << (int16)b), (int16) (a.v << (int16)b), (int16) (a.z << (int16)b) ); }
182 {
return a.u == b.u && a.v == b.v && a.z == b.z; }
185 {
return a.u != b.u || a.v != b.v || a.z != b.z; }
187 void operator+= (
TilePoint a) { u += a.u; v += a.v; z += a.z; }
188 void operator-= (
TilePoint a) { u -= a.u; v -= a.v; z -= a.z; }
190 int16 quickHDistance() {
191 int16 au = (int16)
ABS(u),
195 return (int16)(au + (av >> 1));
197 return (int16)(av + (au >> 1));
204 void debugPrint(
int level = 0,
const char *msg =
"TilePoint:") {
205 debug(level,
"%s %d, %d, %d", msg, u, v, z);
208 #include "common/pack-end.h" 256 TilePoint32( int32 nu, int32 nv, int32 nz ) { u = nu; v = nv; z = nz; }
261 {
return TilePoint32( a.u + b.u, a.v + b.v, a.z + b.z ); }
267 {
return TilePoint32( a.u - b.u, a.v - b.v, a.z - b.z ); }
270 {
return TilePoint32( a.u * (int32)b, a.v * (int32)b, a.z * (int32)b ); }
273 {
return TilePoint32( a.u / (int32)b, a.v / (int32)b, a.z / (int32)b ); }
276 {
return TilePoint32( a.u >> (int32)b, a.v >> (int32)b, a.z >> (int32)b ); }
279 {
return TilePoint32( a.u << (int32)b, a.v << (int32)b, a.z << (int32)b ); }
282 {
return a.u == b.u && a.v == b.v && a.z == b.z; }
285 {
return a.u != b.u || a.v != b.v || a.z != b.z; }
287 void operator+= (
TilePoint32 a) { u += a.u; v += a.v; z += a.z; }
288 void operator-= (
TilePoint32 a) { u -= a.u; v -= a.v; z -= a.z; }
290 int32 quickHDistance(
void ) {
294 if (au > av)
return au + (av >> 1);
295 else return av + (au >> 1);
Definition: memstream.h:194
Definition: tcoords.h:127
Definition: tcoords.h:222
void debug(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: tcoords.h:243
FORCEINLINE int16 readSint16LE()
Definition: stream.h:543
FORCEINLINE void writeSint16LE(int16 value)
Definition: stream.h:194
T ABS(T x)
Definition: util.h:56