Skip to content

Commit

Permalink
use 64 bit values for bit writing
Browse files Browse the repository at this point in the history
  • Loading branch information
wootguy committed Nov 9, 2024
1 parent 0e1b013 commit 9dd945f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
8 changes: 4 additions & 4 deletions dlls/mstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions dlls/mstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand Down
8 changes: 1 addition & 7 deletions dlls/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9dd945f

Please sign in to comment.