lib/nbt: Various minor fixes to get the program to compile properly
parent
68fbf3ae20
commit
396b9673fd
|
@ -463,7 +463,7 @@ namespace NBT {
|
|||
case TagType::DOUBLE:
|
||||
// type byte + name size + 8 data bytes -> 11 bytes
|
||||
return ErrorOr<uint64_t>((uint64_t) nameSize.value+11);
|
||||
case TagType::INT8_ARRAY:
|
||||
case TagType::INT8_ARRAY: {
|
||||
// type byte + name size + 4 size bytes -> 7 bytes
|
||||
uint64_t totalSize = (uint64_t) nameSize.value+7;
|
||||
|
||||
|
@ -475,7 +475,8 @@ namespace NBT {
|
|||
totalSize += (uint64_t) arraySize.value;
|
||||
|
||||
return ErrorOr<uint64_t>(totalSize);
|
||||
case TagType::STRING:
|
||||
}
|
||||
case TagType::STRING: {
|
||||
// type byte + name size + 2 size bytes -> 5 bytes
|
||||
uint64_t totalSize = (uint64_t) nameSize.value+5;
|
||||
|
||||
|
@ -487,7 +488,8 @@ namespace NBT {
|
|||
totalSize += (uint64_t) stringSize.value;
|
||||
|
||||
return ErrorOr<uint64_t>(totalSize);
|
||||
case TagType::LIST:
|
||||
}
|
||||
case TagType::LIST: {
|
||||
// type byte + name size + type prefix + 4 size bytes -> 8 bytes
|
||||
uint64_t totalSize = (uint64_t) nameSize.value+8;
|
||||
|
||||
|
@ -506,23 +508,30 @@ namespace NBT {
|
|||
switch (containedType.value) {
|
||||
case TagType::END:
|
||||
factor = 1;
|
||||
break;
|
||||
case TagType::INT8:
|
||||
factor = 1;
|
||||
break;
|
||||
case TagType::INT16:
|
||||
factor = 2;
|
||||
break;
|
||||
case TagType::INT32:
|
||||
factor = 4;
|
||||
break;
|
||||
case TagType::INT64:
|
||||
factor = 8;
|
||||
break;
|
||||
case TagType::FLOAT:
|
||||
factor = 4;
|
||||
break;
|
||||
case TagType::DOUBLE:
|
||||
factor = 8;
|
||||
break;
|
||||
default:
|
||||
// How would you even get here?
|
||||
return ErrorOr<uint64_t>(true, ErrorCodes::UNKNOWN);
|
||||
}
|
||||
totalSize += listSize*factor;
|
||||
totalSize += listSize.value*factor;
|
||||
return ErrorOr<uint64_t>(totalSize);
|
||||
} else {
|
||||
if (containedType.value == TagType::COMPOUND || containedType.value == TagType::LIST) return ErrorOr<uint64_t>(false, ErrorCodes::NOT_YET_KNOWN);
|
||||
|
@ -530,7 +539,8 @@ namespace NBT {
|
|||
}
|
||||
|
||||
return ErrorOr<uint64_t>(true, ErrorCodes::UNKNOWN);
|
||||
case TagType::INT32_ARRAY:
|
||||
}
|
||||
case TagType::INT32_ARRAY: {
|
||||
// type byte + name size + 4 size bytes -> 7 bytes
|
||||
uint64_t totalSize = (uint64_t) nameSize.value+7;
|
||||
|
||||
|
@ -542,7 +552,8 @@ namespace NBT {
|
|||
totalSize += (uint64_t) arraySize.value*4;
|
||||
|
||||
return ErrorOr<uint64_t>(totalSize);
|
||||
case TagType::INT64_ARRAY:
|
||||
}
|
||||
case TagType::INT64_ARRAY: {
|
||||
// type byte + name size + 4 size bytes -> 7 bytes
|
||||
uint64_t totalSize = (uint64_t) nameSize.value+7;
|
||||
|
||||
|
@ -554,6 +565,7 @@ namespace NBT {
|
|||
totalSize += (uint64_t) arraySize.value*8;
|
||||
|
||||
return ErrorOr<uint64_t>(totalSize);
|
||||
}
|
||||
// fall-through in case of unknown tag or parsing error
|
||||
default:
|
||||
return ErrorOr<uint64_t>(true, ErrorCodes::UNKNOWN);
|
||||
|
|
Loading…
Reference in New Issue