From fea8bf485c00463c5daffafcbc79ad632ade8b1b Mon Sep 17 00:00:00 2001 From: Jordan Cristiano Date: Wed, 24 Jun 2015 23:59:39 -0400 Subject: [PATCH] Implemented json write funcs for netmessages --- demboyz/netmessages/net_disconnect.cpp | 6 +++- demboyz/netmessages/net_file.cpp | 8 ++++- demboyz/netmessages/net_nop.cpp | 3 ++ demboyz/netmessages/net_setconvar.cpp | 14 ++++++++- demboyz/netmessages/net_signonstate.cpp | 7 ++++- demboyz/netmessages/net_stringcmd.cpp | 6 +++- demboyz/netmessages/net_tick.cpp | 8 ++++- demboyz/netmessages/nethandlers.h | 7 ++++- demboyz/netmessages/svc_bspdecal.cpp | 14 ++++++++- demboyz/netmessages/svc_classinfo.cpp | 18 ++++++++++- demboyz/netmessages/svc_createstringtable.cpp | 18 ++++++++++- demboyz/netmessages/svc_crosshairangle.cpp | 10 +++++- demboyz/netmessages/svc_entitymessage.cpp | 9 +++++- demboyz/netmessages/svc_fixangle.cpp | 11 ++++++- demboyz/netmessages/svc_gameevent.cpp | 7 ++++- demboyz/netmessages/svc_gameeventlist.cpp | 23 +++++++++++++- demboyz/netmessages/svc_getcvarvalue.cpp | 7 ++++- demboyz/netmessages/svc_menu.cpp | 8 ++++- demboyz/netmessages/svc_packetentities.cpp | 13 +++++++- demboyz/netmessages/svc_prefetch.cpp | 7 ++++- demboyz/netmessages/svc_print.cpp | 6 +++- demboyz/netmessages/svc_sendtable.cpp | 8 ++++- demboyz/netmessages/svc_serverinfo.cpp | 31 ++++++++++++++++++- demboyz/netmessages/svc_setpause.cpp | 6 +++- demboyz/netmessages/svc_setview.cpp | 6 +++- demboyz/netmessages/svc_sounds.cpp | 9 +++++- demboyz/netmessages/svc_tempentities.cpp | 8 ++++- demboyz/netmessages/svc_updatestringtable.cpp | 9 +++++- demboyz/netmessages/svc_usermessage.cpp | 8 ++++- demboyz/netmessages/svc_voicedata.cpp | 9 +++++- demboyz/netmessages/svc_voiceinit.cpp | 7 ++++- 31 files changed, 281 insertions(+), 30 deletions(-) diff --git a/demboyz/netmessages/net_disconnect.cpp b/demboyz/netmessages/net_disconnect.cpp index a66c97b..0379cd3 100644 --- a/demboyz/netmessages/net_disconnect.cpp +++ b/demboyz/netmessages/net_disconnect.cpp @@ -1,6 +1,7 @@ #include "net_disconnect.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -23,6 +24,9 @@ namespace NetHandlers bool Net_Disconnect_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_Disconnect* data) { + jsonbuf.StartObject("net_disconnect"); + jsonbuf.WriteString("message", data->message); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/net_file.cpp b/demboyz/netmessages/net_file.cpp index 22dec1e..df252d4 100644 --- a/demboyz/netmessages/net_file.cpp +++ b/demboyz/netmessages/net_file.cpp @@ -1,6 +1,7 @@ #include "net_file.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -27,6 +28,11 @@ namespace NetHandlers bool Net_File_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_File* data) { + jsonbuf.StartObject("net_file"); + jsonbuf.WriteUInt32("transferId", data->transferID); + jsonbuf.WriteString("filename", data->filename); + jsonbuf.WriteBool("isRequest", data->isRequest); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/net_nop.cpp b/demboyz/netmessages/net_nop.cpp index d86431d..55703e2 100644 --- a/demboyz/netmessages/net_nop.cpp +++ b/demboyz/netmessages/net_nop.cpp @@ -1,5 +1,6 @@ #include "net_nop.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -20,6 +21,8 @@ namespace NetHandlers bool Net_NOP_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_NOP* data) { + jsonbuf.StartObject("net_nop"); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/net_setconvar.cpp b/demboyz/netmessages/net_setconvar.cpp index 872a2cf..4891019 100644 --- a/demboyz/netmessages/net_setconvar.cpp +++ b/demboyz/netmessages/net_setconvar.cpp @@ -1,6 +1,7 @@ #include "net_setconvar.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -35,6 +36,17 @@ namespace NetHandlers bool Net_SetConVar_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_SetConVar* data) { + jsonbuf.StartObject("net_setconvar"); + jsonbuf.StartArray("cvars"); + for (cvar_t& cvar : data->cvars) + { + jsonbuf.StartObject(); + jsonbuf.WriteString("name", cvar.name); + jsonbuf.WriteString("value", cvar.value); + jsonbuf.EndObject(); + } + jsonbuf.EndArray(); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/net_signonstate.cpp b/demboyz/netmessages/net_signonstate.cpp index 2527382..e3557c0 100644 --- a/demboyz/netmessages/net_signonstate.cpp +++ b/demboyz/netmessages/net_signonstate.cpp @@ -1,6 +1,7 @@ #include "net_signonstate.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -26,6 +27,10 @@ namespace NetHandlers bool Net_SignonState_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_SignonState* data) { + jsonbuf.StartObject("net_signonstate"); + jsonbuf.WriteUInt32("signonState", data->signonState); + jsonbuf.WriteUInt32("spawnCount", data->spawnCount); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/net_stringcmd.cpp b/demboyz/netmessages/net_stringcmd.cpp index 6af9746..5c31f9b 100644 --- a/demboyz/netmessages/net_stringcmd.cpp +++ b/demboyz/netmessages/net_stringcmd.cpp @@ -1,6 +1,7 @@ #include "net_stringcmd.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -23,6 +24,9 @@ namespace NetHandlers bool Net_StringCmd_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_StringCmd* data) { + jsonbuf.StartObject("net_stringcmd"); + jsonbuf.WriteString("command", data->command); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/net_tick.cpp b/demboyz/netmessages/net_tick.cpp index 3c1d29d..31a220a 100644 --- a/demboyz/netmessages/net_tick.cpp +++ b/demboyz/netmessages/net_tick.cpp @@ -1,6 +1,7 @@ #include "net_tick.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -27,6 +28,11 @@ namespace NetHandlers bool Net_Tick_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::Net_Tick* data) { + jsonbuf.StartObject("net_tick"); + jsonbuf.WriteInt32("tick", data->tick); + jsonbuf.WriteUInt32("hostFrameTime", data->hostFrameTime); + jsonbuf.WriteUInt32("hostFrameTimeStdDev", data->hostFrameTimeStdDev); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/nethandlers.h b/demboyz/netmessages/nethandlers.h index 1c0dd99..2653c66 100644 --- a/demboyz/netmessages/nethandlers.h +++ b/demboyz/netmessages/nethandlers.h @@ -4,13 +4,18 @@ #include #include +namespace base +{ + class JsonWriterFile; +} + class bf_read; class bf_write; using BitRead = bf_read; using BitWrite = bf_write; class JsonRead; -class JsonWrite; +using JsonWrite = base::JsonWriterFile; struct SourceGameContext { diff --git a/demboyz/netmessages/svc_bspdecal.cpp b/demboyz/netmessages/svc_bspdecal.cpp index f4ed0ac..892ae72 100644 --- a/demboyz/netmessages/svc_bspdecal.cpp +++ b/demboyz/netmessages/svc_bspdecal.cpp @@ -1,6 +1,7 @@ #include "svc_bspdecal.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" namespace NetHandlers @@ -48,6 +49,17 @@ namespace NetHandlers bool SVC_BSPDecal_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_BSPDecal* data) { + jsonbuf.StartObject("svc_bspdecal"); + jsonbuf.StartObject("position"); + jsonbuf.WriteFloat("x", data->position.x); + jsonbuf.WriteFloat("y", data->position.y); + jsonbuf.WriteFloat("z", data->position.z); + jsonbuf.EndObject(); + jsonbuf.WriteUInt32("decalTextureIndex", data->decalTextureIndex); + jsonbuf.WriteUInt32("entIndex", data->entIndex); + jsonbuf.WriteUInt32("modelIndex", data->modelIndex); + jsonbuf.WriteBool("lowPriority", data->lowPriority); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_classinfo.cpp b/demboyz/netmessages/svc_classinfo.cpp index 4dccf8a..3ecdfb0 100644 --- a/demboyz/netmessages/svc_classinfo.cpp +++ b/demboyz/netmessages/svc_classinfo.cpp @@ -1,6 +1,7 @@ #include "svc_classinfo.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netmath.h" using class_t = NetMsg::SVC_ClassInfo::class_t; @@ -51,6 +52,21 @@ namespace NetHandlers bool SVC_ClassInfo_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_ClassInfo* data) { + jsonbuf.StartObject("svc_classinfo"); + jsonbuf.WriteInt32("numServerClasses", data->numServerClasses); + jsonbuf.WriteBool("createOnClient", data->createOnClient); + if (!data->createOnClient) + { + jsonbuf.StartArray("serverClasses"); + for (class_t& serverClass : data->serverClasses) + { + jsonbuf.WriteUInt32("classId", serverClass.classID); + jsonbuf.WriteString("className", serverClass.className); + jsonbuf.WriteString("dataTableName", serverClass.dataTableName); + } + jsonbuf.EndArray(); + } + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_createstringtable.cpp b/demboyz/netmessages/svc_createstringtable.cpp index c2e8462..411b806 100644 --- a/demboyz/netmessages/svc_createstringtable.cpp +++ b/demboyz/netmessages/svc_createstringtable.cpp @@ -1,6 +1,7 @@ #include "svc_createstringtable.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netmath.h" #include "netcontants.h" @@ -86,6 +87,21 @@ namespace NetHandlers bool SVC_CreateStringTable_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_CreateStringTable* data) { + jsonbuf.StartObject("svc_createstringtable"); + jsonbuf.WriteBool("isFilenames", data->isFileNames); + jsonbuf.WriteString("tableName", data->tableName); + jsonbuf.WriteUInt32("maxEntries", data->maxEntries); + jsonbuf.WriteUInt32("numEntries", data->numEntries); + jsonbuf.WriteInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBool("isUserDataFixedSize", data->isUserDataFixedSize); + jsonbuf.WriteUInt32("userDataSize", data->userDataSize); + jsonbuf.WriteUInt32("userDataSizeBits", data->userDataSizeBits); + if (context.protocol > 14) + { + jsonbuf.WriteBool("unk1", data->unk1); + } + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_crosshairangle.cpp b/demboyz/netmessages/svc_crosshairangle.cpp index 447616e..51e9368 100644 --- a/demboyz/netmessages/svc_crosshairangle.cpp +++ b/demboyz/netmessages/svc_crosshairangle.cpp @@ -1,6 +1,7 @@ #include "svc_crosshairangle.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include namespace NetHandlers @@ -28,6 +29,13 @@ namespace NetHandlers bool SVC_CrosshairAngle_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_CrosshairAngle* data) { + jsonbuf.StartObject("svc_crosshairangle"); + jsonbuf.StartObject("angle"); + jsonbuf.WriteFloat("pitch", data->x); + jsonbuf.WriteFloat("yaw", data->y); + jsonbuf.WriteFloat("roll", data->z); + jsonbuf.EndObject(); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_entitymessage.cpp b/demboyz/netmessages/svc_entitymessage.cpp index 2698acd..a89a66d 100644 --- a/demboyz/netmessages/svc_entitymessage.cpp +++ b/demboyz/netmessages/svc_entitymessage.cpp @@ -1,6 +1,7 @@ #include "svc_entitymessage.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" #include "netmath.h" @@ -32,6 +33,12 @@ namespace NetHandlers bool SVC_EntityMessage_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_EntityMessage* data) { + jsonbuf.StartObject("svc_entitymessage"); + jsonbuf.WriteUInt32("entIndex", data->entIndex); + jsonbuf.WriteUInt32("classId", data->classID); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_fixangle.cpp b/demboyz/netmessages/svc_fixangle.cpp index d534be3..0ec5ce2 100644 --- a/demboyz/netmessages/svc_fixangle.cpp +++ b/demboyz/netmessages/svc_fixangle.cpp @@ -1,6 +1,7 @@ #include "svc_fixangle.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include namespace NetHandlers @@ -30,6 +31,14 @@ namespace NetHandlers bool SVC_FixAngle_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_FixAngle* data) { + jsonbuf.StartObject("svc_fixangle"); + jsonbuf.WriteBool("relative", data->relative); + jsonbuf.StartObject("angle"); + jsonbuf.WriteFloat("pitch", data->x); + jsonbuf.WriteFloat("yaw", data->y); + jsonbuf.WriteFloat("roll", data->z); + jsonbuf.EndObject(); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_gameevent.cpp b/demboyz/netmessages/svc_gameevent.cpp index 8930de9..30a54b9 100644 --- a/demboyz/netmessages/svc_gameevent.cpp +++ b/demboyz/netmessages/svc_gameevent.cpp @@ -1,6 +1,7 @@ #include "svc_gameevent.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" #include "netmath.h" @@ -28,6 +29,10 @@ namespace NetHandlers bool SVC_GameEvent_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_GameEvent* data) { + jsonbuf.StartObject("svc_gameevent"); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_gameeventlist.cpp b/demboyz/netmessages/svc_gameeventlist.cpp index cb08e7c..a60c2de 100644 --- a/demboyz/netmessages/svc_gameeventlist.cpp +++ b/demboyz/netmessages/svc_gameeventlist.cpp @@ -1,6 +1,7 @@ #include "svc_gameeventlist.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" #include "netmath.h" @@ -53,6 +54,26 @@ namespace NetHandlers bool SVC_GameEventList_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_GameEventList* data) { + jsonbuf.StartObject("svc_gameeventlist"); + jsonbuf.StartArray("eventDescriptors"); + for (const EventDescriptor& event : data->eventDescriptors) + { + jsonbuf.StartObject(); + jsonbuf.WriteUInt32("id", event.id); + jsonbuf.WriteString("name", event.name); + jsonbuf.StartArray("values"); + for (const EventValue& value : event.values) + { + jsonbuf.StartObject(); + jsonbuf.WriteUInt32("type", value.type); + jsonbuf.WriteString("name", value.name); + jsonbuf.EndObject(); + } + jsonbuf.EndArray(); + jsonbuf.EndObject(); + } + jsonbuf.EndArray(); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_getcvarvalue.cpp b/demboyz/netmessages/svc_getcvarvalue.cpp index 3c62da0..c6b5302 100644 --- a/demboyz/netmessages/svc_getcvarvalue.cpp +++ b/demboyz/netmessages/svc_getcvarvalue.cpp @@ -1,6 +1,7 @@ #include "svc_getcvarvalue.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -25,6 +26,10 @@ namespace NetHandlers bool SVC_GetCvarValue_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_GetCvarValue* data) { + jsonbuf.StartObject("svc_getcvarvalue"); + jsonbuf.WriteInt32("cookie", data->cookie); + jsonbuf.WriteString("cvarName", data->cvarName); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_menu.cpp b/demboyz/netmessages/svc_menu.cpp index 5a1bee1..59aa3a3 100644 --- a/demboyz/netmessages/svc_menu.cpp +++ b/demboyz/netmessages/svc_menu.cpp @@ -1,6 +1,7 @@ #include "svc_menu.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" using DialogType = NetMsg::SVC_Menu::DialogType; @@ -41,6 +42,11 @@ namespace NetHandlers bool SVC_Menu_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Menu* data) { + jsonbuf.StartObject("svc_menu"); + jsonbuf.WriteInt32("dialogType", static_cast(data->type)); + jsonbuf.WriteUInt32("dataLengthInBytes", data->dataLengthInBytes); + jsonbuf.WriteBytes("data", data->menuBinaryKeyValues.get(), data->dataLengthInBytes); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_packetentities.cpp b/demboyz/netmessages/svc_packetentities.cpp index a2c3eb0..a8cdf5e 100644 --- a/demboyz/netmessages/svc_packetentities.cpp +++ b/demboyz/netmessages/svc_packetentities.cpp @@ -1,6 +1,7 @@ #include "svc_packetentities.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" #include "netmath.h" @@ -54,6 +55,16 @@ namespace NetHandlers bool SVC_PacketEntities_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_PacketEntities* data) { + jsonbuf.StartObject("svc_packetentities"); + jsonbuf.WriteInt32("maxEntries", data->maxEntries); + jsonbuf.WriteBool("isDelta", data->isDelta); + jsonbuf.WriteInt32("deltaFromTick", data->deltaFromTick); + jsonbuf.WriteUInt32("baselineIndex", data->baselineIndex); + jsonbuf.WriteUInt32("numUpdatedEntries", data->numUpdatedEntries); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBool("updateBaseline", data->updateBaseline); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_prefetch.cpp b/demboyz/netmessages/svc_prefetch.cpp index beafd47..e49b01f 100644 --- a/demboyz/netmessages/svc_prefetch.cpp +++ b/demboyz/netmessages/svc_prefetch.cpp @@ -1,6 +1,7 @@ #include "svc_prefetch.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" namespace NetHandlers @@ -39,6 +40,10 @@ namespace NetHandlers bool SVC_Prefetch_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Prefetch* data) { + jsonbuf.StartObject("svc_prefetch"); + jsonbuf.WriteUInt32("type", data->type); + jsonbuf.WriteUInt32("soundIndex", data->soundIndex); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_print.cpp b/demboyz/netmessages/svc_print.cpp index cfbb22e..38883ce 100644 --- a/demboyz/netmessages/svc_print.cpp +++ b/demboyz/netmessages/svc_print.cpp @@ -1,6 +1,7 @@ #include "svc_print.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -23,6 +24,9 @@ namespace NetHandlers bool SVC_Print_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Print* data) { + jsonbuf.StartObject("svc_print"); + jsonbuf.WriteString("text", data->text); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_sendtable.cpp b/demboyz/netmessages/svc_sendtable.cpp index 2f4a073..685ad9e 100644 --- a/demboyz/netmessages/svc_sendtable.cpp +++ b/demboyz/netmessages/svc_sendtable.cpp @@ -1,6 +1,7 @@ #include "svc_sendtable.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netmath.h" namespace NetHandlers @@ -29,6 +30,11 @@ namespace NetHandlers bool SVC_SendTable_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_SendTable* data) { + jsonbuf.StartObject("svc_sendtable"); + jsonbuf.WriteBool("needsDecoder", data->needsDecoder); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_serverinfo.cpp b/demboyz/netmessages/svc_serverinfo.cpp index 27d18e7..38ce54f 100644 --- a/demboyz/netmessages/svc_serverinfo.cpp +++ b/demboyz/netmessages/svc_serverinfo.cpp @@ -1,6 +1,7 @@ #include "svc_serverinfo.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -73,6 +74,34 @@ namespace NetHandlers bool SVC_ServerInfo_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_ServerInfo* data) { + jsonbuf.StartObject("svc_serverinfo"); + jsonbuf.WriteInt32("protocol", data->protocol); + jsonbuf.WriteUInt32("serverCount", data->serverCount); + jsonbuf.WriteBool("isHltv", data->isHLTV); + jsonbuf.WriteBool("isDedicated", data->isDedicated); + jsonbuf.WriteUInt32("clientCrc", data->clientCRC); + jsonbuf.WriteUInt32("maxClasses", data->maxClasses); + if (context.protocol <= 17) + { + jsonbuf.WriteUInt32("mapCRC", data->mapCRC); + } + else + { + jsonbuf.WriteBytes("unk1", data->unk1, sizeof(data->unk1)); + } + jsonbuf.WriteUInt32("playerSlot", data->playerSlot); + jsonbuf.WriteUInt32("maxClients", data->maxClients); + jsonbuf.WriteFloat("tickInterval", data->tickInterval); + jsonbuf.WriteString("os", &data->os, 1); + jsonbuf.WriteString("gameDir", data->gameDir); + jsonbuf.WriteString("mapName", data->mapName); + jsonbuf.WriteString("skyName", data->skyName); + jsonbuf.WriteString("hostName", data->hostName); + if (context.protocol > 15) + { + jsonbuf.WriteBool("unk2", data->unk2); + } + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_setpause.cpp b/demboyz/netmessages/svc_setpause.cpp index 881c6ad..a921036 100644 --- a/demboyz/netmessages/svc_setpause.cpp +++ b/demboyz/netmessages/svc_setpause.cpp @@ -1,6 +1,7 @@ #include "svc_setpause.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -23,6 +24,9 @@ namespace NetHandlers bool SVC_SetPause_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_SetPause* data) { + jsonbuf.StartObject("svc_setpause"); + jsonbuf.WriteBool("isPaused", data->isPaused); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_setview.cpp b/demboyz/netmessages/svc_setview.cpp index b3f48be..7c1d6c1 100644 --- a/demboyz/netmessages/svc_setview.cpp +++ b/demboyz/netmessages/svc_setview.cpp @@ -1,6 +1,7 @@ #include "svc_setview.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" namespace NetHandlers @@ -24,6 +25,9 @@ namespace NetHandlers bool SVC_SetView_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_SetView* data) { + jsonbuf.StartObject("svc_setview"); + jsonbuf.WriteUInt32("entIndex", data->entIndex); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_sounds.cpp b/demboyz/netmessages/svc_sounds.cpp index c883d37..39adb87 100644 --- a/demboyz/netmessages/svc_sounds.cpp +++ b/demboyz/netmessages/svc_sounds.cpp @@ -1,6 +1,7 @@ #include "svc_sounds.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netmath.h" namespace NetHandlers @@ -47,6 +48,12 @@ namespace NetHandlers bool SVC_Sounds_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_Sounds* data) { + jsonbuf.StartObject("svc_sounds"); + 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; } diff --git a/demboyz/netmessages/svc_tempentities.cpp b/demboyz/netmessages/svc_tempentities.cpp index 0ee23d1..0304f65 100644 --- a/demboyz/netmessages/svc_tempentities.cpp +++ b/demboyz/netmessages/svc_tempentities.cpp @@ -1,6 +1,7 @@ #include "svc_tempentities.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netcontants.h" #include "netmath.h" @@ -44,6 +45,11 @@ namespace NetHandlers bool SVC_TempEntities_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_TempEntities* data) { + jsonbuf.StartObject("svc_tempentities"); + jsonbuf.WriteUInt32("numEntries", data->numEntries); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_updatestringtable.cpp b/demboyz/netmessages/svc_updatestringtable.cpp index ade98f4..896374f 100644 --- a/demboyz/netmessages/svc_updatestringtable.cpp +++ b/demboyz/netmessages/svc_updatestringtable.cpp @@ -1,6 +1,7 @@ #include "svc_updatestringtable.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netmath.h" #include "netcontants.h" @@ -40,6 +41,12 @@ namespace NetHandlers bool SVC_UpdateStringTable_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_UpdateStringTable* data) { + jsonbuf.StartObject("svc_updatestringtable"); + jsonbuf.WriteUInt32("tableId", data->tableID); + jsonbuf.WriteUInt32("numChangedEntries", data->numChangedEntries); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_usermessage.cpp b/demboyz/netmessages/svc_usermessage.cpp index d6e92dd..28bfcbd 100644 --- a/demboyz/netmessages/svc_usermessage.cpp +++ b/demboyz/netmessages/svc_usermessage.cpp @@ -1,6 +1,7 @@ #include "svc_usermessage.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netmath.h" #include "netcontants.h" #include @@ -32,6 +33,11 @@ namespace NetHandlers bool SVC_UserMessage_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_UserMessage* data) { + jsonbuf.StartObject("svc_usermessage"); + jsonbuf.WriteUInt32("msgType", data->msgType); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_voicedata.cpp b/demboyz/netmessages/svc_voicedata.cpp index 57692c8..b22a3f9 100644 --- a/demboyz/netmessages/svc_voicedata.cpp +++ b/demboyz/netmessages/svc_voicedata.cpp @@ -1,6 +1,7 @@ #include "svc_voicedata.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" #include "netmath.h" namespace NetHandlers @@ -31,6 +32,12 @@ namespace NetHandlers bool SVC_VoiceData_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_VoiceData* data) { + jsonbuf.StartObject("svc_voicedata"); + jsonbuf.WriteUInt32("fromClientIndex", data->fromClientIndex); + jsonbuf.WriteBool("proximity", data->proximity); + jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits); + jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits); + jsonbuf.EndObject(); return true; } diff --git a/demboyz/netmessages/svc_voiceinit.cpp b/demboyz/netmessages/svc_voiceinit.cpp index 077a2ca..56759eb 100644 --- a/demboyz/netmessages/svc_voiceinit.cpp +++ b/demboyz/netmessages/svc_voiceinit.cpp @@ -1,6 +1,7 @@ #include "svc_voiceinit.h" -#include "sourcesdk/bitbuf.h" +#include "base/bitfile.h" +#include "base/jsonfile.h" namespace NetHandlers { @@ -25,6 +26,10 @@ namespace NetHandlers bool SVC_VoiceInit_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_VoiceInit* data) { + jsonbuf.StartObject("svc_voiceinit"); + jsonbuf.WriteString("voiceCodec", data->voiceCodec); + jsonbuf.WriteUInt32("quality", data->quality); + jsonbuf.EndObject(); return true; }