Fix ChunkEntity.isMoreRecentThan() if both chunks linked to last forward

Imagine scenario:

[this] -> [chunkToCheck] -> [lastForwardChunk]

Then, both `isLastForward` checks will not return, and also the `chunkToCheck.doesNextChunksVerifyCondition { it == this }` will return false.
Since both chunks are connected to the last forward chunk, `isMoreRecent()` will still return `true`, which is wrong in this case.
So do not only check if chunkToCheck has this as any of the next chunks, but also the other way round.
This commit is contained in:
SpiritCroc 2022-03-11 11:22:26 +01:00
parent 0564942b0c
commit 6ba02629ec

View File

@ -223,6 +223,9 @@ internal fun ChunkEntity.isMoreRecentThan(chunkToCheck: ChunkEntity): Boolean {
if (chunkToCheck.doesNextChunksVerifyCondition { it == this }) { if (chunkToCheck.doesNextChunksVerifyCondition { it == this }) {
return true return true
} }
if (this.doesNextChunksVerifyCondition { it == chunkToCheck }) {
return false
}
// Otherwise check if this chunk is linked to last forward // Otherwise check if this chunk is linked to last forward
if (this.doesNextChunksVerifyCondition { it.isLastForward }) { if (this.doesNextChunksVerifyCondition { it.isLastForward }) {
return true return true