[ox] Make model TypeVersion mandatory so Claw can do version checking
This commit is contained in:
1
deps/ox/src/ox/claw/read.hpp
vendored
1
deps/ox/src/ox/claw/read.hpp
vendored
@@ -45,6 +45,7 @@ Error readClaw(const char *buff, std::size_t buffLen, T *val) {
|
||||
return OxError(Error_ClawTypeMismatch, "Claw Read: Type mismatch");
|
||||
}
|
||||
if (header.typeVersion != getModelTypeVersion<T>()) {
|
||||
oxDebugf("version: {}, {}", header.typeVersion, getModelTypeVersion<T>());
|
||||
return OxError(Error_ClawTypeVersionMismatch, "Claw Read: Type Version mismatch");
|
||||
}
|
||||
switch (header.fmt) {
|
||||
|
6
deps/ox/src/ox/claw/test/tests.cpp
vendored
6
deps/ox/src/ox/claw/test/tests.cpp
vendored
@@ -22,7 +22,7 @@
|
||||
|
||||
union TestUnion {
|
||||
static constexpr auto TypeName = "TestUnion";
|
||||
static constexpr auto Fields = 3;
|
||||
static constexpr auto TypeVersion = 1;
|
||||
bool Bool;
|
||||
uint32_t Int = 5;
|
||||
char String[32];
|
||||
@@ -30,7 +30,7 @@ union TestUnion {
|
||||
|
||||
struct TestStructNest {
|
||||
static constexpr auto TypeName = "TestStructNest";
|
||||
static constexpr auto Fields = 3;
|
||||
static constexpr auto TypeVersion = 1;
|
||||
bool Bool = false;
|
||||
uint32_t Int = 0;
|
||||
ox::BString<32> String = "";
|
||||
@@ -38,7 +38,7 @@ struct TestStructNest {
|
||||
|
||||
struct TestStruct {
|
||||
static constexpr auto TypeName = "TestStruct";
|
||||
static constexpr auto Fields = 16;
|
||||
static constexpr auto TypeVersion = 1;
|
||||
bool Bool = false;
|
||||
int32_t Int = 0;
|
||||
int32_t Int1 = 0;
|
||||
|
2
deps/ox/src/ox/claw/write.hpp
vendored
2
deps/ox/src/ox/claw/write.hpp
vendored
@@ -26,7 +26,7 @@ struct TypeInfoCatcher {
|
||||
const char *name = nullptr;
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int = T::Fields) noexcept {
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int = T::TypeVersion) noexcept {
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user