Fixing bugs introduced in previous commit
- Fixed AbstractContextRO.isSubcontexting() - Fixed push(...) overrides in FilterServerContext - Fixed DefaultChunkLogic.tmp_generateTickLists() - Debug screen now also lists visible and loaded chunks - AbstractContextRO.Frame now has a toString()
This commit is contained in:
parent
0a45613e45
commit
a03c783fc9
@ -31,65 +31,71 @@ public abstract class AbstractContextRO<
|
||||
E extends EntityGeneric
|
||||
> implements TileGenericContextRO<B, T, E> {
|
||||
//@formatter:on
|
||||
|
||||
|
||||
public static final int MAX_SUBCONTEXTS = 64;
|
||||
|
||||
|
||||
protected class Frame {
|
||||
|
||||
|
||||
public final Vec3i location = new Vec3i();
|
||||
public RelFace face;
|
||||
public int layer;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Frame [x=" + location.x + ", y=" + location.y + ", z=" + location.z + ", face=" + face + ", layer="
|
||||
+ layer + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected Frame frame = null;
|
||||
|
||||
|
||||
private final StashingStack<Frame> frameStack = new StashingStack<>(MAX_SUBCONTEXTS, Frame::new);
|
||||
|
||||
|
||||
@Override
|
||||
public void pop() {
|
||||
if (!isSubcontexting()) {
|
||||
throw new IllegalStateException("Cannot pop(): already top frame");
|
||||
}
|
||||
|
||||
|
||||
frame = frameStack.pop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockGenericContextRO<B, T, E> push(Vec3i location) {
|
||||
frame = frameStack.push();
|
||||
|
||||
|
||||
frame.location.set(location.x, location.y, location.z);
|
||||
frame.face = null;
|
||||
frame.layer = -1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileStackGenericContextRO<B, T, E> push(Vec3i location, RelFace face) {
|
||||
frame = frameStack.push();
|
||||
|
||||
|
||||
frame.location.set(location.x, location.y, location.z);
|
||||
frame.face = face;
|
||||
frame.layer = -1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileGenericContextRO<B, T, E> push(Vec3i location, RelFace face, int layer) {
|
||||
frame = frameStack.push();
|
||||
|
||||
|
||||
frame.location.set(location.x, location.y, location.z);
|
||||
frame.face = face;
|
||||
frame.layer = layer;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSubcontexting() {
|
||||
return frameStack.isEmpty();
|
||||
return !frameStack.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class Server {
|
||||
*/
|
||||
public ServerWorldContext createContext() {
|
||||
|
||||
return new ReportingServerContext(DefaultServerContext.empty().inRealWorldOf(this).build()).withListener(worldAccessor);
|
||||
return new ReportingServerContext(DefaultServerContext.empty().inRealWorldOf(this).build()).withListener(worldAccessor).setPassToParent(false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -235,8 +235,10 @@ public class DefaultChunkLogic implements ChunkLogic {
|
||||
BlockLogic block = blockContext.logic().getBlock();
|
||||
Coordinates.convertInWorldToInChunk(location, blockInChunk);
|
||||
|
||||
if (!(block instanceof TickableBlock))
|
||||
if (!(block instanceof TickableBlock)) {
|
||||
blockContext.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (((TickableBlock) block).getTickingPolicy(blockContext) == TickingPolicy.REGULAR) {
|
||||
tickingBlocks.add(blockInChunk);
|
||||
@ -248,16 +250,17 @@ public class DefaultChunkLogic implements ChunkLogic {
|
||||
|
||||
for (int i = 0; i < stack.size(); ++i) {
|
||||
ServerTileContextRO tileContext = blockContext.push(face, i);
|
||||
|
||||
TileLogic tile = stack.get(i);
|
||||
|
||||
if (!(tile instanceof TickableTile))
|
||||
return;
|
||||
if (!(tile instanceof TickableTile)) {
|
||||
tileContext.pop();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((TickableTile) tile).getTickingPolicy(tileContext) == TickingPolicy.REGULAR) {
|
||||
tickingTiles.add(stack.getData().getReference(i));
|
||||
}
|
||||
|
||||
|
||||
tileContext.pop();
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class DefaultServerContextImpl extends DefaultServerContext
|
||||
*/
|
||||
public boolean requireContextRole(Role role) throws IllegalStateException {
|
||||
|
||||
boolean ok = !isBuilder && getRole().compareTo(role) <= 0;
|
||||
boolean ok = !isBuilder && getRole().compareTo(role) >= 0;
|
||||
if (!ok) {
|
||||
complainAboutIllegalState(role, false);
|
||||
}
|
||||
|
@ -179,17 +179,20 @@ public abstract class FilterServerContext implements ServerTileContext {
|
||||
|
||||
@Override
|
||||
public ServerBlockContext push(Vec3i location) {
|
||||
return parent.push(location);
|
||||
parent.push(location);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerTileStackContext push(Vec3i location, RelFace face) {
|
||||
return parent.push(location, face);
|
||||
parent.push(location, face);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerTileContext push(Vec3i location, RelFace face, int layer) {
|
||||
return parent.push(location, face, layer);
|
||||
parent.push(location, face, layer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,7 @@ import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical;
|
||||
import ru.windcorp.progressia.client.localization.Localizer;
|
||||
import ru.windcorp.progressia.client.localization.MutableString;
|
||||
import ru.windcorp.progressia.client.localization.MutableStringLocalized;
|
||||
import ru.windcorp.progressia.client.world.WorldRender;
|
||||
import ru.windcorp.progressia.common.Units;
|
||||
import ru.windcorp.progressia.common.util.dynstr.DynamicStrings;
|
||||
import ru.windcorp.progressia.server.Server;
|
||||
@ -128,14 +129,37 @@ public class LayerTestGUI extends GUILayer {
|
||||
128
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
group.addChild(
|
||||
new DynamicLabel(
|
||||
"ChunkUpdatesDisplay",
|
||||
"ChunkStatsDisplay",
|
||||
font,
|
||||
DynamicStrings.builder()
|
||||
.addDyn(new MutableStringLocalized("LayerTestGUI.ChunkUpdatesDisplay"))
|
||||
.addDyn(ClientState.getInstance().getWorld()::getPendingChunkUpdates)
|
||||
.addDyn(new MutableStringLocalized("LayerTestGUI.ChunkStatsDisplay"))
|
||||
.addDyn(() -> {
|
||||
if (ClientState.getInstance() == null) {
|
||||
return -1;
|
||||
} else {
|
||||
WorldRender world = ClientState.getInstance().getWorld();
|
||||
return world.getChunks().size() - world.getPendingChunkUpdates();
|
||||
}
|
||||
}, 4)
|
||||
.add('/')
|
||||
.addDyn(() -> {
|
||||
if (ClientState.getInstance() == null) {
|
||||
return -1;
|
||||
} else {
|
||||
return ClientState.getInstance().getWorld().getPendingChunkUpdates();
|
||||
}
|
||||
}, 4)
|
||||
.add('/')
|
||||
.addDyn(() -> {
|
||||
if (ServerState.getInstance() == null) {
|
||||
return -1;
|
||||
} else {
|
||||
return ServerState.getInstance().getWorld().getChunks().size();
|
||||
}
|
||||
}, 4)
|
||||
.buildSupplier(),
|
||||
128
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ LayerTestGUI.LanguageDisplay = Language: %5s (L)
|
||||
LayerTestGUI.FPSDisplay = FPS:
|
||||
LayerTestGUI.TPSDisplay = TPS:
|
||||
LayerTestGUI.TPSDisplay.NA = TPS: n/a
|
||||
LayerTestGUI.ChunkUpdatesDisplay = Pending updates:
|
||||
LayerTestGUI.ChunkStatsDisplay = Chunks vis/pnd/load:
|
||||
LayerTestGUI.PosDisplay = Pos:
|
||||
LayerTestGUI.PosDisplay.NA.Client = Pos: client n/a
|
||||
LayerTestGUI.PosDisplay.NA.Entity = Pos: entity n/a
|
||||
|
@ -11,7 +11,7 @@ LayerTestGUI.LanguageDisplay = Язык: %5s (L)
|
||||
LayerTestGUI.FPSDisplay = FPS:
|
||||
LayerTestGUI.TPSDisplay = TPS:
|
||||
LayerTestGUI.TPSDisplay.NA = TPS: н/д
|
||||
LayerTestGUI.ChunkUpdatesDisplay = Обновления в очереди:
|
||||
LayerTestGUI.ChunkStatsDisplay = Чанки вид/очр/загр:
|
||||
LayerTestGUI.PosDisplay = Поз:
|
||||
LayerTestGUI.PosDisplay.NA.Client = Поз: клиент н/д
|
||||
LayerTestGUI.PosDisplay.NA.Entity = Поз: сущность н/д
|
||||
|
Reference in New Issue
Block a user