Bugfixes, game startup connection
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.net;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.function.*;
|
||||
@@ -20,6 +21,7 @@ public class Net{
|
||||
private boolean server;
|
||||
private boolean active;
|
||||
private boolean clientLoaded;
|
||||
private @Nullable StreamBuilder currentStream;
|
||||
|
||||
private final Array<Object> packetQueue = new Array<>();
|
||||
private final ObjectMap<Class<?>, Consumer> clientListeners = new ObjectMap<>();
|
||||
@@ -196,6 +198,10 @@ public class Net{
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable StreamBuilder getCurrentStream(){
|
||||
return currentStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a client listener for when an object is recieved.
|
||||
*/
|
||||
@@ -217,7 +223,8 @@ public class Net{
|
||||
|
||||
if(object instanceof StreamBegin){
|
||||
StreamBegin b = (StreamBegin)object;
|
||||
streams.put(b.id, new StreamBuilder(b));
|
||||
streams.put(b.id, currentStream = new StreamBuilder(b));
|
||||
|
||||
}else if(object instanceof StreamChunk){
|
||||
StreamChunk c = (StreamChunk)object;
|
||||
StreamBuilder builder = streams.get(c.id);
|
||||
@@ -228,6 +235,7 @@ public class Net{
|
||||
if(builder.isDone()){
|
||||
streams.remove(builder.id);
|
||||
handleClientReceived(builder.build());
|
||||
currentStream = null;
|
||||
}
|
||||
}else if(clientListeners.get(object.getClass()) != null){
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class NetConnection{
|
||||
}
|
||||
|
||||
public void kick(KickReason reason){
|
||||
Log.info("Kicking connection {0}; Reason: {2}", address, reason.name());
|
||||
Log.info("Kicking connection {0}; Reason: {1}", address, reason.name());
|
||||
|
||||
if(player != null && (reason == KickReason.kick || reason == KickReason.banned || reason == KickReason.vote) && player.uuid != null){
|
||||
PlayerInfo info = netServer.admins.getInfo(player.uuid);
|
||||
|
||||
@@ -16,13 +16,16 @@ public class Streamable implements Packet{
|
||||
public final int id;
|
||||
public final byte type;
|
||||
public final int total;
|
||||
public final ByteArrayOutputStream stream;
|
||||
public final ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
|
||||
public StreamBuilder(StreamBegin begin){
|
||||
id = begin.id;
|
||||
type = begin.type;
|
||||
total = begin.total;
|
||||
stream = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
public float progress(){
|
||||
return (float)stream.size() / total;
|
||||
}
|
||||
|
||||
public void add(byte[] bytes){
|
||||
|
||||
@@ -310,8 +310,8 @@ public class JoinDialog extends FloatingDialog{
|
||||
buildServer(host, button);
|
||||
}
|
||||
|
||||
void connect(String ip, int port){
|
||||
if(Core.settings.getString("name").trim().isEmpty()){
|
||||
public void connect(String ip, int port){
|
||||
if(player.name.trim().isEmpty()){
|
||||
ui.showInfo("$noname");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user