From b4376ab5907d582574eb38b074daac7dd970e2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sun, 8 Oct 2023 02:30:43 +0300 Subject: [PATCH 1/3] Add owner property to tile elements for scripting --- distribution/openrct2.d.ts | 1 + .../scripting/bindings/world/ScTileElement.cpp | 15 +++++++++++++++ .../scripting/bindings/world/ScTileElement.hpp | 3 +++ 3 files changed, 19 insertions(+) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 0d954e7cdb..3978348619 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -1472,6 +1472,7 @@ declare global { occupiedQuadrants: number; isGhost: boolean; isHidden: boolean; /** Take caution when changing this field, it may invalidate TileElements you have stored in your script. */ + owner: number; } interface SurfaceElement extends BaseTileElement { diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index 4eb6f23553..5ef22ad0a1 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -2033,6 +2033,20 @@ namespace OpenRCT2::Scripting } } + DukValue ScTileElement::owner_get() const + { + auto& scriptEngine = GetContext()->GetScriptEngine(); + auto* ctx = scriptEngine.GetContext(); + duk_push_uint(ctx, _element->GetOwner()); + return DukValue::take_from_stack(ctx); + } + + void ScTileElement::owner_set(uint8_t value) + { + ThrowIfGameStateNotMutable(); + _element->SetOwner(value); + } + void ScTileElement::Invalidate() { MapInvalidateTileFull(_coords); @@ -2051,6 +2065,7 @@ namespace OpenRCT2::Scripting ctx, &ScTileElement::occupiedQuadrants_get, &ScTileElement::occupiedQuadrants_set, "occupiedQuadrants"); dukglue_register_property(ctx, &ScTileElement::isGhost_get, &ScTileElement::isGhost_set, "isGhost"); dukglue_register_property(ctx, &ScTileElement::isHidden_get, &ScTileElement::isHidden_set, "isHidden"); + dukglue_register_property(ctx, &ScTileElement::owner_get, &ScTileElement::owner_set, "owner"); // Track | Small Scenery | Wall | Entrance | Large Scenery | Banner dukglue_register_property(ctx, &ScTileElement::direction_get, &ScTileElement::direction_set, "direction"); diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.hpp b/src/openrct2/scripting/bindings/world/ScTileElement.hpp index f7bba6416a..3a48a23e06 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.hpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.hpp @@ -202,6 +202,9 @@ namespace OpenRCT2::Scripting DukValue direction_get() const; void direction_set(uint8_t value); + DukValue owner_get() const; + void owner_set(uint8_t value); + void Invalidate(); public: From 0ffbd65576f46de9122d410128b5f00a09be5525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sun, 8 Oct 2023 02:30:55 +0300 Subject: [PATCH 2/3] Bump plugin API version --- src/openrct2/scripting/ScriptEngine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index 530644349d..0926da6f16 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -47,7 +47,7 @@ namespace OpenRCT2 namespace OpenRCT2::Scripting { - static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 80; + static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 81; // Versions marking breaking changes. static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33; From 34ed27b0755d42e4af6c6eb8e8bc50373d72af10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sun, 8 Oct 2023 02:39:35 +0300 Subject: [PATCH 3/3] Update changelog.txt --- distribution/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index ebc4925220..8e959803e6 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -3,6 +3,7 @@ - Feature: [#20141] Add additional track pieces to the Giga Coaster. - Feature: [OpenMusic#46] Added Mystic ride music style. - Feature: [#20825] Made setting the game speed a game action. +- Feature: [#20853] [Plugin] Add “BaseTileElement.owner” which is saved in the park file. - Change: [#20790] Default ride price set to free if park charges for entry. - Fix: [#20356] Cannot set tertiary colour on small scenery. - Fix: [#20737] Spent money in player window underflows when getting refunds.