From 4a693fee486694b8dcd5c96be39e71c231facf6b Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Sat, 2 Nov 2013 08:49:32 -0400 Subject: [PATCH] Fixed a large issue with mass packet updates What was going on and i didn't see this till now is the tanks were updating every single time the network's tank changed. Too fix this i've changed the tanks to no update until after the network recalculates the tanks volume. This way the tanks will only update if there volume has changed which was the original design. --- src/dark/api/fluid/INetworkFluidPart.java | 4 ++-- .../tilenetwork/fluid/NetworkFluidContainers.java | 6 +++--- .../tilenetwork/fluid/NetworkFluidTiles.java | 4 ++-- .../common/prefab/TileEntityFluidNetworkTile.java | 14 ++++++++++---- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/dark/api/fluid/INetworkFluidPart.java b/src/dark/api/fluid/INetworkFluidPart.java index 3e55f9a8..e2a0fd99 100644 --- a/src/dark/api/fluid/INetworkFluidPart.java +++ b/src/dark/api/fluid/INetworkFluidPart.java @@ -21,11 +21,11 @@ public interface INetworkFluidPart extends IFluidHandler, INetworkPart /** Fills the pipe in the same way that fill method is called in IFluidHandler. This is used so * the network has a direct method to access the pipes internal fluid storage */ - public int fillTankContent(int index, FluidStack stack, boolean doFill); + public int fillTankContent(int index, FluidStack stack, boolean doFill, boolean update); /** Removes from from the pipe in the same way that drain method is called in IFluidHandler. This * is used so the network has a direct method to access the pipes internal fluid storage */ - public FluidStack drainTankContent(int index, int volume, boolean doDrain); + public FluidStack drainTankContent(int index, int volume, boolean doDrain, boolean update); /** Can the fluid pass from one side to the next. Used by path finder to see if the fluid can * move threw the pipes. diff --git a/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidContainers.java b/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidContainers.java index e3921383..cb56854e 100644 --- a/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidContainers.java +++ b/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidContainers.java @@ -51,7 +51,7 @@ public class NetworkFluidContainers extends NetworkFluidTiles { if (part instanceof IFluidHandler) { - ((INetworkFluidPart) part).drainTankContent(0, Integer.MAX_VALUE, true); + ((INetworkFluidPart) part).drainTankContent(0, Integer.MAX_VALUE, true, false); } if (part instanceof TileEntity && ((TileEntity) part).yCoord < lowestY) { @@ -85,8 +85,8 @@ public class NetworkFluidContainers extends NetworkFluidTiles /* Fill all tanks on this level */ for (INetworkFluidPart part : parts) { - part.drainTankContent(0, Integer.MAX_VALUE, true); - fillStack.amount -= part.fillTankContent(0, FluidHelper.getStack(fillStack, fillvolume), true); + part.drainTankContent(0, Integer.MAX_VALUE, true, false); + fillStack.amount -= part.fillTankContent(0, FluidHelper.getStack(fillStack, fillvolume), true, true); } } diff --git a/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java b/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java index 86f8e618..da801c9e 100644 --- a/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java +++ b/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java @@ -132,11 +132,11 @@ public class NetworkFluidTiles extends NetworkTileEntities if (par instanceof INetworkFluidPart) { //EMPTY TANK - ((INetworkFluidPart) par).drainTankContent(0, Integer.MAX_VALUE, true); + ((INetworkFluidPart) par).drainTankContent(0, Integer.MAX_VALUE, true, false); //FILL TANK if (stack != null) { - stack.amount -= ((INetworkFluidPart) par).fillTankContent(0, FluidHelper.getStack(stack, fillVol), true); + stack.amount -= ((INetworkFluidPart) par).fillTankContent(0, FluidHelper.getStack(stack, fillVol), true, true); membersFilled++; } } diff --git a/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java b/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java index d6f4b841..05527520 100644 --- a/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java +++ b/src/dark/fluid/common/prefab/TileEntityFluidNetworkTile.java @@ -237,7 +237,7 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i } @Override - public int fillTankContent(int index, FluidStack stack, boolean doFill) + public int fillTankContent(int index, FluidStack stack, boolean doFill, boolean update) { if (index == 0) { @@ -246,7 +246,10 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i if (p != fill) { //TODO add a catch to this so we don't send a dozen packets for one updates - this.sendTankUpdate(index); + if (update) + { + this.sendTankUpdate(index); + } this.internalTanksInfo[index] = this.getTank().getInfo(); } return fill; @@ -255,7 +258,7 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i } @Override - public FluidStack drainTankContent(int index, int volume, boolean doDrain) + public FluidStack drainTankContent(int index, int volume, boolean doDrain, boolean update) { if (index == 0) { @@ -263,7 +266,10 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i FluidStack stack = this.getTank().drain(volume, doDrain); if (prev != null && (stack == null || prev.amount != stack.amount)) { - this.sendTankUpdate(index); + if (update) + { + this.sendTankUpdate(index); + } this.internalTanksInfo[index] = this.getTank().getInfo(); } return stack;