mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-14 01:37:36 +07:00
Fixed Kryo crash
This commit is contained in:
@ -7,7 +7,6 @@ import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
import io.anuke.kryonet.KryoClient;
|
||||
import io.anuke.kryonet.KryoServer;
|
||||
import io.anuke.mindustry.io.PlatformFunction;
|
||||
@ -65,8 +64,6 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
|
||||
config.hideStatusBar = true;
|
||||
|
||||
Log.set(Log.LEVEL_DEBUG);
|
||||
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
|
@ -95,6 +95,8 @@ public class NetServer extends Module{
|
||||
|
||||
Gdx.app.postRunnable(() -> Vars.ui.showInfo(Bundles.format("text.server.disconnected", player.name)));
|
||||
|
||||
player.remove();
|
||||
|
||||
DisconnectPacket dc = new DisconnectPacket();
|
||||
dc.playerid = player.id;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.desktop;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
import io.anuke.kryonet.KryoClient;
|
||||
import io.anuke.kryonet.KryoServer;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
@ -59,8 +58,6 @@ public class DesktopLauncher {
|
||||
|
||||
Mindustry.args = Array.with(arg);
|
||||
|
||||
Log.set(Log.LEVEL_DEBUG);
|
||||
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
|
Binary file not shown.
@ -26,13 +26,25 @@ public class KryoClient implements ClientProvider{
|
||||
Connect c = new Connect();
|
||||
c.id = connection.getID();
|
||||
c.addressTCP = connection.getRemoteAddressTCP().toString();
|
||||
Net.handleClientReceived(c);
|
||||
|
||||
try{
|
||||
Net.handleClientReceived(c);
|
||||
}catch (Exception e){
|
||||
Gdx.app.exit();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected (Connection connection) {
|
||||
Disconnect c = new Disconnect();
|
||||
Net.handleClientReceived(c);
|
||||
|
||||
try{
|
||||
Net.handleClientReceived(c);
|
||||
}catch (Exception e){
|
||||
Gdx.app.exit();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,20 +31,34 @@ public class KryoServer implements ServerProvider {
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
server.addListener(new Listener(){
|
||||
|
||||
@Override
|
||||
public void connected (Connection connection) {
|
||||
Connect c = new Connect();
|
||||
c.id = connection.getID();
|
||||
c.addressTCP = connection.getRemoteAddressTCP().toString();
|
||||
Net.handleServerReceived(c, c.id);
|
||||
connections.add(c.id);
|
||||
|
||||
try {
|
||||
Net.handleServerReceived(c, c.id);
|
||||
connections.add(c.id);
|
||||
}catch (Exception e){
|
||||
Gdx.app.exit();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected (Connection connection) {
|
||||
Disconnect c = new Disconnect();
|
||||
c.id = connection.getID();
|
||||
Net.handleServerReceived(c, c.id);
|
||||
|
||||
try{
|
||||
Net.handleServerReceived(c, c.id);
|
||||
}catch (Exception e){
|
||||
Gdx.app.exit();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
connections.removeValue(c.id);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user