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

trams are unable to turn based on lane arrows on shared car-tram lanes. #1053

Closed
WildQuoll opened this issue Feb 6, 2021 · 10 comments · Fixed by #1501
Closed

trams are unable to turn based on lane arrows on shared car-tram lanes. #1053

WildQuoll opened this issue Feb 6, 2021 · 10 comments · Fixed by #1501
Assignees
Labels
BUG Defect detected confirmed Represents confirmed issue or bug LANE ROUTING Feature: Lane arrows / connectors PATHFINDER Pathfinding tweaks or issues
Milestone

Comments

@WildQuoll
Copy link

Describe the problem

TMPE appears to apply overly strict restrictions on trams changing lanes on junctions, preventing tram lines from be placed in situations where it shouldn't.

In this example I've got a 4-lane 2-way road with tram tracks running down the middle (https://steamcommunity.com/sharedfiles/filedetails/?id=2130577793) and the Snowfall DLC 2-lane 1-way road with tram track:
1

I am placing a tram stop on the 4-lane 2-way road (on the right), and then attempting to place the next stop on the 2-lane road. As you can see, the game won't let me to:
2

I am guessing TMPE is forbidding all vehicles using the left lane on the 4-lane road from entering the right lane on the 2-lane road. While this makes sense for cars, this restriction should not be applied to trams.

The issue does not occur if the 4-lane road is replaced with a similar road, where the central lanes are tram only (https://steamcommunity.com/sharedfiles/filedetails/?id=2130576379).

The issue only occurs when using TMPE.

Steps to reproduce

  1. Build a junction like on the screenshot using the 4L 2-way road with tram tracks (https://steamcommunity.com/sharedfiles/filedetails/?id=2130577793) and the Snowfall DLC 2L 1-way road with tram track.
  2. Place a tram stop on the 4L road.
  3. Attempt to place the next tram stop on the 2L road. Notice that the game will refuse to connect them.
@WildQuoll WildQuoll added BUG Defect detected triage Awaiting issue categorisation labels Feb 6, 2021
@krzychu124
Copy link
Member

Hi, have you tried enabling "Allow lane change at junction" option?
It's interesting problem and I'll take a look what is going on there.

@WildQuoll
Copy link
Author

I have tried that option, it didn't make any difference.

I have also tried "Busses may ignore lane arrows" in case that applied to trams as well, but also no luck.

@krzychu124 krzychu124 added investigating Issue currently under investigation JUNCTION RESTRICTIONS Feature: Junction restrictions confirmed Represents confirmed issue or bug and removed triage Awaiting issue categorisation investigating Issue currently under investigation labels Feb 8, 2021
@krzychu124
Copy link
Member

It's can be temporarily fixed using lane connector tool, but I'll try to improve current lane routing algorithm to cover similar cases

@RLemonache
Copy link

There is such a problem when connecting trams into roundabouts as well. They will not ignore lane arrows, making it impossible for them to stay in the roundabout to make a u-turn. I think I can work around this issue, but it would be fantastic if I didn't have too, since many tram roads position them on shared lanes with cars.
TMPE Trams
Here is an example, I illustrated the lane arrows in gray, the dotted line is the intended path.
The purple line is the alternative path using the center of the roundabout for tram specific roads, which would force the use of traffic lights at the junction, being obviously less than ideal...
I'll take any suggestions on how to fix this, if there are any, thanks!

@kianzarrin
Copy link
Collaborator

kianzarrin commented Mar 26, 2022

Interestingly trams will not turn right only when there is a right turn arrow!
image

if (applyHighwayRules || // highway rules enabled
	(nextIncomingDir == ArrowDirection.Right && hasLeftArrow) || // valid incoming right
	(nextIncomingDir == ArrowDirection.Left && hasRightArrow) || // valid incoming left
	(nextIncomingDir == ArrowDirection.Forward && hasForwardArrow) || // valid incoming straight
	(nextIncomingDir == ArrowDirection.Turn && canTurn) /*valid turning lane*/) 
{
	// matching arrow for law obiding cars
	isCompatibleLane = true;
	transitionType = LaneEndTransitionType.Default;
} else if (nextIsConnectedWithPrev) {
	// no matching arrow for SOS/reckless/trams
	transitionType = LaneEndTransitionType.Relaxed;
	if (numNextRelaxedTransitionDatas < MAX_NUM_TRANSITIONS) {
		nextRelaxedTransitionDatas[
			numNextRelaxedTransitionDatas++].Set(
			nextLaneId,
			nextLaneIndex,
			transitionType,
			nextSegmentId,
			isNodeStartNodeOfNextSegment,
			GlobalConfig.Instance.PathFinding.IncompatibleLaneDistance /*2*/);
	}
}
...
if (isCompatibleLane) {
	if (numNextCompatibleTransitionDatas < MAX_NUM_TRANSITIONS) {
		nextCompatibleOuterSimilarIndices[numNextCompatibleTransitionDatas] = nextMatchingOuterSimilarLaneIndex;
		compatibleLaneIndexToLaneConnectionIndex[numNextCompatibleTransitionDatas] = currentLaneConnectionTransIndex;
		nextCompatibleTransitionDatas[numNextCompatibleTransitionDatas++].Set(
			nextLaneId,
			nextLaneIndex,
			transitionType,
			nextSegmentId,
			isNodeStartNodeOfNextSegment);
	}
}

@kianzarrin
Copy link
Collaborator

kianzarrin commented Mar 26, 2022

Damn this is also influenced by the lane arrows of the non-tram lane (3rd image bellow)!
image

@kianzarrin
Copy link
Collaborator

kianzarrin commented Mar 26, 2022

@aubergine10 do you know all the issues with regard to mixed train/car lanes?
so far I know of these:
on mixed car/tram lanes:
1- good: normal cars are only restricted by lane arrows (bus, SOS, and reckless cars ignore lane arrows as usual).
2- good: trams are only restricted by turn angle.
3- bad: cars have similarLaneIndex == 0 which might encourage them to turn into outer-most lane instead of the inner-most lane. (any issue associated with this?) EDIT: This does not happen because Vehicle/TransportVehicle lanes are grouped together.
4- trams are confused too by lane arrows for some reason (probably AI). [this issue]
5- bad: cannot set lane connection for trams/cars separately [#354]
6- bad: tracked vehicles spend time calculating the turn angle. this could be cached.

5 and 6 can be fixed if I mark lane transitions for car/track.
Is that right? any other problem I missed?

@kianzarrin kianzarrin added LANE ROUTING Feature: Lane arrows / connectors PATHFINDER Pathfinding tweaks or issues and removed JUNCTION RESTRICTIONS Feature: Junction restrictions labels Mar 26, 2022
@kianzarrin kianzarrin changed the title Overly restrictive lane routing for trams on shared car-tram lanes trams are unable to turn based on lane arrows on shared car-tram lanes. Mar 26, 2022
@originalfoo
Copy link
Member

1- good: normal cars are only restricted by lane arrows (bus, SOS, and reckless cars ignore lane arrows as usual).

Bus should only ignore lane arrows if the relevant option is set in mod options. Same for evacuation buses.

Another thing, although I've not yet determined the cause, is that sometimes buses will go off their route (they'll travel along different road even though no bus route on that road). Next time in game I'll try and get some screenshots to illustrate and create issue for that.

@ian76g
Copy link

ian76g commented Apr 15, 2022

Another thing, although I've not yet determined the cause, is that sometimes buses will go off their route (they'll travel along different road even though no bus route on that road). Next time in game I'll try and get some screenshots to illustrate and create issue for that.

Reason:
Sometimes a firetruck is "working" on the route of the bus - so the regular road/route is blocked. The bus then drives a "detour" arround the firemen dousing a fire.... nice feature!

@originalfoo
Copy link
Member

Reason: Sometimes a firetruck is "working" on the route of the bus - so the regular road/route is blocked. The bus then drives a "detour" arround the firemen dousing a fire.... nice feature!

No, this wasn't caused by the Blocked flag. They were routinely going off-route and the only way I could stop them doing it was to add vehicle restrictions and reduce speed of road.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG Defect detected confirmed Represents confirmed issue or bug LANE ROUTING Feature: Lane arrows / connectors PATHFINDER Pathfinding tweaks or issues
Projects
None yet
6 participants