Skip to content

Complete SC5/SV5 round-trip serialization and editor support in ObjectEditor - #261

Draft
LeftofZen with Copilot wants to merge 2 commits into
masterfrom
copilot/complete-serialization-deserialization
Draft

Complete SC5/SV5 round-trip serialization and editor support in ObjectEditor#261
LeftofZen with Copilot wants to merge 2 commits into
masterfrom
copilot/complete-serialization-deserialization

Conversation

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This updates the partial SC5/SV5 implementation to support reliable load/save round-tripping for OpenLoco map files, including packed object chunks and tile-element data. It also fills key S5 structure gaps and wires map-file editing paths needed by the editor UI.

  • S5 binary model + serializer parity

    • Completed SCV5 write-path support for packed objects (S5Header + ObjectHeader + encoded payload).
    • Preserved packed-object chunk encoding/bytes on read so unchanged files can round-trip byte-identically.
    • Added tile-element serialization (TileElement.Write) and switched save logic to emit edited tile elements when available.
    • Corrected non-scenario game-state writing to emit the correct save struct variants (GameStateSave1/GameStateSave2).
    • Removed read-time state mutation that altered fix flags and broke binary stability.
  • S5 structure correctness fixes

    • Fixed ScenarioOptions.LandDistributionPatterns to the correct array shape.
    • Corrected scenario Orders sizing to kMaxOrders.
    • Made S5Header serializable as a nested loco struct to support chunk-based object serialization paths.
  • Editor behavior

    • Enabled SC5/SV5 save/save-as flow in the SCV5 view model.
    • Updated tile-element rendering/edit surface to expose subtype/sub-structure fields for in-editor modifications.
  • Regression coverage

    • Added SC5 and SV5 round-trip tests that assert load -> save yields byte-identical output.
// Packed object write format now mirrors OpenLoco S5 layout.
foreach (var packedObject in PackedObjects)
{
    bytes.AddRange(packedObject.Header.Write().ToArray());
    bytes.AddRange(
        packedObject.RawChunk
        ?? SawyerStreamWriter.WriteChunkCore(packedObject.Data, packedObject.Encoding));
}

Copilot AI and others added 2 commits September 2, 2026 06:55
Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants