mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-15 03:11:07 -07:00
Merge de5e334b64 into adb9a82d84
This commit is contained in:
commit
d535edd642
2 changed files with 39 additions and 11 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue