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

@ -43,18 +43,26 @@ namespace NetHandlers
bool SVC_Sounds_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_Sounds* data)
{
return true;
base::JsonReaderObject reader = jsonbuf.ParseObject();
assert(!reader.HasReadError());
data->reliableSound = reader.ReadBool("reliableSound");
data->numSounds = reader.ReadUInt32("numSounds");
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_Sounds_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Sounds* data)
{
jsonbuf.StartObject("svc_sounds");
jsonbuf.Reset();
jsonbuf.StartObject();
jsonbuf.WriteBool("reliableSound", data->reliableSound);
jsonbuf.WriteUInt32("numSounds", data->numSounds);
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
jsonbuf.EndObject();
return true;
return jsonbuf.IsComplete();
}
void SVC_Sounds_ToString_Internal(std::ostringstream& out, NetMsg::SVC_Sounds* data)