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

Minor fixes for trains, use IsEntityValid for other calls checking if the entity exists #2902

Merged
merged 2 commits into from
Dec 25, 2024

Conversation

AvarianKnight
Copy link
Contributor

Goal of this PR

Fix some oversights in some code regarding entity validation, trains, and how deletions for trains are handled, and how setting orphan mode is handled for trains

How is this PR achieving the goal

Make code that iterates over trains more generic so we can re-use it throughout more code.

Make calls that were previously just checking for !entity also check for if the entity is being deleted, fixes some cases

When called on trains SET_ENTITY_ORPHAN_MODE will also set the orphan mode for all trains attached, fixing the possibility of partial deletes from a train not being relevant.

Change DELETE_ENTITY to not allow it to be called on train carriages, as we don't have a way to write to the sync node of the current train that one of its links no longer exists, this could lead to broken state and possibly cause weird issues.

Add DELETE_TRAIN which when called on any part of the train will delete the entire train.

This PR applies to the following area(s)

Server

Successfully tested on

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.

@AvarianKnight
Copy link
Contributor Author

AvarianKnight commented Nov 1, 2024

train-test.zip

This was the script used to test this for orphan mode, DELETE_ENTITY and DELETE_TRAIN, making sure this doesn't effect migration is a bit harder and would probably require an actual server using trains.

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Nov 1, 2024
@AvarianKnight AvarianKnight force-pushed the tweak/train-fixes branch 2 times, most recently from ebb195c to b4b698c Compare November 5, 2024 04:03
@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 Nov 5, 2024
Copy link
Contributor

@FabianTerhorst FabianTerhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks a lot for the contribution.

@FabianTerhorst FabianTerhorst added ready-to-merge This PR is enqueued for merging and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Dec 22, 2024
@prikolium-cfx prikolium-cfx merged commit cf42c3e into citizenfx:master Dec 25, 2024
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR is enqueued for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants