You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document outlines the specific workarounds and "hacky" solutions implemented in `unren-go` to support complex features like cross-platform macOS detection and robust automation piping.
4
+
5
+
## 1. macOS `.app` Transparency (The Detector Hack)
6
+
**Using macOS Game Files on Linux/Windows**
7
+
8
+
Ren'Py games on macOS are packaged as `.app` bundles, which are directories. The actual game assets (RPYC/RPA) live deep inside at `Contents/Resources/autorun/`.
9
+
To make this transparent to the user (so they can just point at `Game.app`), we implemented a path redirection hack in `detector/detector.go`.
// Switch context to the autorun folder which acts as the game root
20
+
absDir = macAutorun
21
+
}
22
+
}
23
+
```
24
+
We aggressively rewrite the `absDir` variable if we suspect a macOS bundle. This allows the rest of the detection logic (checking for `game/`) to work unchanged.
25
+
26
+
## 2. OS-Agnostic Python Detection
27
+
**Finding Mac Binaries on Linux**
28
+
29
+
Normally, `runner.go` should verify the OS (`runtime.GOOS`) before deciding where to look for the Python interpreter. However, to support analyzing macOS games on Linux (detecting version, etc.), we removed the OS guard.
30
+
31
+
**Location:**`runner/runner.go` -> `findPython`
32
+
**The Hack:**
33
+
```go
34
+
// Check for macOS App Bundle structure (Check unconditionally to support cross-OS inspection)
We check for the Mac binary *unconditionally*. While we can't *execute* this binary on Linux/Windows, detecting it allows the `GameInfo` struct to be populated correctly, letting the tool report the Ren'Py version and file counts even if it can't run the decompression.
41
+
42
+
## 3. Pipeline State Mutation
43
+
**The `-e -d` Pipeline Fix**
44
+
45
+
When running `unren-go -e -d`, the tool extracts RPAs and then immediately tries to decompile RPYCs. The problem is that the `game` struct is populated *before* extraction, so the decompiler doesn't know about the files that were just created.
46
+
47
+
**Location:**`main.go` -> `handleExtractRPA`
48
+
**The Hack:**
49
+
```go
50
+
// Refresh RPYC file list in case new files were extracted
51
+
// This ensures that if decompilation runs after this, it sees the new files
We actively mutate the `game.RPYCFiles` slice inside the extraction polling function. This couples the detection state with the extraction action, but it's the most efficient way to ensure the pipeline proceeds without a full re-detection loop.
57
+
58
+
## 4. Vendor Script Patching
59
+
**Fixing `rpatool.py` Exit Codes**
60
+
61
+
The original `rpatool` library returns exit code `0` (Success) even if it encounters errors during batch extraction. This made implementing the `--clean` flag dangerous, as we rely on exit codes to know if it's safe to delete source files.
We injected error tracking logic into the upstream script:
66
+
```python
67
+
errors =0
68
+
# ... inside loops ...
69
+
exceptExceptionas e:
70
+
errors +=1
71
+
# ... at end of file ...
72
+
if errors >0:
73
+
sys.exit(1)
74
+
```
75
+
Instead of wrapping the python execution in complex stderr parsing (which is brittle), we patched the "vendor" code directly to behave like a standard CLI tool. This ensures `unren-go` receives a clear signal (`exit status 1`) if *anything* goes wrong, protecting user data.
0 commit comments