Ensure not to update with an older block change entry. +comments.

This commit is contained in:
asofold 2016-11-25 21:08:01 +01:00
parent c477f1af72
commit 30979935ce
2 changed files with 21 additions and 9 deletions

View File

@ -1199,12 +1199,16 @@ public class MovingData extends ACheckData {
* @param to
*/
public void updateBlockChangeReference(final BlockChangeEntry entry, final RichBoundsLocation to) {
blockChangeRef.lastUsedEntry = entry; // Unchecked.
if (to.isBlockIntersecting(entry.x, entry.y, entry.z)) {
blockChangeRef.valid = true;
}
else {
blockChangeRef.valid = false;
// TODO: Move method to BlockChangeReference to keep things easy to overview for now.
// TODO: updateBlockChangeReference ... Span(entry, to !?)|Final()
if (blockChangeRef.lastUsedEntry == null || blockChangeRef.lastUsedEntry.id < entry.id) {
blockChangeRef.lastUsedEntry = entry; // Unchecked.
if (to.isBlockIntersecting(entry.x, entry.y, entry.z)) {
blockChangeRef.valid = true;
}
else {
blockChangeRef.valid = false;
}
}
}

View File

@ -198,7 +198,7 @@ public class BlockChangeTracker {
* Simple class for helping with query functionality. Reference a
* BlockChangeEntry and contain more information, such as validity for
* further use/effects. This is meant for storing the state of last-consumed
* ids for a context within some data.
* block change entries for a context within some data.
*
* @author asofold
*
@ -214,7 +214,13 @@ public class BlockChangeTracker {
/** Last used block change entry, highest id.*/
public BlockChangeEntry lastUsedEntry = null;
/** Indicate if the set id can still be used.*/
/**
* Indicate if the timing of the last entry is still regarded as valid.
*/
/*
* TODO: Subject to change, switching to tick rather than id (ids can be
* inverted, thus lock out paths).
*/
public boolean valid = false;
/**
@ -228,7 +234,9 @@ public class BlockChangeTracker {
* @return
*/
public boolean canUpdateWith(final BlockChangeEntry entry) {
return this.lastUsedEntry == null || entry.id > this.lastUsedEntry.id || entry.id == this.lastUsedEntry.id && valid;
// Love access methods: return this.lastUsedEntry == null || entry.id > this.lastUsedEntry.id || entry.id == this.lastUsedEntry.id && valid;
// TODO: There'll be a span perhaps.
return this.lastUsedEntry == null || entry.tick > this.lastUsedEntry.tick || entry.tick == this.lastUsedEntry.tick && valid;
}
/**