diff --git a/core/src/com/riiablo/engine/client/ClientNetworkReceiver.java b/core/src/com/riiablo/engine/client/ClientNetworkReceiver.java index 21f2045e..f0adb1a7 100644 --- a/core/src/com/riiablo/engine/client/ClientNetworkReceiver.java +++ b/core/src/com/riiablo/engine/client/ClientNetworkReceiver.java @@ -21,7 +21,6 @@ import com.badlogic.gdx.physics.box2d.Body; import com.riiablo.Riiablo; import com.riiablo.codec.excel.MonStats; -import com.riiablo.codec.util.BitStream; import com.riiablo.engine.Dirty; import com.riiablo.engine.Engine; import com.riiablo.engine.EntityFactory; @@ -38,7 +37,9 @@ import com.riiablo.engine.server.component.MapWrapper; import com.riiablo.engine.server.component.Player; import com.riiablo.engine.server.component.Position; import com.riiablo.engine.server.component.Velocity; +import com.riiablo.io.ByteInput; import com.riiablo.item.Item; +import com.riiablo.item.ItemReader; import com.riiablo.map.Map; import com.riiablo.net.packet.d2gs.AngleP; import com.riiablo.net.packet.d2gs.BeltToCursor; @@ -112,6 +113,8 @@ public class ClientNetworkReceiver extends IntervalSystem { @Wire(name = "output") protected TextArea output; + protected static final ItemReader itemReader = new ItemReader(); // TODO: inject + private final ByteBuffer buffer = ByteBuffer.allocate(1 << 20).order(ByteOrder.LITTLE_ENDIAN); private final EntitySync sync = new EntitySync(); @@ -312,9 +315,8 @@ public class ClientNetworkReceiver extends IntervalSystem { ItemP item = findTable(sync, ComponentP.ItemP, new ItemP()); PositionP position = findTable(sync, ComponentP.PositionP, new PositionP()); byte[] bytes = BufferUtils.readRemaining(item.dataAsByteBuffer()); - BitStream bitStream = new BitStream(bytes); -// bitStream.skip(D2S.ItemData.SECTION_HEADER_BITS); - Item itemObj = com.riiablo.item.Item.loadFromStream(bitStream); + ByteInput byteInput = ByteInput.wrap(bytes); + Item itemObj = itemReader.readItem(byteInput); return factory.createItem(itemObj, position.x(), position.y()); } case WRP: { diff --git a/core/src/com/riiablo/item/Item.java b/core/src/com/riiablo/item/Item.java index 46c47680..1354fabe 100644 --- a/core/src/com/riiablo/item/Item.java +++ b/core/src/com/riiablo/item/Item.java @@ -18,8 +18,6 @@ import com.riiablo.codec.excel.Misc; import com.riiablo.codec.excel.SetItems; import com.riiablo.codec.excel.UniqueItems; import com.riiablo.codec.excel.Weapons; -import com.riiablo.codec.util.BitStream; -import com.riiablo.io.ByteInput; public class Item { private static final String TAG = "Item"; @@ -30,19 +28,8 @@ public class Item { private static final boolean SIMPLE_FLAGS = !true; private static final boolean ONLY_KNOWN_FLAGS = SIMPLE_FLAGS && true; - private static final ItemReader DEFAULT_SERIALIZER = new ItemReader(); // TODO: inject private static final ItemLabeler DEFAULT_LABELER = new ItemLabeler(); // TODO: inject - /** - * @deprecated use {@link ItemReader#readItem(ByteInput)} instead! - */ - @Deprecated - public static Item loadFromStream(BitStream bitStream) { - // FIXME: workaround for BitStream backcompat - ByteInput bitInput = ByteInput.wrap(bitStream.getBufferAtPos()); - return DEFAULT_SERIALIZER.readSingleItem(bitInput); - } - public static final float ETHEREAL_ALPHA = 2 / 3f; public static final int VERSION_100 = 0; diff --git a/core/src/com/riiablo/item/ItemReader.java b/core/src/com/riiablo/item/ItemReader.java index b68bd9a5..9fe5c721 100644 --- a/core/src/com/riiablo/item/ItemReader.java +++ b/core/src/com/riiablo/item/ItemReader.java @@ -5,7 +5,6 @@ import com.badlogic.gdx.utils.Array; import com.riiablo.Riiablo; import com.riiablo.codec.excel.Gems; -import com.riiablo.codec.util.BitStream; import com.riiablo.io.BitInput; import com.riiablo.io.ByteInput; import com.riiablo.logger.LogManager; @@ -48,7 +47,6 @@ public class ItemReader { } public Item readSingleItem(ByteInput in) { - /** FIXME: workaround for {@link Item#loadFromStream(BitStream)} */ final int itemOffset = in.bytesRead(); /** @see Item#data */ log.trace("Reading item..."); log.trace("Validating item signature");