2016-06-25 18:58:04 +01:00
|
|
|
/*****************************************************************************
|
2022-10-01 03:42:14 -04:00
|
|
|
* Copyright (c) 2014-2022 OpenRCT2 developers
|
2016-06-25 18:58:04 +01: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
|
2016-06-25 18:58:04 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-06-25 18:58:04 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2017-12-19 15:08:48 +00:00
|
|
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
|
|
|
|
|
2018-06-22 23:03:20 +02:00
|
|
|
#include "SmallSceneryObject.h"
|
|
|
|
|
|
2016-06-25 18:58:04 +01:00
|
|
|
#include "../core/IStream.hpp"
|
2020-10-02 11:31:20 +01:00
|
|
|
#include "../core/Json.hpp"
|
2016-06-25 18:58:04 +01:00
|
|
|
#include "../core/Memory.hpp"
|
2017-11-24 11:05:54 +01:00
|
|
|
#include "../core/String.hpp"
|
2018-01-05 21:17:33 +00:00
|
|
|
#include "../drawing/Drawing.h"
|
2021-12-07 20:55:27 +00:00
|
|
|
#include "../drawing/Image.h"
|
2017-12-19 15:08:48 +00:00
|
|
|
#include "../interface/Cursors.h"
|
2018-01-06 18:32:25 +01:00
|
|
|
#include "../localisation/Language.h"
|
2018-01-11 10:59:26 +01:00
|
|
|
#include "../world/Scenery.h"
|
2017-12-04 20:09:38 +01:00
|
|
|
#include "../world/SmallScenery.h"
|
2016-06-25 18:58:04 +01:00
|
|
|
|
2018-08-12 12:50:40 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2020-07-30 23:01:22 +02:00
|
|
|
void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStream* stream)
|
2016-06-25 18:58:04 +01:00
|
|
|
{
|
2020-07-30 23:01:22 +02:00
|
|
|
stream->Seek(6, OpenRCT2::STREAM_SEEK_CURRENT);
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags = stream->ReadValue<uint32_t>();
|
|
|
|
|
_legacyType.height = stream->ReadValue<uint8_t>();
|
|
|
|
|
_legacyType.tool_id = static_cast<CursorID>(stream->ReadValue<uint8_t>());
|
2022-03-22 21:35:44 +00:00
|
|
|
_legacyType.price = stream->ReadValue<int16_t>() * 10;
|
|
|
|
|
_legacyType.removal_price = stream->ReadValue<int16_t>() * 10;
|
2020-07-30 23:01:22 +02:00
|
|
|
stream->Seek(4, OpenRCT2::STREAM_SEEK_CURRENT);
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.animation_delay = stream->ReadValue<uint16_t>();
|
|
|
|
|
_legacyType.animation_mask = stream->ReadValue<uint16_t>();
|
|
|
|
|
_legacyType.num_frames = stream->ReadValue<uint16_t>();
|
|
|
|
|
_legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL;
|
2016-06-25 18:58:04 +01:00
|
|
|
|
2020-08-29 04:36:58 +02:00
|
|
|
GetStringTable().Read(context, stream, ObjectStringID::NAME);
|
2016-06-25 18:58:04 +01:00
|
|
|
|
2016-07-09 19:16:38 +01:00
|
|
|
rct_object_entry sgEntry = stream->ReadValue<rct_object_entry>();
|
2021-03-12 11:04:04 +01:00
|
|
|
SetPrimarySceneryGroup(ObjectEntryDescriptor(sgEntry));
|
2016-06-25 18:58:04 +01:00
|
|
|
|
2021-10-01 21:50:05 +02:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS))
|
2016-06-25 18:58:04 +01:00
|
|
|
{
|
2017-07-25 22:26:43 +01:00
|
|
|
_frameOffsets = ReadFrameOffsets(stream);
|
2016-06-25 18:58:04 +01:00
|
|
|
}
|
2019-03-18 22:56:14 +01:00
|
|
|
// This crude method was used by RCT2. JSON objects have a flag for this property.
|
2021-06-04 02:14:41 +01:00
|
|
|
if (_legacyType.height > 64)
|
2019-03-18 22:56:14 +01:00
|
|
|
{
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags |= SMALL_SCENERY_FLAG_IS_TREE;
|
2019-03-18 22:56:14 +01:00
|
|
|
}
|
2016-06-25 18:58:04 +01:00
|
|
|
|
2017-12-11 13:06:59 +00:00
|
|
|
GetImageTable().Read(context, stream);
|
2016-07-02 17:23:06 +01:00
|
|
|
|
|
|
|
|
// Validate properties
|
2021-06-04 02:14:41 +01:00
|
|
|
if (_legacyType.price <= 0)
|
2016-07-02 17:23:06 +01:00
|
|
|
{
|
2020-10-10 12:21:07 -03:00
|
|
|
context->LogError(ObjectError::InvalidProperty, "Price can not be free or negative.");
|
2016-07-02 17:23:06 +01:00
|
|
|
}
|
2021-06-04 02:14:41 +01:00
|
|
|
if (_legacyType.removal_price <= 0)
|
2016-07-02 17:23:06 +01:00
|
|
|
{
|
|
|
|
|
// Make sure you don't make a profit when placing then removing.
|
2022-03-22 21:35:44 +00:00
|
|
|
const auto reimbursement = _legacyType.removal_price;
|
2021-06-04 02:14:41 +01:00
|
|
|
if (reimbursement > _legacyType.price)
|
2016-07-02 17:23:06 +01:00
|
|
|
{
|
2020-10-10 12:21:07 -03:00
|
|
|
context->LogError(ObjectError::InvalidProperty, "Sell price can not be more than buy price.");
|
2016-07-02 17:23:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
2016-06-25 18:58:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SmallSceneryObject::Load()
|
|
|
|
|
{
|
2017-12-11 13:06:59 +00:00
|
|
|
GetStringTable().Sort();
|
2016-06-25 18:58:04 +01:00
|
|
|
_legacyType.name = language_allocate_object_string(GetName());
|
2017-12-11 13:06:59 +00:00
|
|
|
_legacyType.image = gfx_object_allocate_images(GetImageTable().GetImages(), GetImageTable().GetCount());
|
2016-06-25 18:58:04 +01:00
|
|
|
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL;
|
2016-06-26 16:06:03 +01:00
|
|
|
|
2021-10-01 21:50:05 +02:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS))
|
2016-06-26 16:06:03 +01:00
|
|
|
{
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.frame_offsets = _frameOffsets.data();
|
2016-06-26 16:06:03 +01:00
|
|
|
}
|
2017-11-24 11:05:54 +01:00
|
|
|
|
|
|
|
|
PerformFixes();
|
2016-06-25 18:58:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SmallSceneryObject::Unload()
|
|
|
|
|
{
|
|
|
|
|
language_free_object_string(_legacyType.name);
|
2017-12-11 13:06:59 +00:00
|
|
|
gfx_object_free_images(_legacyType.image, GetImageTable().GetCount());
|
2016-07-03 18:02:18 +01:00
|
|
|
|
|
|
|
|
_legacyType.name = 0;
|
|
|
|
|
_legacyType.image = 0;
|
2016-06-25 18:58:04 +01:00
|
|
|
}
|
|
|
|
|
|
2018-06-22 23:03:20 +02:00
|
|
|
void SmallSceneryObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const
|
2016-07-02 11:35:46 +01:00
|
|
|
{
|
2021-11-29 14:36:36 +01:00
|
|
|
auto imageId = ImageId(_legacyType.image);
|
2021-10-01 21:50:05 +02:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR))
|
2016-07-02 11:35:46 +01:00
|
|
|
{
|
2021-11-29 14:36:36 +01:00
|
|
|
imageId = imageId.WithPrimary(COLOUR_BORDEAUX_RED);
|
2021-10-01 21:50:05 +02:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR))
|
2016-07-02 11:35:46 +01:00
|
|
|
{
|
2021-11-29 14:36:36 +01:00
|
|
|
imageId = imageId.WithSecondary(COLOUR_YELLOW);
|
2016-07-02 11:35:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-03-20 14:36:22 +00:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_TERTIARY_COLOUR))
|
|
|
|
|
{
|
|
|
|
|
imageId = imageId.WithSecondary(COLOUR_DARK_BROWN);
|
|
|
|
|
}
|
2016-07-02 11:35:46 +01:00
|
|
|
|
2021-06-04 02:14:41 +01:00
|
|
|
auto screenCoords = ScreenCoordsXY{ width / 2, (height / 2) + (_legacyType.height / 2) };
|
2020-06-23 23:32:34 +02:00
|
|
|
screenCoords.y = std::min(screenCoords.y, height - 16);
|
2016-07-02 11:35:46 +01:00
|
|
|
|
2021-10-01 21:50:05 +02:00
|
|
|
if ((_legacyType.HasFlag(SMALL_SCENERY_FLAG_FULL_TILE)) && (_legacyType.HasFlag(SMALL_SCENERY_FLAG_VOFFSET_CENTRE)))
|
2016-07-02 11:35:46 +01:00
|
|
|
{
|
2020-06-23 23:32:34 +02:00
|
|
|
screenCoords.y -= 12;
|
2016-07-02 11:35:46 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-29 14:36:36 +01:00
|
|
|
gfx_draw_sprite(dpi, imageId, screenCoords);
|
2016-07-02 11:35:46 +01:00
|
|
|
|
2021-10-01 21:50:05 +02:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_GLASS))
|
2016-07-02 11:35:46 +01:00
|
|
|
{
|
2022-10-04 12:28:15 -04:00
|
|
|
imageId = ImageId(_legacyType.image + 4).WithTransparency(COLOUR_BORDEAUX_RED);
|
2021-11-29 14:36:36 +01:00
|
|
|
gfx_draw_sprite(dpi, imageId, screenCoords);
|
2016-07-02 11:35:46 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-01 21:50:05 +02:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_ANIMATED_FG))
|
2016-07-02 11:35:46 +01:00
|
|
|
{
|
2021-11-29 14:36:36 +01:00
|
|
|
imageId = ImageId(_legacyType.image + 4);
|
2021-10-01 21:50:05 +02:00
|
|
|
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR))
|
2016-07-02 11:35:46 +01:00
|
|
|
{
|
2021-11-29 14:36:36 +01:00
|
|
|
imageId = imageId.WithSecondary(COLOUR_YELLOW);
|
2016-07-02 11:35:46 +01:00
|
|
|
}
|
2021-11-29 14:36:36 +01:00
|
|
|
gfx_draw_sprite(dpi, imageId, screenCoords);
|
2016-07-02 11:35:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 23:01:22 +02:00
|
|
|
std::vector<uint8_t> SmallSceneryObject::ReadFrameOffsets(OpenRCT2::IStream* stream)
|
2016-06-25 18:58:04 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t frameOffset;
|
|
|
|
|
auto data = std::vector<uint8_t>();
|
|
|
|
|
data.push_back(stream->ReadValue<uint8_t>());
|
|
|
|
|
while ((frameOffset = stream->ReadValue<uint8_t>()) != 0xFF)
|
2016-06-25 18:58:04 +01:00
|
|
|
{
|
2017-07-25 22:26:43 +01:00
|
|
|
data.push_back(frameOffset);
|
2016-06-25 18:58:04 +01:00
|
|
|
}
|
2017-07-25 22:26:43 +01:00
|
|
|
data.push_back(frameOffset);
|
2018-02-07 19:56:46 +00:00
|
|
|
return data;
|
2016-06-25 18:58:04 +01:00
|
|
|
}
|
2017-11-24 11:05:54 +01:00
|
|
|
|
2018-01-10 16:14:36 +01:00
|
|
|
// clang-format off
|
2017-11-24 11:05:54 +01:00
|
|
|
void SmallSceneryObject::PerformFixes()
|
|
|
|
|
{
|
2020-05-07 19:35:30 +01:00
|
|
|
auto identifier = GetLegacyIdentifier();
|
2021-03-12 11:04:04 +01:00
|
|
|
static const auto& scgWalls = Object::GetScgWallsHeader();
|
2017-11-24 11:05:54 +01:00
|
|
|
|
2021-07-31 13:10:00 +01:00
|
|
|
// ToonTowner's base blocks. Put them in the Walls and Roofs group.
|
2020-05-07 19:35:30 +01:00
|
|
|
if (identifier == "XXBBCL01" ||
|
|
|
|
|
identifier == "XXBBMD01" ||
|
|
|
|
|
identifier == "ARBASE2 ")
|
2017-11-24 11:05:54 +01:00
|
|
|
{
|
2021-03-12 11:04:04 +01:00
|
|
|
SetPrimarySceneryGroup(scgWalls);
|
2017-11-24 11:05:54 +01:00
|
|
|
}
|
2017-11-24 12:27:22 +01:00
|
|
|
|
|
|
|
|
// ToonTowner's Pirate roofs. Make them show up in the Pirate Theming.
|
2022-08-02 21:53:17 +02:00
|
|
|
if (identifier == "TTPIRF05" ||
|
2020-05-07 19:35:30 +01:00
|
|
|
identifier == "TTPRF09 " ||
|
|
|
|
|
identifier == "TTPRF10 " ||
|
|
|
|
|
identifier == "TTPRF11 ")
|
2017-11-24 12:27:22 +01:00
|
|
|
{
|
2021-03-12 11:04:04 +01:00
|
|
|
static const auto& scgPirat = GetScgPiratHeader();
|
|
|
|
|
SetPrimarySceneryGroup(scgPirat);
|
2017-11-24 12:27:22 +01:00
|
|
|
}
|
2017-11-24 13:17:25 +01:00
|
|
|
|
|
|
|
|
// ToonTowner's wooden roofs. Make them show up in the Mine Theming.
|
2020-05-07 19:35:30 +01:00
|
|
|
if (identifier == "TTRFWD01" ||
|
|
|
|
|
identifier == "TTRFWD02" ||
|
|
|
|
|
identifier == "TTRFWD03" ||
|
|
|
|
|
identifier == "TTRFWD04" ||
|
|
|
|
|
identifier == "TTRFWD05" ||
|
|
|
|
|
identifier == "TTRFWD06" ||
|
|
|
|
|
identifier == "TTRFWD07" ||
|
|
|
|
|
identifier == "TTRFWD08")
|
2017-11-24 13:17:25 +01:00
|
|
|
{
|
2021-03-12 11:04:04 +01:00
|
|
|
static const auto& scgMine = GetScgMineHeader();
|
|
|
|
|
SetPrimarySceneryGroup(scgMine);
|
2017-11-24 13:17:25 +01:00
|
|
|
}
|
2017-11-24 13:56:11 +01:00
|
|
|
|
|
|
|
|
// ToonTowner's glass roofs. Make them show up in the Abstract Theming.
|
2020-05-07 19:35:30 +01:00
|
|
|
if (identifier == "TTRFGL01" ||
|
|
|
|
|
identifier == "TTRFGL02" ||
|
|
|
|
|
identifier == "TTRFGL03")
|
2017-11-24 13:56:11 +01:00
|
|
|
{
|
2021-03-12 11:04:04 +01:00
|
|
|
static const auto& scgAbstr = GetScgAbstrHeader();
|
|
|
|
|
SetPrimarySceneryGroup(scgAbstr);
|
2017-11-24 13:56:11 +01:00
|
|
|
}
|
2017-11-24 11:05:54 +01:00
|
|
|
}
|
2018-01-10 16:14:36 +01:00
|
|
|
// clang-format on
|
2017-12-01 11:54:25 +01:00
|
|
|
|
2021-03-12 11:04:04 +01:00
|
|
|
ObjectEntryDescriptor SmallSceneryObject::GetScgPiratHeader() const
|
2017-12-01 11:54:25 +01:00
|
|
|
{
|
2021-10-27 14:21:14 +02:00
|
|
|
return ObjectEntryDescriptor("rct2.scenery_group.scgpirat");
|
2017-12-01 11:54:25 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-12 11:04:04 +01:00
|
|
|
ObjectEntryDescriptor SmallSceneryObject::GetScgMineHeader() const
|
2017-12-01 11:54:25 +01:00
|
|
|
{
|
2021-07-31 11:00:41 +02:00
|
|
|
return ObjectEntryDescriptor("rct2.scgmine");
|
2017-12-01 11:54:25 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-12 11:04:04 +01:00
|
|
|
ObjectEntryDescriptor SmallSceneryObject::GetScgAbstrHeader() const
|
2017-12-01 11:54:25 +01:00
|
|
|
{
|
2021-10-27 14:21:14 +02:00
|
|
|
return ObjectEntryDescriptor("rct2.scenery_group.scgabstr");
|
2017-12-01 11:54:25 +01:00
|
|
|
}
|
2017-12-19 15:08:48 +00:00
|
|
|
|
2020-08-12 23:05:23 +01:00
|
|
|
void SmallSceneryObject::ReadJson(IReadObjectContext* context, json_t& root)
|
2017-12-19 15:08:48 +00:00
|
|
|
{
|
2020-08-12 23:05:23 +01:00
|
|
|
Guard::Assert(root.is_object(), "SmallSceneryObject::ReadJson expects parameter root to be object");
|
2017-12-19 15:08:48 +00:00
|
|
|
|
2020-08-12 23:05:23 +01:00
|
|
|
auto properties = root["properties"];
|
2017-12-19 15:08:48 +00:00
|
|
|
|
2020-08-12 23:05:23 +01:00
|
|
|
if (properties.is_object())
|
2017-12-19 21:05:19 +00:00
|
|
|
{
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.height = Json::GetNumber<uint8_t>(properties["height"]);
|
|
|
|
|
_legacyType.tool_id = Cursor::FromString(Json::GetString(properties["cursor"]), CursorID::StatueDown);
|
2022-03-23 18:14:03 -03:00
|
|
|
_legacyType.price = Json::GetNumber<int16_t>(properties["price"]) * 10;
|
|
|
|
|
_legacyType.removal_price = Json::GetNumber<int16_t>(properties["removalPrice"]) * 10;
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.animation_delay = Json::GetNumber<uint16_t>(properties["animationDelay"]);
|
|
|
|
|
_legacyType.animation_mask = Json::GetNumber<uint16_t>(properties["animationMask"]);
|
|
|
|
|
_legacyType.num_frames = Json::GetNumber<uint16_t>(properties["numFrames"]);
|
2020-08-12 23:05:23 +01:00
|
|
|
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags = Json::GetFlags<uint32_t>(
|
2020-08-12 23:05:23 +01:00
|
|
|
properties,
|
2017-12-19 21:05:19 +00:00
|
|
|
{
|
2020-08-12 23:05:23 +01:00
|
|
|
{ "SMALL_SCENERY_FLAG_VOFFSET_CENTRE", SMALL_SCENERY_FLAG_VOFFSET_CENTRE },
|
|
|
|
|
{ "requiresFlatSurface", SMALL_SCENERY_FLAG_REQUIRE_FLAT_SURFACE },
|
|
|
|
|
{ "isRotatable", SMALL_SCENERY_FLAG_ROTATABLE },
|
|
|
|
|
{ "isAnimated", SMALL_SCENERY_FLAG_ANIMATED },
|
|
|
|
|
{ "canWither", SMALL_SCENERY_FLAG_CAN_WITHER },
|
|
|
|
|
{ "canBeWatered", SMALL_SCENERY_FLAG_CAN_BE_WATERED },
|
|
|
|
|
{ "hasOverlayImage", SMALL_SCENERY_FLAG_ANIMATED_FG },
|
|
|
|
|
{ "hasGlass", SMALL_SCENERY_FLAG_HAS_GLASS },
|
|
|
|
|
{ "hasPrimaryColour", SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR },
|
|
|
|
|
{ "SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1", SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1 },
|
|
|
|
|
{ "SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4", SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4 },
|
|
|
|
|
{ "isClock", SMALL_SCENERY_FLAG_IS_CLOCK },
|
|
|
|
|
{ "SMALL_SCENERY_FLAG_SWAMP_GOO", SMALL_SCENERY_FLAG_SWAMP_GOO },
|
|
|
|
|
{ "SMALL_SCENERY_FLAG17", SMALL_SCENERY_FLAG17 },
|
|
|
|
|
{ "isStackable", SMALL_SCENERY_FLAG_STACKABLE },
|
|
|
|
|
{ "prohibitWalls", SMALL_SCENERY_FLAG_NO_WALLS },
|
|
|
|
|
{ "hasSecondaryColour", SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR },
|
|
|
|
|
{ "hasNoSupports", SMALL_SCENERY_FLAG_NO_SUPPORTS },
|
|
|
|
|
{ "SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED", SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED },
|
|
|
|
|
{ "SMALL_SCENERY_FLAG_COG", SMALL_SCENERY_FLAG_COG },
|
|
|
|
|
{ "allowSupportsAbove", SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP },
|
|
|
|
|
{ "supportsHavePrimaryColour", SMALL_SCENERY_FLAG_PAINT_SUPPORTS },
|
|
|
|
|
{ "SMALL_SCENERY_FLAG27", SMALL_SCENERY_FLAG27 },
|
|
|
|
|
{ "isTree", SMALL_SCENERY_FLAG_IS_TREE },
|
2022-03-20 14:36:22 +00:00
|
|
|
{ "hasTertiaryColour", SMALL_SCENERY_FLAG_HAS_TERTIARY_COLOUR },
|
2020-08-12 23:05:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Determine shape flags from a shape string
|
|
|
|
|
auto shape = Json::GetString(properties["shape"]);
|
|
|
|
|
if (!shape.empty())
|
|
|
|
|
{
|
|
|
|
|
auto quarters = shape.substr(0, 3);
|
|
|
|
|
if (quarters == "2/4")
|
|
|
|
|
{
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags |= SMALL_SCENERY_FLAG_FULL_TILE | SMALL_SCENERY_FLAG_HALF_SPACE;
|
2020-08-12 23:05:23 +01:00
|
|
|
}
|
|
|
|
|
else if (quarters == "3/4")
|
|
|
|
|
{
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags |= SMALL_SCENERY_FLAG_FULL_TILE | SMALL_SCENERY_FLAG_THREE_QUARTERS;
|
2020-08-12 23:05:23 +01:00
|
|
|
}
|
|
|
|
|
else if (quarters == "4/4")
|
|
|
|
|
{
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags |= SMALL_SCENERY_FLAG_FULL_TILE;
|
2020-08-12 23:05:23 +01:00
|
|
|
}
|
|
|
|
|
if (shape.size() >= 5)
|
|
|
|
|
{
|
|
|
|
|
if ((shape.substr(3) == "+D"))
|
|
|
|
|
{
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags |= SMALL_SCENERY_FLAG_DIAGONAL;
|
2020-08-12 23:05:23 +01:00
|
|
|
}
|
2017-12-19 21:05:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-12 23:05:23 +01:00
|
|
|
|
|
|
|
|
auto jFrameOffsets = properties["frameOffsets"];
|
|
|
|
|
if (jFrameOffsets.is_array())
|
|
|
|
|
{
|
|
|
|
|
_frameOffsets = ReadJsonFrameOffsets(jFrameOffsets);
|
2021-06-04 02:14:41 +01:00
|
|
|
_legacyType.flags |= SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS;
|
2020-08-12 23:05:23 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-12 11:04:04 +01:00
|
|
|
SetPrimarySceneryGroup(ObjectEntryDescriptor(Json::GetString(properties["sceneryGroup"])));
|
2017-12-19 21:05:19 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-12 23:05:23 +01:00
|
|
|
PopulateTablesFromJson(context, root);
|
2017-12-19 15:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-12 23:05:23 +01:00
|
|
|
std::vector<uint8_t> SmallSceneryObject::ReadJsonFrameOffsets(json_t& jFrameOffsets)
|
2017-12-19 15:08:48 +00:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
std::vector<uint8_t> offsets;
|
2020-08-12 23:05:23 +01:00
|
|
|
|
2021-01-09 05:59:55 +09:00
|
|
|
for (const auto& jOffset : jFrameOffsets)
|
2017-12-19 15:08:48 +00:00
|
|
|
{
|
2020-08-12 23:05:23 +01:00
|
|
|
offsets.push_back(Json::GetNumber<uint8_t>(jOffset));
|
2017-12-19 15:08:48 +00:00
|
|
|
}
|
|
|
|
|
return offsets;
|
|
|
|
|
}
|