diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 05424e8a1f..4fc380d240 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -606,7 +606,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ @Remote(targets = Loc.client, called = Loc.server) public static void dropItem(Player player, float angle){ - if(player == null) return; + if(player == null || player.unit() == null) return; if(net.server() && player.unit().stack.amount <= 0){ throw new ValidateException(player, "Player cannot drop an item."); diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 071c5f923b..6fa30baea5 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -601,7 +601,7 @@ public class UnitType extends UnlockableContent implements Senseable{ if(unit.controller() instanceof CommandAI ai && ai.currentCommand() == UnitCommand.mineCommand){ out.add(UnitStance.mineAuto); for(Item item : indexer.getAllPresentOres()){ - if(unit.canMine(item)){ + if(unit.canMine(item) && ((mineFloor && indexer.hasOre(item)) || (mineWalls && indexer.hasWallOre(item)))){ var itemStance = ItemUnitStance.getByItem(item); if(itemStance != null){ out.add(itemStance); diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index e70e0af9af..0800964bca 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -22,6 +22,7 @@ import static mindustry.Vars.*; public class Weather extends UnlockableContent{ /** Global random variable used for rendering. */ public static final Rand rand = new Rand(); + private static final float boundMax = 10000 * 8f; /** Default duration of this weather event in ticks. */ public float duration = 10f * Time.toMinutes; @@ -129,8 +130,8 @@ public class Weather extends UnlockableContent{ float scl = rand.random(0.5f, 1f); float scl2 = rand.random(0.5f, 1f); float size = rand.random(sizeMin, sizeMax); - float x = (rand.random(0f, world.unitWidth()) + Time.time * windx * scl2); - float y = (rand.random(0f, world.unitHeight()) + Time.time * windy * scl); + float x = (rand.random(0f, boundMax) + Time.time * windx * scl2); + float y = (rand.random(0f, boundMax) + Time.time * windy * scl); float alpha = rand.random(minAlpha, maxAlpha); float rotation = randomParticleRotation ? rand.random(0f, 360f) : 0f; @@ -168,8 +169,8 @@ public class Weather extends UnlockableContent{ float scl = rand.random(0.5f, 1f); float scl2 = rand.random(0.5f, 1f); float size = rand.random(sizeMin, sizeMax); - float x = (rand.random(0f, world.unitWidth()) + Time.time * xspeed * scl2); - float y = (rand.random(0f, world.unitHeight()) - Time.time * yspeed * scl); + float x = (rand.random(0f, boundMax) + Time.time * xspeed * scl2); + float y = (rand.random(0f, boundMax) - Time.time * yspeed * scl); float tint = rand.random(1f) * alpha; x -= Tmp.r1.x; @@ -202,8 +203,8 @@ public class Weather extends UnlockableContent{ int pos = (int)((time)); float life = time % 1f; - float x = (rand.random(0f, world.unitWidth()) + pos*953); - float y = (rand.random(0f, world.unitHeight()) - pos*453); + float x = (rand.random(0f, boundMax) + pos*953); + float y = (rand.random(0f, boundMax) - pos*453); x -= Tmp.r1.x; y -= Tmp.r1.y; diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 6dea071c9f..453c73e9a4 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -381,24 +381,28 @@ public class ServerControl implements ApplicationListener{ } }else{ result = maps.getShuffleMode().next(preset, state.map); - info("Randomized next map to be @.", result.plainName()); + if(result != null){ + info("Randomized next map to be @.", result.plainName()); + } } info("Loading map..."); logic.reset(); - lastMode = preset; - Core.settings.put("lastServerMode", lastMode.name()); - try{ - world.loadMap(result, result.applyRules(lastMode)); - state.rules = result.applyRules(preset); - logic.play(); + if(result != null){ + lastMode = preset; + Core.settings.put("lastServerMode", lastMode.name()); + try{ + world.loadMap(result, result.applyRules(lastMode)); + state.rules = result.applyRules(preset); + logic.play(); - info("Map loaded."); + info("Map loaded."); - netServer.openServer(); - }catch(MapException e){ - err("@: @", e.map.plainName(), e.getMessage()); + netServer.openServer(); + }catch(MapException e){ + err("@: @", e.map.plainName(), e.getMessage()); + } } });