Skip to content

Optimize ToastPRP.ps1 and fix pipeline bugs#2

Open
CannibalToast wants to merge 1 commit into
Masterfrom
cursor/toastprp-optimization-06f5
Open

Optimize ToastPRP.ps1 and fix pipeline bugs#2
CannibalToast wants to merge 1 commit into
Masterfrom
cursor/toastprp-optimization-06f5

Conversation

@CannibalToast
Copy link
Copy Markdown
Owner

Summary

General review and optimization of ToastPRP.ps1, the Fallout 4 precombine/previs automation script. Focus was on correctness bugs that could break the pipeline, plus targeted performance and maintainability improvements.

What the script does

ToastPRP.ps1 automates the full Precombine → PSG compression → mesh archive → CDX → Previs → final pack → zip workflow for Fallout 4 modding. It orchestrates:

  • FO4Edit/xEdit (PJM and merge scripts via window-title automation)
  • Creation Kit (ckpe_loader / f4ck_loader / creationkit.exe)
  • bsarch (BA2 pack/unpack)
  • Texture archive renaming (.ba2.ba22 for CK compatibility)

Prerequisites: Mod Organizer 2, script in the FO4 install directory, PJM script already run on the target ESP.

Bugs fixed

Issue Impact
Missing comma between PackMeshVis and CreateZip in $functions CreateZip was never a separate step; one-off/resume could call a non-existent function
$scriptPath / $jsonFileDestinationPath / $meshesSubdir undefined Setup validation, JSON relocation, and mesh packing could fail silently or error
DLBSArch re-downloaded on every run when file existed Slow runs, unnecessary network I/O
Execute menu used $_.Index on strings Resume menu showed blank indices
PSG cleanup used relative $EXT paths Wrong files could be deleted depending on cwd
finally always reported success Misleading outcome after errors

Optimizations

  • Get-TextureArchiveFiles: Scans only the Data folder root (not recursive tree walk) with one combined regex — faster on large mod lists.
  • PackMesh / PackMeshVis: Shared mesh-staging logic without duplicated blocks.
  • Archiver mesh check: Uses $script:MeshesSubdir and stops after first file found instead of listing entire trees twice.
  • Clearer failures: QueryESP / DLBSArch now throw on fatal setup issues so the main catch/finally path reports accurately.

Testing

  • PowerShell parser validation (ParseFile) passes on Linux/pwsh.
  • Full end-to-end run requires Windows + FO4 + CK + xEdit (not available in this environment).

Follow-ups (not in this PR)

  • Invoke-xEdit still uses busy-polling on window titles; could use Wait-Process where CK exposes exit codes.
  • Rename-Texture -Wait loop is largely redundant after synchronous Rename-Item (could be removed in a future cleanup).
  • Consider splitting the ~1.2k line script into dot-sourced modules for easier maintenance.
Open in Web Open in Cursor 

- Fix missing comma that merged PackMeshVis and CreateZip in the step list
- Fix undefined variables (scriptPath, meshesSubdir, jsonFileDestinationPath)
- Fix DLBSArch to validate existing bsarch instead of re-downloading every run
- Fix Execute resume menu numbering and PSG cleanup paths
- Optimize texture archive discovery (Data root only, single regex)
- Deduplicate PackMesh/PackMeshVis staging and improve error reporting

Co-authored-by: CannibalToast <CannibalToast@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Warning

Review limit reached

@CannibalToast, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 43 minutes and 47 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: db38ed30-fd8e-49ce-a260-8bbb5a55e2a4

📥 Commits

Reviewing files that changed from the base of the PR and between 0e61d31 and 5b7a1a5.

📒 Files selected for processing (1)
  • ToastPRP.ps1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CannibalToast CannibalToast marked this pull request as ready for review June 2, 2026 03:54
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