* Calculate the size of the table header. * @param slt The SaveLoad table with objects to save/load. * @return size of given object. */
| 1621 | * @return size of given object. |
| 1622 | */ |
| 1623 | static 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. |
no test coverage detected