Code Monkey home page Code Monkey logo

openrct2-costinflator's Issues

Ride upkeep grows exponentially when during ratings calculation

When the ratings for a tracked ride are in the progress of being calculated, and Ride Running Cost multipler is greater than 1.00, the running cost of the ride grows exponentially.

The cause of this appears to relate to the 'ride.ratings.calculate' hook of the plugin API: When the ratings for a ride are being calculated, the game invokes the 'ride.ratings.calculate' hook periodically. However, the ride's upkeep value is unchanged until after the ratings finished calculating. Since the plugin adjusts the ride upkeep value every time the hook is raised, the plugin can end up multiplying again an already adjusted upkeep value, hence the exponential growth of the value. The log output below demonstrates this behavior. The last two entries show the ride upkeep being applied eventually by the game to their correct values, and so get adjusted correctly by the plugin.

'Setting upkeep of ride 0 to 268 * 2.00 = 536'
'Setting upkeep of ride 0 to 536 * 2.00 = 1072'
'Setting upkeep of ride 0 to 1072 * 2.00 = 2144'
'Setting upkeep of ride 0 to 2144 * 2.00 = 4288'
'Setting upkeep of ride 0 to 4288 * 2.00 = 8576'
'Setting upkeep of ride 0 to 8576 * 2.00 = 17152'
'Setting upkeep of ride 0 to 17152 * 2.00 = 34304'
'Setting upkeep of ride 0 to 266 * 2.00 = 532'
'Setting upkeep of ride 0 to 266 * 2.00 = 532'

This issue can fixed by detecting that the ride ratings are being calculated and skip the recalculation step. Detecting ride ratings are being calculated can be done by checking the current ratings - if a rating metric is being calculated, it is -1 or 0. Therefore, the Ride Running Cost multiplier should only take effect for a ride if all of its rating metrics are greater than 0.

To Reproduce

  1. Start a new park, open the Cost Inflator settings window and set a multiplier of 2.00 (or anything greater than 1.00) for Ride Running Costs.
  2. Construct a tracked ride and set its state to 'testing' and observe the ride's running cost (and optionally the plugin log).

Expected behavior
The ride running cost should remain unchanged until the ride ratings having finished calculating

Actual behavior
The ride running cost grows exponentially while the ride ratings are being calculated, then returns to the correct value once rating calculations are complete.

Plugin version: 0.1.0
OpenRCT2 version: 0.4.1

Does not work in Multiplayer

As title says, the plugin does not work in multiplayer.
If only one of client/server uses it, it has no effect on the other one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.