-
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
Something is wrong with speed limits tool #1346
Comments
The number comes from SpeedLimitManager API returning the numbers. As that's a dictionary with segmentId as a key, it should not return anything for a new segment that did not exist before. But then also this code was touched by @kianzarrin should get his opinion too. |
Added some debugging to the if (isHoveredHandle) {
try {
Log.Info(
$"overrideSpeedlimitForward = {overrideSpeedlimitForward}, " +
$"overrideSpeedlimitBack = {overrideSpeedlimitBack}, " +
$"drawSpeedlimit = {drawSpeedlimit}, " +
$"defaultSpeedLimit = {defaultSpeedLimit}");
}
catch (Exception ex) {
ex.LogException();
}
} Here's what came up when hovering over one of the speed icons (note: log is in km/h whereas images earlier in this issue are showing MPH):
So it seems SpeedValue? overrideSpeedlimitForward =
SpeedLimitManager.Instance.CalculateCustomSpeedLimit(segmentId, finalDir: NetInfo.Direction.Forward);
SpeedValue? overrideSpeedlimitBack =
SpeedLimitManager.Instance.CalculateCustomSpeedLimit(segmentId, finalDir: NetInfo.Direction.Backward);
SpeedValue? drawSpeedlimit = GetAverageSpeedlimit(
forward: overrideSpeedlimitForward,
back: overrideSpeedlimitBack); Will now start digging in to those to find out where the error creeps in. |
Results of extended logging:
The public SpeedValue GetDefaultSpeedLimit(NetInfo netinfo, NetInfo.Lane laneInfo, bool db = false) {
if (customNetinfoSpeedLimits_.TryGetValue(netinfo, out float speedLimit)) {
if (db) {
Log.Info($"customNetinfoSpeedLimits_ = {speedLimit}");
}
return new SpeedValue(speedLimit);
} else {
if (db) {
Log.Info($"laneInfo.m_speedLimit = {laneInfo.m_speedLimit}, as SpeedValue = {new SpeedValue(laneInfo.m_speedLimit)}");
}
return new SpeedValue(laneInfo.m_speedLimit);
}
} So 20 MPH (30 km/h) is the actual prefab speed of the road.... But why is it not getting the 30 MPH (50 km/h) custom default speed for the road if that value is shown when viewing/editing default speeds? Now I need to dig in to how |
var defaultSpeedLimit = new SpeedValue(
gameUnits: SpeedLimitManager.Instance.CalculateCustomNetinfoSpeedLimit(info: neti)); Calls (some code trimmed for brevity).... public float CalculateCustomNetinfoSpeedLimit(NetInfo info) {
return !customNetinfoSpeedLimits_.TryGetValue(info, out float speedLimit)
? GetVanillaNetInfoSpeedLimit(info)
: speedLimit;
} Which is recognisable from previous comment... if (customNetinfoSpeedLimits_.TryGetValue(netinfo, out float speedLimit)) { ... So assuming there isn't an entry in private float GetVanillaNetInfoSpeedLimit(NetInfo info) {
float? maxSpeedLimit = null;
if (info.m_lanes != null) {
foreach (var laneInfo in info.m_lanes) {
float speedLimit = laneInfo.m_speedLimit;
if (maxSpeedLimit == null || speedLimit > maxSpeedLimit) {
maxSpeedLimit = speedLimit;
}
}
}
return maxSpeedLimit ?? 0f;
} So, that's not checking lane types or vehicle types... Example, if there was a |
Annnnd there's the culprit.... - Info 440.2720848: m_vehicleType = None, laneInfo.m_laneType = None, speedLimit = 1
- Info 440.2727466: m_vehicleType = None, laneInfo.m_laneType = None, speedLimit = 1
- Info 440.2734355: m_vehicleType = None, laneInfo.m_laneType = None, speedLimit = 1
- Info 440.2740341: m_vehicleType = None, laneInfo.m_laneType = None, speedLimit = 1
- Info 440.2746089: m_vehicleType = None, laneInfo.m_laneType = None, speedLimit = 1
+ Info 440.2752129: m_vehicleType = Car, laneInfo.m_laneType = Vehicle, speedLimit = 0.6
+ Info 440.2757840: m_vehicleType = Car, laneInfo.m_laneType = Vehicle, speedLimit = 0.6
Info 440.2763682: m_vehicleType = None, laneInfo.m_laneType = Pedestrian, speedLimit = 0.1
Info 440.2769400: m_vehicleType = None, laneInfo.m_laneType = Pedestrian, speedLimit = 0.1 This would also explain all the weirdness I was getting with speed overlays a while back - and why changing default speed for a network was solving those issues. Should be easy to fix, will send PR shortly. |
if (laneInfo.MayHaveCustomSpeedLimits()) { ... :) |
- [Meta] TM:PE 11.6.4-hotfix-7 - [Meta] Bugfix for default speeds which affects speed limits tool, overlays, and roundabout curvature speed - [Fixed] Default netinfo speed should only inspect customisable lanes #1362 #1346 (aubergine18) - [Fixed] Fix `SPEED_TO_MPH` value in `ApiConstants.cs` #1364 #1363 #988 (aubergine18) - [Removed] Obsolete: `SPEED_TO_MPH` and `SPEED_TO_KMPH` in `Constants.cs` #1364 #1363 (aubergine18)
Describe the problem
I slapped down a bunch of roads while testing airport stuff:
Note how they all have 'custom override' speeds 20 mph.
However, I didn't set those overrides. I've done nothing to those roads other than splat them down on the map.
The default speeds of those roads are 30 mph.
Where did the 20 mph come from?
The text was updated successfully, but these errors were encountered: