11package mindustry .maps .filters ;
22
33import arc .scene .ui .layout .*;
4+ import mindustry .*;
45import mindustry .gen .*;
56import mindustry .logic .*;
67import mindustry .maps .filters .FilterOption .*;
@@ -40,8 +41,19 @@ public void build(Table table){
4041 public void apply (Tiles tiles , GenerateInput in ){
4142 executor = new LExecutor ();
4243 executor .privileged = true ;
43- executor .isFilter = true ;
44- configure (code );
44+
45+ try {
46+ //assembler has no variables, all the standard ones are null
47+ executor .load (LAssembler .assemble (code , true ));
48+ }catch (Throwable ignored ){
49+ //if loading code
50+ return ;
51+ }
52+
53+ //this updates map width/height global variables
54+ logicVars .update ();
55+
56+ //NOTE: all tile operations will call setNet for tiles, but that should have no overhead during world loading
4557
4658 //limited run
4759 for (int i = 1 ; i < maxInstructionsExecution ; i ++){
@@ -59,24 +71,4 @@ public char icon(){
5971 public boolean isPost (){
6072 return true ;
6173 }
62-
63- void configure (String code ){
64- try {
65- //create assembler to store extra variables
66- LAssembler asm = LAssembler .assemble (code , true );
67-
68- asm .putConst ("@mapw" , world .width ());
69- asm .putConst ("@maph" , world .height ());
70- asm .putConst ("@links" , executor .links .length );
71- asm .putConst ("@ipt" , 1 );
72-
73- asm .putConst ("@thisx" , 0 );
74- asm .putConst ("@thisy" , 0 );
75-
76- executor .load (asm );
77- }catch (Exception e ){
78- //handle malformed code and replace it with nothing
79- executor .load (LAssembler .assemble (code = "" , true ));
80- }
81- }
8274}
0 commit comments