Made server close when core is destroyed
This commit is contained in:
@@ -409,6 +409,7 @@ public class Control extends Module{
|
||||
|
||||
Timers.run(60, () -> {
|
||||
ui.restart.show();
|
||||
netServer.handleGameOver();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ import io.anuke.ucore.modules.Module;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class NetClient extends Module {
|
||||
public static final Color[] colorArray = {Color.ORANGE, Color.SCARLET, Color.LIME, Color.PURPLE,
|
||||
Color.GOLD, Color.PINK, Color.SKY, Color.GOLD, Color.VIOLET,
|
||||
@@ -292,6 +294,11 @@ public class NetClient extends Module {
|
||||
Tile tile = Vars.world.tile(packet.position);
|
||||
if(tile != null) tile.block().configure(tile, packet.data);
|
||||
});
|
||||
|
||||
Net.handle(GameOverPacket.class, packet -> {
|
||||
kicked = true;
|
||||
Gdx.app.postRunnable(ui.restart::show);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -216,6 +216,11 @@ public class NetServer extends Module{
|
||||
Gdx.app.postRunnable(() -> Vars.ui.chatfrag.addMessage(message, null));
|
||||
}
|
||||
|
||||
public void handleGameOver(){
|
||||
Net.send(new GameOverPacket(), SendMode.tcp);
|
||||
Timers.runTask(30f, () -> GameState.set(State.menu));
|
||||
}
|
||||
|
||||
public void handleBullet(BulletType type, Entity owner, float x, float y, float angle, short damage){
|
||||
BulletPacket packet = new BulletPacket();
|
||||
packet.x = x;
|
||||
|
||||
@@ -135,4 +135,8 @@ public class Packets {
|
||||
public static class EntityRequestPacket{
|
||||
public int id;
|
||||
}
|
||||
|
||||
public static class GameOverPacket{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class Registrator {
|
||||
BlockConfigPacket.class,
|
||||
EntityRequestPacket.class,
|
||||
ConnectConfirmPacket.class,
|
||||
GameOverPacket.class,
|
||||
|
||||
Class.class,
|
||||
byte[].class,
|
||||
|
||||
@@ -64,13 +64,17 @@ public class JoinDialog extends FloatingDialog {
|
||||
}
|
||||
join.hide();
|
||||
}).disabled(b -> Settings.getString("ip").isEmpty() || Strings.parseInt(Settings.getString("port")) == Integer.MIN_VALUE || Net.active());
|
||||
|
||||
join.shown(() -> {
|
||||
join.getTitleLabel().setText(renaming != null ? "$text.server.edit" : "$text.server.add");
|
||||
});
|
||||
|
||||
setup();
|
||||
|
||||
shown(this::refreshLocal);
|
||||
shown(() -> {
|
||||
refreshLocal();
|
||||
refreshRemote();
|
||||
});
|
||||
}
|
||||
|
||||
void setupRemote(){
|
||||
|
||||
Reference in New Issue
Block a user