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

Function SlAutolength

src/saveload/saveload.cpp:2101–2123  ·  view source on GitHub ↗

* Do something of which I have no idea what it is :P * @param proc The callback procedure that is called * @param arg The variable that will be used for the callback procedure */

Source from the content-addressed store, hash-verified

2099 * @param arg The variable that will be used for the callback procedure
2100 */
2101void SlAutolength(AutolengthProc *proc, int arg)
2102{
2103 assert(_sl.action == SLA_SAVE);
2104
2105 /* Tell it to calculate the length */
2106 _sl.need_length = NL_CALCLENGTH;
2107 _sl.obj_len = 0;
2108 proc(arg);
2109
2110 /* Setup length */
2111 _sl.need_length = NL_WANTLENGTH;
2112 SlSetLength(_sl.obj_len);
2113
2114 size_t start_pos = _sl.dumper->GetSize();
2115 size_t expected_offs = start_pos + _sl.obj_len;
2116
2117 /* And write the stuff */
2118 proc(arg);
2119
2120 if (expected_offs != _sl.dumper->GetSize()) {
2121 SlErrorCorruptFmt("Invalid chunk size when writing autolength block, expected {}, got {}", _sl.obj_len, _sl.dumper->GetSize() - start_pos);
2122 }
2123}
2124
2125void ChunkHandler::LoadCheck(size_t len) const
2126{

Callers 2

SaveMethod · 0.85
SaveMethod · 0.85

Calls 3

SlSetLengthFunction · 0.85
SlErrorCorruptFmtFunction · 0.85
GetSizeMethod · 0.45

Tested by

no test coverage detected