Skip to content

Commit 1661ec0

Browse files
committed
fix: 修复 Lobby API 端口 7446 未开放的问题
1 parent 0799c94 commit 1661ec0

3 files changed

Lines changed: 103 additions & 3 deletions

File tree

OpenRA.Game/Game.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public static class Game
7575
internal static OrderManager OrderManager;
7676
static Server.Server server;
7777

78+
public static LobbyCommandServer LobbyServer;
79+
7880
public static MersenneTwister CosmeticRandom = new(); // not synced
7981

8082
public static Renderer Renderer;
@@ -111,6 +113,12 @@ public static OrderManager JoinServer(ConnectionTarget endpoint, string password
111113
lastConnectionState = ConnectionState.PreConnecting;
112114
ConnectionStateChanged(OrderManager, password, newConnection);
113115

116+
if (LobbyServer == null)
117+
{
118+
LobbyServer = new LobbyCommandServer(7446, OrderManager);
119+
LobbyServer.Start();
120+
}
121+
114122
return om;
115123
}
116124

OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,17 @@ internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer,
165165

166166
services = modData.Manifest.Get<WebServices>();
167167

168-
lobbyServer = new LobbyCommandServer(7446, orderManager);
169-
LobbyCommands.Register(lobbyServer);
170-
lobbyServer.Start();
168+
if (Game.LobbyServer == null)
169+
{
170+
lobbyServer = new LobbyCommandServer(7446, orderManager);
171+
LobbyCommands.Register(lobbyServer);
172+
lobbyServer.Start();
173+
}
174+
else
175+
{
176+
lobbyServer = Game.LobbyServer;
177+
LobbyCommands.Register(lobbyServer);
178+
}
171179

172180
Game.LobbyInfoChanged += UpdateCurrentMap;
173181
Game.LobbyInfoChanged += UpdatePlayerList;

package_win.ps1

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
$distBase = "dist"
4+
$distDir = "$distBase\win-x64"
5+
6+
# Ensure output directory exists and is clean
7+
if (Test-Path $distBase) {
8+
Remove-Item $distBase -Recurse -Force
9+
}
10+
New-Item -ItemType Directory -Path $distDir | Out-Null
11+
12+
Write-Host "Copying core files from bin directory..." -ForegroundColor Cyan
13+
14+
# We need to merge files from bin (managed dlls) and bin\win-x64 (runtime and exe)
15+
# 1. Copy the win-x64 runtime/exe files first
16+
$binWin64 = "bin\win-x64"
17+
if (Test-Path $binWin64) {
18+
Copy-Item "$binWin64\*" -Destination $distDir -Recurse -Force
19+
} else {
20+
Write-Warning "bin\win-x64 not found. The game might not launch."
21+
}
22+
23+
# 2. Copy the managed DLLs from bin root, avoiding the nested win-x64 folder
24+
# This fixes the missing OpenRA.Mods.Cnc.dll issue
25+
$binRoot = "bin"
26+
if (Test-Path $binRoot) {
27+
Get-ChildItem -Path $binRoot -File | ForEach-Object {
28+
Copy-Item $_.FullName -Destination $distDir -Force
29+
}
30+
}
31+
32+
# 2. Copy Game Assets (Mods and Shaders)
33+
# These are usually in the root, not inside bin
34+
Write-Host "Copying assets (mods, glsl)..." -ForegroundColor Cyan
35+
$modsDest = "$distDir\mods"
36+
$glslDest = "$distDir\glsl"
37+
38+
if (-not (Test-Path $modsDest)) { New-Item -ItemType Directory -Path $modsDest | Out-Null }
39+
if (-not (Test-Path $glslDest)) { New-Item -ItemType Directory -Path $glslDest | Out-Null }
40+
41+
# Copy all mods
42+
if (Test-Path "mods") {
43+
Copy-Item "mods\*" -Destination $modsDest -Recurse
44+
} else {
45+
Write-Warning "Directory 'mods' not found in root."
46+
}
47+
48+
# Copy shaders
49+
if (Test-Path "glsl") {
50+
Copy-Item "glsl\*" -Destination $glslDest -Recurse
51+
} else {
52+
Write-Warning "Directory 'glsl' not found in root."
53+
}
54+
55+
# 3. Copy Documentation
56+
Write-Host "Copying licenses and docs..." -ForegroundColor Cyan
57+
Copy-Item "AUTHORS", "COPYING", "socket-apis.md", "VERSION", "global mix database.dat" -Destination $distDir -ErrorAction SilentlyContinue
58+
59+
# 4. Create Launch Scripts
60+
Write-Host "Creating launcher scripts..." -ForegroundColor Cyan
61+
62+
# Launch OpenRA (Generic) - similar to user's reference
63+
$genericLauncher = @"
64+
@echo off
65+
setlocal ENABLEDELAYEDEXPANSION
66+
67+
set "BASE=%~dp0win-x64"
68+
cd /d "%BASE%"
69+
70+
set "MODARG=Game.Mod=copilot"
71+
if exist "%CD%\mods\copilot\mod.yaml" (
72+
set "MODARG=Game.Mod=%CD%\mods\copilot"
73+
)
74+
75+
start "" "OpenRA.exe" %MODARG% %*
76+
endlocal
77+
"@
78+
Set-Content -Path "$distBase\launch-openra.cmd" -Value $genericLauncher
79+
80+
Write-Host "------------------------------------------------------" -ForegroundColor Green
81+
Write-Host "Build Complete (Copy Mode)!" -ForegroundColor Green
82+
Write-Host "Location: $distBase" -ForegroundColor Green
83+
Write-Host "Action: Run 'launch-openra.cmd' to play." -ForegroundColor Green
84+
Write-Host "------------------------------------------------------" -ForegroundColor Green

0 commit comments

Comments
 (0)