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

Function SlCalcConvFileLen

src/saveload/saveload.cpp:636–657  ·  view source on GitHub ↗

* Return the size in bytes of a certain type of normal/atomic variable * as it appears in a saved game. See VarTypes * @param conv VarType type of variable that is used for calculating the size * @return Return the size of this type in bytes */

Source from the content-addressed store, hash-verified

634 * @return Return the size of this type in bytes
635 */
636static inline uint8_t SlCalcConvFileLen(VarType conv)
637{
638 switch (GetVarFileType(conv)) {
639 case SLE_FILE_END: return 0;
640 case SLE_FILE_I8: return sizeof(int8_t);
641 case SLE_FILE_U8: return sizeof(uint8_t);
642 case SLE_FILE_I16: return sizeof(int16_t);
643 case SLE_FILE_U16: return sizeof(uint16_t);
644 case SLE_FILE_I32: return sizeof(int32_t);
645 case SLE_FILE_U32: return sizeof(uint32_t);
646 case SLE_FILE_I64: return sizeof(int64_t);
647 case SLE_FILE_U64: return sizeof(uint64_t);
648 case SLE_FILE_STRINGID: return sizeof(uint16_t);
649
650 case SLE_FILE_STRING:
651 return SlReadArrayLength();
652
653 case SLE_FILE_STRUCT:
654 default:
655 NOT_REACHED();
656 }
657}
658
659/** Return the size in bytes of a reference (pointer) */
660static inline size_t SlCalcRefLen()

Callers 7

SlCopyInternalFunction · 0.85
SlCopyFunction · 0.85
SlCalcArrayLenFunction · 0.85
SlCalcLenMethod · 0.85
SlCalcTableHeaderFunction · 0.85
SlCalcObjMemberLengthFunction · 0.85
SlObjectMemberFunction · 0.85

Calls 3

GetVarFileTypeFunction · 0.85
SlReadArrayLengthFunction · 0.85
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected