Move dedicated server code to OpenRA.Server.exe
This commit is contained in:
29
Makefile
29
Makefile
@@ -87,7 +87,7 @@ INSTALL_PROGRAM = $(INSTALL) -m755
|
|||||||
INSTALL_DATA = $(INSTALL) -m644
|
INSTALL_DATA = $(INSTALL) -m644
|
||||||
|
|
||||||
# program targets
|
# program targets
|
||||||
CORE = pdefault pnull game utility
|
CORE = pdefault pnull game utility server
|
||||||
TOOLS = gamemonitor
|
TOOLS = gamemonitor
|
||||||
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
|
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
|
||||||
|
|
||||||
@@ -231,6 +231,9 @@ check: utility mods
|
|||||||
@echo
|
@echo
|
||||||
@echo "Checking for explicit interface violations..."
|
@echo "Checking for explicit interface violations..."
|
||||||
@mono --debug OpenRA.Utility.exe all --check-explicit-interfaces
|
@mono --debug OpenRA.Utility.exe all --check-explicit-interfaces
|
||||||
|
@echo
|
||||||
|
@echo "Checking for code style violations in OpenRA.Server..."
|
||||||
|
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Server
|
||||||
|
|
||||||
NUNIT_CONSOLE := $(shell test -f thirdparty/download/nunit3-console.exe && echo mono thirdparty/download/nunit3-console.exe || \
|
NUNIT_CONSOLE := $(shell test -f thirdparty/download/nunit3-console.exe && echo mono thirdparty/download/nunit3-console.exe || \
|
||||||
which nunit3-console 2>/dev/null || which nunit2-console 2>/dev/null || which nunit-console 2>/dev/null)
|
which nunit3-console 2>/dev/null || which nunit2-console 2>/dev/null || which nunit-console 2>/dev/null)
|
||||||
@@ -286,6 +289,15 @@ utility_LIBS = $(COMMON_LIBS) $(utility_DEPS) thirdparty/download/ICSharpCode.Sh
|
|||||||
PROGRAMS += utility
|
PROGRAMS += utility
|
||||||
utility: $(utility_TARGET)
|
utility: $(utility_TARGET)
|
||||||
|
|
||||||
|
# Dedicated server
|
||||||
|
server_SRCS := $(shell find OpenRA.Server/ -iname '*.cs')
|
||||||
|
server_TARGET = OpenRA.Server.exe
|
||||||
|
server_KIND = exe
|
||||||
|
server_DEPS = $(game_TARGET)
|
||||||
|
server_LIBS = $(COMMON_LIBS) $(server_DEPS)
|
||||||
|
PROGRAMS += server
|
||||||
|
server: $(server_TARGET)
|
||||||
|
|
||||||
# Patches binary headers to work around a mono bug
|
# Patches binary headers to work around a mono bug
|
||||||
fixheader.exe: packaging/fixheader.cs
|
fixheader.exe: packaging/fixheader.cs
|
||||||
@echo CSC fixheader.exe
|
@echo CSC fixheader.exe
|
||||||
@@ -315,7 +327,7 @@ $(foreach prog,$(PROGRAMS),$(eval $(call BUILD_ASSEMBLY,$(prog))))
|
|||||||
#
|
#
|
||||||
default: core
|
default: core
|
||||||
|
|
||||||
core: game platforms mods utility
|
core: game platforms mods utility server
|
||||||
|
|
||||||
tools: gamemonitor
|
tools: gamemonitor
|
||||||
|
|
||||||
@@ -465,9 +477,22 @@ endif
|
|||||||
@$(INSTALL_PROGRAM) -m +rx openra "$(BIN_INSTALL_DIR)"
|
@$(INSTALL_PROGRAM) -m +rx openra "$(BIN_INSTALL_DIR)"
|
||||||
@-$(RM) openra
|
@-$(RM) openra
|
||||||
|
|
||||||
|
@echo "#!/bin/sh" > openra-server
|
||||||
|
@echo 'cd "$(gameinstalldir)"' >> openra-server
|
||||||
|
ifeq ($(DEBUG), $(filter $(DEBUG),false no n off 0))
|
||||||
|
@echo 'mono OpenRA.Server.exe "$$@"' >> openra-server
|
||||||
|
else
|
||||||
|
@echo 'mono --debug OpenRA.Server.exe "$$@"' >> openra-server
|
||||||
|
endif
|
||||||
|
|
||||||
|
@$(INSTALL_DIR) "$(BIN_INSTALL_DIR)"
|
||||||
|
@$(INSTALL_PROGRAM) -m +rx openra-server "$(BIN_INSTALL_DIR)"
|
||||||
|
@-$(RM) openra-server
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@-$(RM_R) "$(DATA_INSTALL_DIR)"
|
@-$(RM_R) "$(DATA_INSTALL_DIR)"
|
||||||
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra"
|
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra"
|
||||||
|
@-$(RM_F) "$(BIN_INSTALL_DIR)/openra-server"
|
||||||
@-$(RM_F) "$(DESTDIR)$(datadir)/applications/openra.desktop"
|
@-$(RM_F) "$(DESTDIR)$(datadir)/applications/openra.desktop"
|
||||||
@-$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/16x16/apps/openra.png"
|
@-$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/16x16/apps/openra.png"
|
||||||
@-$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/32x32/apps/openra.png"
|
@-$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/32x32/apps/openra.png"
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound = new Sound(Settings.Server.Dedicated ? "Null" : Settings.Sound.Engine);
|
Sound = new Sound(Settings.Sound.Engine);
|
||||||
|
|
||||||
GlobalChat = new GlobalChat();
|
GlobalChat = new GlobalChat();
|
||||||
|
|
||||||
@@ -341,17 +341,11 @@ namespace OpenRA
|
|||||||
|
|
||||||
Sound.StopVideo();
|
Sound.StopVideo();
|
||||||
|
|
||||||
ModData = new ModData(mod, !Settings.Server.Dedicated);
|
ModData = new ModData(mod, true);
|
||||||
|
|
||||||
using (new PerfTimer("LoadMaps"))
|
using (new PerfTimer("LoadMaps"))
|
||||||
ModData.MapCache.LoadMaps();
|
ModData.MapCache.LoadMaps();
|
||||||
|
|
||||||
if (Settings.Server.Dedicated)
|
|
||||||
{
|
|
||||||
RunDedicatedServer();
|
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var installData = ModData.Manifest.Get<ContentInstaller>();
|
var installData = ModData.Manifest.Get<ContentInstaller>();
|
||||||
var isModContentInstalled = installData.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)));
|
var isModContentInstalled = installData.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)));
|
||||||
|
|
||||||
@@ -398,37 +392,6 @@ namespace OpenRA
|
|||||||
ModData.LoadScreen.StartGame(args);
|
ModData.LoadScreen.StartGame(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RunDedicatedServer()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Settings.Server.Map = ModData.MapCache.ChooseInitialMap(Settings.Server.Map, CosmeticRandom);
|
|
||||||
Settings.Save();
|
|
||||||
CreateServer(Settings.Server.Clone());
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Thread.Sleep(100);
|
|
||||||
|
|
||||||
if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
|
|
||||||
{
|
|
||||||
Console.WriteLine("No one is playing, shutting down...");
|
|
||||||
server.Shutdown();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.Server.DedicatedLoop)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Starting a new server instance...");
|
|
||||||
ModData.MapCache.LoadMaps();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LoadEditor(string mapUid)
|
public static void LoadEditor(string mapUid)
|
||||||
{
|
{
|
||||||
StartGame(mapUid, WorldType.Editor);
|
StartGame(mapUid, WorldType.Editor);
|
||||||
@@ -811,7 +774,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void CreateServer(ServerSettings settings)
|
public static void CreateServer(ServerSettings settings)
|
||||||
{
|
{
|
||||||
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, ModData);
|
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, ModData, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CreateLocalServer(string map)
|
public static int CreateLocalServer(string map)
|
||||||
@@ -824,7 +787,7 @@ namespace OpenRA
|
|||||||
AllowPortForward = false
|
AllowPortForward = false
|
||||||
};
|
};
|
||||||
|
|
||||||
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), settings, ModData);
|
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), settings, ModData, false);
|
||||||
|
|
||||||
return server.Port;
|
return server.Port;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,16 +50,12 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var resolution = GetResolution(graphicSettings);
|
var resolution = GetResolution(graphicSettings);
|
||||||
|
|
||||||
var rendererName = serverSettings.Dedicated ? "Null" : graphicSettings.Renderer;
|
var rendererName = graphicSettings.Renderer;
|
||||||
var rendererPath = Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms." + rendererName + ".dll"));
|
var rendererPath = Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms." + rendererName + ".dll"));
|
||||||
|
|
||||||
Device = CreateDevice(Assembly.LoadFile(rendererPath), resolution.Width, resolution.Height, graphicSettings.Mode);
|
Device = CreateDevice(Assembly.LoadFile(rendererPath), resolution.Width, resolution.Height, graphicSettings.Mode);
|
||||||
|
TempBufferSize = graphicSettings.BatchSize;
|
||||||
if (!serverSettings.Dedicated)
|
SheetSize = graphicSettings.SheetSize;
|
||||||
{
|
|
||||||
TempBufferSize = graphicSettings.BatchSize;
|
|
||||||
SheetSize = graphicSettings.SheetSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("shp"));
|
WorldSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("shp"));
|
||||||
WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba"));
|
WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba"));
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace OpenRA.Server
|
|||||||
public readonly IPAddress Ip;
|
public readonly IPAddress Ip;
|
||||||
public readonly int Port;
|
public readonly int Port;
|
||||||
public readonly MersenneTwister Random = new MersenneTwister();
|
public readonly MersenneTwister Random = new MersenneTwister();
|
||||||
|
public readonly bool Dedicated;
|
||||||
|
|
||||||
// Valid player connections
|
// Valid player connections
|
||||||
public List<Connection> Conns = new List<Connection>();
|
public List<Connection> Conns = new List<Connection>();
|
||||||
@@ -117,7 +118,7 @@ namespace OpenRA.Server
|
|||||||
t.GameEnded(this);
|
t.GameEnded(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Server(IPEndPoint endpoint, ServerSettings settings, ModData modData)
|
public Server(IPEndPoint endpoint, ServerSettings settings, ModData modData, bool dedicated)
|
||||||
{
|
{
|
||||||
Log.AddChannel("server", "server.log");
|
Log.AddChannel("server", "server.log");
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ namespace OpenRA.Server
|
|||||||
var localEndpoint = (IPEndPoint)listener.LocalEndpoint;
|
var localEndpoint = (IPEndPoint)listener.LocalEndpoint;
|
||||||
Ip = localEndpoint.Address;
|
Ip = localEndpoint.Address;
|
||||||
Port = localEndpoint.Port;
|
Port = localEndpoint.Port;
|
||||||
|
Dedicated = dedicated;
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
|
|
||||||
Settings.Name = OpenRA.Settings.SanitizedServerName(Settings.Name);
|
Settings.Name = OpenRA.Settings.SanitizedServerName(Settings.Name);
|
||||||
@@ -148,7 +149,7 @@ namespace OpenRA.Server
|
|||||||
RandomSeed = randomSeed,
|
RandomSeed = randomSeed,
|
||||||
Map = settings.Map,
|
Map = settings.Map,
|
||||||
ServerName = settings.Name,
|
ServerName = settings.Name,
|
||||||
Dedicated = settings.Dedicated,
|
Dedicated = dedicated,
|
||||||
DisableSingleplayer = settings.DisableSinglePlayer,
|
DisableSingleplayer = settings.DisableSinglePlayer,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -380,7 +381,7 @@ namespace OpenRA.Server
|
|||||||
// Send initial ping
|
// Send initial ping
|
||||||
SendOrderTo(newConn, "Ping", Game.RunTime.ToString(CultureInfo.InvariantCulture));
|
SendOrderTo(newConn, "Ping", Game.RunTime.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
if (Settings.Dedicated)
|
if (Dedicated)
|
||||||
{
|
{
|
||||||
var motdFile = Platform.ResolvePath("^", "motd.txt");
|
var motdFile = Platform.ResolvePath("^", "motd.txt");
|
||||||
if (!File.Exists(motdFile))
|
if (!File.Exists(motdFile))
|
||||||
@@ -490,7 +491,7 @@ namespace OpenRA.Server
|
|||||||
{
|
{
|
||||||
DispatchOrdersToClients(null, 0, new ServerOrder("Message", text).Serialize());
|
DispatchOrdersToClients(null, 0, new ServerOrder("Message", text).Serialize());
|
||||||
|
|
||||||
if (Settings.Dedicated)
|
if (Dedicated)
|
||||||
Console.WriteLine("[{0}] {1}".F(DateTime.Now.ToString(Settings.TimestampFormat), text));
|
Console.WriteLine("[{0}] {1}".F(DateTime.Now.ToString(Settings.TimestampFormat), text));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,7 +588,7 @@ namespace OpenRA.Server
|
|||||||
|
|
||||||
// Client was the server admin
|
// Client was the server admin
|
||||||
// TODO: Reassign admin for game in progress via an order
|
// TODO: Reassign admin for game in progress via an order
|
||||||
if (LobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin && State == ServerState.WaitingPlayers)
|
if (Dedicated && dropClient.IsAdmin && State == ServerState.WaitingPlayers)
|
||||||
{
|
{
|
||||||
// Remove any bots controlled by the admin
|
// Remove any bots controlled by the admin
|
||||||
LobbyInfo.Clients.RemoveAll(c => c.Bot != null && c.BotControllerClientIndex == toDrop.PlayerIndex);
|
LobbyInfo.Clients.RemoveAll(c => c.Bot != null && c.BotControllerClientIndex == toDrop.PlayerIndex);
|
||||||
@@ -607,10 +608,10 @@ namespace OpenRA.Server
|
|||||||
if (!Conns.Any())
|
if (!Conns.Any())
|
||||||
TempBans.Clear();
|
TempBans.Clear();
|
||||||
|
|
||||||
if (Conns.Any() || LobbyInfo.GlobalSettings.Dedicated)
|
if (Conns.Any() || Dedicated)
|
||||||
SyncLobbyClients();
|
SyncLobbyClients();
|
||||||
|
|
||||||
if (!LobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin)
|
if (!Dedicated && dropClient.IsAdmin)
|
||||||
Shutdown();
|
Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,12 +65,6 @@ namespace OpenRA
|
|||||||
[Desc("Value in milliseconds when to terminate the game. Needs to be at least 10000 (10 s) to enable the timer.")]
|
[Desc("Value in milliseconds when to terminate the game. Needs to be at least 10000 (10 s) to enable the timer.")]
|
||||||
public int TimeOut = 0;
|
public int TimeOut = 0;
|
||||||
|
|
||||||
[Desc("Run in headless mode with an empty renderer and without sound output.")]
|
|
||||||
public bool Dedicated = false;
|
|
||||||
|
|
||||||
[Desc("Automatically restart when a game ends. Disable this when something else already takes care about it.")]
|
|
||||||
public bool DedicatedLoop = true;
|
|
||||||
|
|
||||||
[Desc("Disallow games where only one player plays with bots.")]
|
[Desc("Disallow games where only one player plays with bots.")]
|
||||||
public bool DisableSinglePlayer = false;
|
public bool DisableSinglePlayer = false;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
lastPing = Game.RunTime;
|
lastPing = Game.RunTime;
|
||||||
|
|
||||||
// Ignore client timeout in singleplayer games to make debugging easier
|
// Ignore client timeout in singleplayer games to make debugging easier
|
||||||
if (server.LobbyInfo.IsSinglePlayer && !server.Settings.Dedicated)
|
if (server.LobbyInfo.IsSinglePlayer && !server.Dedicated)
|
||||||
foreach (var c in server.Conns.ToList())
|
foreach (var c in server.Conns.ToList())
|
||||||
server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
|
server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
|
||||||
else
|
else
|
||||||
|
|||||||
99
OpenRA.Server/OpenRA.Server.csproj
Normal file
99
OpenRA.Server/OpenRA.Server.csproj
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>9.0.30729</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{76F621A1-3D8E-4A99-9F7E-B071EB657817}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>OpenRA.Server</RootNamespace>
|
||||||
|
<AssemblyName>OpenRA.Server</AssemblyName>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation />
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<OutputPath>..\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>..\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
|
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||||
|
<Name>OpenRA.Game</Name>
|
||||||
|
<Private>False</Private>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
58
OpenRA.Server/Program.cs
Normal file
58
OpenRA.Server/Program.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading;
|
||||||
|
using OpenRA.Support;
|
||||||
|
|
||||||
|
namespace OpenRA.Server
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Log.AddChannel("debug", "dedicated-debug.log");
|
||||||
|
Log.AddChannel("perf", "dedicated-perf.log");
|
||||||
|
Log.AddChannel("server", "dedicated-server.log");
|
||||||
|
|
||||||
|
// HACK: The engine code assumes that Game.Settings is set.
|
||||||
|
// This isn't nearly as bad as ModData, but is still not very nice.
|
||||||
|
Game.InitializeSettings(new Arguments(args));
|
||||||
|
var settings = Game.Settings.Server;
|
||||||
|
|
||||||
|
// HACK: The engine code *still* assumes that Game.ModData is set
|
||||||
|
var mod = Game.Settings.Game.Mod;
|
||||||
|
var modData = Game.ModData = new ModData(mod, false);
|
||||||
|
modData.MapCache.LoadMaps();
|
||||||
|
|
||||||
|
settings.Map = modData.MapCache.ChooseInitialMap(settings.Map, new MersenneTwister());
|
||||||
|
|
||||||
|
Console.WriteLine("Starting dedicated server for mod: " + mod);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var server = new Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, modData, true);
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
if (server.State == ServerState.GameStarted && server.Conns.Count < 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine("No one is playing, shutting down...");
|
||||||
|
server.Shutdown();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Starting a new server instance...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Utility", "OpenRA.Ut
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Platforms.Null", "OpenRA.Platforms.Null\OpenRA.Platforms.Null.csproj", "{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Platforms.Null", "OpenRA.Platforms.Null\OpenRA.Platforms.Null.csproj", "{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Server", "OpenRA.Server\OpenRA.Server.csproj", "{76F621A1-3D8E-4A99-9F7E-B071EB657817}"
|
||||||
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.D2k", "OpenRA.Mods.D2k\OpenRA.Mods.D2k.csproj", "{C0B0465C-6BE2-409C-8770-3A9BF64C4344}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.D2k", "OpenRA.Mods.D2k\OpenRA.Mods.D2k.csproj", "{C0B0465C-6BE2-409C-8770-3A9BF64C4344}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.TS", "OpenRA.Mods.TS\OpenRA.Mods.TS.csproj", "{5457CBF5-4CE4-421E-A8BF-9FD6C9732E1D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.TS", "OpenRA.Mods.TS\OpenRA.Mods.TS.csproj", "{5457CBF5-4CE4-421E-A8BF-9FD6C9732E1D}"
|
||||||
@@ -127,6 +129,10 @@ Global
|
|||||||
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Debug|x86.Build.0 = Debug|x86
|
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Debug|x86.Build.0 = Debug|x86
|
||||||
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Release|x86.ActiveCfg = Release|x86
|
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Release|x86.ActiveCfg = Release|x86
|
||||||
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Release|x86.Build.0 = Release|x86
|
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Release|x86.Build.0 = Release|x86
|
||||||
|
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|x86.Build.0 = Release|x86
|
||||||
{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Debug|x86.ActiveCfg = Debug|x86
|
{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Debug|x86.Build.0 = Debug|x86
|
{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Debug|x86.Build.0 = Debug|x86
|
||||||
{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Release|x86.ActiveCfg = Release|x86
|
{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
|||||||
@@ -8,15 +8,13 @@
|
|||||||
|
|
||||||
Name="${Name:-"Dedicated Server"}"
|
Name="${Name:-"Dedicated Server"}"
|
||||||
Mod="${Mod:-"ra"}"
|
Mod="${Mod:-"ra"}"
|
||||||
Dedicated="True"
|
|
||||||
DedicatedLoop="True"
|
|
||||||
ListenPort="${ListenPort:-"1234"}"
|
ListenPort="${ListenPort:-"1234"}"
|
||||||
ExternalPort="${ExternalPort:-"1234"}"
|
ExternalPort="${ExternalPort:-"1234"}"
|
||||||
AdvertiseOnline="${AdvertiseOnline:-"True"}"
|
AdvertiseOnline="${AdvertiseOnline:-"True"}"
|
||||||
AllowPortForward="${AllowPortForward:-"False"}"
|
AllowPortForward="${AllowPortForward:-"False"}"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
mono --debug OpenRA.Game.exe Game.Mod=$Mod Server.Dedicated=$Dedicated Server.DedicatedLoop=$DedicatedLoop \
|
mono --debug OpenRA.Server.exe Game.Mod=$Mod \
|
||||||
Server.Name="$Name" Server.ListenPort=$ListenPort Server.ExternalPort=$ExternalPort \
|
Server.Name="$Name" Server.ListenPort=$ListenPort Server.ExternalPort=$ExternalPort \
|
||||||
Server.AdvertiseOnline=$AdvertiseOnline Server.AllowPortForward=$AllowPortForward
|
Server.AdvertiseOnline=$AdvertiseOnline Server.AllowPortForward=$AllowPortForward
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# launch script (executed by Desura)
|
# launch script (executed by Desura)
|
||||||
mono OpenRA.Game.exe Server.Dedicated=False Server.DedicatedLoop=False "$@"
|
mono OpenRA.Game.exe "$@"
|
||||||
if [ $? != 0 -a $? != 1 ]
|
if [ $? != 0 -a $? != 1 ]
|
||||||
then
|
then
|
||||||
ZENITY=`which zenity` || echo "OpenRA needs zenity installed to display a graphical error dialog. See ~/.openra. for log files."
|
ZENITY=`which zenity` || echo "OpenRA needs zenity installed to display a graphical error dialog. See ~/.openra. for log files."
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ markdown DOCUMENTATION.md > DOCUMENTATION.html
|
|||||||
markdown Lua-API.md > Lua-API.html
|
markdown Lua-API.md > Lua-API.html
|
||||||
|
|
||||||
# List of files that are packaged on all platforms
|
# List of files that are packaged on all platforms
|
||||||
FILES=('OpenRA.Game.exe' 'OpenRA.Game.exe.config' 'OpenRA.Utility.exe' \
|
FILES=('OpenRA.Game.exe' 'OpenRA.Game.exe.config' 'OpenRA.Utility.exe' 'OpenRA.Server.exe' \
|
||||||
'OpenRA.Platforms.Default.dll' 'OpenRA.Platforms.Null.dll' \
|
'OpenRA.Platforms.Default.dll' 'OpenRA.Platforms.Null.dll' \
|
||||||
'lua' 'glsl' 'mods/common' 'mods/ra' 'mods/cnc' 'mods/d2k' 'mods/modchooser' \
|
'lua' 'glsl' 'mods/common' 'mods/ra' 'mods/cnc' 'mods/d2k' 'mods/modchooser' \
|
||||||
'AUTHORS' 'COPYING' 'README.html' 'CONTRIBUTING.html' 'DOCUMENTATION.html' 'CHANGELOG.html' \
|
'AUTHORS' 'COPYING' 'README.html' 'CONTRIBUTING.html' 'DOCUMENTATION.html' 'CHANGELOG.html' \
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ Section "Game" GAME
|
|||||||
File "${SRCDIR}\OpenRA.Game.exe"
|
File "${SRCDIR}\OpenRA.Game.exe"
|
||||||
File "${SRCDIR}\OpenRA.Game.exe.config"
|
File "${SRCDIR}\OpenRA.Game.exe.config"
|
||||||
File "${SRCDIR}\OpenRA.Utility.exe"
|
File "${SRCDIR}\OpenRA.Utility.exe"
|
||||||
|
File "${SRCDIR}\OpenRA.Server.exe"
|
||||||
File "${SRCDIR}\OpenRA.Platforms.Null.dll"
|
File "${SRCDIR}\OpenRA.Platforms.Null.dll"
|
||||||
File "${SRCDIR}\OpenRA.Platforms.Default.dll"
|
File "${SRCDIR}\OpenRA.Platforms.Default.dll"
|
||||||
File "${SRCDIR}\ICSharpCode.SharpZipLib.dll"
|
File "${SRCDIR}\ICSharpCode.SharpZipLib.dll"
|
||||||
@@ -190,6 +191,7 @@ Function ${UN}Clean
|
|||||||
Delete $INSTDIR\OpenRA.Game.exe
|
Delete $INSTDIR\OpenRA.Game.exe
|
||||||
Delete $INSTDIR\OpenRA.Game.exe.config
|
Delete $INSTDIR\OpenRA.Game.exe.config
|
||||||
Delete $INSTDIR\OpenRA.Utility.exe
|
Delete $INSTDIR\OpenRA.Utility.exe
|
||||||
|
Delete $INSTDIR\OpenRA.Server.exe
|
||||||
Delete $INSTDIR\OpenRA.Platforms.Null.dll
|
Delete $INSTDIR\OpenRA.Platforms.Null.dll
|
||||||
Delete $INSTDIR\OpenRA.Platforms.Default.dll
|
Delete $INSTDIR\OpenRA.Platforms.Default.dll
|
||||||
Delete $INSTDIR\ICSharpCode.SharpZipLib.dll
|
Delete $INSTDIR\ICSharpCode.SharpZipLib.dll
|
||||||
|
|||||||
Reference in New Issue
Block a user