2017-10-13 22:23:07 +02:00
|
|
|
/*****************************************************************************
|
2018-06-15 14:07:34 +02:00
|
|
|
* Copyright (c) 2014-2018 OpenRCT2 developers
|
2017-10-13 22:23:07 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2017-10-13 22:23:07 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2017-10-13 22:23:07 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../common.h"
|
|
|
|
|
2018-06-22 23:17:03 +02:00
|
|
|
#define LOCATION_NULL ((int16_t)(uint16_t)0x8000)
|
2017-10-13 22:23:07 +02:00
|
|
|
#define RCT_XY8_UNDEFINED 0xFFFF
|
2018-06-22 23:17:03 +02:00
|
|
|
#define MakeXY16(x, y) \
|
|
|
|
{ \
|
|
|
|
(int16_t)(x), (int16_t)(y) \
|
|
|
|
}
|
2017-10-13 22:23:07 +02:00
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
2018-06-22 23:17:03 +02:00
|
|
|
struct LocationXY8
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t x, y;
|
2017-10-13 22:23:07 +02:00
|
|
|
};
|
2018-06-20 17:28:51 +02:00
|
|
|
uint16_t xy;
|
2017-10-13 22:23:07 +02:00
|
|
|
};
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2017-10-13 22:23:07 +02:00
|
|
|
assert_struct_size(LocationXY8, 2);
|
|
|
|
|
2018-06-22 23:17:03 +02:00
|
|
|
struct sLocationXY8
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int8_t x, y;
|
2018-03-03 11:21:42 +01:00
|
|
|
};
|
|
|
|
assert_struct_size(sLocationXY8, 2);
|
|
|
|
|
2018-06-22 23:17:03 +02:00
|
|
|
struct LocationXY16
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int16_t x, y;
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2017-10-13 22:23:07 +02:00
|
|
|
assert_struct_size(LocationXY16, 4);
|
|
|
|
|
2018-06-22 23:17:03 +02:00
|
|
|
struct LocationXYZ16
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int16_t x, y, z;
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2017-10-13 22:23:07 +02:00
|
|
|
assert_struct_size(LocationXYZ16, 6);
|
2018-02-14 09:42:26 +01:00
|
|
|
#pragma pack(pop)
|
2018-02-14 11:31:49 +01:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
constexpr int32_t COORDS_NULL = -1;
|
2018-03-07 19:10:50 +01:00
|
|
|
|
2018-04-26 17:30:37 +02:00
|
|
|
/**
|
|
|
|
* Tile coordinates use 1 x/y increment per tile and 1 z increment per step.
|
|
|
|
* Regular ('big', 'sprite') coordinates use 32 x/y increments per tile and 8 z increments per step.
|
|
|
|
*/
|
2018-03-10 21:35:24 +01:00
|
|
|
struct CoordsXY
|
2018-02-14 11:31:49 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t x, y;
|
2018-02-14 11:31:49 +01:00
|
|
|
};
|
|
|
|
|
2018-03-10 21:35:24 +01:00
|
|
|
struct TileCoordsXY
|
2018-02-14 11:31:49 +01:00
|
|
|
{
|
2018-03-10 21:35:24 +01:00
|
|
|
TileCoordsXY() = default;
|
2018-06-22 23:17:03 +02:00
|
|
|
TileCoordsXY(int32_t x_, int32_t y_)
|
|
|
|
: x(x_)
|
|
|
|
, y(y_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
explicit TileCoordsXY(CoordsXY c)
|
|
|
|
: x(c.x / 32)
|
|
|
|
, y(c.y / 32)
|
|
|
|
{
|
|
|
|
}
|
2018-04-18 20:34:34 +02:00
|
|
|
TileCoordsXY& operator+=(const TileCoordsXY rhs)
|
|
|
|
{
|
|
|
|
x += rhs.x;
|
|
|
|
y += rhs.y;
|
2018-04-18 21:10:15 +02:00
|
|
|
return *this;
|
2018-04-18 20:34:34 +02:00
|
|
|
}
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t x = 0, y = 0;
|
2018-02-14 11:31:49 +01:00
|
|
|
};
|
|
|
|
|
2018-03-10 21:35:24 +01:00
|
|
|
struct CoordsXYZ
|
2018-02-14 11:31:49 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t x, y, z;
|
2018-02-14 11:31:49 +01:00
|
|
|
};
|
|
|
|
|
2018-03-10 21:35:24 +01:00
|
|
|
struct TileCoordsXYZ
|
2018-02-14 11:31:49 +01:00
|
|
|
{
|
2018-03-10 21:35:24 +01:00
|
|
|
TileCoordsXYZ() = default;
|
2018-06-22 23:17:03 +02:00
|
|
|
TileCoordsXYZ(int32_t x_, int32_t y_, int32_t z_)
|
|
|
|
: x(x_)
|
|
|
|
, y(y_)
|
|
|
|
, z(z_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
explicit TileCoordsXYZ(CoordsXY c, int32_t z_)
|
|
|
|
: x(c.x / 32)
|
|
|
|
, y(c.y / 32)
|
|
|
|
, z(z_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
explicit TileCoordsXYZ(CoordsXYZ c)
|
|
|
|
: x(c.x / 32)
|
|
|
|
, y(c.y / 32)
|
|
|
|
, z(c.z / 8)
|
|
|
|
{
|
|
|
|
}
|
2018-04-18 20:56:09 +02:00
|
|
|
TileCoordsXYZ& operator+=(const TileCoordsXY rhs)
|
|
|
|
{
|
|
|
|
x += rhs.x;
|
|
|
|
y += rhs.y;
|
2018-04-18 21:10:15 +02:00
|
|
|
return *this;
|
2018-04-18 20:56:09 +02:00
|
|
|
}
|
2018-12-30 00:47:21 +01:00
|
|
|
|
|
|
|
bool operator==(const TileCoordsXYZ& other) const
|
|
|
|
{
|
|
|
|
return x == other.x && y == other.y && z == other.z;
|
|
|
|
}
|
|
|
|
bool operator!=(const TileCoordsXYZ& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t x = 0, y = 0, z = 0;
|
2018-02-14 11:31:49 +01:00
|
|
|
};
|
|
|
|
|
2018-04-26 17:30:37 +02:00
|
|
|
struct CoordsXYZD
|
2018-02-14 11:31:49 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t x, y, z;
|
|
|
|
uint8_t direction;
|
2018-03-07 19:10:50 +01:00
|
|
|
|
2018-06-22 23:17:03 +02:00
|
|
|
bool isNull() const
|
|
|
|
{
|
|
|
|
return x == COORDS_NULL;
|
|
|
|
};
|
2018-02-14 11:31:49 +01:00
|
|
|
};
|
|
|
|
|
2018-04-26 17:30:37 +02:00
|
|
|
struct TileCoordsXYZD
|
2018-02-14 11:31:49 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t x, y, z;
|
|
|
|
uint8_t direction;
|
2018-03-07 19:10:50 +01:00
|
|
|
|
2018-06-22 23:17:03 +02:00
|
|
|
bool isNull() const
|
|
|
|
{
|
|
|
|
return x == COORDS_NULL;
|
|
|
|
};
|
2018-02-14 11:31:49 +01:00
|
|
|
};
|