From 9dd945f17f89b751fad490687ecf76e9565d1be5 Mon Sep 17 00:00:00 2001 From: wootguy Date: Fri, 8 Nov 2024 17:56:28 -0800 Subject: [PATCH] use 64 bit values for bit writing --- dlls/mstream.cpp | 8 ++++---- dlls/mstream.h | 4 ++-- dlls/util.cpp | 8 +------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/dlls/mstream.cpp b/dlls/mstream.cpp index f23dfa65..43707167 100644 --- a/dlls/mstream.cpp +++ b/dlls/mstream.cpp @@ -60,13 +60,13 @@ uint32_t mstream::readBit() return (*((uint8_t*)pos) & (1 << currentBit++)) != 0; } -uint32_t mstream::readBits(uint8_t bitCount) +uint64_t mstream::readBits(uint8_t bitCount) { - uint32_t val = 0; + uint64_t val = 0; for (int i = 0; i < bitCount; i++) { // TODO: read a byte if position and bitcount allow - val |= readBit() << i; + val |= (uint64_t)readBit() << i; } return val; @@ -162,7 +162,7 @@ bool mstream::writeBit(bool value) { return 1; } -uint8_t mstream::writeBits(uint32_t value, uint8_t bitCount) { +uint8_t mstream::writeBits(uint64_t value, uint8_t bitCount) { for (int i = 0; i < bitCount; i++) { // TODO: write a byte if position and bitcount allow diff --git a/dlls/mstream.h b/dlls/mstream.h index 0c0cdb6a..a6a08ad9 100644 --- a/dlls/mstream.h +++ b/dlls/mstream.h @@ -26,7 +26,7 @@ class EXPORT mstream // returns 0-1 for bit that was read, or -1 for EOM uint32_t readBit(); - uint32_t readBits(uint8_t bitCount); + uint64_t readBits(uint8_t bitCount); Vector readBitVec3Coord(); @@ -43,7 +43,7 @@ class EXPORT mstream bool writeBit(bool value); // write bitCount bits from value. Returns bits written - uint8_t writeBits(uint32_t value, uint8_t bitCount); + uint8_t writeBits(uint64_t value, uint8_t bitCount); // write zeroes into the remaining bits at the current byte, then increment the position to the next byte // true if position was incremented diff --git a/dlls/util.cpp b/dlls/util.cpp index 733e0026..9fc9f029 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -2576,13 +2576,7 @@ const char* getPlayerUniqueId(edict_t* plr) { return "STEAM_ID_NULL"; } - const char* steamId = (*g_engfuncs.pfnGetPlayerAuthId)(plr); - - if (!strcmp(steamId, "STEAM_ID_LAN") || !strcmp(steamId, "BOT")) { - steamId = STRING(plr->v.netname); - } - - return steamId; + return g_engfuncs.pfnGetPlayerAuthId(plr); } uint64_t steamid_to_steamid64(const char* steamid) {