pre cw with probe and a bunch script to read game behavior
This commit is contained in:
1 parent
5120219ae2
commit
da8a32f60d
310 files changed
+219693
-872
No files matched your search
@@ -5,6 +5,7 @@ $interactiveMenu = [string]::IsNullOrWhiteSpace($Action)
|
||||
$menuCloseDelaySeconds = 5
|
||||
$launcherExitCode = 0
|
||||
Set-Location -LiteralPath $PSScriptRoot
|
||||
. (Join-Path $PSScriptRoot 'tools/go-toolchain.ps1')
|
||||
|
||||
function Merge-Settings($Base, $Override) {
|
||||
foreach ($property in $Override.PSObject.Properties) {
|
||||
@@ -38,13 +39,10 @@ function Start-ProjectServer([string]$Name) {
|
||||
Write-Host "Started $Name (PID $($process.Id)) in its own visible console."
|
||||
}
|
||||
function Build-Servers {
|
||||
$go = $env:GAC_GO_COMMAND
|
||||
if ([string]::IsNullOrWhiteSpace($go)) { $go = $settings.launcher.go_command }
|
||||
if ([string]::IsNullOrWhiteSpace($go)) { throw 'Set launcher.go_command or GAC_GO_COMMAND.' }
|
||||
$command = Get-Command -Name $go -CommandType Application -ErrorAction Stop
|
||||
$go = Resolve-GoToolchain $settings.launcher
|
||||
foreach ($name in @('gameserver', 'sdkserver')) {
|
||||
$next = Resolve-ProjectPath ($name + '-go.next.exe')
|
||||
& $command.Source build -o $next ('./cmd/' + $name)
|
||||
& $go build -o $next ('./cmd/' + $name)
|
||||
if ($LASTEXITCODE -ne 0) { throw "Build failed: $name. Existing binaries were not replaced." }
|
||||
}
|
||||
foreach ($name in @('gameserver-go', 'sdkserver-go')) {
|
||||
@@ -82,6 +80,7 @@ try {
|
||||
Merge-Settings $settings (Get-Content -LiteralPath $localPath -Raw | ConvertFrom-Json)
|
||||
}
|
||||
$variables = @{
|
||||
account_name='GAC_ACCOUNT_NAME';
|
||||
player_uid='GAC_PLAYER_UID'; client_version='GAC_CLIENT_VERSION'; game_host='GAC_GAME_HOST'; game_port='GAC_GAME_PORT';
|
||||
sdk_host='GAC_SDK_HOST'; sdk_port='GAC_SDK_PORT'; public_game_host='GAC_PUBLIC_GAME_HOST';
|
||||
public_sdk_url='GAC_PUBLIC_SDK_URL'
|
||||
@@ -90,6 +89,35 @@ try {
|
||||
$value = [Environment]::GetEnvironmentVariable($variables[$key])
|
||||
if ($null -ne $value) { $settings | Add-Member -MemberType NoteProperty -Name $key -Value $value -Force }
|
||||
}
|
||||
foreach ($pair in @(@('begin_time','GAC_ACTIVITY_BEGIN_TIME'),@('end_time','GAC_ACTIVITY_END_TIME'))) {
|
||||
$value = [Environment]::GetEnvironmentVariable($pair[1])
|
||||
if ($null -ne $value) {
|
||||
if (-not $settings.activity_schedule) { $settings | Add-Member -MemberType NoteProperty -Name activity_schedule -Value ([pscustomobject]@{}) }
|
||||
$settings.activity_schedule | Add-Member -MemberType NoteProperty -Name $pair[0] -Value $value -Force
|
||||
}
|
||||
}
|
||||
$liveStaleSecondsText = [string]$settings.battle_diagnostics.live_report_stale_seconds
|
||||
$liveStaleSecondsOverride = [Environment]::GetEnvironmentVariable('GAC_LIVE_BATTLE_STALE_SECONDS')
|
||||
if ($null -ne $liveStaleSecondsOverride) {
|
||||
if (-not $settings.battle_diagnostics) {
|
||||
$settings | Add-Member -MemberType NoteProperty -Name battle_diagnostics -Value ([pscustomobject]@{})
|
||||
}
|
||||
$settings.battle_diagnostics | Add-Member -MemberType NoteProperty -Name live_report_stale_seconds -Value $liveStaleSecondsOverride -Force
|
||||
$liveStaleSecondsText = $liveStaleSecondsOverride
|
||||
}
|
||||
$liveStaleSeconds = [uint16]0
|
||||
if (-not [uint16]::TryParse($liveStaleSecondsText, [ref]$liveStaleSeconds) -or $liveStaleSeconds -eq 0) {
|
||||
throw 'battle_diagnostics.live_report_stale_seconds must be an integer between 1 and 65535.'
|
||||
}
|
||||
$activityBegin = [long]0
|
||||
$activityEnd = [long]0
|
||||
if (-not $settings.activity_schedule -or
|
||||
$null -eq $settings.activity_schedule.begin_time -or $null -eq $settings.activity_schedule.end_time -or
|
||||
-not [long]::TryParse([string]$settings.activity_schedule.begin_time,[ref]$activityBegin) -or
|
||||
-not [long]::TryParse([string]$settings.activity_schedule.end_time,[ref]$activityEnd) -or
|
||||
$activityBegin -lt 0 -or $activityEnd -le $activityBegin) {
|
||||
throw 'activity_schedule requires nonnegative begin_time and end_time greater than begin_time.'
|
||||
}
|
||||
$configuredUID = [uint32]0
|
||||
if (-not [uint32]::TryParse([string]$settings.player_uid, [ref]$configuredUID) -or $configuredUID -eq 0) {
|
||||
throw 'player_uid must be an integer between 1 and 4294967295.'
|
||||
@@ -100,8 +128,8 @@ try {
|
||||
throw "$key must be a port between 1 and $([uint16]::MaxValue)."
|
||||
}
|
||||
}
|
||||
foreach ($key in @('client_version','game_host','sdk_host','public_game_host','public_sdk_url')) {
|
||||
if ([string]::IsNullOrWhiteSpace($settings.$key)) { throw "Missing setting: $key" }
|
||||
foreach ($key in @('account_name','client_version','game_host','sdk_host','public_game_host','public_sdk_url')) {
|
||||
if ($settings.$key -isnot [string] -or [string]::IsNullOrWhiteSpace($settings.$key)) { throw "Missing or invalid string setting: $key" }
|
||||
}
|
||||
foreach ($key in @('game_host','sdk_host','public_game_host')) {
|
||||
if ([string]$settings.$key -match '[/\\\s]') { throw "Invalid host: $key" }
|
||||
@@ -110,7 +138,17 @@ try {
|
||||
if (-not [Uri]::TryCreate($settings.public_sdk_url, [UriKind]::Absolute, [ref]$uri) -or $uri.Scheme -notin @('http','https') -or $uri.Query -or $uri.Fragment -or $uri.UserInfo) {
|
||||
throw 'public_sdk_url must be an HTTP(S) base URL.'
|
||||
}
|
||||
if ($Action -eq 'check') { Write-Host 'Configuration valid.'; exit 0 }
|
||||
$leaseSeconds = [uint32]0
|
||||
if ($settings.srtool.lease_file -isnot [string] -or [string]::IsNullOrWhiteSpace($settings.srtool.lease_file) -or -not [uint32]::TryParse([string]$settings.srtool.lease_seconds,[ref]$leaseSeconds) -or $leaseSeconds -eq 0) { throw 'Set srtool.lease_file and positive uint32 srtool.lease_seconds.' }
|
||||
$install = $settings.launcher.go_install
|
||||
if ($install -and $install.enabled) {
|
||||
if ([string]::IsNullOrWhiteSpace($install.directory)) { throw 'Set launcher.go_install.directory.' }
|
||||
foreach ($key in @('manifest_url','download_url')) {
|
||||
$uri = $null
|
||||
if (-not [Uri]::TryCreate($install.$key, [UriKind]::Absolute, [ref]$uri) -or $uri.Scheme -ne 'https' -or $uri.UserInfo -or $uri.Fragment) { throw "launcher.go_install.$key must be an HTTPS URL." }
|
||||
}
|
||||
}
|
||||
if ($Action -eq 'check') { Write-Host "Configuration valid. Activity schedule: $activityBegin -> $activityEnd"; exit 0 }
|
||||
if ([string]::IsNullOrWhiteSpace($Action)) {
|
||||
Write-Host "GaC hkrpg GO | Client $($settings.client_version)"
|
||||
Write-Host "Game UDP $($settings.game_host):$($settings.game_port) | SDK HTTP $($settings.sdk_host):$($settings.sdk_port)"
|
||||
@@ -127,6 +165,7 @@ try {
|
||||
{ $_ -in @('4','gs') } { Start-ProjectServer 'gameserver-go'; break }
|
||||
{ $_ -in @('5','proxy') } { Start-ProjectServer 'sdkserver-go'; Start-ProjectServer 'gameserver-go'; Start-External 'proxy_path' 'GAC_PROXY_PATH'; break }
|
||||
{ $_ -in @('6','build') } { Build-Servers; break }
|
||||
'requirements' { $go = Resolve-GoToolchain $settings.launcher; Write-Host "Go ready: $go"; break }
|
||||
'7' { break }
|
||||
{ $_ -in @('8','stop') } { Stop-ProjectServer 'sdkserver-go'; Stop-ProjectServer 'gameserver-go'; break }
|
||||
default { throw "Unknown action: $Action" }
|
||||
|
||||
Reference in new issue
Block a user