Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
support stations with multiple stops with the same name #164
This patch allows stations with the same name to be used if one of the following is true:
That means the following still gives the purple error light:
What is allowed:
The patch should not change any correct LTN setup. And it's unlikely that a LTN setup with broken (same name) stations accidentally becomes valid.
Didn't know about ipairs being bad, will change that and the other issues.
For setLamp there are two cases: errors need to go to all stops, train events should go to one stop. Will have to look into that.
I didn't benchmark the signals. The code only runs for stations with the same name and now ignores wires on depots. So there shouldn't be a performance loss for exiting setups at least. I see that you loop over all stations so maybe getting the signals once per loop would be better. If you have many stations with the same name getting the signals every time is O(n^2) work. My usual use case is n=2 though so not noticeable for me. I will have to make a test case with say 50 stations with the same name. That should stress the code.
referenced this pull request
Apr 2, 2019
The Station module contains all the stuff that works on the station name instead of individual stops. Every stop has a station and a station can have many stops. Deliveries are from station to station. This used to be in stop.activeDeliveries.
The biggest change is probably that I used sets (tbl[k] = true) instead of an arrays (table.insert(tbl, k)) for a few things. This allows faster insert, remove and lookup.
There are some new cases for lamp colors + count:
This should only affect new stations with multiple stops. I tried to not change anything for existing setups with one stop per station.
The code now passed all my test setups. So I'm going to use this in a real game to see if any other errors show up.
Thanks for explanation, could you comment your functions and changes. So I can have a rough sense of what that part is doing and why.