diff --git a/core/src/mindustry/entities/comp/PlayerComp.java b/core/src/mindustry/entities/comp/PlayerComp.java index 834d4c239a..5c340b8afe 100644 --- a/core/src/mindustry/entities/comp/PlayerComp.java +++ b/core/src/mindustry/entities/comp/PlayerComp.java @@ -65,10 +65,13 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra return team.core(); } - /** @return largest/closest core, with largest cores getting priority */ + /** @return largest/closest core, with the largest cores getting priority */ @Nullable public CoreBuild bestCore(){ - return team.cores().min(Structs.comps(Structs.comparingInt(c -> -c.block.size), Structs.comparingFloat(c -> c.dst(x, y)))); + var cores = team.cores(); + //if someone screws up the map and adds an invalid core, prioritize the core that's supported + //if there's only one core, there are no other options + return cores.min(b -> cores.size == 1 || ((CoreBlock)b.block).unitType.supportsEnv(state.rules.env), Structs.comps(Structs.comparingInt(c -> -c.block.size), Structs.comparingFloat(c -> c.dst2(x, y)))); } public TextureRegion icon(){ diff --git a/core/src/mindustry/ui/dialogs/ResearchDialog.java b/core/src/mindustry/ui/dialogs/ResearchDialog.java index abc8f66aa0..13bfcd6617 100644 --- a/core/src/mindustry/ui/dialogs/ResearchDialog.java +++ b/core/src/mindustry/ui/dialogs/ResearchDialog.java @@ -606,10 +606,15 @@ public class ResearchDialog extends BaseDialog{ TechNode node = (TechNode)button.userObject; - infoTable.exited(() -> { - if(hoverNode == button && !infoTable.hasMouse() && !hoverNode.hasMouse()){ - hoverNode = null; - rebuild(); + infoTable.addListener(new InputListener(){ + @Override + public void exit(InputEvent event, float x, float y, int pointer, Element fromActor){ + Element e = Core.scene.hit(x, y, true); + + if(hoverNode == button && !(e != null && (e.isDescendantOf(infoTable) || e.isDescendantOf(hoverNode))) && (Core.app.isDesktop() || pointer == 0)){ + hoverNode = null; + rebuild(); + } } });