Pathfind updates / Less reflection / Platform cleanup

This commit is contained in:
Anuken
2018-08-31 23:19:36 -04:00
parent 565f8a2b4d
commit a2960f5c50
12 changed files with 87 additions and 66 deletions

View File

@@ -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();
}
}

View File

@@ -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(){