Last active
February 17, 2023 02:00
-
-
Save getchoo/31f4d5f96d268d7c3aadc114fb7a538e to your computer and use it in GitHub Desktop.
symlink files from a retail Team Fortress 2 build to a patched build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
symlink files from a retail Team Fortress 2 build to a patched build | |
#> | |
param ( | |
[Parameter(Mandatory=$true)] | |
[string]$TF2Dir | |
) | |
$VerbosePreference = "Continue" | |
function Make-Symlink { | |
param ( | |
[String]$Path | |
) | |
$linkpath = "./game/$Path" | |
$targetpath = "$TF2Dir/$Path" | |
Write-Verbose -Message "Linking $linkpath to $targetpath" | |
New-Item -ItemType SymbolicLink -Path $linkpath -Target $targetpath | |
} | |
function Glob-Symlink { | |
param ( | |
[String]$Path, | |
[String]$Glob | |
) | |
Get-ChildItem -Path "$TF2Dir\$Path\*" -Include $Glob | % { $_.Name } | % { Make-Symlink -Path $Path/$_ } | |
} | |
Write-Verbose -Message "Copying ./game_clean/copy/ to ./game/" | |
Copy-Item -Recurse -Force ./game_clean/copy/* ./game/ | |
Write-Verbose -Message "Creating ./game/tf/materials" | |
New-Item -Type Directory -Path ./game/tf/materials | |
$targets = "hl2","platform" | |
$targets += ,"maps","media","resource","scripts" | % { "tf/$_" } | |
$targets += ,"models","vgui" | % { "tf/materials/$_" } | |
ForEach ($t in $targets) { | |
Make-Symlink -Path $t | |
} | |
Glob-Symlink -Glob '' -Path 'bin' | |
ForEach ($g in '*.vpk','*.cache') { Glob-Symlink -Glob $g -Path 'tf' } | |
Write-Verbose -Message "Copying $TF2Dir/tf/gamestate.txt to ./game/tf" | |
Copy-Item -Force $TF2Dir/tf/gamestate.txt ./game/tf/ | |
Write-Verbose -Message "Copying $TF2Dir/tf/cfg to ./game/tf/cfg" | |
Copy-Item -Recurse -Force $TF2Dir/tf/cfg/ ./game/tf/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment