[ox/claw] Fix Claw read to check for type/version compatibility
This commit is contained in:
9
deps/ox/src/ox/claw/read.hpp
vendored
9
deps/ox/src/ox/claw/read.hpp
vendored
@@ -19,6 +19,9 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
constexpr auto Error_ClawTypeMismatch = 200;
|
||||
constexpr auto Error_ClawTypeVersionMismatch = 200;
|
||||
|
||||
struct ClawHeader {
|
||||
String typeName;
|
||||
int typeVersion = -1;
|
||||
@@ -38,6 +41,12 @@ Result<Buffer> stripClawHeader(const ox::Buffer &buff) noexcept;
|
||||
template<typename T>
|
||||
Error readClaw(const char *buff, std::size_t buffLen, T *val) {
|
||||
oxRequire(header, readClawHeader(buff, buffLen));
|
||||
if (header.typeName != getModelTypeName<T>()) {
|
||||
return OxError(Error_ClawTypeMismatch, "Claw Read: Type mismatch");
|
||||
}
|
||||
if (header.typeVersion != getModelTypeVersion<T>()) {
|
||||
return OxError(Error_ClawTypeVersionMismatch, "Claw Read: Type Verion mismatch");
|
||||
}
|
||||
switch (header.fmt) {
|
||||
case ClawFormat::Metal:
|
||||
{
|
||||
|
Reference in New Issue
Block a user