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

feat(extra-natives/five): track switching #3044

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

Ehbw
Copy link
Contributor

@Ehbw Ehbw commented Dec 26, 2024

Goal of this PR

Introduce a way to register track switching. Track switching allows for a train to change the track index it is currently navigating along. Suggested by @glitchdetector

How is this PR achieving the goal

introduces REGISTER_TRACK_SWITCH and SET_TRACK_SWITCH_ACTIVE to allow for registration of a train switch and ability to enable/disable the track switch

This PR applies to the following area(s)

FiveM, Natives

Successfully tested on

A test resource showing the functionality of all new natives and test cases are provided #3044 (comment)

Game builds: 1604, 2060, 3258, 3407

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

@Ehbw Ehbw force-pushed the feat/track-switching branch from 155f6ac to b027b49 Compare December 26, 2024 22:13
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Dec 26, 2024
@TheGamerzs
Copy link
Contributor

TheGamerzs commented Jan 4, 2025

Great feature.

Using the example, when the train gets to the end track node after a switch, it warps back to the old track to the node index of:
(Not verified) OldSwitchNode - NewSwitchNode (in the example it seems: 3899 - 87)

I tested this with multiple clients:
If two clients have a different value for a switch (or not registered)
And one of the clients is standing on the train engine or carriages they will fling up in the sky, at the switch node

(Not sure if related to the native or my (VM or hardware))
I had two clients (cl2).
Client A registered the switch and created the train.
Client B (No switch registered) then was driving the train with Client A on a carriage.
Client B then began switching tracks (Unexpected behaviour), this seemed to switch fine.
Once Client B got to the end of the track and warped back (to the first issue location), my graphics stopped streaming new ~~~~assets then the issue with textures being a massive triangle then froze the VM
(Only happened when testing this)
This was my VM error.

@Ehbw
Copy link
Contributor Author

Ehbw commented Jan 4, 2025

If two clients have a different value for a switch (or not registered)
And one of the clients is standing on the train engine or carriages they will fling up in the sky, at the switch node

That's to be expected. When using this in a script you should ideally register the same value across all clients.

Client A registered the switch and created the train.
Client B (No switch registered) then was driving the train with Client A on a carriage.
Client B then began switching tracks (Unexpected behaviour), this seemed to switch fine.
Once Client B got to the end of the track and warped back (to the first issue location), my graphics stopped streaming new assets then the issue with textures being a massive triangle then froze the VM

The freezing does seem to be unrelated and tied to your VM. Although with the example I provided, the track it switches to is marked as a loop track (although it does not create an actual loop) rather then something like a ping-pong track and therefore will teleport back to node 0 (which is located close to the train tunnel in that area of the map)

@Ehbw Ehbw force-pushed the feat/track-switching branch from b027b49 to 7074aa4 Compare February 17, 2025 16:22
@nikez nikez force-pushed the feat/track-switching branch from 7074aa4 to 35a4edf Compare February 20, 2025 00:37
@nikez
Copy link
Contributor

nikez commented Feb 20, 2025

Should solve the previous issues + added a few more natives that could be good to have.

@nikez nikez force-pushed the feat/track-switching branch from 35a4edf to 76ab6c5 Compare February 20, 2025 00:51
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed invalid Requires changes before it's considered valid and can be (re)triaged triage Needs a preliminary assessment to determine the urgency and required action labels Feb 20, 2025
@nikez
Copy link
Contributor

nikez commented Feb 20, 2025

test-pr-3044.zip

Test script for @dalekenium-cfx

@dalekenium-cfx
Copy link
Contributor

Looked over the code, looks good so far. I will pull, build and run the testing script.

@dalekenium-cfx dalekenium-cfx self-assigned this Feb 20, 2025
@dalekenium-cfx
Copy link
Contributor

Looks like all the tests passed:
image

Everything checks out to me, I approve.

@dalekenium-cfx dalekenium-cfx added the ready-to-merge This PR is enqueued for merging label Feb 20, 2025
@prikolium-cfx prikolium-cfx merged commit feee18a into citizenfx:master Feb 21, 2025
4 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged ready-to-merge This PR is enqueued for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants