feat(server/state): add train getters for already synced fields - #4093
Open
Github-Samuel wants to merge 1 commit into
Open
feat(server/state): add train getters for already synced fields#4093Github-Samuel wants to merge 1 commit into
Github-Samuel wants to merge 1 commit into
Conversation
CTrainGameStateDataNode parses more than the existing train natives read back. Add getters for the fields that are serialized unconditionally, so they don't depend on a game build: - GET_TRAIN_CONFIG_INDEX - GET_TRAIN_DISTANCE_FROM_ENGINE - IS_MISSION_TRAIN - DOES_TRAIN_HAVE_PASSENGER_CARRIAGES - IS_TRAIN_RENDERED_DERAILED - DOES_TRAIN_FORCE_DOORS_OPEN The fields behind Is2372/IsWinterUpdate25 are left alone. Signed-off-by: Samuel Nicol <99494967+Github-Samuel@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal of this PR
Read back a few more train fields server-side. The server already parses them out of the train sync node, there just aren't natives for them yet.
How is this PR achieving the goal
CTrainGameStateDataNodefills in more ofCTrainGameStateDataNodeDatathan the current getters expose. These six are all serialized unconditionally:so this adds:
GET_TRAIN_CONFIG_INDEXtrainConfigIndexGET_TRAIN_DISTANCE_FROM_ENGINEdistanceFromEngineIS_MISSION_TRAINisMissionTrainDOES_TRAIN_HAVE_PASSENGER_CARRIAGEShasPassengerCarriagesIS_TRAIN_RENDERED_DERAILEDrenderDerailedDOES_TRAIN_FORCE_DOORS_OPENforceDoorsOpenEach one is the same shape as the getters already there, e.g.
GET_TRAIN_STATE:I left the build gated fields out on purpose.
carriageSpeedandisTrackDirectionForwardsare only serialized underIsWinterUpdate25(), andallowRemovalByPopulation/highPrecisionBlendingonly underIs2372(), so a getter for those would read an uninitialised member on older builds unless it carried the same gate.stopAtStationsis in the same boat and is already handled byDOES_TRAIN_STOP_AT_STATIONS.DOES_TRAIN_FORCE_DOORS_OPENreads the per train synced flag, which isn't quite the same thing as the client sideSET_TRAINS_FORCE_DOORS_OPENthat sets it globally, so I noted that in its page.This PR applies to the following area(s)
FXServer, OneSync, Natives
Successfully tested on
Game builds: n/a for the gated fields since none are used; the six added are build independent
Platforms: Windows, Linux
Checklist
I could not do a full server build locally so I left the first box unchecked. What I did check is that each field is actually written by the parser and not behind a build gate, and that none of the six names collide with an existing native in
ext/native-declsor the natives stash.