-
-
Notifications
You must be signed in to change notification settings - Fork 410
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
Custom train tracks #250
Custom train tracks #250
Conversation
(cherry picked from commit 45d1a26)
(cherry picked from commit e2c5fcb)
(cherry picked from commit 7624868)
(cherry picked from commit 92a1f42)
includes code for getDefaultTrack, but it doesn't return a recognisable train-track element yet...
This reverts commit 5cc1de4.
- Add CClientTrainTrackManager - Remove track IDs from the server entirely - Use track IDs only in internal Game SA logic This commit breaks network compatibility which will be fixed soon though
84a4dd6
to
7442da7
Compare
Something else is terribly fucked now, train won't even move, lol. |
|
||
// NOTE(qaisjp): I have no idea what the below comment is talking about. | ||
// place as close to point as possible (rather than at node)? (maybe) (actually seems to have an effect on the speed, so changed from 1 to 0) | ||
0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one problem: you can't set the train position of streamed out trains. Try placing two trains (
t1
andt21
) on the same track, near each other (trainPositionsp1
andp2
). Then disconnect, and use your server console to place them at the exact same position (setp1 = p2
). Then reconnect (or restart the game and reconnect) and you'll find that the trains have moved.
TODO: we could set the train position here? otherwise the client's train will not match what the server requested it to be. there might be a better time for setting the train position than here, though, such as when the train streams in
This **fully backwards compatible** pull request contains initial support for the train track element and the ability to change between default train tracks. This is the first in a series of pull requests that intends to pick apart the `feature/custom-train-tracks` branch in #250, so that it can be confidently reviewed and merged without worrying about bugs too much. You can get default track elements using the below documentation. This documentation is currently only accurate server-side. Client-side it will just return the same number you provide, as clients do not yet have a concept of track elements. ```lua -- OOP: TrainTrack.getDefaultTrack(trackID) train-track getDefaultTrack(number trackID) -- trackID: the ID of the default track, one of `0`, `1`, `2`, `3`. ``` And then set (or get) the track of a train using the following functions: ```lua -- OOP: v:setTrack(t) bool setTrainTrack(vehicle v, train-track t) -- OOP: v:getTrack(v) train-track getTrainTrack(vehicle v) ``` I have tested sync with one and two players, and track and position _syncing_ seems to work great. The only client changes this PR brings is exposing existing client to the Lua API (a partial revert of 89b5620 / #1713). The client-side `setTrainTrack` function is not protected, and can run on server trains. This is consistent with the behaviour of `setTrainPosition`, `setTrainDirection` and `setTrainSpeed`. Finally, since this code is based on the original `feature/custom-train-tracks` branch: Co-authored-by: Jusonex <jusonex96@gmail.com> Co-authored-by: Cazomino05 <Cazomino05@gmail.com> Co-authored-by: "sebasdevelopment@gmx.com" <sebasdevelopment@gmx.com>
This PR closes #388