mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Fixed #2344
This commit is contained in:
parent
1c17c38e15
commit
5b727ac6fd
@ -345,6 +345,7 @@ public class NetClient implements ApplicationListener{
|
||||
Groups.clear();
|
||||
netClient.removed.clear();
|
||||
logic.reset();
|
||||
netClient.connecting = true;
|
||||
|
||||
net.setClientLoaded(false);
|
||||
|
||||
|
@ -706,10 +706,12 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
@Remote(targets = Loc.client)
|
||||
public static void connectConfirm(Player player){
|
||||
player.add();
|
||||
|
||||
if(player.con == null || player.con.hasConnected) return;
|
||||
|
||||
player.add();
|
||||
player.con.hasConnected = true;
|
||||
|
||||
if(Config.showConnectMessages.bool()){
|
||||
Call.sendMessage("[accent]" + player.name + "[accent] has connected.");
|
||||
Log.info("&lm[@] &y@ has connected. ", player.uuid(), player.name);
|
||||
|
@ -116,6 +116,6 @@ public abstract class LStatement{
|
||||
}
|
||||
|
||||
public String name(){
|
||||
return getClass().getSimpleName().replace("Statement", "");
|
||||
return Strings.insertSpaces(getClass().getSimpleName().replace("Statement", ""));
|
||||
}
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ public class Net{
|
||||
}
|
||||
|
||||
public void disconnect(){
|
||||
Log.info("Disconnecting.");
|
||||
provider.disconnectClient();
|
||||
server = false;
|
||||
active = false;
|
||||
|
@ -35,7 +35,7 @@ public class LogicBlock extends Block{
|
||||
update = true;
|
||||
configurable = true;
|
||||
|
||||
config(byte[].class, LogicBuild::readCompressed);
|
||||
config(byte[].class, (LogicBuild build, byte[] data) -> build.readCompressed(data, true));
|
||||
|
||||
config(Integer.class, (LogicBuild entity, Integer pos) -> {
|
||||
if(entity.connections.contains(pos)){
|
||||
@ -80,11 +80,13 @@ public class LogicBlock extends Block{
|
||||
public String code = "";
|
||||
public LExecutor executor = new LExecutor();
|
||||
public float accumulator = 0;
|
||||
|
||||
//TODO refactor this system, it's broken.
|
||||
public IntSeq connections = new IntSeq();
|
||||
public IntSeq invalidConnections = new IntSeq();
|
||||
public boolean loaded = false;
|
||||
|
||||
public void readCompressed(byte[] data){
|
||||
public void readCompressed(byte[] data, boolean relative){
|
||||
DataInputStream stream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
|
||||
|
||||
try{
|
||||
@ -99,7 +101,8 @@ public class LogicBlock extends Block{
|
||||
|
||||
int cons = stream.readInt();
|
||||
for(int i = 0; i < cons; i++){
|
||||
connections.add(stream.readInt());
|
||||
int pos = stream.readInt();
|
||||
connections.add(relative ? Point2.pack(Point2.x(pos) + tileX(), Point2.y(pos) + tileY()) : pos);
|
||||
}
|
||||
|
||||
updateCode(new String(bytes, charset));
|
||||
@ -211,14 +214,17 @@ public class LogicBlock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String config(){
|
||||
//set connections to use relative coordinates, not absolute (TODO maybe just store them like this?)
|
||||
public byte[] config(){
|
||||
return compress(code, relativeConnections());
|
||||
}
|
||||
|
||||
public IntSeq relativeConnections(){
|
||||
IntSeq copy = new IntSeq(connections);
|
||||
for(int i = 0; i < copy.size; i++){
|
||||
int pos = copy.items[i];
|
||||
copy.items[i] = Point2.pack(Point2.x(pos) - tileX(), Point2.y(pos) - tileY());
|
||||
}
|
||||
return JsonIO.write(new LogicConfig(code, copy));
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -264,7 +270,7 @@ public class LogicBlock extends Block{
|
||||
|
||||
cont.button(Icon.pencil, Styles.clearTransi, () -> {
|
||||
Vars.ui.logic.show(code, code -> {
|
||||
configure(compress(code, connections));
|
||||
configure(compress(code, relativeConnections()));
|
||||
});
|
||||
});
|
||||
|
||||
@ -331,7 +337,7 @@ public class LogicBlock extends Block{
|
||||
int compl = read.i();
|
||||
byte[] bytes = new byte[compl];
|
||||
read.b(bytes);
|
||||
readCompressed(bytes);
|
||||
readCompressed(bytes, false);
|
||||
}else{
|
||||
code = read.str();
|
||||
connections.clear();
|
||||
|
@ -924,7 +924,7 @@ public class ServerControl implements ApplicationListener{
|
||||
players.add(p);
|
||||
p.clearUnit();
|
||||
}
|
||||
|
||||
|
||||
logic.reset();
|
||||
|
||||
Call.worldDataBegin();
|
||||
|
Loading…
Reference in New Issue
Block a user