MCPcopy Create free account
hub / github.com/assaultcube/AC / getbits

Method getbits

source/src/tools.h:288–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286 bitbuf(T &oq) : q(oq), blen(0) {}
287
288 int getbits(int n)
289 {
290 int res = 0, p = 0;
291 while(n > 0)
292 {
293 if(!blen) q.get();
294 int r = 8 - blen;
295 if(r > n) r = n;
296 res |= ((q.buf[q.len - 1] >> blen) & ((1 << r) - 1)) << p;
297 n -= r; p += r;
298 blen = (blen + r) % 8;
299 }
300 return res;
301 }
302
303 void putbits(int n, int v)
304 {

Callers 2

parsepositionsFunction · 0.80
processFunction · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected