[Plugin] Add track progress property to vehicles#13593
Conversation
|
Have you tried running clang-format on your changes? |
No I haven't, I was looking into how to do that after the checks failed. I'll fix that tonight. :) |
|
This wont be able to set the correct sprite for vehicles going through reverser elements or rotate elements like log flumes, heartline. |
|
I think it will need to hook in early to the UpdateMotion functions. The vehicle placement code uses UpdateMotion to place the vehicles and this ensures that all of the values are correct. I'm not too sure how you would achieve that though. Edit: Possibly could work by setting the value of Something like:
|
|
@duncanspumpkin Thank you for your reply. I'll give the remaining_distance a shot. What does it exactly hold? The distance to travel within this frame? Or the distance to the next track piece? Or something else? |
|
From memory the units are the same as track progress. It's a sort of left over amount after a vehicle update when things don't quite line up |
This can be used in conjuction with OpenRCT2#13593 to change the placement of vehicles on a track
This can be used in conjuction with OpenRCT2#13593 to change the placement of vehicles on a track
|
@duncanspumpkin I realise I checked in your code from #13607 here as well. Should I remove it or should it merge fine after your PR has been merged? |
This can be used in conjuction with #13593 to change the placement of vehicles on a track
Could you rebase now that my code has been merged. |
Sure! I'll do that tonight or tomorrow when I have time. :) |
1cfaf49 to
21c20b1
Compare
| UpdateTrackMotion(nullptr); | ||
| ClearUpdateFlag(VEHICLE_UPDATE_FLAG_SINGLE_CAR_POSITION); | ||
|
|
||
| const Ride* curRide = GetRide(); |
There was a problem hiding this comment.
I'm pretty sure you don't need to do any of this moveInfo changes. UpdateTrackMotion should take care of it.
There was a problem hiding this comment.
Yes you're right, I'll remove it. :)
| bool Vehicle::UpdateMotionCollisionDetection(const CoordsXYZ& loc, uint16_t* otherVehicleIndex) | ||
| { | ||
| if (HasUpdateFlag(VEHICLE_UPDATE_FLAG_COLLISION_DISABLED)) | ||
| if (HasUpdateFlag(VEHICLE_UPDATE_FLAG_COLLISION_DISABLED) || HasUpdateFlag(VEHICLE_UPDATE_FLAG_SINGLE_CAR_POSITION)) |
There was a problem hiding this comment.
Any reason you are doing this rather than just setting VEHICLE_UPDATE_FLAG_COLLISION_DISABLED as well as VEHICLE_UPDATE_FLAG_SINGLE_CAR_POSITION
There was a problem hiding this comment.
I can do that yes, that sounds like a better idea. Will it not interfere with any other code if I clear the VEHICLE_UPDATE_FLAG_COLLISION_DISABLED-flag again after UpdateTrackMotion? I am not sure when and where this flag is used elsewhere.
There was a problem hiding this comment.
I know it's used for vehicle placement (which is not an issue). Have a look see if it's set for anything else
There was a problem hiding this comment.
The only case I can find is the Giga Coaster cablelift, where it is enabled permanently. I don't think UpdateMotionCollisionDetection is called for the cablelift though, so it seems safe to clear it. :)
In all other cases where the flag is set (when vehicles are created), it is immediately cleared afterwards already.
|
This looks reasonable. Assuming it all works fine on your plugin I've no issues with it. @IntelOrca do you have anything to add? |
Yes it works perfect in my plugin. :) Only quirk I could find is that modifying a car on a slope sometimes moves other vehicles on the train as well. (Like I mentioned on Discord.) Other than that I tested a lot of special rides like Reverser Coaster, Chairlift, Giga Coaster, Lift, Go Karts, Heartline Twister, Log Flume reversers etc. as well and they all work perfectly. (And no crashes or freezes either.) If you guys wanna test it as well with the plugin, just let me know and I can send over the *.js file for it! |
|
Just wondering whether |
I can change it to
Who wants to make the final choice? 😃 |
|
Just |
|
Yeah, my thoughts are that move is likely to mean, move by a coordinate relative to the map rather than an amount relative to the track. So I think it should just have a different name in case we have another function called |
|
So |
|
@duncanspumpkin any personal suggestions? |
|
No opinions here |
|
The |
|
Okay finally, you just need to increment the plugin API version number and add this to the changelog. Sorry, I should have mentioned that previously. |
c30bfef to
918bd01
Compare
|
Great, no worries! I think it should be properly rebased now? And the plugin API version and changelog have been updated. :) |
Hey all, this is my draft attempt at adding a property for track progress to vehicles for plugins. This would be very useful for my RideVehicleEditor plugin to adjust spacing between vehicles, and maybe others can find some usefulness in it as well!
If the chosen value is beyond the maximum amount of the current track piece, the vehicle will go to the relative position on the next track piece.What I'm still planning to do:
Clamp track progress at the end of tracks (for non-complete circuits).Sometimes if it jumps to the next or previous track, the position is off by 1.Test it thoroughly to make sure it doesn't crash or mess up the game somehow (so far it doesn't seem to).Update 21 dec:
A screenshot of it working ingame:

Right now it works surprisingly well and I haven't really found any issues so far.
I'd love to hear feedback though. This is my first pull request and I'm not even sure if this is the best approach for it. Please let me know if this is something that would fit into the source code and if there is anything I should change.