Files
pokemon/scripts/repair-playnite-after-pc-hack.ps1
ginnoirandClaude Opus 4.8 809600a04d feat: ROM-hack dedup, conflict resolution, and vault library_path resync
Catalog cleanup pass across gb/gbc/gba/nds/3ds:
- Standardize nonstandard hack filenames to `Pokemon - <Name> [Hack].<ext>`;
  remove verified byte-identical duplicates (conform-rom-names.sh).
- Resolve 9 version-conflicts via side-by-side emulator comparison
  (resolve-version-conflicts.sh): promote newer builds, keep genuine
  distinct hacks, fix a mislabeled Dark Rising slot (was the Digimon
  crossover "Worlds Collide"), and rebuild Mega Power 5.77 + HeartGold
  Generations v2.0 fresh from their patches.
- Resync 286 vault notes' `library_path` to the real on-disk [Hack] files
  and fix 15 stale platform fields (resync-vault-library-paths.py).
- Regenerate MOC tables + wiki/catalog.json (396 notes).

Also includes pending Playnite PC-hack setup/repair scripts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 14:29:05 -05:00

68 lines
3.0 KiB
PowerShell

<#
.SYNOPSIS
Undo Playnite damage from setup-playnite-pc-hack.ps1 LiteDB writes.
Fixes:
1. Removes broken GameScannerConfig (null emulator, scoop\apps) from scanners.db
2. Clears active library filter that restricts view to RomM only
3. Disables pc_windows RomM mapping until emulator is recreated in Playnite UI
Playnite must be fully closed before running.
#>
$ErrorActionPreference = 'Stop'
if (Get-Process -Name 'Playnite*' -ErrorAction SilentlyContinue) {
throw 'Close Playnite completely, then re-run.'
}
$playniteConfig = Join-Path $env:LOCALAPPDATA 'Playnite\config.json'
$scannersDb = Join-Path $env:LOCALAPPDATA 'Playnite\library\scanners.db'
$rommConfig = Join-Path $env:LOCALAPPDATA 'Playnite\ExtensionsData\9700aa21-447d-41b4-a989-acd38f407d9f\config.json'
$liteDbDll = Join-Path $env:LOCALAPPDATA 'Playnite\LiteDB.dll'
$orphanEmuId = 'fa12bc5e-dbb9-4d21-b1e6-a67c2fa6a513'
$nullEmuId = '00000000-0000-0000-0000-000000000000'
# --- 1. Remove broken emulator scanner ---
Add-Type -Path $liteDbDll
$db = [LiteDB.LiteDatabase]::new("Filename=$scannersDb")
$col = $db.GetCollection('GameScannerConfig')
$removed = 0
foreach ($doc in @($col.FindAll())) {
$emuId = if ($doc['EmulatorId'].IsGuid) { $doc['EmulatorId'].AsGuid.ToString() } else { $doc['EmulatorId'].AsString }
$dir = if ($doc.ContainsKey('Directory')) { $doc['Directory'].AsString } else { '' }
if ($emuId -eq $nullEmuId -or $dir -like '*\scoop\apps') {
$col.Delete($doc['_id']) | Out-Null
$removed++
Write-Host "Removed broken scanner: Directory=$dir EmulatorId=$emuId"
}
}
$db.Dispose()
if ($removed -eq 0) { Write-Host 'No broken GameScannerConfig entries found.' }
# --- 2. Clear RomM-only library filter ---
$cfg = Get-Content -Raw $playniteConfig | ConvertFrom-Json
if ($cfg.FilterSettings.Library -and $cfg.FilterSettings.Library.Ids -and $cfg.FilterSettings.Library.Ids.Count -gt 0) {
$ids = @($cfg.FilterSettings.Library.Ids)
Write-Host "Clearing library filter (was: $($ids -join ', '))"
$cfg.FilterSettings.Library.Ids = @()
}
$cfg | ConvertTo-Json -Depth 20 | Set-Content -Encoding UTF8 $playniteConfig
Write-Host 'Playnite config: library filter cleared.'
# --- 3. Disable orphan pc_windows RomM mapping ---
$romm = Get-Content -Raw $rommConfig | ConvertFrom-Json
$pc = $romm.Mappings | Where-Object { $_.PlatformId -eq 'pc_windows' } | Select-Object -First 1
if ($pc) {
if ($pc.EmulatorId -eq $orphanEmuId) {
$pc.Enabled = $false
Write-Host "Disabled pc_windows RomM mapping (orphan emulator $orphanEmuId)."
Write-Host 'Re-enable after adding Pokemon PC Hack Launcher in Playnite UI.'
} else {
Write-Host "pc_windows mapping uses emulator $($pc.EmulatorId) - left enabled."
}
$romm | ConvertTo-Json -Depth 8 -Compress | Set-Content -Encoding UTF8 $rommConfig
}
Write-Host "`nDone. Open Playnite - full library should be visible again."
Write-Host 'Emulated-game scan errors on startup should be gone.'