Skip to content

实现 issue #85,调整 replay world-data 与分发处理#116

Open
Wind-DeterMination-backup wants to merge 4 commits intoTinyLake:mainfrom
Wind-DeterMination-backup:betterreplay
Open

实现 issue #85,调整 replay world-data 与分发处理#116
Wind-DeterMination-backup wants to merge 4 commits intoTinyLake:mainfrom
Wind-DeterMination-backup:betterreplay

Conversation

@Wind-DeterMination-backup
Copy link
Copy Markdown

@Wind-DeterMination-backup Wind-DeterMination-backup commented Mar 15, 2026

概要

关联 issue: #85
分支: betterreplay
Draft PR: #116

本 PR 仍处于 Draft 状态。

本次实现

当前已完成并复核的改动包括:

  • ReplayController 中调整 replay playback 的 world-data begin 调用路径。
  • ArcNetProvider 的 replay notify 路径中显式写为 (NetConnection)this
  • 将 world-data 读取改为通过 EOF 循环写入 ByteArrayOutputStream
  • replayServerDispatchPacket 从静态 Packet 改为 ThreadLocal<Packet>,并处理 send / sendExcept 周围的保存与恢复。

兼容性说明

  • 代码实现保持 Java 8 目标兼容,遵循当前的 --release 8 约束。
  • 针对 Gemini 提出的“使用 readAllBytes() 简化流读取”建议,本 PR 未采纳,因为该 API 不属于 Java 8 可用范围。

验证

已完成编译验证:

  • .\\gradlew.bat :core:compileJava 成功通过。

Gemini 审查状态

  • 当前已无 critical / high 级别问题残留。
  • 仅剩 1 条 medium 建议:将流读取替换为 readAllBytes()
  • 该建议当前未采纳,原因是仓库构建目标仍为 Java 8(--release 8)。

后续仍可继续补充更完整的运行期验证结果;当前 PR 仍保持 Draft。

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a major overhaul to the replay system, shifting from a packet-centric recording approach to one that captures full world states at key moments. This foundational change enables advanced replay functionalities such as observer mode and the ability to jump back to specific game checkpoints, significantly enhancing the utility and detail of recorded sessions.

Highlights

  • Enhanced Replay Recording: The replay recording pipeline has been significantly improved to capture sessions based on world-data boundaries, offering a more comprehensive and robust recording of game states beyond just packet streams.
  • Observer-Style Playback and Checkpoints: New features enable observer-style playback and the ability to create and rewind to periodic checkpoints, allowing for more flexible and interactive replay analysis.
  • Replay Bridge Integration: A new client patch, 0074-HC-ReplayController-world-data-bridge.patch, has been added to integrate the world-data replay bridge within the core networking components, facilitating the new recording capabilities.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • patches/client/0074-HC-ReplayController-world-data-bridge.patch
    • Added a new patch file that modifies core networking classes (NetClient.java, NetServer.java, ArcNetProvider.java, Net.java) to integrate the replay bridge, enabling the capture and notification of world data and network packets to the ReplayController.
  • src/mindustryX/bundles/UiTextBundle.kt
    • Added new Chinese UI text entries for replay rewind functionality, specifically for 'Rewind to previous checkpoint' and 'No replay checkpoint is available yet'.
  • src/mindustryX/bundles/UiTextBundleEn.kt
    • Added new English UI text entries for replay rewind functionality, specifically for 'Rewind to previous checkpoint' and 'No replay checkpoint is available yet'.
  • src/mindustryX/features/ReplayController.java
    • Refactored replay recording logic to use ReplayRecordingSession and handle world data and keyframe metadata.
    • Implemented new playback state management, including suspension, resumption, and generation tracking.
    • Introduced checkpointing functionality, allowing the capture and restoration of game states during playback.
    • Added UI elements for replay rewind in the paused dialog.
    • Updated showInfo to display more detailed replay record information.
  • src/mindustryX/features/ReplayData.kt
    • Introduced a new container format for replay data, including StorageFormat, RecordType, RecordInfo, and PlaybackRecord enums and sealed classes.
    • Updated Writer to support writing world data and keyframe metadata, and to handle both legacy and new container formats.
    • Updated Reader to parse the new container format, read different record types, and provide methods for reading world data and keyframe metadata.
    • Enhanced PacketInfo with trailingBytes and unreadLength for better record parsing.
  • src/mindustryX/features/replay/ReplayCheckpoint.java
    • Added a new class to represent a replay checkpoint, storing world data, offset, and the next record ordinal.
    • Provided a static method to capture the current world state as a checkpoint.
  • src/mindustryX/features/replay/ReplayKeyframeMeta.java
    • Added a new class to encapsulate metadata for replay keyframes, including timeline, tag, flags, and snapshot size.
  • src/mindustryX/features/replay/ReplayRecordingSession.java
    • Added a new class to manage the lifecycle of a replay recording session, handling file operations and writing various record types.
Activity
  • An AI review (gpt-5.4-high) was conducted, which found no blocker or high-priority issues in the replay path related to issue [Feature] 录制系统新设计 #85.
  • The AI review also confirmed that the regenerated client patch (0074-HC-ReplayController-world-data-bridge.patch) is clean and consistent with the core changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances the replay functionality by introducing a new recording pipeline based on world data boundaries instead of just packet streams. It adds support for checkpoints and rewinding during playback, which is a major feature. The replay file format has been updated to a more flexible container format to support these new features. The changes are extensive and well-structured, using reflection to bridge core game logic with mod features, and introducing new classes to manage recording sessions and replay data. I've found one critical issue that would prevent compilation and one suggestion for improvement. Overall, this is a great improvement to the replay system.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant improvement to the replay recording system, shifting from packet-based recording to a more robust world-data-based approach. This enables features like observer-style playback and checkpoint rewinding. The changes are extensive, introducing a new replay file format, session management classes, and a complex ReplayController to handle the new logic. The use of reflection via ReplayBridge to decouple the mod from core game logic is noted. While the overall implementation is of high quality, I've identified a few critical and high-severity issues that should be addressed. Specifically, there's a potentially missing method that could cause compilation errors, a risky silent exception catch, and a non-robust stream reading implementation.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances the replay recording system by introducing a new container-based replay format, enabling recording from world data boundaries, and adding support for playback checkpoints and rewinding. The changes are extensive, touching networking hooks, data serialization, and the replay controller logic. The implementation is robust, with good handling of concurrency and backward compatibility for the old replay format. My review found one critical issue in the client patch where an incorrect this reference is used, which would lead to a runtime error. I've also provided a suggestion to simplify stream reading logic for better clarity and robustness.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant improvement to the replay recording and playback system. It refactors the replay data format to be more extensible, allowing for world data and other metadata to be stored alongside packets. It also adds a major new feature: checkpointing and rewinding during playback. The implementation is comprehensive and well-structured, using reflection to create a bridge to the core game code, which is a good approach for modding. I've found a couple of areas for improvement regarding I/O robustness and thread safety that could prevent potential replay corruption. Overall, this is an excellent contribution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant improvement to the replay recording system. It moves from a packet-only stream to a more robust model based on world-data boundaries, and adds support for observer-style playback with checkpoint and rewind functionality. The implementation is well-structured, introducing a new container format for replay files and using a ReplayBridge with reflection for loose coupling with the core game code, which is a solid approach for modding. The new concurrency controls and data models for replays are well thought out. I have one suggestion to simplify the code for reading stream data.

@Wind-DeterMination-backup Wind-DeterMination-backup changed the title feat: improve replay recording pipeline for #85 betterreplay: 实现 issue #85,调整 replay world-data 与分发处理 Mar 15, 2026
@Wind-DeterMination-backup
Copy link
Copy Markdown
Author

已根据 Gemini 历史审查意见完成以下调整,并已重新核对:

  • ReplayController 中调整了 replay playback 的 world-data begin 调用路径。
  • ArcNetProvider 中把 replay notify 路径显式写成 (NetConnection)this
  • 将 world-data 读取逻辑改为通过 EOF 循环写入 ByteArrayOutputStream
  • replayServerDispatchPacket 从静态 Packet 改为 ThreadLocal<Packet>,并在 send / sendExcept 周围加入保存与恢复逻辑。

当前 Gemini 已无 critical / high 级别结论残留。

仍有 1 条 medium 建议未采纳:将流读取进一步改成 readAllBytes()。本仓库当前目标仍为 Java 8,构建约束为 --release 8,因此这里继续保留 Java 8 兼容的 ByteArrayOutputStream 实现。

@Wind-DeterMination-backup Wind-DeterMination-backup changed the title betterreplay: 实现 issue #85,调整 replay world-data 与分发处理 实现 issue #85,调整 replay world-data 与分发处理 Mar 15, 2026
@Wind-DeterMination-backup Wind-DeterMination-backup marked this pull request as ready for review March 15, 2026 09:58
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.

1 participant