MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SlReadSimpleGamma

Function SlReadSimpleGamma

src/saveload/saveload.cpp:470–493  ·  view source on GitHub ↗

* Read in the header descriptor of an object or an array. * If the highest bit is set (7), then the index is bigger than 127 * elements, so use the next byte to read in the real value. * The actual value is then both bytes added with the first shifted * 8 bits to the left, and dropping the highest bit (which only indicated a big index). * x = ((x & 0x7F) << 8) + SlReadByte(); * @return Retur

Source from the content-addressed store, hash-verified

468 * @return Return the value of the index
469 */
470static uint SlReadSimpleGamma()
471{
472 uint i = SlReadByte();
473 if (HasBit(i, 7)) {
474 i &= ~0x80;
475 if (HasBit(i, 6)) {
476 i &= ~0x40;
477 if (HasBit(i, 5)) {
478 i &= ~0x20;
479 if (HasBit(i, 4)) {
480 i &= ~0x10;
481 if (HasBit(i, 3)) {
482 SlErrorCorrupt("Unsupported gamma");
483 }
484 i = SlReadByte(); // 32 bits only.
485 }
486 i = (i << 8) | SlReadByte();
487 }
488 i = (i << 8) | SlReadByte();
489 }
490 i = (i << 8) | SlReadByte();
491 }
492 return i;
493}
494
495/**
496 * Write the header descriptor of an object or an array.

Callers 2

SlReadSparseIndexFunction · 0.85
SlReadArrayLengthFunction · 0.85

Calls 3

SlReadByteFunction · 0.85
HasBitFunction · 0.85
SlErrorCorruptFunction · 0.85

Tested by

no test coverage detected