mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-22 02:07:26 +07:00
Added comments explaining the need for some buffer position manipulations
This commit is contained in:
parent
3f51d1d503
commit
d13fb953d5
@ -2,15 +2,23 @@ package com.riiablo.engine.client;
|
||||
|
||||
import com.google.flatbuffers.ByteBufferUtil;
|
||||
import com.google.flatbuffers.Table;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.artemis.ComponentMapper;
|
||||
import com.artemis.annotations.All;
|
||||
import com.artemis.annotations.Wire;
|
||||
import com.artemis.systems.IntervalSystem;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.net.Socket;
|
||||
import com.badlogic.gdx.physics.box2d.Body;
|
||||
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.excel.MonStats;
|
||||
import com.riiablo.codec.util.BitStream;
|
||||
@ -70,13 +78,6 @@ import com.riiablo.util.BufferUtils;
|
||||
import com.riiablo.util.DebugUtils;
|
||||
import com.riiablo.widget.TextArea;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.Arrays;
|
||||
|
||||
@All
|
||||
public class ClientNetworkReceiver extends IntervalSystem {
|
||||
private static final String TAG = "ClientNetworkReceiver";
|
||||
@ -136,7 +137,7 @@ public class ClientNetworkReceiver extends IntervalSystem {
|
||||
if (DEBUG_PACKET) Gdx.app.debug(TAG, p++ + " packet type " + D2GSData.name(d2gs.dataType()) + ":" + size + "B");
|
||||
process(d2gs);
|
||||
// System.out.println(buffer.position() + "->" + (buffer.position() + size + 4));
|
||||
buffer.position(buffer.position() + size + 4);
|
||||
buffer.position(buffer.position() + size + 4); // advance position passed current packet + size prefix of next packet
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
@ -2,14 +2,22 @@ package com.riiablo.engine.client;
|
||||
|
||||
import com.google.flatbuffers.ByteBufferUtil;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
|
||||
import com.artemis.ComponentMapper;
|
||||
import com.artemis.annotations.All;
|
||||
import com.artemis.annotations.Wire;
|
||||
import com.artemis.systems.IntervalSystem;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.net.Socket;
|
||||
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.engine.server.component.Angle;
|
||||
import com.riiablo.engine.server.component.CofAlphas;
|
||||
@ -32,13 +40,6 @@ import com.riiablo.net.packet.d2gs.VelocityP;
|
||||
import com.riiablo.save.CharData;
|
||||
import com.riiablo.util.ArrayUtils;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
|
||||
@All
|
||||
public class ClientNetworkSyncronizer extends IntervalSystem {
|
||||
private static final String TAG = "ClientNetworkSyncronizer";
|
||||
@ -110,6 +111,7 @@ public class ClientNetworkSyncronizer extends IntervalSystem {
|
||||
WritableByteChannel channelOut = Channels.newChannel(out);
|
||||
channelOut.write(builder.dataBuffer());
|
||||
|
||||
// Before we can connect, we need to wait for our connection ack to be received
|
||||
boolean connected = false;
|
||||
ByteBuffer buffer = ByteBuffer.allocate(1 << 20).order(ByteOrder.LITTLE_ENDIAN);
|
||||
while (!connected) {
|
||||
@ -127,7 +129,7 @@ public class ClientNetworkSyncronizer extends IntervalSystem {
|
||||
if (!connected) {
|
||||
if (DEBUG_CONNECT) Gdx.app.debug(TAG, "dropping... ");
|
||||
// System.out.println(buffer.position() + "->" + (buffer.position() + size + 4));
|
||||
buffer.position(buffer.position() + size + 4);
|
||||
buffer.position(buffer.position() + size + 4); // advance position passed current packet + size prefix of next packet
|
||||
continue;
|
||||
}
|
||||
Connection connection = (Connection) d2gs.data(new Connection());
|
||||
@ -135,7 +137,7 @@ public class ClientNetworkSyncronizer extends IntervalSystem {
|
||||
if (!connected) {
|
||||
if (DEBUG_CONNECT) Gdx.app.debug(TAG, "dropping... ");
|
||||
// System.out.println(buffer.position() + "->" + (buffer.position() + size + 4));
|
||||
buffer.position(buffer.position() + size + 4);
|
||||
buffer.position(buffer.position() + size + 4); // advance position passed current packet + size prefix of next packet
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user