diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index c852d63981..a0cb26a57c 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -60,7 +60,7 @@ public class LExecutor{ public @Nullable LogicBuild build; public IntSet linkIds = new IntSet(); public Team team = Team.derelict; - public boolean privileged = false, isFilter = false; + public boolean privileged = false; //yes, this is a minor memory leak, but it's probably not significant enough to matter protected static IntFloatMap unitTimeouts = new IntFloatMap(); diff --git a/core/src/mindustry/maps/filters/LogicFilter.java b/core/src/mindustry/maps/filters/LogicFilter.java index fc5f6129f0..6b53bb1636 100644 --- a/core/src/mindustry/maps/filters/LogicFilter.java +++ b/core/src/mindustry/maps/filters/LogicFilter.java @@ -1,6 +1,7 @@ package mindustry.maps.filters; import arc.scene.ui.layout.*; +import mindustry.*; import mindustry.gen.*; import mindustry.logic.*; import mindustry.maps.filters.FilterOption.*; @@ -40,8 +41,19 @@ public class LogicFilter extends GenerateFilter{ public void apply(Tiles tiles, GenerateInput in){ executor = new LExecutor(); executor.privileged = true; - executor.isFilter = true; - configure(code); + + try{ + //assembler has no variables, all the standard ones are null + executor.load(LAssembler.assemble(code, true)); + }catch(Throwable ignored){ + //if loading code + return; + } + + //this updates map width/height global variables + logicVars.update(); + + //NOTE: all tile operations will call setNet for tiles, but that should have no overhead during world loading //limited run for(int i = 1; i < maxInstructionsExecution; i++){ @@ -59,24 +71,4 @@ public class LogicFilter extends GenerateFilter{ public boolean isPost(){ return true; } - - void configure(String code){ - try{ - //create assembler to store extra variables - LAssembler asm = LAssembler.assemble(code, true); - - asm.putConst("@mapw", world.width()); - asm.putConst("@maph", world.height()); - asm.putConst("@links", executor.links.length); - asm.putConst("@ipt", 1); - - asm.putConst("@thisx", 0); - asm.putConst("@thisy", 0); - - executor.load(asm); - }catch(Exception e){ - //handle malformed code and replace it with nothing - executor.load(LAssembler.assemble(code = "", true)); - } - } }