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

Function SlCalcTableHeader

src/saveload/saveload.cpp:1623–1644  ·  view source on GitHub ↗

* Calculate the size of the table header. * @param slt The SaveLoad table with objects to save/load. * @return size of given object. */

Source from the content-addressed store, hash-verified

1621 * @return size of given object.
1622 */
1623static size_t SlCalcTableHeader(const SaveLoadTable &slt)
1624{
1625 size_t length = 0;
1626
1627 for (auto &sld : slt) {
1628 if (!SlIsObjectValidInSavegame(sld)) continue;
1629
1630 length += SlCalcConvFileLen(SLE_UINT8);
1631 length += SlCalcStdStringLen(&sld.name);
1632 }
1633
1634 length += SlCalcConvFileLen(SLE_UINT8); // End-of-list entry.
1635
1636 for (auto &sld : slt) {
1637 if (!SlIsObjectValidInSavegame(sld)) continue;
1638 if (sld.cmd == SL_STRUCTLIST || sld.cmd == SL_STRUCT) {
1639 length += SlCalcTableHeader(sld.handler->GetDescription());
1640 }
1641 }
1642
1643 return length;
1644}
1645
1646/**
1647 * Calculate the size of an object.

Callers 1

SlTableHeaderFunction · 0.85

Calls 4

SlCalcConvFileLenFunction · 0.85
SlCalcStdStringLenFunction · 0.85
GetDescriptionMethod · 0.45

Tested by

no test coverage detected