lib/nbt: Change behavior of totalTagSize to treat encounters of compounds and lists as errors
I stumbled over this when writing the unit test. Previously, it would return an error code but explicitly mark it as not being an error. This was intended behavior but I decided to change it because I didn’t anticipate it when writing the test. Technically `ErrorOr<T>` can be used to pass any message alongside `T`, but practically, it is reasonable to assume that the error code is `ErrorCodes::SUCCESS` when `isError` is false. Therefore, this feature should be really only used in the weirdest edge cases - if at all. Even then, it is most likely still preferable to flag it as an error and just hand the resulting `T` back using the long constructor `ErrorOr<T>(bool, uint8_t, T)`.BodgeMaster-unfinished
parent
149285c357
commit
acc19ae100
|
@ -395,8 +395,8 @@ namespace NBT {
|
||||||
} else {
|
} else {
|
||||||
nextTag = data[currentPosition];
|
nextTag = data[currentPosition];
|
||||||
}
|
}
|
||||||
// deal with compound tags separately
|
// deal with compound tags and lists separately
|
||||||
if (nextTag == TagType::COMPOUND || nextTag == TagType::LIST) return ErrorOr<uint64_t>(false, ErrorCodes::NOT_YET_KNOWN);
|
if (nextTag == TagType::COMPOUND || nextTag == TagType::LIST) return ErrorOr<uint64_t>(true, ErrorCodes::NOT_YET_KNOWN);
|
||||||
// deal with end tag before trying to access the name
|
// deal with end tag before trying to access the name
|
||||||
if (nextTag == TagType::END) return ErrorOr<uint64_t>(1);
|
if (nextTag == TagType::END) return ErrorOr<uint64_t>(1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue