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

Function SlWriteSimpleGamma

src/saveload/saveload.cpp:512–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510 */
511
512static void SlWriteSimpleGamma(size_t i)
513{
514 if (i >= (1 << 7)) {
515 if (i >= (1 << 14)) {
516 if (i >= (1 << 21)) {
517 if (i >= (1 << 28)) {
518 assert(i <= UINT32_MAX); // We can only support 32 bits for now.
519 SlWriteByte((uint8_t)(0xF0));
520 SlWriteByte((uint8_t)(i >> 24));
521 } else {
522 SlWriteByte((uint8_t)(0xE0 | (i >> 24)));
523 }
524 SlWriteByte((uint8_t)(i >> 16));
525 } else {
526 SlWriteByte((uint8_t)(0xC0 | (i >> 16)));
527 }
528 SlWriteByte((uint8_t)(i >> 8));
529 } else {
530 SlWriteByte((uint8_t)(0x80 | (i >> 8)));
531 }
532 }
533 SlWriteByte((uint8_t)i);
534}
535
536/** Return how many bytes used to encode a gamma value */
537static inline uint SlGetGammaLength(size_t i)

Callers 2

SlWriteSparseIndexFunction · 0.85
SlWriteArrayLengthFunction · 0.85

Calls 1

SlWriteByteFunction · 0.85

Tested by

no test coverage detected