mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
WIP on making NBT tag parsing soft instead of hard error when encountering unexpected tag type, begins to address #966
This commit is contained in:
parent
1787c92ca5
commit
7366c9a749
@ -115,5 +115,10 @@ enum CC_ERRORS {
|
|||||||
ERR_NO_AUDIO_OUTPUT = 0xCCDED05DUL, /* No audio output devices are connected */
|
ERR_NO_AUDIO_OUTPUT = 0xCCDED05DUL, /* No audio output devices are connected */
|
||||||
ERR_INVALID_DATA_URL = 0xCCDED05EUL, /* Invalid URL provided to download from */
|
ERR_INVALID_DATA_URL = 0xCCDED05EUL, /* Invalid URL provided to download from */
|
||||||
ERR_INVALID_OPEN_URL = 0xCCDED05FUL, /* Invalid URL provided to open in new tab */
|
ERR_INVALID_OPEN_URL = 0xCCDED05FUL, /* Invalid URL provided to open in new tab */
|
||||||
|
|
||||||
|
NBT_ERR_EXPECTED_I8 = 0xCCDED060UL, /* Expected I8 NBT tag */
|
||||||
|
NBT_ERR_EXPECTED_I16 = 0xCCDED061UL, /* Expected I16 NBT tag */
|
||||||
|
NBT_ERR_EXPECTED_I32 = 0xCCDED062UL, /* Expected I32 NBT tag */
|
||||||
|
NBT_ERR_EXPECTED_F32 = 0xCCDED063UL, /* Expected F32 NBT tag */
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -330,28 +330,38 @@ struct NbtTag {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static cc_uint8 NbtTag_U8(struct NbtTag* tag) {
|
static cc_uint8 NbtTag_U8(struct NbtTag* tag) {
|
||||||
if (tag->type != NBT_I8) Logger_Abort("Expected I8 NBT tag");
|
if (tag->type == NBT_I8) return tag->value.u8;
|
||||||
return tag->value.u8;
|
|
||||||
|
tag->result = NBT_ERR_EXPECTED_I8;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_int16 NbtTag_I16(struct NbtTag* tag) {
|
static cc_int16 NbtTag_I16(struct NbtTag* tag) {
|
||||||
if (tag->type != NBT_I16) Logger_Abort("Expected I16 NBT tag");
|
if (tag->type == NBT_I16) return tag->value.i16;
|
||||||
return tag->value.i16;
|
|
||||||
|
tag->result = NBT_ERR_EXPECTED_I16;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_uint16 NbtTag_U16(struct NbtTag* tag) {
|
static cc_uint16 NbtTag_U16(struct NbtTag* tag) {
|
||||||
if (tag->type != NBT_I16) Logger_Abort("Expected I16 NBT tag");
|
if (tag->type == NBT_I16) return tag->value.u16;
|
||||||
return tag->value.u16;
|
|
||||||
|
tag->result = NBT_ERR_EXPECTED_I16;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int NbtTag_I32(struct NbtTag* tag) {
|
static int NbtTag_I32(struct NbtTag* tag) {
|
||||||
if (tag->type != NBT_I32) Logger_Abort("Expected I32 NBT tag");
|
if (tag->type == NBT_I32) return tag->value.i32;
|
||||||
return tag->value.i32;
|
|
||||||
|
tag->result = NBT_ERR_EXPECTED_I32;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float NbtTag_F32(struct NbtTag* tag) {
|
static float NbtTag_F32(struct NbtTag* tag) {
|
||||||
if (tag->type != NBT_F32) Logger_Abort("Expected F32 NBT tag");
|
if (tag->type == NBT_F32) return tag->value.f32;
|
||||||
return tag->value.f32;
|
|
||||||
|
tag->result = NBT_ERR_EXPECTED_F32;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_uint8* NbtTag_U8_Array(struct NbtTag* tag, int minSize) {
|
static cc_uint8* NbtTag_U8_Array(struct NbtTag* tag, int minSize) {
|
||||||
|
@ -84,6 +84,11 @@ static const char* GetCCErrorDesc(cc_result res) {
|
|||||||
case ERR_NO_AUDIO_OUTPUT: return "No audio output devices plugged in";
|
case ERR_NO_AUDIO_OUTPUT: return "No audio output devices plugged in";
|
||||||
case ERR_INVALID_DATA_URL: return "Cannot download from invalid URL";
|
case ERR_INVALID_DATA_URL: return "Cannot download from invalid URL";
|
||||||
case ERR_INVALID_OPEN_URL: return "Cannot navigate to invalid URL";
|
case ERR_INVALID_OPEN_URL: return "Cannot navigate to invalid URL";
|
||||||
|
|
||||||
|
case NBT_ERR_EXPECTED_I8: return "Expected I8 NBT tag";
|
||||||
|
case NBT_ERR_EXPECTED_I16: return "Expected I16 NBT tag";
|
||||||
|
case NBT_ERR_EXPECTED_I32: return "Expected I32 NBT tag";
|
||||||
|
case NBT_ERR_EXPECTED_F32: return "Expected F32 NBT tag";
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user