Fixed not copying trailing bits from dem_stringtables

This commit is contained in:
Jordan Cristiano 2015-06-29 23:31:06 -04:00
parent 65089f3585
commit cfc6498c25
2 changed files with 24 additions and 0 deletions

View File

@ -127,6 +127,15 @@ namespace DemHandlers
{
StringTable_BitRead(bitbuf, &table);
}
// copy trailing bits for binary completeness
const unsigned int numBitsLeft = bitbuf.GetNumBitsLeft();
assert(numBitsLeft < 8);
data->numTrailingBits = numBitsLeft;
if (numBitsLeft > 0)
{
data->trailingBitsValue = bitbuf.ReadUBitLong(numBitsLeft);
}
return !bitbuf.IsOverflowed();
}
@ -142,6 +151,10 @@ namespace DemHandlers
{
StringTable_BitWrite(bitbuf, &table);
}
if (data->numTrailingBits > 0)
{
bitbuf.WriteUBitLong(data->trailingBitsValue, data->numTrailingBits);
}
demofile.WriteRawData(bitbuf.GetBasePointer(), bitbuf.GetNumBytesWritten());
return !bitbuf.IsOverflowed();
}
@ -162,6 +175,15 @@ namespace DemHandlers
jsonbuf.EndObject();
}
jsonbuf.EndArray();
jsonbuf.WriteUInt32("numTrailingBits", data->numTrailingBits);
if (data->numTrailingBits > 0)
{
jsonbuf.WriteUInt32("trailingBitsValue", data->trailingBitsValue);
}
else
{
jsonbuf.WriteNull("trailingBitsValue");
}
return true;
}
}

View File

@ -27,6 +27,8 @@ namespace DemMsg
};
Array<StringTable> stringtables;
uint16_t numTrailingBits;
uint16_t trailingBitsValue;
};
}