Skip to content

Commit

Permalink
Prefer std::array and COORDS defines on Map::CoordsDirectionDelta
Browse files Browse the repository at this point in the history
  • Loading branch information
tupaschoal committed Jan 19, 2020
1 parent 0d88c73 commit b7e9b36
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/openrct2/world/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,18 @@ using namespace OpenRCT2;
/**
* Replaces 0x00993CCC, 0x00993CCE
*/
const CoordsXY CoordsDirectionDelta[] = { { -32, 0 }, { 0, +32 }, { +32, 0 }, { 0, -32 },
{ -32, +32 }, { +32, +32 }, { +32, -32 }, { -32, -32 } };
// clang-format off
const std::array<CoordsXY, 8> CoordsDirectionDelta = {
CoordsXY{ -COORDS_XY_STEP, 0 },
CoordsXY{ 0, +COORDS_XY_STEP },
CoordsXY{ +COORDS_XY_STEP, 0 },
CoordsXY{ 0, -COORDS_XY_STEP },
CoordsXY{ -COORDS_XY_STEP, +COORDS_XY_STEP },
CoordsXY{ +COORDS_XY_STEP, +COORDS_XY_STEP },
CoordsXY{ +COORDS_XY_STEP, -COORDS_XY_STEP },
CoordsXY{ -COORDS_XY_STEP, -COORDS_XY_STEP }
};
// clang-format on

const TileCoordsXY TileDirectionDelta[] = { { -1, 0 }, { 0, +1 }, { +1, 0 }, { 0, -1 },
{ -1, +1 }, { +1, +1 }, { +1, -1 }, { -1, -1 } };
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/world/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ enum
CREATE_CROSSING_MODE_PATH_OVER_TRACK,
};

extern const CoordsXY CoordsDirectionDelta[];
extern const std::array<CoordsXY, 8> CoordsDirectionDelta;
extern const TileCoordsXY TileDirectionDelta[];

extern uint16_t gWidePathTileLoopX;
Expand Down
18 changes: 9 additions & 9 deletions test/testpaint/Compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ uint32_t gScenarioTicks;
uint8_t gCurrentRotation;

// clang-format off
const CoordsXY CoordsDirectionDelta[] = {
{ -32, 0 },
{ 0, +32 },
{ +32, 0 },
{ 0, -32 },
{ -32, +32 },
{ +32, +32 },
{ +32, -32 },
{ -32, -32 },
constexpr const std::array<CoordsXY, 8> CoordsDirectionDelta = {
CoordsXY{ -COORDS_XY_STEP, 0 },
CoordsXY{ 0, +COORDS_XY_STEP },
CoordsXY{ +COORDS_XY_STEP, 0 },
CoordsXY{ 0, -COORDS_XY_STEP },
CoordsXY{ -COORDS_XY_STEP, +COORDS_XY_STEP },
CoordsXY{ +COORDS_XY_STEP, +COORDS_XY_STEP },
CoordsXY{ +COORDS_XY_STEP, -COORDS_XY_STEP },
CoordsXY{ -COORDS_XY_STEP, -COORDS_XY_STEP },
};

const TileCoordsXY TileDirectionDelta[] = {
Expand Down

0 comments on commit b7e9b36

Please sign in to comment.