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

Custom train tracks #250

Closed
wants to merge 70 commits into from
Closed

Custom train tracks #250

wants to merge 70 commits into from

Conversation

qaisjp
Copy link
Contributor

@qaisjp qaisjp commented Jul 22, 2018

This PR closes #388

Cazomino05 and others added 30 commits July 13, 2016 18:38
(cherry picked from commit 45d1a26)
(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...
- 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
@multitheftauto multitheftauto unlocked this conversation Oct 12, 2020
@qaisjp qaisjp changed the title WIP: custom train tracks Custom train tracks Oct 12, 2020
@StrixG StrixG added this to the Backlog milestone Oct 12, 2020
@qaisjp qaisjp force-pushed the feature/custom-train-tracks branch 3 times, most recently from 84a4dd6 to 7442da7 Compare October 12, 2020 21:42
@qaisjp
Copy link
Contributor Author

qaisjp commented Oct 12, 2020

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);

Copy link
Contributor Author

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 and t21) on the same track, near each other (trainPositions p1 and p2). Then disconnect, and use your server console to place them at the exact same position (set p1 = 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

qaisjp added a commit that referenced this pull request Oct 16, 2020
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>
@qaisjp qaisjp removed this from the Confirmed Issues milestone Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to create custom train tracks
7 participants