Fixing stuff
-Got rid of some annoying logging -Format
This commit is contained in:
parent
9c26418354
commit
b7dcbb0f30
@ -39,8 +39,7 @@ public class ProgressiaLauncher {
|
|||||||
GUI.addTopLayer(new LayerTitle("Title"));
|
GUI.addTopLayer(new LayerTitle("Title"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void play()
|
public static void play() {
|
||||||
{
|
|
||||||
proxy.setupServer();
|
proxy.setupServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +63,10 @@ public class ClientProxy implements Proxy {
|
|||||||
|
|
||||||
TestMusicPlayer.start();
|
TestMusicPlayer.start();
|
||||||
|
|
||||||
//setupServer();
|
// setupServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupServer()
|
public void setupServer() {
|
||||||
{
|
|
||||||
ServerState.startServer();
|
ServerState.startServer();
|
||||||
ClientState.connectToLocalServer();
|
ClientState.connectToLocalServer();
|
||||||
}
|
}
|
||||||
|
@ -65,18 +65,20 @@ public class ClientState {
|
|||||||
setInstance(client);
|
setInstance(client);
|
||||||
|
|
||||||
MutableString t = new MutableStringLocalized("LayerText.Load");
|
MutableString t = new MutableStringLocalized("LayerText.Load");
|
||||||
layer = new LayerTestText("Text",() -> {t.update(); return t.get();});
|
layer = new LayerTestText("Text", () -> {
|
||||||
|
t.update();
|
||||||
|
return t.get();
|
||||||
|
});
|
||||||
|
|
||||||
ServerState.getInstance().getChunkManager().register((ChunksLoadStartListener)() -> {
|
ServerState.getInstance().getChunkManager().register((ChunksLoadStartListener) () -> {
|
||||||
if (firstLoad)
|
if (firstLoad) {
|
||||||
{
|
|
||||||
|
|
||||||
GUI.addTopLayer(layer);
|
GUI.addTopLayer(layer);
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ServerState.getInstance().getChunkManager().register((ChunksLoadFinishListener)() -> {
|
ServerState.getInstance().getChunkManager().register((ChunksLoadFinishListener) () -> {
|
||||||
if (firstLoad)
|
if (firstLoad) {
|
||||||
{
|
|
||||||
GUI.removeLayer(layer);
|
GUI.removeLayer(layer);
|
||||||
|
|
||||||
LayerWorld layerWorld = new LayerWorld(client);
|
LayerWorld layerWorld = new LayerWorld(client);
|
||||||
@ -92,14 +94,12 @@ public class ClientState {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void disconnectFromLocalServer()
|
public static void disconnectFromLocalServer() {
|
||||||
{
|
for (Layer layer : GUI.getLayers()) {
|
||||||
for (Layer layer : GUI.getLayers())
|
|
||||||
{
|
|
||||||
GUI.removeLayer(layer);
|
GUI.removeLayer(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ServerState.getInstance().getClientManager();
|
// ServerState.getInstance().getClientManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientState() {
|
private ClientState() {
|
||||||
|
@ -25,8 +25,6 @@ import ru.windcorp.progressia.client.audio.backend.Speaker;
|
|||||||
public class Music
|
public class Music
|
||||||
extends Sound {
|
extends Sound {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Music(SoundType soundType, int timeLength, float pitch, float gain) {
|
public Music(SoundType soundType, int timeLength, float pitch, float gain) {
|
||||||
super(soundType, timeLength, new Vec3(), new Vec3(), pitch, gain);
|
super(soundType, timeLength, new Vec3(), new Vec3(), pitch, gain);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,8 @@ public class GraphicsBackend {
|
|||||||
0,
|
0,
|
||||||
vidmode.width(),
|
vidmode.width(),
|
||||||
vidmode.height(),
|
vidmode.height(),
|
||||||
0);
|
0
|
||||||
|
);
|
||||||
isFullscreen = true;
|
isFullscreen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +180,8 @@ public class GraphicsBackend {
|
|||||||
(vidmode.height() - getFrameHeight()) / 2,
|
(vidmode.height() - getFrameHeight()) / 2,
|
||||||
getFrameWidth(),
|
getFrameWidth(),
|
||||||
getFrameHeight(),
|
getFrameHeight(),
|
||||||
0);
|
0
|
||||||
|
);
|
||||||
isFullscreen = false;
|
isFullscreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +104,7 @@ public abstract class BasicButton extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicButton(String name, String label, Font labelFont)
|
public BasicButton(String name, String label, Font labelFont) {
|
||||||
{
|
|
||||||
this(name, new Label(name + ".Label", labelFont, label));
|
this(name, new Label(name + ".Label", labelFont, label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,8 @@ public class RadioButton extends BasicButton {
|
|||||||
addChild(group);
|
addChild(group);
|
||||||
|
|
||||||
addListener(KeyEvent.class, e -> {
|
addListener(KeyEvent.class, e -> {
|
||||||
if (e.isRelease()) return false;
|
if (e.isRelease())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (e.getKey() == GLFW.GLFW_KEY_LEFT || e.getKey() == GLFW.GLFW_KEY_UP) {
|
if (e.getKey() == GLFW.GLFW_KEY_LEFT || e.getKey() == GLFW.GLFW_KEY_UP) {
|
||||||
if (this.group != null) {
|
if (this.group != null) {
|
||||||
@ -149,7 +150,8 @@ public class RadioButton extends BasicButton {
|
|||||||
group.selectNext();
|
group.selectNext();
|
||||||
removeAction(group.listener);
|
removeAction(group.listener);
|
||||||
group.buttons.remove(this);
|
group.buttons.remove(this);
|
||||||
group.getSelected(); // Clear reference if this was the only button in the group
|
group.getSelected(); // Clear reference if this was the only button
|
||||||
|
// in the group
|
||||||
}
|
}
|
||||||
|
|
||||||
this.group = group;
|
this.group = group;
|
||||||
@ -178,7 +180,8 @@ public class RadioButton extends BasicButton {
|
|||||||
this.checked = checked;
|
this.checked = checked;
|
||||||
|
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
group.listener.accept(this); // Failsafe for manual invocations of setChecked()
|
group.listener.accept(this); // Failsafe for manual invocations of
|
||||||
|
// setChecked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class RadioButtonGroup {
|
public class RadioButtonGroup {
|
||||||
|
|
||||||
private final Collection<Consumer<RadioButtonGroup>> actions = Collections.synchronizedCollection(new ArrayList<>());
|
private final Collection<Consumer<RadioButtonGroup>> actions = Collections
|
||||||
|
.synchronizedCollection(new ArrayList<>());
|
||||||
final List<RadioButton> buttons = Collections.synchronizedList(new ArrayList<>());
|
final List<RadioButton> buttons = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
|
||||||
private RadioButton selected = null;
|
private RadioButton selected = null;
|
||||||
|
@ -51,7 +51,8 @@ public class ChunkRenderModel implements Renderable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(ShapeRenderHelper renderer) {
|
public void render(ShapeRenderHelper renderer) {
|
||||||
if (model == null) return;
|
if (model == null)
|
||||||
|
return;
|
||||||
|
|
||||||
renderer.pushTransform().translate(
|
renderer.pushTransform().translate(
|
||||||
chunk.getX() * ChunkData.BLOCKS_PER_CHUNK,
|
chunk.getX() * ChunkData.BLOCKS_PER_CHUNK,
|
||||||
|
@ -75,7 +75,9 @@ public abstract class BlockRenderTexturedCube
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void getFaces(
|
public final void getFaces(
|
||||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
ChunkData chunk,
|
||||||
|
Vec3i blockInChunk,
|
||||||
|
BlockFace blockFace,
|
||||||
boolean inner,
|
boolean inner,
|
||||||
Consumer<Face> output,
|
Consumer<Face> output,
|
||||||
Vec3 offset
|
Vec3 offset
|
||||||
@ -84,7 +86,9 @@ public abstract class BlockRenderTexturedCube
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Face createFace(
|
private Face createFace(
|
||||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
ChunkData chunk,
|
||||||
|
Vec3i blockInChunk,
|
||||||
|
BlockFace blockFace,
|
||||||
boolean inner,
|
boolean inner,
|
||||||
Vec3 offset
|
Vec3 offset
|
||||||
) {
|
) {
|
||||||
@ -110,7 +114,13 @@ public abstract class BlockRenderTexturedCube
|
|||||||
|
|
||||||
if (!opaque) {
|
if (!opaque) {
|
||||||
for (int i = 0; i < BLOCK_FACE_COUNT; ++i) {
|
for (int i = 0; i < BLOCK_FACE_COUNT; ++i) {
|
||||||
faces[i + BLOCK_FACE_COUNT] = createFace(chunk, blockInChunk, BlockFace.getFaces().get(i), true, Vectors.ZERO_3);
|
faces[i + BLOCK_FACE_COUNT] = createFace(
|
||||||
|
chunk,
|
||||||
|
blockInChunk,
|
||||||
|
BlockFace.getFaces().get(i),
|
||||||
|
true,
|
||||||
|
Vectors.ZERO_3
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,9 @@ public abstract class TileRenderSurface extends TileRender implements TileOptimi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void getFaces(
|
public final void getFaces(
|
||||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
ChunkData chunk,
|
||||||
|
Vec3i blockInChunk,
|
||||||
|
BlockFace blockFace,
|
||||||
boolean inner,
|
boolean inner,
|
||||||
Consumer<Face> output,
|
Consumer<Face> output,
|
||||||
Vec3 offset
|
Vec3 offset
|
||||||
@ -68,7 +70,9 @@ public abstract class TileRenderSurface extends TileRender implements TileOptimi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Face createFace(
|
private Face createFace(
|
||||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
ChunkData chunk,
|
||||||
|
Vec3i blockInChunk,
|
||||||
|
BlockFace blockFace,
|
||||||
boolean inner,
|
boolean inner,
|
||||||
Vec3 offset
|
Vec3 offset
|
||||||
) {
|
) {
|
||||||
|
@ -95,9 +95,12 @@ public interface GenericChunk<Self extends GenericChunk<Self, B, T, TS>, B exten
|
|||||||
default boolean isSurfaceBiC(Vec3i blockInChunk) {
|
default boolean isSurfaceBiC(Vec3i blockInChunk) {
|
||||||
int hits = 0;
|
int hits = 0;
|
||||||
|
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.x)) hits++;
|
if (Coordinates.isOnChunkBorder(blockInChunk.x))
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.y)) hits++;
|
hits++;
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.z)) hits++;
|
if (Coordinates.isOnChunkBorder(blockInChunk.y))
|
||||||
|
hits++;
|
||||||
|
if (Coordinates.isOnChunkBorder(blockInChunk.z))
|
||||||
|
hits++;
|
||||||
|
|
||||||
return hits >= 1;
|
return hits >= 1;
|
||||||
}
|
}
|
||||||
@ -117,9 +120,12 @@ public interface GenericChunk<Self extends GenericChunk<Self, B, T, TS>, B exten
|
|||||||
default boolean isEdgeBiC(Vec3i blockInChunk) {
|
default boolean isEdgeBiC(Vec3i blockInChunk) {
|
||||||
int hits = 0;
|
int hits = 0;
|
||||||
|
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.x)) hits++;
|
if (Coordinates.isOnChunkBorder(blockInChunk.x))
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.y)) hits++;
|
hits++;
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.z)) hits++;
|
if (Coordinates.isOnChunkBorder(blockInChunk.y))
|
||||||
|
hits++;
|
||||||
|
if (Coordinates.isOnChunkBorder(blockInChunk.z))
|
||||||
|
hits++;
|
||||||
|
|
||||||
return hits >= 2;
|
return hits >= 2;
|
||||||
}
|
}
|
||||||
@ -139,9 +145,12 @@ public interface GenericChunk<Self extends GenericChunk<Self, B, T, TS>, B exten
|
|||||||
default boolean isVertexBiC(Vec3i blockInChunk) {
|
default boolean isVertexBiC(Vec3i blockInChunk) {
|
||||||
int hits = 0;
|
int hits = 0;
|
||||||
|
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.x)) hits++;
|
if (Coordinates.isOnChunkBorder(blockInChunk.x))
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.y)) hits++;
|
hits++;
|
||||||
if (Coordinates.isOnChunkBorder(blockInChunk.z)) hits++;
|
if (Coordinates.isOnChunkBorder(blockInChunk.y))
|
||||||
|
hits++;
|
||||||
|
if (Coordinates.isOnChunkBorder(blockInChunk.z))
|
||||||
|
hits++;
|
||||||
|
|
||||||
return hits == 3;
|
return hits == 3;
|
||||||
}
|
}
|
||||||
|
@ -81,24 +81,20 @@ public class ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ChunksLoadListener
|
public interface ChunksLoadListener {
|
||||||
{
|
|
||||||
void handle(boolean starting);
|
void handle(boolean starting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
private interface ChunksLoadEventListener
|
private interface ChunksLoadEventListener {
|
||||||
{
|
|
||||||
void handle();
|
void handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ChunksLoadStartListener extends ChunksLoadEventListener
|
public interface ChunksLoadStartListener extends ChunksLoadEventListener {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ChunksLoadFinishListener extends ChunksLoadEventListener
|
public interface ChunksLoadFinishListener extends ChunksLoadEventListener {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,9 +105,10 @@ public class ChunkManager {
|
|||||||
private final ChunkSet toLoad = ChunkSets.newHashSet();
|
private final ChunkSet toLoad = ChunkSets.newHashSet();
|
||||||
private final ChunkSet toUnload = ChunkSets.newHashSet();
|
private final ChunkSet toUnload = ChunkSets.newHashSet();
|
||||||
|
|
||||||
private Collection<ChunksLoadListener> listeners = Collections.synchronizedCollection( new ArrayList<>());
|
private Collection<ChunksLoadListener> listeners = Collections.synchronizedCollection(new ArrayList<>());
|
||||||
private Collection<ChunksLoadStartListener> startListeners = Collections.synchronizedCollection( new ArrayList<>());
|
private Collection<ChunksLoadStartListener> startListeners = Collections.synchronizedCollection(new ArrayList<>());
|
||||||
private Collection<ChunksLoadFinishListener> finishListeners = Collections.synchronizedCollection( new ArrayList<>());
|
private Collection<ChunksLoadFinishListener> finishListeners = Collections
|
||||||
|
.synchronizedCollection(new ArrayList<>());
|
||||||
|
|
||||||
// TODO replace with a normal Map managed by some sort of PlayerListener,
|
// TODO replace with a normal Map managed by some sort of PlayerListener,
|
||||||
// weak maps are weak
|
// weak maps are weak
|
||||||
@ -132,23 +129,19 @@ public class ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(ChunksLoadListener cll)
|
public void register(ChunksLoadListener cll) {
|
||||||
{
|
|
||||||
listeners.add(cll);
|
listeners.add(cll);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(ChunksLoadStartListener clsl)
|
public void register(ChunksLoadStartListener clsl) {
|
||||||
{
|
|
||||||
startListeners.add(clsl);
|
startListeners.add(clsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(ChunksLoadFinishListener clfl)
|
public void register(ChunksLoadFinishListener clfl) {
|
||||||
{
|
|
||||||
finishListeners.add(clfl);
|
finishListeners.add(clfl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterAll()
|
public void unregisterAll() {
|
||||||
{
|
|
||||||
listeners.clear();
|
listeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,9 +171,8 @@ public class ChunkManager {
|
|||||||
|
|
||||||
private void processQueues() {
|
private void processQueues() {
|
||||||
|
|
||||||
if (toUnload.size()!=0 || toLoad.size()!=0)
|
if (toUnload.size() != 0 || toLoad.size() != 0) {
|
||||||
{
|
LogManager.getLogger().info(String.valueOf(toUnload.size()) + " " + String.valueOf(toLoad.size()));
|
||||||
LogManager.getLogger().info(String.valueOf(toUnload.size())+" "+String.valueOf( toLoad.size()));
|
|
||||||
}
|
}
|
||||||
listeners.forEach(l -> l.handle(false));
|
listeners.forEach(l -> l.handle(false));
|
||||||
startListeners.forEach(sl -> sl.handle());
|
startListeners.forEach(sl -> sl.handle());
|
||||||
@ -241,7 +233,7 @@ public class ChunkManager {
|
|||||||
{
|
{
|
||||||
WorldData world = getServer().getWorld().getData();
|
WorldData world = getServer().getWorld().getData();
|
||||||
|
|
||||||
//Collection<ChunkData> chunks = world.getChunks();
|
// Collection<ChunkData> chunks = world.getChunks();
|
||||||
Collection<Vec3i> chunkPoss = new HashSet<Vec3i>();
|
Collection<Vec3i> chunkPoss = new HashSet<Vec3i>();
|
||||||
|
|
||||||
world.forEachChunk(c -> {
|
world.forEachChunk(c -> {
|
||||||
|
@ -73,8 +73,7 @@ public class PlayerManager {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(Player player)
|
public void removePlayer(Player player) {
|
||||||
{
|
|
||||||
players.remove(player);
|
players.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,7 @@ public class ServerThread implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (isShuttingDown)
|
if (isShuttingDown) {
|
||||||
{
|
|
||||||
getTicker().stop();
|
getTicker().stop();
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
return;
|
return;
|
||||||
@ -90,7 +89,7 @@ public class ServerThread implements Runnable {
|
|||||||
|
|
||||||
isShuttingDown = true;
|
isShuttingDown = true;
|
||||||
|
|
||||||
//getTicker().stop();
|
// getTicker().stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Server getServer() {
|
public Server getServer() {
|
||||||
|
@ -116,7 +116,6 @@ class Ticker {
|
|||||||
getCoordinator().crash(e, this.name);
|
getCoordinator().crash(e, this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean sleep() {
|
private synchronized boolean sleep() {
|
||||||
|
@ -75,14 +75,14 @@ public class LayerButtonTest extends MenuLayer {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
getContent().addChild(new Button("Menu", "Back To Menu").addAction(b -> {
|
getContent().addChild(new Button("Menu", "Back To Menu").addAction(b -> {
|
||||||
//System.exit(0);
|
// System.exit(0);
|
||||||
//for (Layer layer : GUI.getLayers())
|
// for (Layer layer : GUI.getLayers())
|
||||||
//{
|
// {
|
||||||
// GUI.removeLayer(layer);
|
// GUI.removeLayer(layer);
|
||||||
//}
|
// }
|
||||||
getCloseAction().run();
|
getCloseAction().run();
|
||||||
|
|
||||||
//ClientState.getInstance().;
|
// ClientState.getInstance().;
|
||||||
|
|
||||||
Collection<Player> players = ServerState.getInstance().getPlayerManager().getPlayers();
|
Collection<Player> players = ServerState.getInstance().getPlayerManager().getPlayers();
|
||||||
players.clear();
|
players.clear();
|
||||||
@ -90,21 +90,23 @@ public class LayerButtonTest extends MenuLayer {
|
|||||||
ClientState.disconnectFromLocalServer();
|
ClientState.disconnectFromLocalServer();
|
||||||
|
|
||||||
MutableString t = new MutableStringLocalized("LayerText.Save");
|
MutableString t = new MutableStringLocalized("LayerText.Save");
|
||||||
LayerTestText layer = new LayerTestText("Text",() -> {t.update(); return t.get();});
|
LayerTestText layer = new LayerTestText("Text", () -> {
|
||||||
|
t.update();
|
||||||
|
return t.get();
|
||||||
|
});
|
||||||
|
|
||||||
GUI.addTopLayer(layer);
|
GUI.addTopLayer(layer);
|
||||||
|
|
||||||
ChunkManager cm = ServerState.getInstance().getChunkManager();
|
ChunkManager cm = ServerState.getInstance().getChunkManager();
|
||||||
alive = true;
|
alive = true;
|
||||||
cm.register((ChunksLoadFinishListener)() -> {
|
cm.register((ChunksLoadFinishListener) () -> {
|
||||||
if (alive)
|
if (alive) {
|
||||||
{
|
|
||||||
GUI.removeLayer(layer);
|
GUI.removeLayer(layer);
|
||||||
GUI.addTopLayer(new LayerTitle("Title"));
|
GUI.addTopLayer(new LayerTitle("Title"));
|
||||||
//cm.unregisterAll();
|
// cm.unregisterAll();
|
||||||
alive = false;
|
alive = false;
|
||||||
|
|
||||||
//ServerState.getInstance().;
|
// ServerState.getInstance().;
|
||||||
ServerState.getInstance().shutdown("Safe Exit");
|
ServerState.getInstance().shutdown("Safe Exit");
|
||||||
|
|
||||||
ServerState.setInstance(null);
|
ServerState.setInstance(null);
|
||||||
@ -113,10 +115,9 @@ public class LayerButtonTest extends MenuLayer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//ClientState.getInstance();
|
// ClientState.getInstance();
|
||||||
ClientState.setInstance(null);
|
ClientState.setInstance(null);
|
||||||
//ServerState.getInstance().getChunkManager().unloadAll();
|
// ServerState.getInstance().getChunkManager().unloadAll();
|
||||||
|
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -10,15 +10,15 @@ import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical;
|
|||||||
|
|
||||||
public class LayerTestText extends GUILayer {
|
public class LayerTestText extends GUILayer {
|
||||||
public LayerTestText(String name, Supplier<String> value) {
|
public LayerTestText(String name, Supplier<String> value) {
|
||||||
super(name, new LayoutVertical(20,10));
|
super(name, new LayoutVertical(20, 10));
|
||||||
|
|
||||||
//MutableString title = new MutableStringLocalized("Layer"+name+".Title");
|
// MutableString title = new
|
||||||
|
// MutableStringLocalized("Layer"+name+".Title");
|
||||||
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
||||||
getRoot().addChild(new Label(name+".Text", titleFont, value));
|
getRoot().addChild(new Label(name + ".Text", titleFont, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayerTestText(String name, String value)
|
public LayerTestText(String name, String value) {
|
||||||
{
|
this(name, () -> value);
|
||||||
this(name,() -> value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,21 +14,22 @@ import ru.windcorp.progressia.client.localization.MutableStringLocalized;
|
|||||||
public class LayerTitle extends GUILayer {
|
public class LayerTitle extends GUILayer {
|
||||||
|
|
||||||
public LayerTitle(String name) {
|
public LayerTitle(String name) {
|
||||||
super(name, new LayoutVertical(20,10));
|
super(name, new LayoutVertical(20, 10));
|
||||||
|
|
||||||
MutableString title = new MutableStringLocalized("Layer"+name+".Title");
|
MutableString title = new MutableStringLocalized("Layer" + name + ".Title");
|
||||||
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
||||||
getRoot().addChild(new Label(name+".Title", titleFont, title));
|
getRoot().addChild(new Label(name + ".Title", titleFont, title));
|
||||||
|
|
||||||
Font buttonFont = titleFont;
|
Font buttonFont = titleFont;
|
||||||
MutableString playText = new MutableStringLocalized("Layer"+name+".Play");
|
MutableString playText = new MutableStringLocalized("Layer" + name + ".Play");
|
||||||
getRoot().addChild(new Button(name+".Play", new Label(name+".Play", buttonFont, playText)).addAction(b -> {
|
getRoot().addChild(new Button(name + ".Play", new Label(name + ".Play", buttonFont, playText)).addAction(b -> {
|
||||||
GUI.removeLayer(this);
|
GUI.removeLayer(this);
|
||||||
|
|
||||||
ProgressiaLauncher.play();}));
|
ProgressiaLauncher.play();
|
||||||
|
}));
|
||||||
|
|
||||||
MutableString quitText = new MutableStringLocalized("Layer"+name+".Quit");
|
MutableString quitText = new MutableStringLocalized("Layer" + name + ".Quit");
|
||||||
getRoot().addChild(new Button(name+"Quit", new Label(name+".Quit", buttonFont, quitText)).addAction(b -> {
|
getRoot().addChild(new Button(name + "Quit", new Label(name + ".Quit", buttonFont, quitText)).addAction(b -> {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,8 @@ public class TestMusicPlayer implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void startNextNow() {
|
public static void startNextNow() {
|
||||||
if (instance == null) return;
|
if (instance == null)
|
||||||
|
return;
|
||||||
|
|
||||||
synchronized (instance) {
|
synchronized (instance) {
|
||||||
instance.nextStart = System.currentTimeMillis();
|
instance.nextStart = System.currentTimeMillis();
|
||||||
|
@ -91,8 +91,7 @@ public class TestPlayerControls {
|
|||||||
private LayerTestGUI debugLayer = null;
|
private LayerTestGUI debugLayer = null;
|
||||||
private Runnable updateCallback = null;
|
private Runnable updateCallback = null;
|
||||||
|
|
||||||
public static void resetInstance()
|
public static void resetInstance() {
|
||||||
{
|
|
||||||
INSTANCE = new TestPlayerControls();
|
INSTANCE = new TestPlayerControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,25 +78,29 @@ public class TestWorldDiskIO {
|
|||||||
return loc << 1;
|
return loc << 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private static int intFromNat(int loc) // Possibly unused
|
/*
|
||||||
{
|
* private static int intFromNat(int loc) // Possibly unused
|
||||||
if ((loc & 1) == 1)
|
* {
|
||||||
return -loc >> 1;
|
* if ((loc & 1) == 1)
|
||||||
return loc >> 1;
|
* return -loc >> 1;
|
||||||
}*/
|
* return loc >> 1;
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
private static Vec3i getRegion(Vec3i chunkLoc) {
|
private static Vec3i getRegion(Vec3i chunkLoc) {
|
||||||
return new Vec3i(natFromInt(chunkLoc.x/regionSize.x), natFromInt(chunkLoc.y/regionSize.y), natFromInt(chunkLoc.z/regionSize.z));
|
return new Vec3i(
|
||||||
|
natFromInt(chunkLoc.x / regionSize.x),
|
||||||
|
natFromInt(chunkLoc.y / regionSize.y),
|
||||||
|
natFromInt(chunkLoc.z / regionSize.z)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int mod(int a, int m)
|
private static int mod(int a, int m) {
|
||||||
{
|
return ((a % m) + m) % m;
|
||||||
return ((a%m)+m)%m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vec3i getRegionLoc(Vec3i chunkLoc)
|
private static Vec3i getRegionLoc(Vec3i chunkLoc) {
|
||||||
{
|
return new Vec3i(mod(chunkLoc.x, regionSize.x), mod(chunkLoc.y, regionSize.y), mod(chunkLoc.z, regionSize.z));
|
||||||
return new Vec3i(mod(chunkLoc.x,regionSize.x),mod(chunkLoc.y,regionSize.y),mod(chunkLoc.z,regionSize.z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initRegions() {
|
public static void initRegions() {
|
||||||
@ -130,8 +134,7 @@ public class TestWorldDiskIO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void expand(int sectors)
|
private static void expand(int sectors) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,9 +200,7 @@ public class TestWorldDiskIO {
|
|||||||
ChunkIO.save(chunk, output, IOContext.SAVE);
|
ChunkIO.save(chunk, output, IOContext.SAVE);
|
||||||
writeGenerationHint(chunk, output, server);
|
writeGenerationHint(chunk, output, server);
|
||||||
}
|
}
|
||||||
}
|
} else if (currentFormat == 65536) {
|
||||||
else if (currentFormat == 65536)
|
|
||||||
{
|
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Saving {} {} {}",
|
"Saving {} {} {}",
|
||||||
chunk.getPosition().x,
|
chunk.getPosition().x,
|
||||||
@ -220,48 +221,52 @@ public class TestWorldDiskIO {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
/*if (!dosave)
|
/*
|
||||||
{
|
* if (!dosave)
|
||||||
return;
|
* {
|
||||||
}
|
* return;
|
||||||
dosave = false;*/
|
* }
|
||||||
|
* dosave = false;
|
||||||
|
*/
|
||||||
|
|
||||||
try (
|
try (
|
||||||
RandomAccessFile output = new RandomAccessFile(path.toFile(), "rw")
|
RandomAccessFile output = new RandomAccessFile(path.toFile(), "rw")
|
||||||
) {
|
) {
|
||||||
//LOG.debug(output.read());
|
// LOG.debug(output.read());
|
||||||
if (output.read()<0)
|
if (output.read() < 0) {
|
||||||
{
|
|
||||||
LOG.info("Making header");
|
LOG.info("Making header");
|
||||||
output.writeChars("\0".repeat((offsetBytes+1)*chunksPerRegion));
|
output.writeChars("\0".repeat((offsetBytes + 1) * chunksPerRegion));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3i pos = getRegionLoc(chunk.getPosition());
|
Vec3i pos = getRegionLoc(chunk.getPosition());
|
||||||
int shortOffset = (offsetBytes+1)*(pos.z+regionSize.z*(pos.y + regionSize.y*pos.x));
|
int shortOffset = (offsetBytes + 1) * (pos.z + regionSize.z * (pos.y + regionSize.y * pos.x));
|
||||||
int fullOffset = (offsetBytes+1)*(chunksPerRegion);
|
int fullOffset = (offsetBytes + 1) * (chunksPerRegion);
|
||||||
output.seek(shortOffset);
|
output.seek(shortOffset);
|
||||||
int offset = output.readInt();
|
int offset = output.readInt();
|
||||||
int sectorLength = offset&255;
|
int sectorLength = offset & 255;
|
||||||
offset = offset >> 8;
|
offset = offset >> 8;
|
||||||
if (sectorLength == 0)
|
if (sectorLength == 0) {
|
||||||
{
|
|
||||||
int outputLen = (int) output.length();
|
int outputLen = (int) output.length();
|
||||||
offset = (int) (outputLen-fullOffset)/sectorSize+1;
|
offset = (int) (outputLen - fullOffset) / sectorSize + 1;
|
||||||
output.seek(shortOffset);
|
output.seek(shortOffset);
|
||||||
output.writeInt(offset<<8);
|
output.writeInt(offset << 8);
|
||||||
output.seek(outputLen);
|
output.seek(outputLen);
|
||||||
/*while (output.length()<fullOffset+sectorSize*offset)
|
/*
|
||||||
{
|
* while (output.length()<fullOffset+sectorSize*offset)
|
||||||
output.write((int) (output.length()%256));
|
* {
|
||||||
}*/
|
* output.write((int) (output.length()%256));
|
||||||
output.setLength(fullOffset+offset*sectorSize);
|
* }
|
||||||
//output.write(200);
|
*/
|
||||||
|
output.setLength(fullOffset + offset * sectorSize);
|
||||||
|
// output.write(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
//int bytestoWrite = output.readInt();
|
// int bytestoWrite = output.readInt();
|
||||||
//output.mark(sectorSize*sectorLength);
|
// output.mark(sectorSize*sectorLength);
|
||||||
|
|
||||||
//BufferedOutputStream counter = new BufferedOutputStream(Files.newOutputStream( SAVE_DIR.resolve(tempFile)));
|
// BufferedOutputStream counter = new
|
||||||
|
// BufferedOutputStream(Files.newOutputStream(
|
||||||
|
// SAVE_DIR.resolve(tempFile)));
|
||||||
ByteArrayOutputStream tempDataStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream tempDataStream = new ByteArrayOutputStream();
|
||||||
DataOutputStream trueOutput = new DataOutputStream(
|
DataOutputStream trueOutput = new DataOutputStream(
|
||||||
new DeflaterOutputStream(
|
new DeflaterOutputStream(
|
||||||
@ -271,30 +276,32 @@ public class TestWorldDiskIO {
|
|||||||
// CountingOutputStream countOutput = new
|
// CountingOutputStream countOutput = new
|
||||||
// CountingOutputStream(trueOutput);
|
// CountingOutputStream(trueOutput);
|
||||||
|
|
||||||
//LOG.info("Before: {}",output.);
|
// LOG.info("Before: {}",output.);
|
||||||
//trueOutput.writeBytes("uh try this");
|
// trueOutput.writeBytes("uh try this");
|
||||||
//counter.
|
// counter.
|
||||||
ChunkIO.save(chunk, trueOutput, IOContext.SAVE);
|
ChunkIO.save(chunk, trueOutput, IOContext.SAVE);
|
||||||
writeGenerationHint(chunk, trueOutput, server);
|
writeGenerationHint(chunk, trueOutput, server);
|
||||||
|
|
||||||
/*while (counter.getCount()%sectorSize != 0) {
|
/*
|
||||||
counter.write(0);
|
* while (counter.getCount()%sectorSize != 0) {
|
||||||
}*/
|
* counter.write(0);
|
||||||
|
* }
|
||||||
|
*/
|
||||||
LOG.info("Wrote {} bytes to {},{},{}",trueOutput.size(),chunk.getPosition().x,chunk.getPosition().y,chunk.getPosition().z);
|
|
||||||
|
|
||||||
|
// LOG.info("Wrote {} bytes to
|
||||||
|
// {},{},{}",trueOutput.size(),chunk.getPosition().x,chunk.getPosition().y,chunk.getPosition().z);
|
||||||
|
|
||||||
trueOutput.close();
|
trueOutput.close();
|
||||||
|
|
||||||
byte tempData[] = tempDataStream.toByteArray();
|
byte tempData[] = tempDataStream.toByteArray();
|
||||||
|
|
||||||
output.seek((long) fullOffset+sectorSize*offset);
|
output.seek((long) fullOffset + sectorSize * offset);
|
||||||
output.write(tempData);
|
output.write(tempData);
|
||||||
|
|
||||||
output.seek(shortOffset+offsetBytes);
|
output.seek(shortOffset + offsetBytes);
|
||||||
output.write((int) tempData.length/sectorSize + 1);
|
output.write((int) tempData.length / sectorSize + 1);
|
||||||
LOG.info("Used {} sectors",(int) tempData.length/sectorSize + 1);
|
// LOG.info("Used {} sectors",(int)
|
||||||
|
// tempData.length/sectorSize + 1);
|
||||||
|
|
||||||
output.close();
|
output.close();
|
||||||
|
|
||||||
@ -348,20 +355,21 @@ public class TestWorldDiskIO {
|
|||||||
|
|
||||||
int bfClone = bestFormat;
|
int bfClone = bestFormat;
|
||||||
|
|
||||||
for (int i=0;i<4;i++)
|
for (int i = 0; i < 4; i++) {
|
||||||
{
|
bw.write(bfClone >> 24);
|
||||||
bw.write(bfClone>>24);
|
LOG.debug(bfClone >> 24);
|
||||||
LOG.debug(bfClone>>24);
|
|
||||||
bfClone = bfClone << 8;
|
bfClone = bfClone << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*bw.write(
|
/*
|
||||||
new char[] {
|
* bw.write(
|
||||||
(char) bestFormat / (256 * 256 * 256),
|
* new char[] {
|
||||||
(char) (bestFormat % 256) / (256 * 256),
|
* (char) bestFormat / (256 * 256 * 256),
|
||||||
(char) (bestFormat % (256 * 256)) / (256),
|
* (char) (bestFormat % 256) / (256 * 256),
|
||||||
(char) (bestFormat % (256 * 256 * 256)) }
|
* (char) (bestFormat % (256 * 256)) / (256),
|
||||||
);*/
|
* (char) (bestFormat % (256 * 256 * 256)) }
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -521,32 +529,33 @@ public class TestWorldDiskIO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ChunkData loadRegion(Path path, Vec3i chunkPos, WorldData world, Server server) throws IOException, DecodingException
|
private static ChunkData loadRegion(Path path, Vec3i chunkPos, WorldData world, Server server)
|
||||||
{
|
throws IOException,
|
||||||
|
DecodingException {
|
||||||
try (
|
try (
|
||||||
BufferedInputStream input = new BufferedInputStream(Files.newInputStream(path))
|
BufferedInputStream input = new BufferedInputStream(Files.newInputStream(path))
|
||||||
) {
|
) {
|
||||||
LOG.info(path.toString());
|
// LOG.info(path.toString());
|
||||||
Vec3i pos = getRegionLoc(chunkPos);
|
Vec3i pos = getRegionLoc(chunkPos);
|
||||||
int shortOffset = (offsetBytes+1)*(pos.z+regionSize.z*(pos.y + regionSize.y*pos.x));
|
int shortOffset = (offsetBytes + 1) * (pos.z + regionSize.z * (pos.y + regionSize.y * pos.x));
|
||||||
int fullOffset = (offsetBytes+1)*(chunksPerRegion);
|
int fullOffset = (offsetBytes + 1) * (chunksPerRegion);
|
||||||
input.skipNBytes(shortOffset);
|
input.skipNBytes(shortOffset);
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for (int i=0;i<offsetBytes;i++)
|
for (int i = 0; i < offsetBytes; i++) {
|
||||||
{
|
offset *= 256;
|
||||||
offset*=256;
|
|
||||||
offset += input.read();
|
offset += input.read();
|
||||||
}
|
}
|
||||||
int sectorLength = input.read();
|
int sectorLength = input.read();
|
||||||
input.skipNBytes(fullOffset-shortOffset-offsetBytes-1);
|
input.skipNBytes(fullOffset - shortOffset - offsetBytes - 1);
|
||||||
input.skipNBytes(sectorSize*offset);
|
input.skipNBytes(sectorSize * offset);
|
||||||
|
|
||||||
LOG.info("Read {} sectors", sectorLength);
|
// LOG.info("Read {} sectors", sectorLength);
|
||||||
|
|
||||||
byte tempData[] = input.readNBytes(sectorSize*sectorLength);
|
byte tempData[] = input.readNBytes(sectorSize * sectorLength);
|
||||||
|
|
||||||
DataInputStream trueInput = new DataInputStream(
|
DataInputStream trueInput = new DataInputStream(
|
||||||
new InflaterInputStream(new BufferedInputStream(new ByteArrayInputStream(tempData))));
|
new InflaterInputStream(new BufferedInputStream(new ByteArrayInputStream(tempData)))
|
||||||
|
);
|
||||||
ChunkData chunk = ChunkIO.load(world, chunkPos, trueInput, IOContext.SAVE);
|
ChunkData chunk = ChunkIO.load(world, chunkPos, trueInput, IOContext.SAVE);
|
||||||
readGenerationHint(chunk, trueInput, server);
|
readGenerationHint(chunk, trueInput, server);
|
||||||
trueInput.close();
|
trueInput.close();
|
||||||
|
Reference in New Issue
Block a user