Skip to content

Commit

Permalink
make names more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
spacek531 committed May 13, 2024
1 parent cf97eb7 commit 0c94614
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 61 deletions.
4 changes: 2 additions & 2 deletions src/openrct2/libopenrct2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
<ClInclude Include="object\ObjectTypes.h" />
<ClInclude Include="object\ResourceTable.h" />
<ClInclude Include="object\RideObject.h" />
<ClInclude Include="object\SceneryBoundingBox.h" />
<ClInclude Include="object\SceneryBoundbox.h" />
<ClInclude Include="object\SceneryGroupEntry.h" />
<ClInclude Include="object\SceneryGroupObject.h" />
<ClInclude Include="object\SceneryObject.h" />
Expand Down Expand Up @@ -843,7 +843,7 @@
<ClCompile Include="object\ObjectTypes.cpp" />
<ClCompile Include="object\ResourceTable.cpp" />
<ClCompile Include="object\RideObject.cpp" />
<ClCompile Include="object\SceneryBoundingBox.cpp" />
<ClCompile Include="object\SceneryBoundbox.cpp" />
<ClCompile Include="object\SceneryGroupObject.cpp" />
<ClCompile Include="object\SmallSceneryObject.cpp" />
<ClCompile Include="object\StationObject.cpp" />
Expand Down
38 changes: 19 additions & 19 deletions src/openrct2/object/LargeSceneryObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
#include "../localisation/Language.h"
#include "../world/Banner.h"
#include "../world/Location.hpp"
#include "SceneryBoundingBox.h"
#include "SceneryBoundbox.h"

#include <algorithm>
#include <iterator>

static DefaultBoundingBoxType boundBoxTypes[16] = {
DefaultBoundingBoxType::FullTileBox, // 0000
DefaultBoundingBoxType::FullTileSouthQuadrantBox, // 0001
DefaultBoundingBoxType::FullTileWestQuadrantBox, // 0010
DefaultBoundingBoxType::FullTileSouthwestSideBox, // 0011
DefaultBoundingBoxType::FullTileNorthQuadrantBox, // 0100
DefaultBoundingBoxType::FullTileBox, // 0101 (diagonal of South and North corners)
DefaultBoundingBoxType::FullTileNorthwestSideBox, // 0110
DefaultBoundingBoxType::FullTileBox, // 0111 (triangle of South, West, and North corners)
DefaultBoundingBoxType::FullTileEastQuadrantBox, // 1000
DefaultBoundingBoxType::FullTileSoutheastSideBox, // 1001
DefaultBoundingBoxType::FullTileBox, // 1010 (diagonal of East and West corners)
DefaultBoundingBoxType::FullTileBox, // 1011 (triangle of South, West, and East corners)
DefaultBoundingBoxType::FullTileNortheastSideBox, // 1100
DefaultBoundingBoxType::FullTileBox, // 1101 (triangle of South, West, and North corners)
DefaultBoundingBoxType::FullTileBox, // 1110 (triangle of West, North, and East corners)
DefaultBoundingBoxType::FullTileBox, // 1111
static DefaultBoundBoxType boundBoxTypes[16] = {
DefaultBoundBoxType::FullTileBox, // 0000
DefaultBoundBoxType::FullTileSouthQuadrantBox, // 0001
DefaultBoundBoxType::FullTileWestQuadrantBox, // 0010
DefaultBoundBoxType::FullTileSouthwestSideBox, // 0011
DefaultBoundBoxType::FullTileNorthQuadrantBox, // 0100
DefaultBoundBoxType::FullTileBox, // 0101 (diagonal of South and North corners)
DefaultBoundBoxType::FullTileNorthwestSideBox, // 0110
DefaultBoundBoxType::FullTileBox, // 0111 (triangle of South, West, and North corners)
DefaultBoundBoxType::FullTileEastQuadrantBox, // 1000
DefaultBoundBoxType::FullTileSoutheastSideBox, // 1001
DefaultBoundBoxType::FullTileBox, // 1010 (diagonal of East and West corners)
DefaultBoundBoxType::FullTileBox, // 1011 (triangle of South, West, and East corners)
DefaultBoundBoxType::FullTileNortheastSideBox, // 1100
DefaultBoundBoxType::FullTileBox, // 1101 (triangle of South, West, and North corners)
DefaultBoundBoxType::FullTileBox, // 1110 (triangle of West, North, and East corners)
DefaultBoundBoxType::FullTileBox, // 1111
};

static int32_t getBoundBoxHeight(uint8_t clearanceHeight)
Expand All @@ -56,7 +56,7 @@ static void SetTileBoundingBox(LargeSceneryTile& tile)
}
else
{
tile.boundBoxes = GetDefaultSceneryBoundBoxes(DefaultBoundingBoxType::FullTileLargeBox);
tile.boundBoxes = GetDefaultSceneryBoundBoxes(DefaultBoundBoxType::FullTileLargeBox);
}
tile.spriteOffset = GetDefaultSpriteOffset(DefaultSpriteOffsetType::LargeSceneryOffset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/

#include "SceneryBoundingBox.h"
#include "SceneryBoundbox.h"

static constexpr std::array<CoordsXYZ, DefaultSpriteOffsetType::CountOffset> DefaultSpriteOffsets = {
CoordsXYZ(7, 7, 0), // quarter tile
Expand Down Expand Up @@ -105,7 +105,7 @@ static constexpr SceneryBoundBoxes FullTileThin = {
BoundBoxXYZ({ 15, 15, 0 }, { 2, 2, 0 }),
};

static constexpr std::array<SceneryBoundBoxes, DefaultBoundingBoxType::CountBox> boundBoxes = {
static constexpr std::array<SceneryBoundBoxes, DefaultBoundBoxType::CountBox> boundBoxes = {
QuarterTile,
HalfTile,
FullTileNorthQuadrant,
Expand All @@ -123,32 +123,32 @@ static constexpr std::array<SceneryBoundBoxes, DefaultBoundingBoxType::CountBox>

#pragma endregion

static const EnumMap<DefaultBoundingBoxType> BBoxTypeLookup = {
{ "quarterTile", DefaultBoundingBoxType::QuarterTileBox },
{ "halfTile", DefaultBoundingBoxType::HalfTileBox },
{ "cornerNorth", DefaultBoundingBoxType::FullTileNorthQuadrantBox },
{ "sideNortheast", DefaultBoundingBoxType::FullTileNortheastSideBox },
{ "cornerEast", DefaultBoundingBoxType::FullTileEastQuadrantBox },
{ "sideSoutheast", DefaultBoundingBoxType::FullTileSoutheastSideBox },
{ "cornerSouth", DefaultBoundingBoxType::FullTileSouthQuadrantBox },
{ "sideSouthwest", DefaultBoundingBoxType::FullTileSouthwestSideBox },
{ "cornerEast", DefaultBoundingBoxType::FullTileWestQuadrantBox },
{ "sideNorthwest", DefaultBoundingBoxType::FullTileNorthwestSideBox },
{ "fullTile", DefaultBoundingBoxType::FullTileBox },
{ "fullTileLarge", DefaultBoundingBoxType::FullTileLargeBox },
{ "fullTileThin", DefaultBoundingBoxType::FullTileThinBox }
static const EnumMap<DefaultBoundBoxType> BoundboxTypeLookup = {
{ "quarterTile", DefaultBoundBoxType::QuarterTileBox },
{ "halfTile", DefaultBoundBoxType::HalfTileBox },
{ "cornerNorth", DefaultBoundBoxType::FullTileNorthQuadrantBox },
{ "sideNortheast", DefaultBoundBoxType::FullTileNortheastSideBox },
{ "cornerEast", DefaultBoundBoxType::FullTileEastQuadrantBox },
{ "sideSoutheast", DefaultBoundBoxType::FullTileSoutheastSideBox },
{ "cornerSouth", DefaultBoundBoxType::FullTileSouthQuadrantBox },
{ "sideSouthwest", DefaultBoundBoxType::FullTileSouthwestSideBox },
{ "cornerEast", DefaultBoundBoxType::FullTileWestQuadrantBox },
{ "sideNorthwest", DefaultBoundBoxType::FullTileNorthwestSideBox },
{ "fullTile", DefaultBoundBoxType::FullTileBox },
{ "fullTileLarge", DefaultBoundBoxType::FullTileLargeBox },
{ "fullTileThin", DefaultBoundBoxType::FullTileThinBox }
};

static DefaultBoundingBoxType GetBoundingBoxTypeFromString(const std::string& s)
static DefaultBoundBoxType GetBoundingBoxTypeFromString(const std::string& s)
{
auto result = BBoxTypeLookup.find(s);
return (result != BBoxTypeLookup.end()) ? result->second : DefaultBoundingBoxType::FullTileBox;
auto result = BoundboxTypeLookup.find(s);
return (result != BoundboxTypeLookup.end()) ? result->second : DefaultBoundBoxType::FullTileBox;
}

SceneryBoundBoxes GetDefaultSceneryBoundBoxes(DefaultBoundingBoxType type)
SceneryBoundBoxes GetDefaultSceneryBoundBoxes(DefaultBoundBoxType type)
{
if (type >= DefaultBoundingBoxType::CountBox)
return boundBoxes[DefaultBoundingBoxType::FullTileBox];
if (type >= DefaultBoundBoxType::CountBox)
return boundBoxes[DefaultBoundBoxType::FullTileBox];
return boundBoxes[type];
}

Expand Down Expand Up @@ -199,14 +199,10 @@ SceneryBoundBoxes ReadBoundBoxes(json_t& jBBox, int32_t defaultHeight, bool full
else if (jBBox.is_object())
{
// single box, rotated around (16, 16) if fulltile or (8,8) if quarter tile
CoordsXY rotationCenter = { 8, 8 };
if (fullTile)
{
rotationCenter = { 16, 16 };
}
auto bBox = ReadBoundBox(jBBox);
boxes[0] = bBox;
boxes[1] = RotateBoundBox(bBox, rotationCenter);
CoordsXY rotationCenter = fullTile ? CoordsXY(16, 16) : CoordsXY(8, 8);
auto boundBox = ReadBoundBox(jBBox);
boxes[0] = boundBox;
boxes[1] = RotateBoundBox(boundBox, rotationCenter);
boxes[2] = RotateBoundBox(boxes[1], rotationCenter);
boxes[3] = RotateBoundBox(boxes[2], rotationCenter);
}
Expand All @@ -215,7 +211,7 @@ SceneryBoundBoxes ReadBoundBoxes(json_t& jBBox, int32_t defaultHeight, bool full
Guard::Assert(
jBBox.is_string(),
"boundBox must be an array of four boundBox objects, a single boundBox object, or a string matching the "
"DefaultBoundingBoxType enum.");
"DefaultBoundBoxType enum.");
boxes = GetDefaultSceneryBoundBoxes(GetBoundingBoxTypeFromString(Json::GetString(jBBox)));
for (uint8_t i = 0; i < NumOrthogonalDirections; i++)
boxes[i].length.z = defaultHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
#include "../paint/Boundbox.h"
#include "../world/Scenery.h"

enum DefaultBoundingBoxType : uint8_t
enum DefaultBoundBoxType : uint8_t
{
QuarterTileBox,
HalfTileBox,
FullTileNorthQuadrantBox,
FullTileNortheastSideBox,
FullTileNortheastSideBox, // FullTileNortheastSide is not the same as HalfTile, as some BoundBoxes have different offsets
// and sizes
FullTileEastQuadrantBox,
FullTileSoutheastSideBox,
FullTileSouthQuadrantBox,
Expand All @@ -43,7 +44,7 @@ enum DefaultSpriteOffsetType : uint8_t
CountOffset
};

SceneryBoundBoxes GetDefaultSceneryBoundBoxes(DefaultBoundingBoxType type);
SceneryBoundBoxes GetDefaultSceneryBoundBoxes(DefaultBoundBoxType type);
SceneryBoundBoxes ReadBoundBoxes(json_t& jBBox, int32_t defaultHeight, bool fullTile);
CoordsXYZ GetDefaultSpriteOffset(DefaultSpriteOffsetType type);
CoordsXYZ ReadSpriteOffset(json_t& jCoords);
12 changes: 6 additions & 6 deletions src/openrct2/object/SmallSceneryObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "../interface/Cursors.h"
#include "../localisation/Language.h"
#include "../world/Scenery.h"
#include "SceneryBoundingBox.h"
#include "SceneryBoundbox.h"

#include <algorithm>

Expand Down Expand Up @@ -297,26 +297,26 @@ static int32_t getBoundBoxHeight(uint8_t clearanceHeight)

void SmallSceneryObject::SetBoundingBoxFromFlags()
{
DefaultBoundingBoxType boundBoxType = DefaultBoundingBoxType::QuarterTileBox;
DefaultBoundBoxType boundBoxType = DefaultBoundBoxType::QuarterTileBox;
DefaultSpriteOffsetType spriteOffsetType = DefaultSpriteOffsetType::QuarterTileOffset;
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_FULL_TILE))
{
boundBoxType = DefaultBoundingBoxType::FullTileThinBox;
boundBoxType = DefaultBoundBoxType::FullTileThinBox;
spriteOffsetType = DefaultSpriteOffsetType::FullTileThinOffset;
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HALF_SPACE))
{
spriteOffsetType = DefaultSpriteOffsetType::FullTileOffset;
boundBoxType = DefaultBoundingBoxType::HalfTileBox;
boundBoxType = DefaultBoundBoxType::HalfTileBox;
}
else
{
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_VOFFSET_CENTRE))
{
boundBoxType = DefaultBoundingBoxType::FullTileBox;
boundBoxType = DefaultBoundBoxType::FullTileBox;
spriteOffsetType = DefaultSpriteOffsetType::FullTileOffset;
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_NO_WALLS))
{
boundBoxType = DefaultBoundingBoxType::FullTileLargeBox;
boundBoxType = DefaultBoundBoxType::FullTileLargeBox;
spriteOffsetType = DefaultSpriteOffsetType::FullTileLargeOffset;
}
}
Expand Down

0 comments on commit 0c94614

Please sign in to comment.