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