-
Notifications
You must be signed in to change notification settings - Fork 85
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
Train tracks segment speed limits #1467
Train tracks segment speed limits #1467
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to test in-game, but just some comment on the code for now...
TLM/TLM/UI/SubTools/SpeedLimits/Overlay/OverlaySegmentSpeedlimitHandle.cs
Outdated
Show resolved
Hide resolved
When `null`, the speed will be applied to all lanes _except_ those with `None` direction.
Removes loop of directions.
This is simplified to take advantage of the updates to `SpeedLimitManager.Instance.SetSegmentSpeedLimit()` in which lane direction specification is no longer mandatory. It wipes out several loops, particularly over segment lanes.
I think that field never changes, don't worry. |
warning does not warn about field but behaviour when field type is a non-readonly struct (compiler will create defensive copy on each access (create variable and set it with field value before use) to ensure original value won't ever change) |
if it is harmless then I think it would be wise to hide that warning. if there is too many warnings around then ppl will not pay attention and then important warnings can be ignored. but that is outside the scope of this PR. |
I'll send a commit to suppress that warning inline, handle a few other warnings, and also add lane type & vehicle type checks back in to the segment iteration function (in |
Completely useless warning for: "A closing brace within a C# element, statement, or expression is preceded by a blank line."
Useful for checking if a segment has at least one matching lane for `LANE_TYPES` and `VEHICLE_TYPES`.
|
||
return true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the fact that you have not used goto nextiter
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vowed never to use goto
again in 1986 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think goto has some uses like breaking out of nested loops.
@@ -72,6 +72,41 @@ public static class NetSegmentExtensions { | |||
return new GetSegmentLaneIdsEnumerable(initialLaneId, netInfo.m_lanes.Length, laneBuffer); | |||
} | |||
|
|||
/// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Note]
Based this code laneType
or VehicleType
should never be 0. Maybe we can Assert this condition even if it is only in DEBUG build?
Is there a [NotNull]
or [NotZero]
annotation we can use here?
in some places in CS they check forlaneType == 0 || (laneInfo.m_laneType & laneType) != 0)
but I I think in speed limit manager that does not make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a DEBUG-only AssertNotNone
shortcut to test both params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind. I deleted message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low priority]
is this critical code path. do the assertion need to be debug only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low priority]
is this critical code path. do the assertion need to be debug only?
heh, it was your suggesstion in #1467 (comment) :
Maybe we can Assert this condition even if it is only in DEBUG build?
TLM/TLM/UI/SubTools/SpeedLimits/Overlay/OverlaySegmentSpeedlimitHandle.cs
Show resolved
Hide resolved
TLM/TLM/UI/SubTools/SpeedLimits/Overlay/OverlaySegmentSpeedlimitHandle.cs
Show resolved
Hide resolved
TLM/TLM/UI/SubTools/SpeedLimits/Overlay/OverlaySegmentSpeedlimitHandle.cs
Show resolved
Hide resolved
It's a relic from older incarnation of speed limit tool.
`AnyApplicableLane()` will never return `true` if either of the relevant params are `None`.
another visual problem. when I hold shift on roundabout:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments above.
Sounds like issue with the overlay (not in scope of this PR). Please create issue to track that.
That's just the way the render overlay works; for per-lane it uses icon grid with icon-sized gap in the middle. It could be improved, perhaps, but I wouldn't bother until we create a centralised overlay manager. |
You are right. the problem can be reproduced in master. Ill add it to the same ticket you created. |
@krzychu124 looks like CI server borked - can you prod it to rerun tests? |
👍 |
Closes #1337
SpeedValue
equality check boxing