CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
569 stars 85 forks source link

trams/trains are blocked by their own trailer #1574

Closed kianzarrin closed 2 years ago

kianzarrin commented 2 years ago

fixes #1572. see #1572 code idea comes from CarAI.InvalidPath()

I set all target positions to m_targetPos2 because m_targetPos3 is too far away and train can go out of rail on curved segment. m_targetPos0 or 1 are too close and causes the train to go backward and get stuck.

TMPE.zip

krzychu124 commented 2 years ago

@kianzarrin is there any difference if you do it like e.g. CarAI (update all targets with targetPos3 then reset its w) instead of the other way around?

kianzarrin commented 2 years ago

@krzychu124 is there any difference if you do it like e.g. CarAI (update all targets with targetPos3 then reset its w) instead of the other way around?

No. The W component is discarded (I don't know why its there maybe for future proofing?) in StartPathFind(). The reset of the target pos fields are also discarded. it won't matter what you set them to. you just need to make sure that the one that is used (targetPos3 in case of car, targetPos0 in case of train/tram) is far enough.

I reset them the w for all of because that makes more sense. maybe it helps in future. who ever wrote that code was probably not at his best when he wrote it which is why there are errors inside it.

or maybe I should just not bother with w?

krzychu124 commented 2 years ago

No. The W component is discarded

Noo, w is discarded but only for targetPos3. See red are copies from original targetPos3 (x,y,z,w) and then w is reset to 0f, but only for that one.

w is speed component in the lane units value (1u -> 8f -> 50km/h)

They are all structs so it should behave slightly different if you reset speed first and copy instead of copy then reset speed for last target that's why I asked.

image