SquidDev-CC / CCTweaks

Random additions to ComputerCraft (somewhat deprecated, use CC-Tweaked if you're on Minecraft 1.12).
MIT License
12 stars 2 forks source link

Experimental Controller #51

Closed SquidDev closed 9 years ago

SquidDev commented 9 years ago

This is an attempt to address some of the issues in #48 and #49. @ElvishJerricco is probably going to kill me. I might not merge this, I'm just going to see if it is any better.

There is lots of work still to be done on this - some of the logic is quite convoluted and most is untested.

What this changes

The core aim of this is to reduce network 'noise' - changing of networks, rescanning of peripherals, etc... Instead this provides an additional invalidateNode(INetworkNode) call which is used to only rescan for peripherals one one node. To make this easier, the networkInvalidated signature now takes a oldPeripherals and newPeripherals method, though this may be reverted (as discussed here).

Packet sending is now done in a priority queue instead to (hopefully) ensure that the shortest route is always used. Knowing my luck I've got the logic the wrong way round though.

Internally connections are represented as Points, these hold additional data for nodes, and also double as INetworkAccess - though this may be removed. Each Point holds a cache of peripherals for that node as well as a map for what that node connects to.

The caching of 'per-node' peripherals means we can just fetch peripherals for one node.

Closes #48, fixes #49 and closes #24

SquidDev commented 9 years ago

Nodes work fine, though I'm not sure peripheral invalidation works when creating new networks from existing ones (breaking networks).

Please don't kill me for rewriting bits :worried:.

SquidDev commented 9 years ago

@ElvishJerricco:

What are your thoughts on this. It fixes #49 which is great, but is a rewrite of large parts of the networking code. Should I merge this, change bits or just leave it?

ElvishJerricco commented 9 years ago

Sorry I've been so uninvolved. Lot of things going on. Don't have much time.

Except for today! =P Took a quick look. This looks like the better system, I think. It seems more performant and overall cleaner. I like it if you like it.