Merge remote-tracking branch 'upstream/develop' into new-save-format

This commit is contained in:
ζeh Matt 2021-09-28 01:53:18 +03:00
commit 8ae8a26a0f
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
4 changed files with 8 additions and 32 deletions

View File

@ -215,25 +215,6 @@ void Object::SetAuthors(std::vector<std::string>&& authors)
_authors = std::move(authors);
}
std::optional<uint8_t> rct_object_entry::GetSceneryType() const
{
switch (GetType())
{
case ObjectType::SmallScenery:
return SCENERY_TYPE_SMALL;
case ObjectType::LargeScenery:
return SCENERY_TYPE_LARGE;
case ObjectType::Walls:
return SCENERY_TYPE_WALL;
case ObjectType::Banners:
return SCENERY_TYPE_BANNER;
case ObjectType::PathBits:
return SCENERY_TYPE_PATH_ITEM;
default:
return std::nullopt;
}
}
bool rct_object_entry::IsEmpty() const
{
uint64_t a, b;

View File

@ -119,8 +119,6 @@ struct rct_object_entry
flags |= (static_cast<uint8_t>(newType) & 0x0F);
}
std::optional<uint8_t> GetSceneryType() const;
ObjectSourceGame GetSourceGame() const
{
return static_cast<ObjectSourceGame>((flags & 0xF0) >> 4);

View File

@ -66,7 +66,7 @@ void SceneryGroupObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int3
gfx_draw_sprite(dpi, imageId, screenCoords - ScreenCoordsXY{ 15, 14 }, 0);
}
static std::optional<uint8_t> GetSceneryType(ObjectType type)
static std::optional<uint8_t> GetSceneryType(const ObjectType type)
{
switch (type)
{

View File

@ -48,21 +48,18 @@ static void FreeEntity(EntityBase& entity);
constexpr size_t GetSpatialIndexOffset(int32_t x, int32_t y)
{
size_t index = SPATIAL_INDEX_LOCATION_NULL;
if (x != LOCATION_NULL)
{
x = std::clamp(x, 0, 0xFFFF);
y = std::clamp(y, 0, 0xFFFF);
if (x == LOCATION_NULL)
return SPATIAL_INDEX_LOCATION_NULL;
int16_t flooredX = floor2(x, 32);
uint8_t tileY = y >> 5;
index = (flooredX << 3) | tileY;
}
const auto tileX = std::clamp<size_t>(x / COORDS_XY_STEP, 0, MAXIMUM_MAP_SIZE_TECHNICAL);
const auto tileY = std::clamp<size_t>(y / COORDS_XY_STEP, 0, MAXIMUM_MAP_SIZE_TECHNICAL);
const auto index = tileX * MAXIMUM_MAP_SIZE_TECHNICAL + tileY;
if (index >= sizeof(gSpriteSpatialIndex))
if (index >= std::size(gSpriteSpatialIndex))
{
return SPATIAL_INDEX_LOCATION_NULL;
}
return index;
}