Bugfixes
This commit is contained in:
@@ -104,9 +104,9 @@ public class MapIO{
|
||||
@Override public void end(){}
|
||||
|
||||
@Override
|
||||
public Tile tile(int x, int y){
|
||||
tile.x = (short)x;
|
||||
tile.y = (short)y;
|
||||
public Tile tile(int index){
|
||||
tile.x = (short)(index % map.width);
|
||||
tile.y = (short)(index / map.width);
|
||||
return tile;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,15 @@ public abstract class SaveFileReader{
|
||||
protected final ReusableByteOutStream byteOutputSmall = new ReusableByteOutStream();
|
||||
protected final DataOutputStream dataBytesSmall = new DataOutputStream(byteOutputSmall);
|
||||
protected final ObjectMap<String, String> fallback = ObjectMap.of(
|
||||
"dart-mech-pad", "dart-ship-pad"
|
||||
"dart-mech-pad", "legacy-mech-pad",
|
||||
"dart-ship-pad", "legacy-mech-pad",
|
||||
"javelin-ship-pad", "legacy-mech-pad",
|
||||
"trident-ship-pad", "legacy-mech-pad",
|
||||
"glaive-ship-pad", "legacy-mech-pad",
|
||||
"alpha-mech-pad", "legacy-mech-pad",
|
||||
"tau-mech-pad", "legacy-mech-pad",
|
||||
"omega-mech-pad", "legacy-mech-pad",
|
||||
"delta-mech-pad", "legacy-mech-pad"
|
||||
);
|
||||
|
||||
protected void region(String name, DataInput stream, CounterInputStream counter, IORunner<DataInput> cons) throws IOException{
|
||||
|
||||
@@ -186,7 +186,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
for(int i = 0; i < width * height; i++){
|
||||
int x = i % width, y = i / width;
|
||||
Block block = content.block(stream.readShort());
|
||||
Tile tile = context.tile(x, y);
|
||||
Tile tile = context.tile(i);
|
||||
if(block == null) block = Blocks.air;
|
||||
boolean isCenter = true;
|
||||
|
||||
@@ -214,8 +214,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
int consecutives = stream.readUnsignedByte();
|
||||
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
context.tile(newx, newy).setBlock(block);
|
||||
context.tile(j).setBlock(block);
|
||||
}
|
||||
|
||||
i += consecutives;
|
||||
|
||||
@@ -49,13 +49,12 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
|
||||
//read blocks
|
||||
for(int i = 0; i < width * height; i++){
|
||||
int x = i % width, y = i / width;
|
||||
Block block = content.block(stream.readShort());
|
||||
Tile tile = context.tile(x, y);
|
||||
Tile tile = context.tile(i);
|
||||
if(block == null) block = Blocks.air;
|
||||
|
||||
//occupied by multiblock part
|
||||
boolean occupied = tile.entity != null && !tile.isCenter();
|
||||
boolean occupied = tile.entity != null && !tile.isCenter() && (tile.entity.block() == block || block == Blocks.air);
|
||||
|
||||
//do not override occupied cells
|
||||
if(!occupied){
|
||||
@@ -92,8 +91,7 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
//air is a waste of time and may mess up multiblocks
|
||||
if(block != Blocks.air){
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
context.tile(newx, newy).setBlock(block);
|
||||
context.tile(j).setBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.io.*;
|
||||
import static mindustry.Vars.content;
|
||||
|
||||
public class Save3 extends LegacySaveVersion{
|
||||
|
||||
public Save3(){
|
||||
super(3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user