Fixed overly long startup time, added more debug info
This commit is contained in:
@@ -181,6 +181,10 @@ public class Control extends Module{
|
||||
Effects.effect(Fx.coreexplosion, world.getCore().worldx(), world.getCore().worldy());
|
||||
|
||||
ui.restart.show();
|
||||
|
||||
Timers.runTask(30f, () -> {
|
||||
state.set(State.menu);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,8 @@ public class ServerControl extends Module {
|
||||
Events.on(GameOverEvent.class, () -> {
|
||||
info("Game over!");
|
||||
|
||||
Timers.runTask(10f, () -> {
|
||||
Timers.runTask(30f, () -> {
|
||||
state.set(State.menu);
|
||||
Net.closeServer();
|
||||
|
||||
if(shuffle) {
|
||||
@@ -79,8 +80,6 @@ public class ServerControl extends Module {
|
||||
logic.reset();
|
||||
world.loadMap(map);
|
||||
host();
|
||||
}else{
|
||||
state.set(State.menu);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -292,6 +291,11 @@ public class ServerControl extends Module {
|
||||
info("Saved to slot {0}.", slot);
|
||||
});
|
||||
|
||||
handler.register("gameover", "Force a game over.", arg -> {
|
||||
world.removeBlock(world.getCore());
|
||||
info("Core destroyed.");
|
||||
});
|
||||
|
||||
handler.register("info", "Print debug info", arg -> {
|
||||
info(DebugFragment.debugInfo());
|
||||
});
|
||||
|
||||
@@ -171,7 +171,7 @@ public class Net{
|
||||
|
||||
/**Call to handle a packet being recieved for the server.*/
|
||||
public static void handleServerReceived(int connection, Object object){
|
||||
if(debugNet) serverDebug.handle(object);
|
||||
if(debugNet) serverDebug.handle(connection, object);
|
||||
|
||||
if(serverListeners.get(object.getClass()) != null || listeners.get(object.getClass()) != null){
|
||||
if(serverListeners.get(object.getClass()) != null) serverListeners.get(object.getClass()).accept(connection, object);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.net;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
@@ -27,8 +26,6 @@ public class NetEvents {
|
||||
|
||||
public static void handleGameOver(){
|
||||
Net.send(new GameOverPacket(), SendMode.tcp);
|
||||
state.gameOver = true;
|
||||
state.set(State.menu);
|
||||
}
|
||||
|
||||
public static void handleBullet(BulletType type, Entity owner, float x, float y, float angle, short damage){
|
||||
|
||||
@@ -1,8 +1,58 @@
|
||||
package io.anuke.mindustry.net;
|
||||
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.net.Packets.Disconnect;
|
||||
|
||||
import static io.anuke.mindustry.Vars.playerGroup;
|
||||
|
||||
public class ServerDebug {
|
||||
private IntMap<OrderedMap<Class<?>, Long>> last = new IntMap<>();
|
||||
|
||||
public void handle(Object packet){
|
||||
public void handle(int connection, Object packet){
|
||||
if(!last.containsKey(connection))
|
||||
last.put(connection, new OrderedMap<>());
|
||||
if(packet instanceof Disconnect)
|
||||
last.remove(connection);
|
||||
else
|
||||
last.get(connection).put(packet.getClass(), TimeUtils.millis());
|
||||
}
|
||||
|
||||
public String getOut(){
|
||||
StringBuilder build = new StringBuilder();
|
||||
for(Player player : playerGroup.all()){
|
||||
OrderedMap<Class<?>, Long> map = last.get(player.clientid, new OrderedMap<>());
|
||||
build.append("connection ");
|
||||
build.append(player.clientid);
|
||||
build.append(" / player '");
|
||||
build.append(player.name);
|
||||
build.append("'\n");
|
||||
|
||||
for(Class<?> type : map.orderedKeys()){
|
||||
build.append(" ");
|
||||
build.append(elapsed(type, map));
|
||||
build.append("\n");
|
||||
}
|
||||
}
|
||||
return build.toString();
|
||||
}
|
||||
|
||||
private String elapsed(Class<?> type, OrderedMap<Class<?>, Long> last) {
|
||||
long t = last.get(type, -1L);
|
||||
if (t == -1) {
|
||||
return ClassReflection.getSimpleName(type) + ": <never>";
|
||||
} else {
|
||||
float el = TimeUtils.timeSinceMillis(t) / 1000f;
|
||||
String tu;
|
||||
if (el > 1f) {
|
||||
tu = (int) el + "s";
|
||||
} else {
|
||||
tu = (int) (el * 60) + "f";
|
||||
}
|
||||
return ClassReflection.getSimpleName(type) + ": " + tu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,13 +106,14 @@ public class DebugFragment implements Fragment {
|
||||
return join(
|
||||
"net.active: " + Net.active(),
|
||||
"net.server: " + Net.server(),
|
||||
"chat.open: " + ui.chatfrag.chatOpen(),
|
||||
"chat.messages: " + ui.chatfrag.getMessagesSize(),
|
||||
Net.client() ? "chat.open: " + ui.chatfrag.chatOpen() : "",
|
||||
Net.client() ? "chat.messages: " + ui.chatfrag.getMessagesSize() : "",
|
||||
"players: " + playerGroup.size(),
|
||||
"enemies: " + enemyGroup.size(),
|
||||
"tiles: " + tileGroup.size(),
|
||||
world.getCore() != null ? "core.health: " + world.getCore().entity.health : "",
|
||||
"",
|
||||
clientDebug.getOut()
|
||||
!Net.server() ? clientDebug.getOut() : serverDebug.getOut()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user