Removed Item#loadFromStream(BitStream)

ClientNetworkReceiver requires injection of ItemReader
Changed ClientNetworkReceiver to read item instead of single item
Removed workaround comment for ItemReader
This commit is contained in:
Collin Smith 2020-09-05 17:43:44 -07:00
parent 4571f8ce18
commit c96f787cf9
3 changed files with 6 additions and 19 deletions

View File

@ -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: {

View File

@ -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;

View File

@ -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");