Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin: SmallSceneryObject.removalPrice is incorrect for objects that refund on removal #21987

Open
Logg-y opened this issue May 7, 2024 · 0 comments
Labels
bug Something went wrong. plug-in Related to the plugin system of OpenRCT2.

Comments

@Logg-y
Copy link

Logg-y commented May 7, 2024

Operating System

Windows 10 x64

OpenRCT2 build

OpenRCT2, v0.4.11 (18d2b5e) provided by GitHub

Base game

RollerCoaster Tycoon 2, RollerCoaster Tycoon Classic

Area(s) with this issue?

This is a development issue

Describe the issue

Scenery objects with a negative removalPrice seem to return a wrong value when accessed through the plugin API, specifically they return positive values some power of two larger than the true value, almost like there is a signedness bug somewhere. For most objects this is 256, for other things like the most expensive thing I could find in a hurry (Mythological theming golden fleece) the error is 4096.

There's every chance that this is somehow user error as well, I'm very new to JS/TS.

Steps to reproduce

The code in question:

export function removalPriceBug(): void
{
    for (let y = 0; y < map.size.y; y++) {
        for (let x = 0; x < map.size.x; x++) {
            let tile = map.getTile(x, y);
            for (let i = 0; i < tile.numElements; i++) {
                let element = tile.getElement(i);
                if (element.type === 'small_scenery') {
                    let scenery = objectManager.getObject("small_scenery", element.object);
                    if (scenery.removalPrice != 0)
                    {
                        park.postMessage("item " + scenery.identifier + " has removal price: " + scenery.removalPrice);
                    }
                }
            }
        }
    }
}

This works fine for things with a positive removal cost.

Attachments

No response

@Logg-y Logg-y added the bug Something went wrong. label May 7, 2024
@Gymnasiast Gymnasiast added the plug-in Related to the plugin system of OpenRCT2. label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something went wrong. plug-in Related to the plugin system of OpenRCT2.
Projects
None yet
Development

No branches or pull requests

2 participants