Add footpath object flags to API (#26322)

* add footpath object flags to API

* Add changelog

---------

Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
Stephan SpenglerandTulio Leao authored and GitHub committed 2026-06-06 16:31:03 -03:00
1 parent d8a6aab651
commit bcdac632a4
5 files changed
+45 -1

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
0.5.2 (in development)
------------------------------------------------------------------------
- Improved: [#26322] Add footpath flags to FootpathSurfaceObject in the plugin API.
- Improved: [#26566] Improve the performance of sorting sprites.
- Fix: [#26350] ListViews altered by plugins post their creation are not invalidated.
- Fix: [#26565] Game crashes when switching to another tab in the guest window.
+6
View File
@@ -2263,6 +2263,10 @@ declare global {
}
interface FootpathSurfaceObject extends LoadedImageObject {
readonly flags: number;
}
interface FootpathAdditionObject extends SceneryObject {
}
@@ -5775,6 +5779,7 @@ declare global {
getObject(type: "small_scenery", index: number): SmallSceneryObject;
getObject(type: "large_scenery", index: number): LargeSceneryObject;
getObject(type: "wall", index: number): WallObject;
getObject(type: "footpath_surface", index: number): FootpathSurfaceObject;
getObject(type: "footpath_addition", index: number): FootpathAdditionObject;
getObject(type: "banner", index: number): BannerObject;
getObject(type: "scenery_group", index: number): SceneryGroupObject;
@@ -5788,6 +5793,7 @@ declare global {
getAllObjects(type: "small_scenery"): SmallSceneryObject[];
getAllObjects(type: "large_scenery"): LargeSceneryObject[];
getAllObjects(type: "wall"): WallObject[];
getAllObjects(type: "footpath_surface"): FootpathSurfaceObject[];
getAllObjects(type: "footpath_addition"): FootpathAdditionObject[];
getAllObjects(type: "banner"): BannerObject[];
getAllObjects(type: "scenery_group"): SceneryGroupObject[];
+1 -1
View File
@@ -43,7 +43,7 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting
{
// Grepped from CI (.github/workflows/publish-plugin-types.yml); keep the format `kPluginApiVersion = N`.
static constexpr int32_t kPluginApiVersion = 113;
static constexpr int32_t kPluginApiVersion = 114;
// Versions marking breaking changes.
static constexpr int32_t kApiVersionPeepDeprecation = 33;
@@ -12,6 +12,7 @@
#ifdef ENABLE_SCRIPTING
#include "../../../Context.h"
#include "../../../object/FootpathSurfaceObject.h"
#include "../../../object/LargeSceneryObject.h"
#include "../../../object/ObjectManager.h"
#include "../../../object/RideObject.h"
@@ -899,6 +900,38 @@ namespace OpenRCT2::Scripting
}
};
class ScFootpathSurfaceObject final : public ScObject
{
public:
static JSValue New(JSContext* ctx, ObjectType type, int32_t index)
{
JSValue obj = ScObject::New(ctx, type, index);
AddFuncs(ctx, obj);
return obj;
}
private:
static void AddFuncs(JSContext* ctx, JSValue obj)
{
static constexpr JSCFunctionListEntry funcs[] = {
JS_CGETSET_DEF("flags", ScFootpathSurfaceObject::flags_get, nullptr),
};
JS_SetPropertyFunctionList(ctx, obj, funcs, std::size(funcs));
}
static JSValue flags_get(JSContext* ctx, JSValue thisVal)
{
auto footpathObject = GetFootpathSurfaceObject(thisVal);
return JS_NewUint32(ctx, footpathObject != nullptr ? footpathObject->Flags : 0);
}
protected:
static FootpathSurfaceObject* GetFootpathSurfaceObject(JSValue thisVal)
{
return static_cast<FootpathSurfaceObject*>(GetObject(thisVal));
}
};
class ScSceneryGroupObject final : public ScObject
{
public:
@@ -306,6 +306,10 @@ JSValue ScObjectManager::CreateScObject(JSContext* ctx, ObjectType type, int32_t
{
return ScBannerObject::New(ctx, type, index);
}
case ObjectType::footpathSurface:
{
return ScFootpathSurfaceObject::New(ctx, type, index);
}
case ObjectType::sceneryGroup:
{
return ScSceneryGroupObject::New(ctx, type, index);