Open S-S-X opened 2 years ago
Not having this legacy crap makes everything easier to manage and will be overall improvement for technical implementation making feature development a lot simpler. Comments / concerns / ideas for solutions?
Not having this legacy crap makes everything easier to manage and will be overall improvement for technical implementation making feature development a lot simpler.
I'm getting to the same conclusion in a few other mods too, but yeah: removing old and unneeded stuff is always good in terms of maintainability :+1:
Comments / concerns / ideas for solutions?
Can't contribute on that one, haven't touched this code in a while :/
Network cache building currently begins from master cable which decides network id. This id is later used to find master node location in world. This whole thing was left there to keep some behavior closer to previous when caching, network and switching station stuff were refactored in #96
This master node is currently also used to check for switching station when network is executed through technic globalstep handler. This check was left there to follow old behavior but I don't really see reason to check for switching station node at all, after network is started it could just stay active as long as its TTL is positive and ignore switching stations completely. https://github.com/mt-mods/technic/blob/ec3a52c668ec6786e925e197fc01d75bb7f5bb93/technic/machines/switching_station_globalstep.lua#L51-L58
Keeping master node was more just easy way to drop switching stations from network and allow switching stations to only reset TTL instead of actually running networks. Network ID could of course be based on node position but network ID should not be guaranteed or ever used to find network position. Instead it should be just ID to get node tables and network itself should not have any master positions, it is just unnecessary and complicates things.
This network master node however is both useless and practically makes one of switching station more important/significant than others. For example while all connected switching stations are only resetting network TTL removing one that is immediately above master cable node will reset that network while removing any other switching station will not affect caches. https://github.com/mt-mods/technic/blob/ec3a52c668ec6786e925e197fc01d75bb7f5bb93/technic/machines/switching_station.lua#L58-L63
This ^^ is probably biggest problem here: decide whether there's still other switching stations in network when switching station is removed, should network be stopped or not. Reference counters could be used but unfortunately nodes can easily disappear from world without any callbacks to Lua side... and removal of switching station is often intentional action and it is expected that machines stop immediately when last switching station is removed.