Alternate sync implementation for non-update blocks - Closes #11099

This commit is contained in:
Anuken
2025-08-06 21:54:38 +02:00
parent 6707ff5fdf
commit 0bdf4efcdd
5 changed files with 21 additions and 12 deletions

View File

@@ -23,6 +23,7 @@ import mindustry.net.*;
import mindustry.net.Administration.*;
import mindustry.net.Packets.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import java.io.*;
import java.net.*;
@@ -931,19 +932,20 @@ public class NetServer implements ApplicationListener{
syncStream.reset();
short sent = 0;
for(Building entity : Groups.build){
if(!entity.block.sync) continue;
sent++;
for(var team : state.teams.present){
for(var build : indexer.getFlagged(team.team, BlockFlag.synced)){
sent++;
dataStream.writeInt(entity.pos());
dataStream.writeShort(entity.block.id);
entity.writeSync(Writes.get(dataStream));
dataStream.writeInt(build.pos());
dataStream.writeShort(build.block.id);
build.writeSync(Writes.get(dataStream));
if(syncStream.size() > maxSnapshotSize){
dataStream.close();
Call.blockSnapshot(sent, syncStream.toByteArray());
sent = 0;
syncStream.reset();
if(syncStream.size() > maxSnapshotSize){
dataStream.close();
Call.blockSnapshot(sent, syncStream.toByteArray());
sent = 0;
syncStream.reset();
}
}
}

View File

@@ -1240,6 +1240,10 @@ public class Block extends UnlockableContent implements Senseable{
flags = flags.with(BlockFlag.hasFogRadius);
}
if(sync){
flags = flags.with(BlockFlag.synced);
}
//initialize default health based on size
if(health == -1){
boolean round = false;

View File

@@ -71,6 +71,7 @@ public class CoreBlock extends StorageBlock{
priority = TargetPriority.core;
flags = EnumSet.of(BlockFlag.core);
unitCapModifier = 10;
sync = false; //core items are synced elsewhere
drawDisabled = false;
canOverdrive = false;
commandable = true;

View File

@@ -21,6 +21,7 @@ public class StorageBlock extends Block{
hasItems = true;
solid = true;
update = false;
sync = true;
destructible = true;
separateItemCapacity = true;
group = BlockGroup.transportation;

View File

@@ -31,7 +31,8 @@ public enum BlockFlag{
unitAssembler,
hasFogRadius,
steamVent,
blockRepair;
blockRepair,
synced;
public final static BlockFlag[] all = values();