Moved Namalsk patching.

Namalsk server mods patching moved to update scope.
This commit is contained in:
Vladislav Salikov
2024-11-19 22:05:52 +03:00
parent a8a061464f
commit 206599127c
4 changed files with 114 additions and 77 deletions

View File

@@ -11,10 +11,10 @@ param (
$param = 0
)
[bool]$update = $param
[bool]$noDelete = $true # For tests - don't delete logs
[bool]$noDelete = $false # For tests - don't delete logs
[string]$logFile = ".\wDayzManager.log"
[string]$steamScript = "wDayzManager.txt"
[string]$iniFile = "wDayzManager.ini"
[string]$iniFile = ".\wDayzManager.ini"
if (-not (Test-Path $iniFile)) {
Write-Error "Can't find file '$iniFile'"
Exit
@@ -25,6 +25,10 @@ $date = Get-Date
[int]$currentDay = ([datetime]$date).Day
[int]$currentHour = ([datetime]$date).Hour
$date2 = Get-Date -Format 's' | ForEach-Object { $_ -replace 'T', ' ' }
Write-Host "$($date2) Starting wDayzManager script"
Write-Host "update = $($update), noDelete = $($noDelete)"
$ini = $config = $servers = $clientMods = $serverMods = $steamProcess = $null
$modNI = $modNS = $namalskMission = $pathNamalskMission = $null
$dayzProcess = $becProcess = $instance = $null
@@ -35,8 +39,6 @@ $startupClientMods = $startupServerMods = $startupMods = $startupParams = $null
$serverProfile = $additionalParams = $dayzArguments = $dayz = $bec = $becArguments = $null
$logsName = $atLogsLocation = $becLogsLocation = $rotatedLogsLocation = $null
Write-Host "=========="
$ini = (Get-IniContent -FilePath $iniFile)
$config = $ini.Config
[string]$serverLocation = $config.serverLocation
@@ -121,6 +123,33 @@ if ($update) {
}
Start-Sleep -Seconds 1
# Patching Namalsk
[bool]$isNamalskIslandPresent = $false
[bool]$isNamalskSurvivalPresent = $false
$clientMods.Item1 | ForEach-Object {
if ($_ -like "*namalsk*" -and $_ -like "*island*") {
$isNamalskIslandPresent = $true
$modNI = $_
Write-Host "Patching Namalsk Island server meta.cpp file ..."
$whatFind_NI = "2288339650"
$replaceWith_NI = "2289456201"
$content = Get-Content -Path "$($serverLocation)\$($modNI)\meta.cpp"
$content = $content -replace $whatFind_NI, $replaceWith_NI
Set-Content -Path "$($serverLocation)\$($modNI)\meta.cpp" -Value $content
}
if ($_ -like "*namalsk*" -and $_ -like "*survival*") {
$isNamalskSurvivalPresent = $true
$modNS = $_
Write-Host "Patching Namalsk Survival server meta.cpp file ..."
$whatFind_NS = "2288336145"
$replaceWith_NS = "2289461232"
$content = Get-Content -Path "$($serverLocation)\$($modNS)\meta.cpp"
$content = $content -replace $whatFind_NS, $replaceWith_NS
Set-Content -Path "$($serverLocation)\$($modNS)\meta.cpp" -Value $content
}
}
# # Customizing servers
# # Overwriting default messages.xml from Namalsk by custom file
# if (Test-Path -Path "$($serverLocation)\.customs") {
@@ -130,34 +159,7 @@ if ($update) {
Write-Host "End of updating server."
Start-Sleep -Seconds 1
}
Write-Host
# Patching Namalsk
[bool]$isNamalskIslandPresent = $false
[bool]$isNamalskSurvivalPresent = $false
$clientMods.Item1 | ForEach-Object {
if ($_ -like "*namalsk*" -and $_ -like "*island*") {
$isNamalskIslandPresent = $true
$modNI = $_
Write-Host "Patching Namalsk Island server meta.cpp file ..."
$whatFind_NI = "2288339650"
$replaceWith_NI = "2289456201"
$content = Get-Content -Path "$($serverLocation)\$($modNI)\meta.cpp"
$content = $content -replace $whatFind_NI, $replaceWith_NI
Set-Content -Path "$($serverLocation)\$($modNI)\meta.cpp" -Value $content
}
if ($_ -like "*namalsk*" -and $_ -like "*survival*") {
$isNamalskSurvivalPresent = $true
$modNS = $_
Write-Host "Patching Namalsk Survival server meta.cpp file ..."
$whatFind_NS = "2288336145"
$replaceWith_NS = "2289461232"
$content = Get-Content -Path "$($serverLocation)\$($modNS)\meta.cpp"
$content = $content -replace $whatFind_NS, $replaceWith_NS
Set-Content -Path "$($serverLocation)\$($modNS)\meta.cpp" -Value $content
}
}
Write-Host
if ($rotateLogs) {
@@ -411,18 +413,22 @@ foreach ($srv in $servers) {
# Write-Host " daysAmount: $($daysAmount)"
# Write-Host " noDelete: $($noDelete)"
# # Starting servers
# Set-Location -Path "$($serverLocation)"
# $dayzProcess[$processID] = Start-Process -FilePath $dayz -ArgumentList $dayzArguments -PassThru
# Starting servers
Set-Location -Path "$($serverLocation)"
$dayzProcess[$processID] = Start-Process -FilePath $dayz -ArgumentList $dayzArguments -PassThru
# $dayzProcess[$processID]
# if ($becLocation) {
# Set-Location -Path "$($becLocation)"
# $becProcess[$processID] = Start-Process -FilePath $bec -ArgumentList $becArguments -PassThru
# $becProcess[$processID]
# }
# Starting BEC
if ($becLocation) {
Set-Location -Path "$($becLocation)"
$becProcess[$processID] = Start-Process -FilePath $bec -ArgumentList $becArguments -PassThru
# $becProcess[$processID]
}
$processID++
Write-Host
Start-Sleep -Seconds 1
}
# Start-Sleep -Seconds 5
Write-Host "=========="
Write-Host "End of wDayzManager script"