Added json reader utilities and implemented json reader functions to dem, net, and svc types

This commit is contained in:
Jordan Cristiano
2015-07-13 23:25:49 -04:00
parent 6be95005c5
commit 0033d3aeba
46 changed files with 1012 additions and 154 deletions

View File

@ -28,17 +28,24 @@ namespace NetHandlers
bool SVC_UserMessage_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_UserMessage* data)
{
return true;
base::JsonReaderObject reader = jsonbuf.ParseObject();
assert(!reader.HasReadError());
data->msgType = reader.ReadUInt32("msgType");
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
return !reader.HasReadError();
}
bool SVC_UserMessage_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_UserMessage* data)
{
jsonbuf.StartObject("svc_usermessage");
jsonbuf.Reset();
jsonbuf.StartObject();
jsonbuf.WriteUInt32("msgType", data->msgType);
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
jsonbuf.EndObject();
return true;
return jsonbuf.IsComplete();
}
void SVC_UserMessage_ToString_Internal(std::ostringstream& out, NetMsg::SVC_UserMessage* data)