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

Method SlCalcLen

src/saveload/saveload.cpp:1361–1370  ·  view source on GitHub ↗

* Internal templated helper to return the size in bytes of a list-like type. * @param storage The storage to find the size of * @param conv VarType type of variable that is used for calculating the size * @param cmd The SaveLoadType ware are saving/loading. */

Source from the content-addressed store, hash-verified

1359 * @param cmd The SaveLoadType ware are saving/loading.
1360 */
1361 static size_t SlCalcLen(const void *storage, VarType conv, SaveLoadType cmd = SL_VAR)
1362 {
1363 assert(cmd == SL_VAR || cmd == SL_REF);
1364
1365 const SlStorageT *list = static_cast<const SlStorageT *>(storage);
1366
1367 int type_size = SlGetArrayLength(list->size());
1368 int item_size = SlCalcConvFileLen(cmd == SL_VAR ? conv : (VarType)SLE_FILE_U32);
1369 return list->size() * item_size + type_size;
1370 }
1371
1372 static void SlSaveLoadMember(SaveLoadType cmd, Tvar *item, VarType conv)
1373 {

Callers

nothing calls this directly

Calls 3

SlGetArrayLengthFunction · 0.85
SlCalcConvFileLenFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected