From d2dbc5e7d596e9ec757d0cb5a9de20f8fdc54db6 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 18 May 2026 15:17:31 -0400 Subject: [PATCH] Fixed #12091 --- core/src/mindustry/core/Logic.java | 3 ++- core/src/mindustry/game/Rules.java | 2 ++ .../src/mindustry/world/blocks/logic/LogicBlock.java | 12 ++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index d431356708..956b53cbf3 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -103,11 +103,12 @@ public class Logic implements ApplicationListener{ if(state.isCampaign()){ //enable building AI on campaign unless the preset disables it - state.rules.coreIncinerates = true; state.rules.infiniteResources = false; state.rules.allowEditRules = false; state.rules.allowEditWorldProcessors = false; + state.rules.worldProcessorPlayerLink = false; + if(state.getPlanet().enemyInfiniteItems){ state.rules.waveTeam.rules().infiniteResources = true; state.rules.waveTeam.rules().fillItems = true; diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 8c44d99cb1..48dd273fdd 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -98,6 +98,8 @@ public class Rules{ public boolean logicUnitBuild = true; /** Whether to allow units to deconstruct blocks with logic. */ public boolean logicUnitDeconstruct = false; + /** If false, world processors can't link to player structures. This is used in the campaign; see issue #12091 */ + public boolean worldProcessorPlayerLink = true; /** If true, world processors can be edited and placed on this map. */ public boolean allowEditWorldProcessors = false; /** If true, world processors no longer update. Used for testing. */ diff --git a/core/src/mindustry/world/blocks/logic/LogicBlock.java b/core/src/mindustry/world/blocks/logic/LogicBlock.java index adb05a4d86..6c466acd96 100644 --- a/core/src/mindustry/world/blocks/logic/LogicBlock.java +++ b/core/src/mindustry/world/blocks/logic/LogicBlock.java @@ -182,7 +182,7 @@ public class LogicBlock extends Block{ @Override public Object pointConfig(Object config, Cons transformer){ - if(config instanceof byte[] data){ + if(config instanceof byte[] data && data.length <= maxCompressedLen){ try(DataInputStream stream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)))){ //discard version for now @@ -208,8 +208,8 @@ public class LogicBlock extends Block{ } return compress(bytes, links); - }catch(IOException e){ - Log.err(e); + }catch(IOException ignored){ + //error should not be logged } } return config; @@ -705,7 +705,7 @@ public class LogicBlock extends Block{ } public boolean validLink(Building other){ - return other != null && other.isValid() && (privileged || (!other.block.privileged && other.team == team && other.within(this, range + other.block.size*tilesize/2f))) && !(other instanceof ConstructBuild); + return other != null && other.isValid() && (privileged || (!other.block.privileged && other.team == team && other.within(this, range + other.block.size*tilesize/2f))) && !(privileged && !state.rules.worldProcessorPlayerLink && other.team == state.rules.defaultTeam) && !(other instanceof ConstructBuild); } @Override @@ -728,8 +728,8 @@ public class LogicBlock extends Block{ //this is a hack to allow configuration to work correctly in the editor for privileged processors if(forceEditor) state.rules.editor = true; byte[] bytes = compress(code, relativeConnections()); - if(bytes.length >= maxCompressedLen){ - ui.showErrorMessage(Core.bundle.format("logic.error.toolong ", maxByteLen, bytes.length)); + if(bytes.length > maxCompressedLen){ + ui.showErrorMessage(Core.bundle.format("logic.error.toolong", maxByteLen, bytes.length)); }else{ configure(bytes); state.rules.editor = prev;