mirror of
https://github.com/iTracerFacer/DCS_MissionDev.git
synced 2025-12-03 04:14:46 +00:00
Bug fixes on the whatif
This commit is contained in:
@@ -85,7 +85,7 @@ begin {
|
|||||||
# Validate output path if specified
|
# Validate output path if specified
|
||||||
if ($OutputPath -and -not (Test-Path $OutputPath)) {
|
if ($OutputPath -and -not (Test-Path $OutputPath)) {
|
||||||
Write-Host "Creating output directory: $OutputPath" -ForegroundColor Yellow
|
Write-Host "Creating output directory: $OutputPath" -ForegroundColor Yellow
|
||||||
New-Item -Path $OutputPath -ItemType Directory -Force | Out-Null
|
New-Item -Path $OutputPath -ItemType Directory -Force -WhatIf:$false | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
$successCount = 0
|
$successCount = 0
|
||||||
@@ -161,7 +161,7 @@ process {
|
|||||||
|
|
||||||
# Create temporary extraction directory
|
# Create temporary extraction directory
|
||||||
$tempDir = Join-Path $env:TEMP ("DCS_Mission_Patch_" + [System.Guid]::NewGuid().ToString())
|
$tempDir = Join-Path $env:TEMP ("DCS_Mission_Patch_" + [System.Guid]::NewGuid().ToString())
|
||||||
New-Item -Path $tempDir -ItemType Directory -Force | Out-Null
|
New-Item -Path $tempDir -ItemType Directory -Force -WhatIf:$false | Out-Null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Extract mission file (it's a ZIP archive)
|
# Extract mission file (it's a ZIP archive)
|
||||||
@@ -178,7 +178,7 @@ process {
|
|||||||
# Create directory if it doesn't exist
|
# Create directory if it doesn't exist
|
||||||
if (-not (Test-Path $luaDestDir)) {
|
if (-not (Test-Path $luaDestDir)) {
|
||||||
Write-Host " Creating l10n/DEFAULT directory..." -ForegroundColor Yellow
|
Write-Host " Creating l10n/DEFAULT directory..." -ForegroundColor Yellow
|
||||||
New-Item -Path $luaDestDir -ItemType Directory -Force | Out-Null
|
New-Item -Path $luaDestDir -ItemType Directory -Force -WhatIf:$false | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
$luaDestPath = Join-Path $luaDestDir $ScriptName
|
$luaDestPath = Join-Path $luaDestDir $ScriptName
|
||||||
@@ -191,7 +191,7 @@ process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Copy Lua script to mission
|
# Copy Lua script to mission
|
||||||
Copy-Item $LuaScriptPath $luaDestPath -Force
|
Copy-Item $LuaScriptPath $luaDestPath -Force -WhatIf:$false
|
||||||
|
|
||||||
# Determine output filename and location
|
# Determine output filename and location
|
||||||
$originalFileName = Split-Path $missionFile -Leaf
|
$originalFileName = Split-Path $missionFile -Leaf
|
||||||
@@ -216,7 +216,7 @@ process {
|
|||||||
|
|
||||||
# Remove existing mission file if it exists
|
# Remove existing mission file if it exists
|
||||||
if (Test-Path $outputMission) {
|
if (Test-Path $outputMission) {
|
||||||
Remove-Item $outputMission -Force
|
Remove-Item $outputMission -Force -WhatIf:$false
|
||||||
}
|
}
|
||||||
|
|
||||||
# Repackage mission file
|
# Repackage mission file
|
||||||
|
|||||||
@@ -303,18 +303,30 @@ foreach ($terrainFolder in $terrainFolders) {
|
|||||||
# Execute the patch script
|
# Execute the patch script
|
||||||
if (-not $runInWhatIfMode) {
|
if (-not $runInWhatIfMode) {
|
||||||
try {
|
try {
|
||||||
# Call Patch-MooseMissions.ps1
|
# Capture output from Patch-MooseMissions.ps1
|
||||||
& $patchScriptPath -MissionPath $latestMission.FullName -LuaScriptPath $MooseLuaPath -ErrorAction Stop
|
$patchOutput = & $patchScriptPath -MissionPath $latestMission.FullName -LuaScriptPath $MooseLuaPath 2>&1
|
||||||
|
|
||||||
# Check if it succeeded (the script will output its own messages)
|
# Display the output
|
||||||
if ($LASTEXITCODE -eq 0 -or $null -eq $LASTEXITCODE) {
|
$patchOutput | ForEach-Object { Write-Output $_ }
|
||||||
|
|
||||||
|
# Check if it succeeded by looking for error indicators in output
|
||||||
|
$errorFound = $false
|
||||||
|
foreach ($line in $patchOutput) {
|
||||||
|
if ($line -match "ERROR:" -or $line -match "Failed: [1-9]") {
|
||||||
|
$errorFound = $true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $errorFound) {
|
||||||
$totalMissionsPatched++
|
$totalMissionsPatched++
|
||||||
} else {
|
} else {
|
||||||
$totalMissionsFailed++
|
$totalMissionsFailed++
|
||||||
|
Write-Host " Mission patch failed - see errors above" -ForegroundColor Red
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host " ERROR: Failed to patch mission - $_" -ForegroundColor Red
|
Write-Host " ERROR: Failed to execute patch script - $_" -ForegroundColor Red
|
||||||
$totalMissionsFailed++
|
$totalMissionsFailed++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user