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

Function SlSaveLoadRef

src/saveload/saveload.cpp:1328–1346  ·  view source on GitHub ↗

* Handle conversion for references. * @param ptr The object being filled/read. * @param conv VarType type of the current element of the struct. */

Source from the content-addressed store, hash-verified

1326 * @param conv VarType type of the current element of the struct.
1327 */
1328void SlSaveLoadRef(void *ptr, VarType conv)
1329{
1330 switch (_sl.action) {
1331 case SLA_SAVE:
1332 SlWriteUint32((uint32_t)ReferenceToInt(*(void **)ptr, (SLRefType)conv));
1333 break;
1334 case SLA_LOAD_CHECK:
1335 case SLA_LOAD:
1336 *(size_t *)ptr = IsSavegameVersionBefore(SLV_69) ? SlReadUint16() : SlReadUint32();
1337 break;
1338 case SLA_PTRS:
1339 *(void **)ptr = IntToReference(*(size_t *)ptr, (SLRefType)conv);
1340 break;
1341 case SLA_NULL:
1342 *(void **)ptr = nullptr;
1343 break;
1344 default: NOT_REACHED();
1345 }
1346}
1347
1348/**
1349 * Template class to help with list-like types.

Callers 2

SlSaveLoadMemberMethod · 0.85
SlObjectMemberFunction · 0.85

Calls 7

SlWriteUint32Function · 0.85
ReferenceToIntFunction · 0.85
IsSavegameVersionBeforeFunction · 0.85
SlReadUint16Function · 0.85
SlReadUint32Function · 0.85
IntToReferenceFunction · 0.85
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected