Skip to content

Commit e8dd71d

Browse files
committed
better debug logging + fix tracking crash
1 parent e3329f2 commit e8dd71d

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/main/java/me/cortex/voxy/client/core/rendering/hierachical/AsyncNodeManager.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,12 @@ public void submitRemoveBatch(MemoryBuffer batch) {//Only called from render thr
648648
public void addTopLevel(long section) {//Only called from render thread
649649
if (!this.running) throw new IllegalStateException("Not running");
650650
long stamp = this.tlnLock.writeLock();
651-
int state = this.tlnAdd.add(section)?1:0;
652-
state -= this.tlnRem.remove(section)?1:0;
651+
int state = 0;
652+
if (!this.tlnRem.remove(section)) {
653+
state += this.tlnAdd.add(section)?1:0;
654+
} else {
655+
state -= 1;
656+
}
653657
if (state != 0) {
654658
if (this.workCounter.getAndAdd(state) == 0) {
655659
LockSupport.unpark(this.thread);
@@ -661,8 +665,12 @@ public void addTopLevel(long section) {//Only called from render thread
661665
public void removeTopLevel(long section) {//Only called from render thread
662666
if (!this.running) throw new IllegalStateException("Not running");
663667
long stamp = this.tlnLock.writeLock();
664-
int state = this.tlnRem.add(section)?1:0;
665-
state -= this.tlnAdd.remove(section)?1:0;
668+
int state = 0;
669+
if (!this.tlnAdd.remove(section)) {
670+
state += this.tlnRem.add(section)?1:0;
671+
} else {
672+
state -= 1;
673+
}
666674
if (state != 0) {
667675
if (this.workCounter.getAndAdd(state) == 0) {
668676
LockSupport.unpark(this.thread);

src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void insertTopLevelNode(long pos) {
162162

163163
public void removeTopLevelNode(long pos) {
164164
if (!this.topLevelNodes.remove(pos)) {
165-
throw new IllegalStateException("Position not in top level map");
165+
throw new IllegalStateException("Position not in top level map: " + WorldEngine.pprintPos(pos));
166166
}
167167
int nodeId = this.activeSectionMap.get(pos);
168168
if (nodeId == -1) {

0 commit comments

Comments
 (0)