1+
12if ( $args -contains " disappear" ) {
23
34$arguments = $args [1 .. ($args.Length - 1 )]
45$ErrorActionPreference = ' Stop'
6+ # $ErrorActionPreference = 'Continue'
57
68$HttpFile = ' '
79$AFile = ' user\sofplus\data\http_tmp'
810$HttpServer = ' https://raw.githubusercontent.com/plowsof/sof1maps/main/'
911
1012# Delete existing http file if it exists
11- If (Test-Path $AFile ) {
12- Remove-Item $AFile
13+ If (Test-Path " $AFile " ) {
14+ Remove-Item " $AFile "
1315 Write-Host ' Deleting existing http file.'
1416}
1517
@@ -23,54 +25,50 @@ $gameProcess = Start-Process -PassThru -FilePath 'SoF.exe' -ArgumentList $argume
2325While ($true ) {
2426 If (Test-Path $AFile ) {
2527 # Read the last line of the mapname file
26- $HttpFile = Get-Content $AFile | Select-Object - Last 1
28+ $HttpFile = Get-Content " $AFile " | Select-Object - Last 1
2729
2830 $HttpFile = $HttpFile.Split (' "' )[3 ]
2931 Write-Host " Map name: $HttpFile "
3032
3133 # Remove .bsp extension and add .zip extension
32- $HttpFile = $HttpFile -replace ' \.bsp$' , ' .zip'
34+ $HttpFile = " $HttpFile " -replace ' \.bsp$' , ' .zip'
3335
3436 # Download the file from the http server
3537 $DestFile = Join-Path ' user\maps' $HttpFile
36-
38+
3739 # Create the directory if it doesn't exist
38- $directory = Split-Path - Path $DestFile - Parent
39- if (! (Test-Path - Path $directory - PathType Container)) {
40- New-Item - Path $directory - ItemType Directory | Out-Null
40+ $directory = Split-Path - LiteralPath " $DestFile "
41+ if (! (Test-Path - LiteralPath " $directory " - PathType Container)) {
42+ New-Item - Path " $directory " - ItemType Directory | Out-Null
4143 }
44+
4245 # Download the file using Invoke-WebRequest
4346 Write-Host " NEUTRAL: Trying to download "" $HttpServer$HttpFile "" to "" $DestFile "" ."
44-
4547 try {
46- $ProgressPreference = ' SilentlyContinue'
4748 $encodedUri = [System.Uri ]::EscapeUriString(" $HttpServer$HttpFile " )
4849 $webClient = New-Object System.Net.WebClient
49- $webClient.DownloadFile ($encodedUri , $DestFile )
50+ $webClient.DownloadFile (" $encodedUri " , " $DestFile " )
5051 Write-Host " SUCCESS: "" $HttpFile "" downloaded to "" $DestFile "" ."
5152
52- # Read-Host -Prompt "Press Enter to continue..."
53-
5453 # Extract the zip file
55- Expand-Archive - LiteralPath $DestFile - DestinationPath ' user' - Force
54+ Expand-Archive - LiteralPath " $DestFile " - DestinationPath ' user' - Force
5655
5756 # Delete the zip file
58- Remove-Item $DestFile
57+ Remove-Item - LiteralPath " $DestFile "
5958
6059 } catch {
6160 # 404 error catch
6261 Write-Host " ERROR: $ ( $_.Exception.Message ) "
6362 }
6463 # Delete the http file
65- Remove-Item $AFile
64+ Remove-Item - LiteralPath " $AFile "
6665 }
6766 # Wait for 2 seconds and check again
6867 Start-Sleep - Seconds 2
6968
7069 if ($gameProcess.HasExited ) {
7170 exit
7271 }
73-
7472}
7573} else {
7674 # $arguments = "-ExecutionPolicy Bypass", "-File `"$PSCommandPath`"", "disappear"
0 commit comments