Implemented fog saving
This commit is contained in:
@@ -135,6 +135,18 @@ public class Save16 extends SaveFileVersion{
|
||||
tiles[x][y] = tile;
|
||||
}
|
||||
|
||||
for(int i = 0; i < width * height; i++){
|
||||
boolean discovered = stream.readBoolean();
|
||||
int consecutives = stream.readUnsignedShort();
|
||||
if(discovered){
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
tiles[newx][newy].setVisibility((byte) 1);
|
||||
}
|
||||
}
|
||||
i += consecutives;
|
||||
}
|
||||
|
||||
world.endMapLoad();
|
||||
}
|
||||
|
||||
@@ -223,5 +235,27 @@ public class Save16 extends SaveFileVersion{
|
||||
i += consecutives;
|
||||
}
|
||||
}
|
||||
|
||||
//write visibility, length-run encoded
|
||||
for(int i = 0; i < world.width() * world.height(); i++){
|
||||
Tile tile = world.tile(i);
|
||||
boolean discovered = tile.discovered();
|
||||
|
||||
int consecutives = 0;
|
||||
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 32767*2-1; j++){
|
||||
Tile nextTile = world.tile(j);
|
||||
|
||||
if(nextTile.discovered() != discovered){
|
||||
break;
|
||||
}
|
||||
|
||||
consecutives++;
|
||||
}
|
||||
|
||||
stream.writeBoolean(discovered);
|
||||
stream.writeShort(consecutives);
|
||||
i += consecutives;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user