feat: headless /getlog output via conditional delegation
Browse filesWhen a log file is open (headless /getlog mode), delegate to the
original ReplayLoader after our Rust path completes. The original
re-parses the replay and writes the log header (date, version strings,
team listing). Globals are overwritten with identical values.
In headful mode (no log file), the Rust path runs standalone.
Both headful (133/0) and headless (byte-identical) tests pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-wormkit/src/replacements/replay.rs
CHANGED
|
@@ -165,7 +165,21 @@ unsafe fn replay_loader_play(state: u32) -> Result<(), ReplayError> {
|
|
| 165 |
match result {
|
| 166 |
Ok(()) => {
|
| 167 |
let _ = log_line("[Replay] Rust replay loading complete");
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
}
|
| 170 |
Err(e) => {
|
| 171 |
let _ = log_line(&format!("[Replay] Parse failed ({e:?}), falling back to original"));
|
|
|
|
| 165 |
match result {
|
| 166 |
Ok(()) => {
|
| 167 |
let _ = log_line("[Replay] Rust replay loading complete");
|
| 168 |
+
|
| 169 |
+
// The /getlog log header (date, version strings, team listing) is
|
| 170 |
+
// produced by the original ReplayLoader's log output section (~600
|
| 171 |
+
// lines of string resource formatting + codepage conversion).
|
| 172 |
+
// Rather than porting all of that, we delegate to the original which
|
| 173 |
+
// re-parses the replay and writes the log header. The globals are
|
| 174 |
+
// overwritten with identical values since the replay data is the same.
|
| 175 |
+
// This is double work but produces byte-identical log output.
|
| 176 |
+
let log_file = *(rb(0x88C370) as *const *mut FILE);
|
| 177 |
+
if !log_file.is_null() {
|
| 178 |
+
let _ = log_line("[Replay] Delegating for /getlog header output");
|
| 179 |
+
delegate_to_original(state)
|
| 180 |
+
} else {
|
| 181 |
+
Ok(())
|
| 182 |
+
}
|
| 183 |
}
|
| 184 |
Err(e) => {
|
| 185 |
let _ = log_line(&format!("[Replay] Parse failed ({e:?}), falling back to original"));
|