Alternate sync implementation for non-update blocks - Closes #11099
This commit is contained in:
@@ -23,6 +23,7 @@ import mindustry.net.*;
|
|||||||
import mindustry.net.Administration.*;
|
import mindustry.net.Administration.*;
|
||||||
import mindustry.net.Packets.*;
|
import mindustry.net.Packets.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
@@ -931,19 +932,20 @@ public class NetServer implements ApplicationListener{
|
|||||||
syncStream.reset();
|
syncStream.reset();
|
||||||
|
|
||||||
short sent = 0;
|
short sent = 0;
|
||||||
for(Building entity : Groups.build){
|
for(var team : state.teams.present){
|
||||||
if(!entity.block.sync) continue;
|
for(var build : indexer.getFlagged(team.team, BlockFlag.synced)){
|
||||||
sent++;
|
sent++;
|
||||||
|
|
||||||
dataStream.writeInt(entity.pos());
|
dataStream.writeInt(build.pos());
|
||||||
dataStream.writeShort(entity.block.id);
|
dataStream.writeShort(build.block.id);
|
||||||
entity.writeSync(Writes.get(dataStream));
|
build.writeSync(Writes.get(dataStream));
|
||||||
|
|
||||||
if(syncStream.size() > maxSnapshotSize){
|
if(syncStream.size() > maxSnapshotSize){
|
||||||
dataStream.close();
|
dataStream.close();
|
||||||
Call.blockSnapshot(sent, syncStream.toByteArray());
|
Call.blockSnapshot(sent, syncStream.toByteArray());
|
||||||
sent = 0;
|
sent = 0;
|
||||||
syncStream.reset();
|
syncStream.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1240,6 +1240,10 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
flags = flags.with(BlockFlag.hasFogRadius);
|
flags = flags.with(BlockFlag.hasFogRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sync){
|
||||||
|
flags = flags.with(BlockFlag.synced);
|
||||||
|
}
|
||||||
|
|
||||||
//initialize default health based on size
|
//initialize default health based on size
|
||||||
if(health == -1){
|
if(health == -1){
|
||||||
boolean round = false;
|
boolean round = false;
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
priority = TargetPriority.core;
|
priority = TargetPriority.core;
|
||||||
flags = EnumSet.of(BlockFlag.core);
|
flags = EnumSet.of(BlockFlag.core);
|
||||||
unitCapModifier = 10;
|
unitCapModifier = 10;
|
||||||
|
sync = false; //core items are synced elsewhere
|
||||||
drawDisabled = false;
|
drawDisabled = false;
|
||||||
canOverdrive = false;
|
canOverdrive = false;
|
||||||
commandable = true;
|
commandable = true;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class StorageBlock extends Block{
|
|||||||
hasItems = true;
|
hasItems = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
update = false;
|
update = false;
|
||||||
|
sync = true;
|
||||||
destructible = true;
|
destructible = true;
|
||||||
separateItemCapacity = true;
|
separateItemCapacity = true;
|
||||||
group = BlockGroup.transportation;
|
group = BlockGroup.transportation;
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ public enum BlockFlag{
|
|||||||
unitAssembler,
|
unitAssembler,
|
||||||
hasFogRadius,
|
hasFogRadius,
|
||||||
steamVent,
|
steamVent,
|
||||||
blockRepair;
|
blockRepair,
|
||||||
|
synced;
|
||||||
|
|
||||||
public final static BlockFlag[] all = values();
|
public final static BlockFlag[] all = values();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user