Skip to content

Feature: Deep SAGE Replay Parser & Rich Match Inspection UI #434

Description

@undead2146

Overview & Motivation

Currently, GenHub includes basic replay header and CRC detection (PR #422), but lacks a comprehensive, deep binary replay parser and a rich match inspection UI.

This feature will implement a pure C# SAGE .rep body packet parser, match outcome analyzer, and modern Avalonia inspection view inspired by the match details layout from GameReplays and research across leading community replay decoders.


Investigation of Community Implementations

  1. rhaivorn/replay-info

    • Winner & Match Outcome Determination: Extracts player quit/self-destruct message indices (e.g., messages 27, 1001-1097), tracks last CRC sync frames, checks for idle kicks and disconnects, and evaluates the true match winner/loser across teams and FFA formats.
    • PRNG Tracking (prng.py): Simulates the SAGE engine's deterministic pseudo-random number generator to follow randomized events and match state changes.
    • Match Configuration: Parses the SAGE game options string (M=, S=, H=, SC=, CH=, SR=, G=, O=) for map dimensions, starting cash, camera height, slot settings, colors, and player factions/armies.
  2. dsalzner/cnc-generals-replay-parser

    • Packet & Order Stream Parsing: Decodes low-level binary command packets for Zero Hour (unit creations, building construction, move commands, multi-unit selections, attack orders).
    • Action & Build Timeline: Traces build sequences over time, unit queue arrival estimates, and command frequencies.
  3. drag0nD/generals-replay-parser

    • Winner Check & Replay Analysis Pipeline (parseV2.py, check_winner.py): Demonstrates offline batch processing, statistical aggregation, filtering corrupted/AI replays, and calculating player performance metrics.

UI & UX Specification (Match Details View)

Based on modern match detail designs (such as GameReplays):

  • Hero Banner / Header:
    • Match Title (e.g., [AS][🛡️] 4 VS 4 50K No Rules)
    • Map Preview Thumbnail with Map Name (e.g., Destruction Station) and starting spawn positions.
  • Match Summary Grid:
    • Game Version (e.g., 082826_QFE1) & Data Pack (e.g., Community Patch 1.0.1)
    • Match Type (e.g., 1v1, 2v2, 3v3, 4v4, FFA)
    • Duration (e.g., 34m 32s)
    • Date & Time Played (e.g., Aug 30, 2026 19:13 – 19:47 GMT)
    • Starting Cash (e.g., $50,000)
    • Camera Height (e.g., 510)
  • Teams & Players Breakdown:
    • Segmented tables per team (Team 1, Team 2, etc.)
    • Player Row:
      • Expandable arrow for detailed player stats
      • Player Name & color indicator
      • Faction / General Army badge (e.g., GLA, USA Airforce, China Infantry, GLA Demo, USA Super Weapon, USA Laser, China Tank)
      • Outcome Badge (Won in green, Lost in red, Observer)
      • Individual player replay download / export action
  • Expanded Player Drawer / Tabs:
    • Actions Per Minute (APM) and total command count
    • Build Order Timeline: Chronological queue of buildings, upgrades, and units
    • Chat Log: In-game chat transcript with timestamps and channel indicators (All / Team)

Technical Architecture & Requirements

  1. IReplayParserService & Packet Decoder (GenHub.Core/Interfaces/Tools/ReplayManager/):

    • Parse GENREP binary chunk stream into strongly typed frame packets (ReplayPacket, CommandPacket).
    • Decode order types (move, attack, construct, train unit, trigger special power, surrender/self-destruct).
    • Compute player APM, effective action frequency, and command distribution.
  2. Outcome & Winner Determination Engine:

    • C# port of the community winner detection algorithm:
      • Scan for self-destruct packets (Type 1003 / 1058 / quit frames).
      • Track remaining active players per team across the timeline.
      • Detect desync frames, disconnected players, and idle kicks.
      • Assign MatchResult (Won, Lost, Draw, Desync, NoResult).
  3. Replay Viewer Dialog & Inspection ViewModel (GenHub/Features/Tools/ReplayManager/):

    • ReplayInspectionViewModel and ReplayInspectionWindow.axaml (or integrated split-pane inspector).
    • Async background parsing with cancellation support and progress reporting.
    • Dynamic theme binding via semantic tokens (ThemeResources.axaml).
  4. Unit & Integration Tests (GenHub.Tests.Core):

    • Full test suite covering 1v1, 2v2, 4v4, FFA, surrender mid-game, disconnect, and desync replay files.

Acceptance Criteria

  • Complete binary replay stream parser implemented in C# adhering to GenHub's OperationResult<T> pattern.
  • Winner, loser, and match duration correctly resolved for standard and custom maps.
  • Match options extracted: starting cash, camera height, rules, seed, map size, and game version.
  • Avalonia UI matches the GameReplays-style overview: map preview, hero metadata grid, team tables with faction badges, and Won/Lost badges.
  • Expandable details for APM, build orders, and in-game chat.
  • Clean asynchronous parsing without blocking UI threads.
  • Comprehensive unit test coverage for replay packet decoding and winner evaluation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions