mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-19 06:45:46 +01:00
Compare commits
13 Commits
d70888f9fb
...
2cafddc2b3
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cafddc2b3 | |||
| 96817cd061 | |||
| d561588490 | |||
| 3078a9fb5c | |||
| 16f74a91c1 | |||
| cc445442c6 | |||
| 8cc2e21088 | |||
| 3a5dac150c | |||
| dd96178c7a | |||
| b8159c92df | |||
| 6dfcb2b5b9 | |||
| 54e4bf45f9 | |||
| 1fb878b5ae |
@@ -24,18 +24,18 @@ static const u8 *nbt_proctag(const u8 *restrict buf, u16 slen) {
|
||||
// integral types
|
||||
case NBT_I8: *dat = *ptr; return ptr;
|
||||
case NBT_I16: *(u16 *)dat = be16toh(*(u16 *)ptr); return ptr + 2;
|
||||
case NBT_I32: // fall through
|
||||
case NBT_I32: __attribute__((fallthrough));
|
||||
case NBT_F32: *(u32 *)dat = be16toh(*(u32 *)ptr); return ptr + 4;
|
||||
case NBT_I64: // fall through
|
||||
case NBT_I64: __attribute__((fallthrough));
|
||||
case NBT_F64: *(u64 *)dat = be16toh(*(u64 *)ptr); return ptr + 8;
|
||||
|
||||
// arrays, handled differently
|
||||
case NBT_LIST:
|
||||
case NBT_ARR_I8:
|
||||
case NBT_STR:
|
||||
case NBT_ARR_I32:
|
||||
case NBT_LIST: __attribute__((fallthrough));
|
||||
case NBT_ARR_I8: __attribute__((fallthrough));
|
||||
case NBT_STR: __attribute__((fallthrough));
|
||||
case NBT_ARR_I32: __attribute__((fallthrough));
|
||||
case NBT_ARR_I64:
|
||||
// TODO: arrlen = nbt_arrbsize(ptr);
|
||||
// arrlen = nbt_arrbsize(ptr);
|
||||
break;
|
||||
|
||||
default: return NULL;
|
||||
@@ -100,26 +100,24 @@ int nbt_primsize(u8 tag) {
|
||||
switch (tag) {
|
||||
case NBT_I8: return 1;
|
||||
case NBT_I16: return 2;
|
||||
case NBT_I32: // fall through
|
||||
case NBT_I32: __attribute__((fallthrough));
|
||||
case NBT_F32: return 4;
|
||||
case NBT_I64: // fall through
|
||||
case NBT_I64: __attribute__((fallthrough));
|
||||
case NBT_F64: return 8;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
size_t nbt_tagdatlen(const u8 *restrict buf) {
|
||||
size_t mems = 0;
|
||||
i32 mems = 0;
|
||||
|
||||
switch (*buf) {
|
||||
case NBT_I8:
|
||||
case NBT_I16:
|
||||
case NBT_I32:
|
||||
case NBT_F32:
|
||||
case NBT_I64:
|
||||
case NBT_F64:
|
||||
mems = nbt_primsize(*buf);
|
||||
return -(mems >= 0) & mems;
|
||||
case NBT_I8: __attribute__((fallthrough));
|
||||
case NBT_I16: __attribute__((fallthrough));
|
||||
case NBT_I32: __attribute__((fallthrough));
|
||||
case NBT_F32: __attribute__((fallthrough));
|
||||
case NBT_I64: __attribute__((fallthrough));
|
||||
case NBT_F64: __attribute__((fallthrough));
|
||||
|
||||
case NBT_ARR_I64: mems += sizeof(i64) - sizeof(i32); __attribute__((fallthrough));
|
||||
case NBT_ARR_I32: mems += sizeof(i32) - sizeof(i8); __attribute__((fallthrough));
|
||||
@@ -137,11 +135,11 @@ size_t nbt_tagdatlen(const u8 *restrict buf) {
|
||||
|
||||
int nbt_isprim(u8 tag) {
|
||||
switch (tag) {
|
||||
case NBT_I8:
|
||||
case NBT_I16:
|
||||
case NBT_I32:
|
||||
case NBT_F32:
|
||||
case NBT_I64:
|
||||
case NBT_I8: __attribute__((fallthrough));
|
||||
case NBT_I16: __attribute__((fallthrough));
|
||||
case NBT_I32: __attribute__((fallthrough));
|
||||
case NBT_F32: __attribute__((fallthrough));
|
||||
case NBT_I64: __attribute__((fallthrough));
|
||||
case NBT_F64:
|
||||
return 1;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user