MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / readBits

Method readBits

Engine/source/core/stream/bitStream.cpp:281–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281void BitStream::readBits(S32 bitCount, void *bitPtr)
282{
283 if(!bitCount)
284 return;
285 if(bitCount + bitNum > maxReadBitNum)
286 {
287 error = true;
288 //AssertFatal(false, "Out of range read");
289 AssertWarn(false, "Out of range read");
290 return;
291 }
292 U8 *stPtr = mDataPtr + (bitNum >> 3);
293 S32 byteCount = (bitCount + 7) >> 3;
294
295 U8 *ptr = (U8 *) bitPtr;
296
297 S32 downShift = bitNum & 0x7;
298 S32 upShift = 8 - downShift;
299
300 U8 curB = *stPtr;
301 const U8 *stEnd = mDataPtr + bufSize;
302 while(byteCount--)
303 {
304 stPtr++;
305 U8 nextB = stPtr < stEnd ? *stPtr : 0;
306 *ptr++ = (curB >> downShift) | (nextB << upShift);
307 curB = nextB;
308 }
309
310 bitNum += bitCount;
311}
312
313bool BitStream::_read(U32 size, void *dataPtr)
314{

Callers 2

unpackUpdateMethod · 0.80
repackClientDatablockMethod · 0.80

Calls 3

readFunction · 0.50
setSizeMethod · 0.45
getBitsMethod · 0.45

Tested by

no test coverage detected