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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants