Bugfixes
This commit is contained in:
@@ -405,13 +405,18 @@ public class NetServer implements ApplicationListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.con.hasConnected){
|
if(!player.con.hasDisconnected){
|
||||||
Events.fire(new PlayerLeave(player));
|
if(player.con.hasConnected){
|
||||||
Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
|
Events.fire(new PlayerLeave(player));
|
||||||
Call.onPlayerDisconnect(player.id);
|
Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
|
||||||
|
Call.onPlayerDisconnect(player.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.info("&lm[{1}] &lc{0} has disconnected. &lg&fi({2})", player.name, player.uuid, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.remove();
|
player.remove();
|
||||||
Log.info("&lm[{1}] &lc{0} has disconnected. &lg&fi({2})", player.name, player.uuid, reason);
|
player.con.hasDisconnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float compound(float speed, float drag){
|
private static float compound(float speed, float drag){
|
||||||
@@ -709,7 +714,12 @@ public class NetServer implements ApplicationListener{
|
|||||||
//iterate through each player
|
//iterate through each player
|
||||||
for(int i = 0; i < playerGroup.size(); i++){
|
for(int i = 0; i < playerGroup.size(); i++){
|
||||||
Player player = playerGroup.all().get(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;
|
NetConnection connection = player.con;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public abstract class NetConnection{
|
|||||||
/** Timestamp of last recieved snapshot. */
|
/** Timestamp of last recieved snapshot. */
|
||||||
public long lastRecievedClientTime;
|
public long lastRecievedClientTime;
|
||||||
|
|
||||||
public boolean hasConnected, hasBegunConnecting;
|
public boolean hasConnected, hasBegunConnecting, hasDisconnected;
|
||||||
public float viewWidth, viewHeight, viewX, viewY;
|
public float viewWidth, viewHeight, viewX, viewY;
|
||||||
|
|
||||||
public NetConnection(String address){
|
public NetConnection(String address){
|
||||||
|
|||||||
@@ -151,20 +151,24 @@ public class ServerControl implements ApplicationListener{
|
|||||||
|
|
||||||
if(Core.settings.getBool("shuffle")){
|
if(Core.settings.getBool("shuffle")){
|
||||||
if(maps.all().size > 0){
|
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 previous = world.getMap();
|
||||||
Map map = maps.random(previous);
|
Map map = maps.find(m -> lastMode.valid(m) && m != previous);
|
||||||
|
|
||||||
Call.onInfoMessage((state.rules.pvp
|
if(map != null){
|
||||||
? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]")
|
|
||||||
+ "\nNext selected map:[accent] " + map.name() + "[]"
|
|
||||||
+ (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[]" : "") + "." +
|
|
||||||
"\nNew game begins in " + roundExtraTime + "[] seconds.");
|
|
||||||
|
|
||||||
info("Selected next map to be {0}.", map.name());
|
Call.onInfoMessage((state.rules.pvp
|
||||||
|
? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]")
|
||||||
|
+ "\nNext selected map:[accent] " + map.name() + "[]"
|
||||||
|
+ (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[]" : "") + "." +
|
||||||
|
"\nNew game begins in " + roundExtraTime + "[] seconds.");
|
||||||
|
|
||||||
play(true, () -> world.loadMap(map, map.applyRules(lastMode)));
|
info("Selected next map to be {0}.", map.name());
|
||||||
|
|
||||||
|
play(true, () -> world.loadMap(map, map.applyRules(lastMode)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
netServer.kickAll(KickReason.gameover);
|
netServer.kickAll(KickReason.gameover);
|
||||||
@@ -813,6 +817,8 @@ public class ServerControl implements ApplicationListener{
|
|||||||
state.rules = world.getMap().applyRules(lastMode);
|
state.rules = world.getMap().applyRules(lastMode);
|
||||||
|
|
||||||
for(Player p : players){
|
for(Player p : players){
|
||||||
|
if(p.con == null) continue;
|
||||||
|
|
||||||
p.reset();
|
p.reset();
|
||||||
if(state.rules.pvp){
|
if(state.rules.pvp){
|
||||||
p.setTeam(netServer.assignTeam(p, new ArrayIterable<>(players)));
|
p.setTeam(netServer.assignTeam(p, new ArrayIterable<>(players)));
|
||||||
|
|||||||
Reference in New Issue
Block a user