mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-28 07:22:21 -08:00
Fixed #10280
This commit is contained in:
parent
0b860fbfe7
commit
899281abe1
1 changed files with 11 additions and 3 deletions
|
|
@ -377,13 +377,15 @@ public class LogicBlock extends Block{
|
|||
asm.putConst("@links", executor.links.length);
|
||||
asm.putConst("@ipt", instructionsPerTick);
|
||||
|
||||
Object oldUnit = null;
|
||||
|
||||
if(keep){
|
||||
oldUnit = executor.unit.objval;
|
||||
//store any older variables
|
||||
for(LVar var : executor.vars){
|
||||
boolean unit = var.name.equals("@unit");
|
||||
if(!var.constant || unit){
|
||||
if(!var.constant){
|
||||
LVar dest = asm.getVar(var.name);
|
||||
if(dest != null && (!dest.constant || unit)){
|
||||
if(dest != null && !dest.constant){
|
||||
dest.isobj = var.isobj;
|
||||
dest.objval = var.objval;
|
||||
dest.numval = var.numval;
|
||||
|
|
@ -395,6 +397,10 @@ public class LogicBlock extends Block{
|
|||
//inject any extra variables
|
||||
if(assemble != null){
|
||||
assemble.get(asm);
|
||||
|
||||
if(oldUnit == null && asm.getVar("@unit") != null && asm.getVar("@unit").objval instanceof Unit u){
|
||||
oldUnit = u;
|
||||
}
|
||||
}
|
||||
|
||||
asm.getVar("@this").setconst(this);
|
||||
|
|
@ -402,6 +408,8 @@ public class LogicBlock extends Block{
|
|||
asm.putConst("@thisy", World.conv(y));
|
||||
|
||||
executor.load(asm);
|
||||
executor.unit.objval = oldUnit;
|
||||
executor.unit.isobj = true;
|
||||
}catch(Exception e){
|
||||
//handle malformed code and replace it with nothing
|
||||
executor.load(LAssembler.assemble(code = "", privileged));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue