[ox] Fix MC negative int encoding and bump MC version to 2

This commit is contained in:
2022-03-03 01:25:54 -06:00
parent bd2dd3f000
commit 6cebe52904
9 changed files with 126 additions and 68 deletions

View File

@@ -41,7 +41,7 @@ Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcep
buffLen -= s3Size + 1;
ClawHeader hdr;
if (fmt == "M1") {
if (fmt == "M2") {
hdr.fmt = ClawFormat::Metal;
} else if (fmt == "O1") {
hdr.fmt = ClawFormat::Organic;

View File

@@ -45,7 +45,6 @@ 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) {

View File

@@ -116,7 +116,7 @@ std::map<std::string_view, ox::Error(*)()> tests = {
{
"ClawHeaderReader2",
[] {
ox::String hdr = "M1;com.drinkingtea.ox.claw.test.Header2;3;";
ox::String hdr = "M2;com.drinkingtea.ox.claw.test.Header2;3;";
auto [ch, err] = ox::readClawHeader(hdr.c_str(), hdr.len() + 1);
oxAssert(err, "Error parsing header");
oxAssert(ch.fmt == ox::ClawFormat::Metal, "Format wrong");

View File

@@ -62,7 +62,7 @@ Result<String> writeClawHeader(T *t, ClawFormat fmt) noexcept {
String out;
switch (fmt) {
case ClawFormat::Metal:
out += "M1;";
out += "M2;";
break;
case ClawFormat::Organic:
out += "O1;";