Fixed mirror filter not accoounting for data
This commit is contained in:
@@ -313,11 +313,14 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
"lastBuild", 0
|
"lastBuild", 0
|
||||||
);
|
);
|
||||||
|
|
||||||
createPlayer();
|
|
||||||
|
|
||||||
saves.load();
|
saves.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSync(){
|
||||||
|
createPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
/** Automatically unlocks things with no requirements and no locked parents. */
|
/** Automatically unlocks things with no requirements and no locked parents. */
|
||||||
public void checkAutoUnlocks(){
|
public void checkAutoUnlocks(){
|
||||||
if(net.client()) return;
|
if(net.client()) return;
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ public class MapGenerateDialog extends BaseDialog{
|
|||||||
public void applyToEditor(Seq<GenerateFilter> filters){
|
public void applyToEditor(Seq<GenerateFilter> filters){
|
||||||
//writeback buffer
|
//writeback buffer
|
||||||
long[] writeTiles = new long[editor.width() * editor.height()];
|
long[] writeTiles = new long[editor.width() * editor.height()];
|
||||||
|
long[] writeData = new long[writeTiles.length];
|
||||||
|
|
||||||
for(GenerateFilter filter : filters){
|
for(GenerateFilter filter : filters){
|
||||||
input.begin(editor.width(), editor.height(), editor::tile);
|
input.begin(editor.width(), editor.height(), editor::tile);
|
||||||
@@ -158,10 +159,10 @@ public class MapGenerateDialog extends BaseDialog{
|
|||||||
//write to buffer
|
//write to buffer
|
||||||
for(int x = 0; x < editor.width(); x++){
|
for(int x = 0; x < editor.width(); x++){
|
||||||
for(int y = 0; y < editor.height(); y++){
|
for(int y = 0; y < editor.height(); y++){
|
||||||
Tile tile = editor.tile(x, y);
|
input.set(editor.tile(x, y));
|
||||||
input.set(x, y, tile.block(), tile.floor(), tile.overlay());
|
|
||||||
filter.apply(input);
|
filter.apply(input);
|
||||||
writeTiles[x + y*world.width()] = PackTile.get(input.block.id, input.floor.id, input.overlay.id);
|
writeTiles[x + y*world.width()] = PackTile.get(input.block.id, input.floor.id, input.overlay.id);
|
||||||
|
writeData[x + y*world.width()] = input.packedData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +179,8 @@ public class MapGenerateDialog extends BaseDialog{
|
|||||||
tile.setBlock(block);
|
tile.setBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tile.setPackedData(writeData[i]);
|
||||||
|
|
||||||
tile.setFloor((Floor)floor);
|
tile.setFloor((Floor)floor);
|
||||||
tile.setOverlay(overlay);
|
tile.setOverlay(overlay);
|
||||||
}
|
}
|
||||||
@@ -431,7 +434,7 @@ public class MapGenerateDialog extends BaseDialog{
|
|||||||
pixmap.each((px, py) -> {
|
pixmap.each((px, py) -> {
|
||||||
int x = px * scaling, y = py * scaling;
|
int x = px * scaling, y = py * scaling;
|
||||||
long tile = buffer1[px + py * w];
|
long tile = buffer1[px + py * w];
|
||||||
input.set(x, y, content.block(PackTile.block(tile)), content.block(PackTile.floor(tile)), content.block(PackTile.overlay(tile)));
|
input.set(x, y, content.block(PackTile.block(tile)), content.block(PackTile.floor(tile)), content.block(PackTile.overlay(tile)), 0);
|
||||||
filter.apply(input);
|
filter.apply(input);
|
||||||
buffer2[px + py * w] = PackTile.get(input.block.id, input.floor.id, input.overlay.id);
|
buffer2[px + py * w] = PackTile.get(input.block.id, input.floor.id, input.overlay.id);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ public abstract class GenerateFilter implements Cloneable{
|
|||||||
long[] buffer = new long[tiles.width * tiles.height];
|
long[] buffer = new long[tiles.width * tiles.height];
|
||||||
|
|
||||||
for(int i = 0; i < tiles.width * tiles.height; i++){
|
for(int i = 0; i < tiles.width * tiles.height; i++){
|
||||||
Tile tile = tiles.geti(i);
|
in.set(tiles.geti(i));
|
||||||
|
|
||||||
in.set(tile.x, tile.y, tile.block(), tile.floor(), tile.overlay());
|
|
||||||
apply(in);
|
apply(in);
|
||||||
|
|
||||||
buffer[i] = PackTile.get(in.block.id, in.floor.id, in.overlay.id);
|
buffer[i] = PackTile.get(in.block.id, in.floor.id, in.overlay.id);
|
||||||
@@ -48,7 +46,7 @@ public abstract class GenerateFilter implements Cloneable{
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
for(Tile tile : tiles){
|
for(Tile tile : tiles){
|
||||||
in.set(tile.x, tile.y, tile.block(), tile.floor(), tile.overlay());
|
in.set(tile);
|
||||||
apply(in);
|
apply(in);
|
||||||
|
|
||||||
if(in.floor instanceof Floor floor){
|
if(in.floor instanceof Floor floor){
|
||||||
@@ -59,6 +57,7 @@ public abstract class GenerateFilter implements Cloneable{
|
|||||||
if(!tile.block().synthetic() && !in.block.synthetic()){
|
if(!tile.block().synthetic() && !in.block.synthetic()){
|
||||||
tile.setBlock(in.block);
|
tile.setBlock(in.block);
|
||||||
}
|
}
|
||||||
|
tile.setPackedData(in.packedData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,15 +147,21 @@ public abstract class GenerateFilter implements Cloneable{
|
|||||||
|
|
||||||
/** output parameters */
|
/** output parameters */
|
||||||
public Block floor, block, overlay;
|
public Block floor, block, overlay;
|
||||||
|
public long packedData;
|
||||||
|
|
||||||
TileProvider buffer;
|
TileProvider buffer;
|
||||||
|
|
||||||
public void set(int x, int y, Block block, Block floor, Block overlay){
|
public void set(int x, int y, Block block, Block floor, Block overlay, long packedData){
|
||||||
this.floor = floor;
|
this.floor = floor;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.overlay = overlay;
|
this.overlay = overlay;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
this.packedData = packedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(Tile tile){
|
||||||
|
set(tile.x, tile.y, tile.block(), tile.floor(), tile.overlay(), tile.getPackedData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin(int width, int height, TileProvider buffer){
|
public void begin(int width, int height, TileProvider buffer){
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class MirrorFilter extends GenerateFilter{
|
|||||||
in.block = tile.block();
|
in.block = tile.block();
|
||||||
}
|
}
|
||||||
in.overlay = tile.overlay();
|
in.overlay = tile.overlay();
|
||||||
|
in.packedData = tile.getPackedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -683,6 +683,17 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getPackedData(){
|
||||||
|
return PackedTileData.get(extraData, data, floorData, overlayData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackedData(long packed){
|
||||||
|
extraData = PackedTileData.extraData(packed);
|
||||||
|
data = PackedTileData.data(packed);
|
||||||
|
floorData = PackedTileData.floorData(packed);
|
||||||
|
overlayData = PackedTileData.overlayData(packed);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void display(Table table){
|
public void display(Table table){
|
||||||
|
|
||||||
@@ -809,4 +820,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Struct
|
||||||
|
class PackedTileDataStruct{
|
||||||
|
int extraData;
|
||||||
|
byte data, floorData, overlayData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user