From 49c7f9a93b5c9c54de8e14dbed111ab442e42a01 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Mon, 21 Apr 2014 16:11:39 -0500 Subject: [PATCH 1/3] Cache Tanks, might be a minor performance benefit. --- parts/p2p/PartP2PLiquids.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/parts/p2p/PartP2PLiquids.java b/parts/p2p/PartP2PLiquids.java index 22a8c39a..afc47682 100644 --- a/parts/p2p/PartP2PLiquids.java +++ b/parts/p2p/PartP2PLiquids.java @@ -22,6 +22,9 @@ import cpw.mods.fml.relauncher.SideOnly; public class PartP2PLiquids extends PartP2PTunnel implements IFluidHandler { + private final static FluidTankInfo[] activeTank = new FluidTankInfo[] { new FluidTankInfo( null, 10000 ) }; + private final static FluidTankInfo[] inactiveTank = new FluidTankInfo[] { new FluidTankInfo( null, 0 ) }; + public TunnelType getTunnelType() { return TunnelType.FLUID; @@ -37,21 +40,21 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl { PartP2PLiquids tun = getInput(); if ( tun != null ) - return new FluidTankInfo[] { new FluidTankInfo( null, 10000 ) }; + return activeTank; } else { try { if ( !getOutputs().isEmpty() ) - return new FluidTankInfo[] { new FluidTankInfo( null, 10000 ) }; + return activeTank; } catch (GridAccessException e) { // :( } } - return new FluidTankInfo[] { new FluidTankInfo( null, 0 ) }; + return inactiveTank; } IFluidHandler cachedTank; From 021e924098ac2900e1aac3ebd1c2a0a5b0ae992f Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 22 Apr 2014 21:49:03 -0500 Subject: [PATCH 2/3] Fixed issue with error prone Grid Visitors. Increased Channel update speed. Renamed Controller Method. --- me/GridConnection.java | 2 +- me/GridNode.java | 29 +++++++++++++---------------- me/cache/PathGridCache.java | 4 ++-- tile/networking/TileController.java | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/me/GridConnection.java b/me/GridConnection.java index 450a3d47..22aaf77a 100644 --- a/me/GridConnection.java +++ b/me/GridConnection.java @@ -24,7 +24,7 @@ public class GridConnection implements IGridConnection, IPathItem private ForgeDirection fromAtoB; private GridNode sideB; - byte visitorIterationNumber = Byte.MIN_VALUE; + Object visitorIterationNumber = null; public int channelData = 0; diff --git a/me/GridNode.java b/me/GridNode.java index af808da9..c33008a7 100644 --- a/me/GridNode.java +++ b/me/GridNode.java @@ -42,10 +42,7 @@ public class GridNode implements IGridNode, IPathItem IGridBlock gridProxy; Grid myGrid; - public static byte currentVisitorIterationNumber = Byte.MIN_VALUE; - public static byte currentChannelsIterationNumber = Byte.MIN_VALUE; - - byte visitorIterationNumber = Byte.MIN_VALUE; + Object visitorIterationNumber = null; // connection criteria AEColor myColor = AEColor.Transparent; @@ -152,12 +149,12 @@ public class GridNode implements IGridNode, IPathItem @Override public void beginVisition(IGridVisitor g) { - currentVisitorIterationNumber++; + Object tracker = new Object(); LinkedList nextRun = new LinkedList(); nextRun.add( this ); - visitorIterationNumber = currentVisitorIterationNumber; + visitorIterationNumber = tracker; if ( g instanceof IGridConnecitonVisitor ) { @@ -173,7 +170,7 @@ public class GridNode implements IGridNode, IPathItem nextRun = new LinkedList(); for (GridNode n : thisRun) - n.visitorConnection( g, nextRun, nextConn ); + n.visitorConnection( tracker, g, nextRun, nextConn ); } } else @@ -184,12 +181,12 @@ public class GridNode implements IGridNode, IPathItem nextRun = new LinkedList(); for (GridNode n : thisRun) - n.visitorNode( g, nextRun ); + n.visitorNode( tracker, g, nextRun ); } } } - private void visitorConnection(IGridVisitor g, LinkedList nextRun, LinkedList nextConnections) + private void visitorConnection(Object tracker, IGridVisitor g, LinkedList nextRun, LinkedList nextConnections) { if ( g.visitNode( this ) ) { @@ -198,23 +195,23 @@ public class GridNode implements IGridNode, IPathItem GridNode gn = (GridNode) gc.getOtherSide( this ); GridConnection gcc = (GridConnection) gc; - if ( gcc.visitorIterationNumber != currentVisitorIterationNumber ) + if ( gcc.visitorIterationNumber != tracker ) { - gcc.visitorIterationNumber = currentChannelsIterationNumber; + gcc.visitorIterationNumber = tracker; nextConnections.add( gc ); } - if ( currentVisitorIterationNumber == gn.visitorIterationNumber ) + if ( tracker == gn.visitorIterationNumber ) continue; - gn.visitorIterationNumber = currentVisitorIterationNumber; + gn.visitorIterationNumber = tracker; nextRun.add( gn ); } } } - private void visitorNode(IGridVisitor g, LinkedList nextRun) + private void visitorNode(Object tracker, IGridVisitor g, LinkedList nextRun) { if ( g.visitNode( this ) ) { @@ -222,10 +219,10 @@ public class GridNode implements IGridNode, IPathItem { GridNode gn = (GridNode) gc.getOtherSide( this ); - if ( currentVisitorIterationNumber == gn.visitorIterationNumber ) + if ( tracker == gn.visitorIterationNumber ) continue; - gn.visitorIterationNumber = currentVisitorIterationNumber; + gn.visitorIterationNumber = tracker; nextRun.add( gn ); } diff --git a/me/cache/PathGridCache.java b/me/cache/PathGridCache.java index a444992e..14ef209a 100644 --- a/me/cache/PathGridCache.java +++ b/me/cache/PathGridCache.java @@ -84,7 +84,7 @@ public class PathGridCache implements IPathingGrid used = 0; int nodes = myGrid.getNodes().size(); - ticksUntilReady = 20 + (nodes / 10); + ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 ); channelsByBlocks = nodes * used; channelPowerUsage = (double) channelsByBlocks / 128.0; @@ -98,7 +98,7 @@ public class PathGridCache implements IPathingGrid else { int nodes = myGrid.getNodes().size(); - ticksUntilReady = 20 + (nodes / 10); + ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 ); closedList = new HashSet(); semiOpen = new HashSet(); diff --git a/tile/networking/TileController.java b/tile/networking/TileController.java index e2a1043b..beb5ffdf 100644 --- a/tile/networking/TileController.java +++ b/tile/networking/TileController.java @@ -83,7 +83,7 @@ public class TileController extends AENetworkPowerTile implements IAEPowerStorag } @MENetworkEventSubscribe - public void onPowerChange(MENetworkControllerChange status) + public void onControllerChange(MENetworkControllerChange status) { updateMeta(); } From ea7e4b68bbe0b78e790592fd4f36a946296133f1 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 22 Apr 2014 21:55:06 -0500 Subject: [PATCH 3/3] Fixed issue with lower power drains appearing to be "Free power" --- me/cache/EnergyGridCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/me/cache/EnergyGridCache.java b/me/cache/EnergyGridCache.java index 9aa90613..a2a9e739 100644 --- a/me/cache/EnergyGridCache.java +++ b/me/cache/EnergyGridCache.java @@ -351,7 +351,7 @@ public class EnergyGridCache implements IEnergyGrid // power information. double drained = extractAEPower( getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); - boolean currentlyHasPower = drained >= drainPerTick - 0.1; + boolean currentlyHasPower = drained >= drainPerTick - 0.001; // ticks since change.. if ( currentlyHasPower == hasPower )