Pathfind updates / Less reflection / Platform cleanup
This commit is contained in:
@@ -240,20 +240,20 @@ public class Packets{
|
||||
|
||||
public int id = lastid++;
|
||||
public int total;
|
||||
public Class<? extends Streamable> type;
|
||||
public byte type;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer){
|
||||
buffer.putInt(id);
|
||||
buffer.putInt(total);
|
||||
buffer.put(Registrator.getID(type));
|
||||
buffer.put(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer){
|
||||
id = buffer.getInt();
|
||||
total = buffer.getInt();
|
||||
type = (Class<? extends Streamable>) Registrator.getByID(buffer.get()).type;
|
||||
type = buffer.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.anuke.mindustry.net;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
import io.anuke.mindustry.net.Packets.StreamBegin;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -18,7 +16,7 @@ public class Streamable implements Packet{
|
||||
|
||||
public static class StreamBuilder{
|
||||
public final int id;
|
||||
public final Class<? extends Streamable> type;
|
||||
public final byte type;
|
||||
public final int total;
|
||||
public final ByteArrayOutputStream stream;
|
||||
|
||||
@@ -38,13 +36,9 @@ public class Streamable implements Packet{
|
||||
}
|
||||
|
||||
public Streamable build(){
|
||||
try{
|
||||
Streamable s = ClassReflection.newInstance(type);
|
||||
s.stream = new ByteArrayInputStream(stream.toByteArray());
|
||||
return s;
|
||||
}catch(ReflectionException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Streamable s = (Streamable) Registrator.getByID(type).constructor.get();
|
||||
s.stream = new ByteArrayInputStream(stream.toByteArray());
|
||||
return s;
|
||||
}
|
||||
|
||||
public boolean isDone(){
|
||||
|
||||
Reference in New Issue
Block a user