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

Method writeBits

Engine/source/core/stream/bitStream.cpp:226–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void BitStream::writeBits(S32 bitCount, const void *bitPtr)
227{
228 if(!bitCount)
229 return;
230
231 if((bitCount + bitNum) > maxWriteBitNum)
232 {
233 error = true;
234 AssertFatal(false, avar("BitStream::writeBits - Out of range write [(%i+%i)/%i]", bitCount, bitNum, maxWriteBitNum));
235 return;
236 }
237
238 // [tom, 8/17/2006] This is probably a lot lamer then it needs to be. However,
239 // at least it doesnt clobber data or overrun the buffer like the old code did.
240 const U8 *ptr = (U8 *)bitPtr;
241
242 for(S32 srcBitNum = 0;srcBitNum < bitCount;srcBitNum++)
243 {
244 if((*(ptr + (srcBitNum >> 3)) & (1 << (srcBitNum & 0x7))) != 0)
245 *(mDataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7));
246 else
247 *(mDataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));
248 bitNum++;
249 }
250}
251
252void BitStream::setBit(S32 bitCount, bool set)
253{

Callers 4

writeHuffBufferMethod · 0.45
packUpdateMethod · 0.45
repackClientDatablockMethod · 0.45
saveDatablockCacheMethod · 0.45

Calls 4

avarFunction · 0.85
writeFunction · 0.50
getSizeMethod · 0.45
getBitsMethod · 0.45

Tested by

no test coverage detected