mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-08 23:07:33 +07:00
Bugfixes
This commit is contained in:
@ -213,9 +213,9 @@ public class MapView extends Element implements GestureListener{
|
|||||||
y = (y - getHeight() / 2 + sclheight / 2 - offsety * zoom) / sclheight * editor.height();
|
y = (y - getHeight() / 2 + sclheight / 2 - offsety * zoom) / sclheight * editor.height();
|
||||||
|
|
||||||
if(editor.drawBlock.size % 2 == 0 && tool != EditorTool.eraser){
|
if(editor.drawBlock.size % 2 == 0 && tool != EditorTool.eraser){
|
||||||
return Tmp.g1.set((int)(x - 0.5f), (int)(y - 0.5f));
|
return Tmp.p1.set((int)(x - 0.5f), (int)(y - 0.5f));
|
||||||
}else{
|
}else{
|
||||||
return Tmp.g1.set((int)x, (int)y);
|
return Tmp.p1.set((int)x, (int)y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class BuildPlan{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object pointConfig(Object config, Cons<Point2> cons){
|
public static Object pointConfig(Block block, Object config, Cons<Point2> cons){
|
||||||
if(config instanceof Point2){
|
if(config instanceof Point2){
|
||||||
config = ((Point2)config).cpy();
|
config = ((Point2)config).cpy();
|
||||||
cons.get((Point2)config);
|
cons.get((Point2)config);
|
||||||
@ -65,6 +65,8 @@ public class BuildPlan{
|
|||||||
cons.get(result[i++]);
|
cons.get(result[i++]);
|
||||||
}
|
}
|
||||||
config = result;
|
config = result;
|
||||||
|
}else if(block != null){
|
||||||
|
config = block.pointConfig(config, cons);
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@ -72,7 +74,7 @@ public class BuildPlan{
|
|||||||
/** If this requests's config is a Point2 or an array of Point2s, this returns a copy of them for transformation.
|
/** If this requests's config is a Point2 or an array of Point2s, this returns a copy of them for transformation.
|
||||||
* Otherwise does nothing. */
|
* Otherwise does nothing. */
|
||||||
public void pointConfig(Cons<Point2> cons){
|
public void pointConfig(Cons<Point2> cons){
|
||||||
this.config = pointConfig(this.config, cons);
|
this.config = pointConfig(block, this.config, cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildPlan copy(){
|
public BuildPlan copy(){
|
||||||
|
@ -583,7 +583,7 @@ public class Schematics implements Loadable{
|
|||||||
int ox = schem.width/2, oy = schem.height/2;
|
int ox = schem.width/2, oy = schem.height/2;
|
||||||
|
|
||||||
schem.tiles.each(req -> {
|
schem.tiles.each(req -> {
|
||||||
req.config = BuildPlan.pointConfig(req.config, p -> {
|
req.config = BuildPlan.pointConfig(req.block, req.config, p -> {
|
||||||
int cx = p.x, cy = p.y;
|
int cx = p.x, cy = p.y;
|
||||||
int lx = cx;
|
int lx = cx;
|
||||||
|
|
||||||
|
@ -405,6 +405,10 @@ public class Block extends UnlockableContent{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object pointConfig(Object config, Cons<Point2> transformer){
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
/** Configure when a null value is passed.*/
|
/** Configure when a null value is passed.*/
|
||||||
public <E extends Building> void configClear(Cons<E> cons){
|
public <E extends Building> void configClear(Cons<E> cons){
|
||||||
configurations.put(void.class, (tile, value) -> cons.get((E)tile));
|
configurations.put(void.class, (tile, value) -> cons.get((E)tile));
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package mindustry.world.blocks.logic;
|
package mindustry.world.blocks.logic;
|
||||||
|
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
|
import arc.struct.Bits;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
@ -77,9 +79,11 @@ public class LogicBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
static byte[] compress(String code, Seq<LogicLink> links){
|
static byte[] compress(String code, Seq<LogicLink> links){
|
||||||
try{
|
return compress(code.getBytes(charset), links);
|
||||||
byte[] bytes = code.getBytes(charset);
|
}
|
||||||
|
|
||||||
|
static byte[] compress(byte[] bytes, Seq<LogicLink> links){
|
||||||
|
try{
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
DataOutputStream stream = new DataOutputStream(new DeflaterOutputStream(baos));
|
DataOutputStream stream = new DataOutputStream(new DeflaterOutputStream(baos));
|
||||||
|
|
||||||
@ -109,6 +113,39 @@ public class LogicBlock extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object pointConfig(Object config, Cons<Point2> transformer){
|
||||||
|
if(config instanceof byte[]){
|
||||||
|
byte[] data = (byte[])config;
|
||||||
|
|
||||||
|
try(DataInputStream stream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)))){
|
||||||
|
//discard version for now
|
||||||
|
stream.read();
|
||||||
|
|
||||||
|
int bytelen = stream.readInt();
|
||||||
|
byte[] bytes = new byte[bytelen];
|
||||||
|
stream.read(bytes);
|
||||||
|
|
||||||
|
int total = stream.readInt();
|
||||||
|
|
||||||
|
Seq<LogicLink> links = new Seq<>();
|
||||||
|
|
||||||
|
for(int i = 0; i < total; i++){
|
||||||
|
String name = stream.readUTF();
|
||||||
|
short x = stream.readShort(), y = stream.readShort();
|
||||||
|
|
||||||
|
transformer.get(Tmp.p1.set(x, y));
|
||||||
|
links.add(new LogicLink(Tmp.p1.x, Tmp.p1.y, name, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return compress(bytes, links);
|
||||||
|
}catch(IOException e){
|
||||||
|
Log.err(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
public static class LogicLink{
|
public static class LogicLink{
|
||||||
public boolean active = true, valid;
|
public boolean active = true, valid;
|
||||||
public int x, y;
|
public int x, y;
|
||||||
@ -139,7 +176,6 @@ public class LogicBlock extends Block{
|
|||||||
DataInputStream stream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
|
DataInputStream stream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
|
||||||
|
|
||||||
try{
|
try{
|
||||||
//discard version, there's only one
|
|
||||||
int version = stream.read();
|
int version = stream.read();
|
||||||
|
|
||||||
int bytelen = stream.readInt();
|
int bytelen = stream.readInt();
|
||||||
@ -301,7 +337,7 @@ public class LogicBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Seq<LogicLink> relativeConnections(){
|
public Seq<LogicLink> relativeConnections(){
|
||||||
Seq<LogicLink> copy = new Seq<>(links);
|
Seq<LogicLink> copy = new Seq<>(links.size);
|
||||||
for(LogicLink l : links){
|
for(LogicLink l : links){
|
||||||
LogicLink c = l.copy();
|
LogicLink c = l.copy();
|
||||||
c.x -= tileX();
|
c.x -= tileX();
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=363906fbb7e0ca5cb07660a8a818912d61691546
|
archash=55e3f18ceeafc718d401b62d0129855f665920e4
|
||||||
|
Reference in New Issue
Block a user