| 719 | } |
| 720 | |
| 721 | bool Serialise(DataSerialiser& serialiser, ReplayRecordData& data) |
| 722 | { |
| 723 | serialiser << data.magic; |
| 724 | if (data.magic != kReplayMagic) |
| 725 | { |
| 726 | LOG_ERROR("Magic does not match %08X, expected: %08X", data.magic, kReplayMagic); |
| 727 | return false; |
| 728 | } |
| 729 | serialiser << data.version; |
| 730 | if (data.version != kReplayVersion && !Compatible(data)) |
| 731 | { |
| 732 | LOG_ERROR("Invalid version detected %04X, expected: %04X", data.version, kReplayVersion); |
| 733 | return false; |
| 734 | } |
| 735 | |
| 736 | serialiser << data.networkId; |
| 737 | #ifndef DISABLE_NETWORK |
| 738 | // NOTE: This does not mean the replay will not function, only a warning. |
| 739 | if (data.networkId != Network::GetVersion()) |
| 740 | { |
| 741 | LOG_WARNING( |
| 742 | "Replay network version mismatch: '%s', expected: '%s'", data.networkId.c_str(), |
| 743 | Network::GetVersion().c_str()); |
| 744 | } |
| 745 | #endif |
| 746 | |
| 747 | serialiser << data.name; |
| 748 | serialiser << data.timeRecorded; |
| 749 | serialiser << data.parkData; |
| 750 | serialiser << data.parkParams; |
| 751 | serialiser << data.cheatData; |
| 752 | serialiser << data.tickStart; |
| 753 | serialiser << data.tickEnd; |
| 754 | |
| 755 | uint32_t countCommands = static_cast<uint32_t>(data.commands.size()); |
| 756 | serialiser << countCommands; |
| 757 | |
| 758 | if (serialiser.IsSaving()) |
| 759 | { |
| 760 | for (auto& command : data.commands) |
| 761 | { |
| 762 | SerialiseCommand(serialiser, const_cast<ReplayCommand&>(command)); |
| 763 | } |
| 764 | } |
| 765 | else |
| 766 | { |
| 767 | for (uint32_t i = 0; i < countCommands; i++) |
| 768 | { |
| 769 | ReplayCommand command = {}; |
| 770 | SerialiseCommand(serialiser, command); |
| 771 | |
| 772 | data.commands.emplace(std::move(command)); |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | uint32_t countChecksums = static_cast<uint32_t>(data.checksums.size()); |
| 777 | serialiser << countChecksums; |
| 778 |
no test coverage detected