Liquid Pipes do a full update periodically for client sync

Added config option in BuildCraftCore regarding long update period
Added to core as it may be used for other things in future too
This commit is contained in:
NeverCast 2012-12-15 21:47:42 +13:00
parent f23ddb476a
commit 7d8efe6296
2 changed files with 13 additions and 5 deletions

View file

@ -92,6 +92,8 @@ public class BuildCraftCore {
public static int updateFactor = 10;
public static long longUpdateFactor = 40;
public static BuildCraftConfiguration mainConfiguration;
public static TreeMap<BlockIndex, PacketUpdate> bufferedDescriptions = new TreeMap<BlockIndex, PacketUpdate>();
@ -189,6 +191,10 @@ public class BuildCraftCore {
factor.comment = "increasing this number will decrease network update frequency, useful for overloaded servers";
updateFactor = factor.getInt(10);
Property longFactor = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"network.stateRefreshPeriod", 40);
longFactor.comment = "delay between full client sync packets, increasing it saves bandwidth, decreasing makes for better client syncronization.";
longUpdateFactor = longFactor.getInt(40);
String powerFrameworkClassName = "buildcraft.energy.PneumaticPowerFramework";
if (!forcePneumaticPower)
{

View file

@ -152,6 +152,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
private final short[] outputCooldown = new short[] {0, 0, 0, 0, 0, 0 };
private final SafeTimeTracker tracker = new SafeTimeTracker();
private int clientSyncCounter = 0;
public PipeTransportLiquids() {
@ -196,7 +197,12 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
if (tracker.markTimeIfDelay(worldObj, BuildCraftCore.updateFactor)) {
PacketLiquidUpdate packet = computeLiquidUpdate(false, true);
boolean init = false;
if(++clientSyncCounter > BuildCraftCore.longUpdateFactor){
clientSyncCounter = 0;
init = true;
}
PacketLiquidUpdate packet = computeLiquidUpdate(init, true);
if(packet != null){
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST);
}
@ -297,10 +303,6 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
public void sendDescriptionPacket() {
super.sendDescriptionPacket();
PacketLiquidUpdate packet = computeLiquidUpdate(true, false);
if(packet != null){
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST);
}
initClient = 6;
}