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