This commit is contained in:
Cardillan 2026-02-26 14:11:04 -08:00 committed by GitHub
commit d535edd642
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 11 deletions

View file

@ -55,6 +55,7 @@ public class LExecutor{
public Building[] links = {};
public @Nullable LogicBuild build;
public IntSet linkIds = new IntSet();
public ObjectSet<Building> disabledBlocks = new ObjectSet<>();
public Team team = Team.derelict;
public boolean privileged = false;
//maps variable name to index in vars; lazily initialized
@ -571,7 +572,9 @@ public class LExecutor{
if(p1.bool()){
b.noSleep();
}else{
// Note: it might be a good idea to remove invalid blocks from the set here
b.lastDisabler = exec.build;
exec.disabledBlocks.add(b);
}
}

View file

@ -429,7 +429,7 @@ public class LogicBlock extends Block{
public void removeFromProximity(){
super.removeFromProximity();
for(var link : executor.links){
for(var link : executor.disabledBlocks){
if(!link.enabled && link.lastDisabler == this){
link.enabled = true;
}
@ -700,7 +700,7 @@ public class LogicBlock extends Block{
@Override
public byte version(){
return 3;
return 4;
}
@Override
@ -746,6 +746,14 @@ public class LogicBlock extends Block{
TypeIO.writeString(write, tag);
write.s(iconTag);
for(var link : executor.disabledBlocks){
// Only store the necessary blocks
if(link.isValid() && !link.enabled && link.lastDisabler == this){
write.i(link.pos());
}
}
write.i(-1);
}
@Override
@ -784,6 +792,24 @@ public class LogicBlock extends Block{
//skip memory, it isn't used anymore
read.skip(memory * 8);
if(privileged && revision >= 2){
ipt = Mathf.clamp(read.s(), 1, maxInstructionsPerTick);
}
if(revision >= 3){
tag = TypeIO.readString(read);
iconTag = (char)read.us();
}
IntSeq tiles = new IntSeq();
if(revision >= 4){
while(true){
int tile = read.i();
if(tile == -1) break;
tiles.add(tile);
}
}
loadBlock = () -> updateCode(code, false, asm -> {
//load up the variables that were stored
for(int i = 0; i < varcount; i++){
@ -801,17 +827,16 @@ public class LogicBlock extends Block{
}
}
}
//load up disabled blocks
tiles.each(pos -> {
Building build = world.build(Point2.x(pos), Point2.y(pos));
if(build != null){
executor.disabledBlocks.add(build);
}
});
});
if(privileged && revision >= 2){
ipt = Mathf.clamp(read.s(), 1, maxInstructionsPerTick);
}
if(revision >= 3){
tag = TypeIO.readString(read);
iconTag = (char)read.us();
}
}
}
}