This commit is contained in:
Anuken
2019-09-25 16:44:55 -04:00
parent 47e723c557
commit fd69241de9
3 changed files with 32 additions and 16 deletions
@@ -405,15 +405,20 @@ public class NetServer implements ApplicationListener{
return;
}
if(!player.con.hasDisconnected){
if(player.con.hasConnected){
Events.fire(new PlayerLeave(player));
Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
Call.onPlayerDisconnect(player.id);
}
player.remove();
Log.info("&lm[{1}] &lc{0} has disconnected. &lg&fi({2})", player.name, player.uuid, reason);
}
player.remove();
player.con.hasDisconnected = true;
}
private static float compound(float speed, float drag){
float total = 0f;
for(int i = 0; i < 50; i++){
@@ -709,7 +714,12 @@ public class NetServer implements ApplicationListener{
//iterate through each player
for(int i = 0; i < playerGroup.size(); i++){
Player player = playerGroup.all().get(i);
if(player.isLocal || player.con == null) continue;
if(player.isLocal) continue;
if(player.con == null || !player.con.isConnected()){
onDisconnect(player, "disappeared");
continue;
}
NetConnection connection = player.con;
@@ -22,7 +22,7 @@ public abstract class NetConnection{
/** Timestamp of last recieved snapshot. */
public long lastRecievedClientTime;
public boolean hasConnected, hasBegunConnecting;
public boolean hasConnected, hasBegunConnecting, hasDisconnected;
public float viewWidth, viewHeight, viewX, viewY;
public NetConnection(String address){
@@ -151,10 +151,13 @@ public class ServerControl implements ApplicationListener{
if(Core.settings.getBool("shuffle")){
if(maps.all().size > 0){
Array<Map> maps = Vars.maps.customMaps().size == 0 ? Vars.maps.defaultMaps() : Vars.maps.customMaps();
Array<Map> maps = Array.with(Vars.maps.customMaps().size == 0 ? Vars.maps.defaultMaps() : Vars.maps.customMaps());
maps.shuffle();
Map previous = world.getMap();
Map map = maps.random(previous);
Map map = maps.find(m -> lastMode.valid(m) && m != previous);
if(map != null){
Call.onInfoMessage((state.rules.pvp
? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]")
@@ -166,6 +169,7 @@ public class ServerControl implements ApplicationListener{
play(true, () -> world.loadMap(map, map.applyRules(lastMode)));
}
}
}else{
netServer.kickAll(KickReason.gameover);
state.set(State.menu);
@@ -813,6 +817,8 @@ public class ServerControl implements ApplicationListener{
state.rules = world.getMap().applyRules(lastMode);
for(Player p : players){
if(p.con == null) continue;
p.reset();
if(state.rules.pvp){
p.setTeam(netServer.assignTeam(p, new ArrayIterable<>(players)));