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

Function LoadTTDPatchExtraChunks

src/saveload/oldloader_sl.cpp:1565–1619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1563}
1564
1565static bool LoadTTDPatchExtraChunks(LoadgameState &ls, int)
1566{
1567 ReadTTDPatchFlags(ls);
1568
1569 Debug(oldloader, 2, "Found {} extra chunk(s)", _old_extra_chunk_nums);
1570
1571 for (int i = 0; i != _old_extra_chunk_nums; i++) {
1572 uint16_t id = ReadUint16(ls);
1573 uint32_t len = ReadUint32(ls);
1574
1575 switch (id) {
1576 /* List of GRFIDs, used in the savegame. 0x8004 is the new ID
1577 * They are saved in a 'GRFID:4 active:1' format, 5 bytes for each entry */
1578 case 0x2:
1579 case 0x8004: {
1580 /* Skip the first element: TTDP hack for the Action D special variables (FFFF0000 01) */
1581 ReadUint32(ls); ReadByte(ls); len -= 5;
1582
1583 ClearGRFConfigList(_grfconfig);
1584 while (len != 0) {
1585 uint32_t grfid = ReadUint32(ls);
1586
1587 if (ReadByte(ls) == 1) {
1588 auto c = std::make_unique<GRFConfig>("TTDP game, no information");
1589 c->ident.grfid = grfid;
1590
1591 Debug(oldloader, 3, "TTDPatch game using GRF file with GRFID {:08X}", std::byteswap(c->ident.grfid));
1592 AppendToGRFConfigList(_grfconfig, std::move(c));
1593 }
1594 len -= 5;
1595 }
1596
1597 /* Append static NewGRF configuration */
1598 AppendStaticGRFConfigs(_grfconfig);
1599 break;
1600 }
1601
1602 /* TTDPatch version and configuration */
1603 case 0x3:
1604 _ttdp_version = ReadUint32(ls);
1605 Debug(oldloader, 3, "Game saved with TTDPatch version {}.{}.{} r{}",
1606 GB(_ttdp_version, 24, 8), GB(_ttdp_version, 20, 4), GB(_ttdp_version, 16, 4), GB(_ttdp_version, 0, 16));
1607 len -= 4;
1608 while (len-- != 0) ReadByte(ls); // skip the configuration
1609 break;
1610
1611 default:
1612 Debug(oldloader, 4, "Skipping unknown extra chunk {}", id);
1613 while (len-- != 0) ReadByte(ls);
1614 break;
1615 }
1616 }
1617
1618 return true;
1619}
1620
1621extern TileIndex _cur_tileloop_tile;
1622extern uint16_t _disaster_delay;

Callers

nothing calls this directly

Calls 9

ReadTTDPatchFlagsFunction · 0.85
ReadUint16Function · 0.85
ReadUint32Function · 0.85
ReadByteFunction · 0.85
ClearGRFConfigListFunction · 0.85
byteswapFunction · 0.85
AppendToGRFConfigListFunction · 0.85
AppendStaticGRFConfigsFunction · 0.85
GBFunction · 0.85

Tested by

no test coverage detected