From 1ca5fbfd2ca0f261867cf66b87c7576fb5add355 Mon Sep 17 00:00:00 2001 From: Gabriel Huber Date: Mon, 25 Apr 2016 22:43:08 +0200 Subject: [PATCH 1/3] Simplified entryIndex assignment in StringTable_BitRead --- demboyz/netmessages/svc_createstringtable.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/demboyz/netmessages/svc_createstringtable.cpp b/demboyz/netmessages/svc_createstringtable.cpp index ec29c97..15ebb6f 100644 --- a/demboyz/netmessages/svc_createstringtable.cpp +++ b/demboyz/netmessages/svc_createstringtable.cpp @@ -21,16 +21,15 @@ static void StringTable_BitRead(NetHandlers::BitRead& bitbuf, SourceGameContext& { const size_t numEncodeBits = math::log2(data->maxEntries); std::vector history; - int lastEntry = -1; + int entryIndex = -1; for (uint i = 0; i < data->numEntries; ++i) { - int entryIndex = lastEntry + 1; + entryIndex++; if (bitbuf.ReadOneBit() == 0) { entryIndex = bitbuf.ReadUBitLong(numEncodeBits); } - lastEntry = entryIndex; const char *pEntry = NULL; char entry[1024]; From 3a36da8a82fa329c264c85f0b9aeef7e32fd996e Mon Sep 17 00:00:00 2001 From: Gabriel Huber Date: Mon, 25 Apr 2016 22:34:54 +0200 Subject: [PATCH 2/3] Removed unnecessary buffer zero assignment in StringTable_BitRead --- demboyz/netmessages/svc_createstringtable.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/demboyz/netmessages/svc_createstringtable.cpp b/demboyz/netmessages/svc_createstringtable.cpp index 15ebb6f..5d4baa6 100644 --- a/demboyz/netmessages/svc_createstringtable.cpp +++ b/demboyz/netmessages/svc_createstringtable.cpp @@ -61,8 +61,6 @@ static void StringTable_BitRead(NetHandlers::BitRead& bitbuf, SourceGameContext& { if (data->isUserDataFixedSize) { - nBytes = data->userDataSize; - tempbuf[nBytes - 1] = 0; bitbuf.ReadBits(tempbuf, data->userDataSizeBits); } else From 99426dc6ef1f9405ed369420c4e877abfc450871 Mon Sep 17 00:00:00 2001 From: Gabriel Huber Date: Tue, 26 Apr 2016 04:04:28 +0200 Subject: [PATCH 3/3] Changed scope of nBytes in StringTable_BitRead --- demboyz/netmessages/svc_createstringtable.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/demboyz/netmessages/svc_createstringtable.cpp b/demboyz/netmessages/svc_createstringtable.cpp index 5d4baa6..a577286 100644 --- a/demboyz/netmessages/svc_createstringtable.cpp +++ b/demboyz/netmessages/svc_createstringtable.cpp @@ -56,7 +56,6 @@ static void StringTable_BitRead(NetHandlers::BitRead& bitbuf, SourceGameContext& const int MAX_USERDATA_BITS = 14; unsigned char tempbuf[(1 << MAX_USERDATA_BITS)] = { 0 }; const void *pUserData = NULL; - int nBytes = 0; if (bitbuf.ReadOneBit() != 0) { if (data->isUserDataFixedSize) @@ -65,7 +64,7 @@ static void StringTable_BitRead(NetHandlers::BitRead& bitbuf, SourceGameContext& } else { - nBytes = bitbuf.ReadUBitLong(MAX_USERDATA_BITS); + int nBytes = bitbuf.ReadUBitLong(MAX_USERDATA_BITS); bitbuf.ReadBytes(tempbuf, nBytes); } pUserData = tempbuf;