1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Reimplement landscape door drawing (#11233)

This commit is contained in:
Michael Steenbeek
2020-04-17 19:59:38 +02:00
committed by GitHub
parent b449e445f7
commit ffa9996336
4 changed files with 20 additions and 5 deletions

View File

@@ -47,7 +47,8 @@ void TerrainEdgeObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32
void TerrainEdgeObject::ReadJson(IReadObjectContext* context, const json_t* root)
{
// auto properties = json_object_get(root, "properties");
auto properties = json_object_get(root, "properties");
HasDoors = ObjectJsonHelpers::GetBoolean(properties, "hasDoors", false);
ObjectJsonHelpers::LoadStrings(root, GetStringTable());
ObjectJsonHelpers::LoadImages(context, root, GetImageTable());

View File

@@ -19,6 +19,7 @@ public:
uint32_t IconImageId{};
uint32_t BaseImageId{};
uint32_t NumImagesLoaded{};
bool HasDoors{};
explicit TerrainEdgeObject(const rct_object_entry& entry)
: Object(entry)

View File

@@ -386,11 +386,22 @@ static uint32_t get_edge_image(uint8_t index, uint8_t type)
return result;
}
static uint32_t get_tunnel_image(uint8_t index, uint8_t type)
static uint32_t get_tunnel_image(ObjectEntryIndex index, uint8_t type)
{
static constexpr uint32_t offsets[] = {
36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 36, 48, 60, 72,
};
static constexpr uint32_t offsets[TUNNEL_TYPE_COUNT] = { 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80,
36, 48, 60, 72, 76, 80, 84, 88, 92, 96, 100 };
bool hasDoors = false;
auto& objMgr = OpenRCT2::GetContext()->GetObjectManager();
auto obj = objMgr.GetLoadedObject(OBJECT_TYPE_TERRAIN_EDGE, index);
if (obj != nullptr)
{
auto tobj = static_cast<TerrainEdgeObject*>(obj);
hasDoors = tobj->HasDoors;
}
if (!hasDoors && type >= REGULAR_TUNNEL_TYPE_COUNT && type < std::size(offsets))
type = TUNNEL_0;
uint32_t result = 0;
if (type < std::size(offsets))

View File

@@ -58,6 +58,8 @@ enum
TUNNEL_13 = 0x0D,
TUNNEL_14 = 0x0E,
TUNNEL_15 = 0x0F,
REGULAR_TUNNEL_TYPE_COUNT,
// Ghost train doors
TUNNEL_DOORS_0 = 16,
TUNNEL_DOORS_1 = 17,