From b0e55063842062fd207a80bbbde6f706cb91567d Mon Sep 17 00:00:00 2001 From: Jordan Cristiano Date: Thu, 25 Jun 2015 00:01:33 -0400 Subject: [PATCH] Added bit size calculation for svc_gameeventlist data --- demboyz/netmessages/svc_gameeventlist.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/demboyz/netmessages/svc_gameeventlist.cpp b/demboyz/netmessages/svc_gameeventlist.cpp index a60c2de..ac627a0 100644 --- a/demboyz/netmessages/svc_gameeventlist.cpp +++ b/demboyz/netmessages/svc_gameeventlist.cpp @@ -8,6 +8,25 @@ using EventDescriptor = NetMsg::SVC_GameEventList::EventDescriptor; using EventValue = NetMsg::SVC_GameEventList::EventValue; +uint32_t CalculateNumDataBits(const std::vector& eventDescriptors) +{ + uint32_t numBits = 0; + for (const EventDescriptor& event : eventDescriptors) + { + numBits += MAX_EVENT_BITS; + // +1 for null char + numBits += (8 * (1 + strlen(event.name))); + // +1 for null bits + numBits += (3 * (1 + event.values.size())); + for (const EventValue& value : event.values) + { + // +1 for null char + numBits += (8 * (1 + strlen(value.name))); + } + } + return numBits; +} + namespace NetHandlers { bool SVC_GameEventList_BitRead_Internal(BitRead& bitbuf, SourceGameContext& context, NetMsg::SVC_GameEventList* data)