From 0936fc655023e6eb9b8bef130a46704785862ec0 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 1 Apr 2018 11:33:30 -0400 Subject: [PATCH] Multithreading crash fixes / Server 'find' command added --- core/assets/version.properties | 4 +-- core/src/io/anuke/mindustry/core/World.java | 2 +- .../anuke/mindustry/net/Administration.java | 12 +++++++++ .../io/anuke/mindustry/world/Placement.java | 15 +++++++---- .../anuke/mindustry/server/ServerControl.java | 27 +++++++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/core/assets/version.properties b/core/assets/version.properties index 836de62cd0..7979052ab3 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,7 +1,7 @@ #Autogenerated file. Do not modify. -#Fri Mar 30 19:18:12 EDT 2018 +#Sun Apr 01 11:24:59 EDT 2018 version=release -androidBuildCode=482 +androidBuildCode=483 name=Mindustry code=3.5 build=custom build diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index 3a2d930d1b..18ba128b32 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -244,7 +244,7 @@ public class World extends Module{ Array removals = target.getLinkedTiles(); for(Tile toremove : removals){ //note that setting a new block automatically unlinks it - toremove.setBlock(Blocks.air); + if(toremove != null) toremove.setBlock(Blocks.air); } } } diff --git a/core/src/io/anuke/mindustry/net/Administration.java b/core/src/io/anuke/mindustry/net/Administration.java index f34fe8aafb..59aa64fb75 100644 --- a/core/src/io/anuke/mindustry/net/Administration.java +++ b/core/src/io/anuke/mindustry/net/Administration.java @@ -172,6 +172,18 @@ public class Administration { return info.admin && ip.equals(info.validAdminIP); } + public Array findByName(String name, boolean last){ + Array result = new Array<>(); + + for(PlayerInfo info : playerInfo.values()){ + if(info.lastName.toLowerCase().equals(name.toLowerCase()) || (last && info.names.contains(name, false))){ + result.add(info); + } + } + + return result; + } + public PlayerInfo getInfo(String id){ return getCreateInfo(id); } diff --git a/core/src/io/anuke/mindustry/world/Placement.java b/core/src/io/anuke/mindustry/world/Placement.java index b3da7e28b5..86e755e28e 100644 --- a/core/src/io/anuke/mindustry/world/Placement.java +++ b/core/src/io/anuke/mindustry/world/Placement.java @@ -106,13 +106,18 @@ public class Placement { rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize); synchronized (Entities.entityLock) { - for (SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)) { - if (e == null) continue; //not sure why this happens? - Rectangle rect = e.hitbox.getRect(e.x, e.y); + //exception sometimes thrown due to multithreading, not sure what else to try at this point + try { + for (SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)) { + if (e == null) continue; //not sure why this happens? + Rectangle rect = e.hitbox.getRect(e.x, e.y); - if (Placement.rect.overlaps(rect)) { - return false; + if (Placement.rect.overlaps(rect)) { + return false; + } } + }catch (Exception e){ + return false; } } diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index 39b91c3f6d..aec207eb5a 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -537,6 +537,33 @@ public class ServerControl extends Module { } }); + handler.register("find", " [check-all-names]", "Find player info(s) by name. Can optionally check for all names a player has had.", arg -> { + boolean checkAll = arg.length == 2 && arg[1].equals("true"); + + Array infos = netServer.admins.findByName(arg[0], checkAll); + + if(infos.size == 1) { + PlayerInfo info = infos.peek(); + Log.info("&lcTrace info for player '{0}' / UUID {1}:", info.lastName, info.id); + Log.info(" &lyall names used: {0}", info.names); + Log.info(" &lyIP: {0}", info.lastIP); + Log.info(" &lyall IPs used: {0}", info.ips); + Log.info(" &lytimes joined: {0}", info.timesJoined); + Log.info(" &lytimes kicked: {0}", info.timesKicked); + Log.info(""); + Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken); + Log.info(" &lytotal blocks placed: {0}", info.totalBlockPlaced); + }else if(infos.size > 1){ + Log.info("&lcMultiple people have been found with that name:"); + for(PlayerInfo info : infos){ + Log.info(" &ly{0}", info.id); + } + Log.info("&lcUse the info command to examine each person individually."); + }else{ + info("Nobody with that name could be found."); + } + }); + handler.register("info", "", "Get global info for a player's UUID.", arg -> { PlayerInfo info = netServer.admins.getInfoOptional(arg[0]);