Fix issue with packet bytes reuse
Big oversight that caused broadcasted (packet sent to multiple clients) packets to only be correct for the first receiver, for example when 3 players were in the same map.
This commit is contained in:
@@ -12,7 +12,6 @@ import java.awt.*;
|
||||
@NotThreadSafe
|
||||
public class ByteBufOutPacket implements OutPacket {
|
||||
private final ByteBuf byteBuf;
|
||||
private byte[] bytes;
|
||||
|
||||
public ByteBufOutPacket() {
|
||||
this.byteBuf = Unpooled.buffer();
|
||||
@@ -32,12 +31,7 @@ public class ByteBufOutPacket implements OutPacket {
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() {
|
||||
if (bytes == null) {
|
||||
// Avoid creating new byte arrays when the packet is broadcast
|
||||
bytes = ByteBufUtil.getBytes(byteBuf);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
return ByteBufUtil.getBytes(byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user