Fixed Bug with Terminal Scroll Bar and Searching.

Switched to Reactive Packet size protection.
This commit is contained in:
AlgorithmX2 2014-02-06 10:57:01 -06:00
parent 3343329ff9
commit c3549e483c
3 changed files with 20 additions and 6 deletions

View file

@ -167,6 +167,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
{
repo.searchString = this.searchField.getText();
repo.updateView();
setScrollBar();
}
else
{

View file

@ -1,6 +1,7 @@
package appeng.container.implementations;
import java.io.IOException;
import java.nio.BufferOverflowException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -136,14 +137,18 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
for (IAEItemStack send : monitorCache)
{
if ( piu.getLength() > 20000 )
try
{
piu.appendItem( send );
}
catch (BufferOverflowException boe)
{
Packet p = piu.getPacket();
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
piu = new PacketMEInventoryUpdate();
}
piu.appendItem( send );
piu = new PacketMEInventoryUpdate();
piu.appendItem( send );
}
}
Packet p = piu.getPacket();

View file

@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.util.LinkedList;
import java.util.List;
@ -26,6 +27,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
// output...
final private ByteArrayOutputStream bytes;
final private DataOutputStream data;
int lastSize = 0;
boolean empty = true;
// input.
@ -59,7 +61,9 @@ public class PacketMEInventoryUpdate extends AppEngPacket
public Packet250CustomPayload getPacket()
{
isChunkDataPacket = false;
configureWrite( bytes.toByteArray() );
byte[] dataOut = new byte[lastSize];
System.arraycopy( bytes.toByteArray(), 0, dataOut, 0, lastSize );
configureWrite( dataOut );
return super.getPacket();
}
@ -71,10 +75,14 @@ public class PacketMEInventoryUpdate extends AppEngPacket
data.writeInt( getPacketID() );
}
public void appendItem(IAEItemStack is) throws IOException
public void appendItem(IAEItemStack is) throws IOException, BufferOverflowException
{
is.writeToPacket( data );
empty = false;
if ( bytes.size() > 20000 )
throw new BufferOverflowException();
else
lastSize = bytes.size();
}
public int getLength()