From 047a09bbbd5c39a3d681adc0ff5f45b513ac4cf8 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 8 Nov 2010 13:13:58 +1300 Subject: [PATCH] Excise previous server extensions code --- OpenRA.FileFormats/Manifest.cs | 2 - OpenRA.Game/Game.cs | 154 ++++------------------ OpenRA.Game/GameRules/Rules.cs | 3 +- OpenRA.Game/GameRules/Settings.cs | 15 --- OpenRA.Game/Graphics/Renderer.cs | 6 +- OpenRA.Game/Network/SyncReport.cs | 1 - OpenRA.Game/Network/UnitOrders.cs | 17 +-- OpenRA.Game/ObjectCreator.cs | 2 +- OpenRA.Game/OpenRA.Game.csproj | 4 +- OpenRA.Game/Server/Connection.cs | 20 +-- OpenRA.Game/Server/IServerExtension.cs | 84 ------------ OpenRA.Game/Server/NullServerExtension.cs | 40 ------ OpenRA.Game/Server/Server.cs | 111 ++++------------ OpenRA.Game/Traits/TraitsInterfaces.cs | 2 - OpenRA.Game/World.cs | 4 - 15 files changed, 67 insertions(+), 398 deletions(-) delete mode 100644 OpenRA.Game/Server/IServerExtension.cs delete mode 100644 OpenRA.Game/Server/NullServerExtension.cs diff --git a/OpenRA.FileFormats/Manifest.cs b/OpenRA.FileFormats/Manifest.cs index be1cfe2e86..5cbac2313b 100644 --- a/OpenRA.FileFormats/Manifest.cs +++ b/OpenRA.FileFormats/Manifest.cs @@ -21,8 +21,6 @@ namespace OpenRA.FileFormats Mods, Folders, Packages, Rules, Sequences, Cursors, Chrome, Assemblies, ChromeLayout, Weapons, Voices, Music, Movies, TileSets; - public string[] LocalRules = new string[0]; - public string[] LocalAssemblies = new string[0]; public readonly string ShellmapUid, LoadScreen; public readonly int TileSize = 24; diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 5951d312b3..b58c203e47 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -220,138 +220,45 @@ namespace OpenRA Console.WriteLine("Loading mods: {0}",string.Join(",",mods)); modData = new ModData( mods ); - - // when this client is running in dedicated mode ... - if (Settings.Server.IsDedicated) - { - // it may specify a yaml extension file (to add non synced traits) - if (!string.IsNullOrEmpty(Settings.Server.ExtensionYaml)) - { - var r = modData.Manifest.LocalRules.ToList(); - r.Add(Settings.Server.ExtensionYaml); - modData.Manifest.LocalRules = r.ToArray(); - } - // and a dll to the assemblies (to add those non synced traits) - if (!string.IsNullOrEmpty(Settings.Server.ExtensionDll)) - { - var r = modData.Manifest.LocalAssemblies.ToList(); - r.Add(Settings.Server.ExtensionDll); - modData.Manifest.LocalAssemblies = r.ToArray(); - } - - if (!string.IsNullOrEmpty(Settings.Server.ExtensionClass)) - Settings.Server.Extension = modData.ObjectCreator.CreateObject(Settings.Server.ExtensionClass); - } - Sound.Initialize(); PerfHistory.items["render"].hasNormalTick = false; PerfHistory.items["batches"].hasNormalTick = false; PerfHistory.items["text"].hasNormalTick = false; PerfHistory.items["cursor"].hasNormalTick = false; + + JoinLocal(); + StartGame(modData.Manifest.ShellmapUid); - if (!Settings.Graphics.UseNullRenderer) + Game.ConnectionStateChanged += orderManager => { - JoinLocal(); - StartGame(modData.Manifest.ShellmapUid); - - Game.ConnectionStateChanged += om => - { - Widget.CloseWindow(); - switch (om.Connection.ConnectionState) - { - case ConnectionState.PreConnecting: - Widget.OpenWindow("MAINMENU_BG"); - break; - case ConnectionState.Connecting: - Widget.OpenWindow("CONNECTING_BG", - new Dictionary - {{"host", om.Host}, {"port", om.Port}}); - break; - case ConnectionState.NotConnected: - Widget.OpenWindow("CONNECTION_FAILED_BG", - new Dictionary - {{"host", om.Host}, {"port", om.Port}}); - break; - case ConnectionState.Connected: - var lobby = Widget.OpenWindow("SERVER_LOBBY", - new Dictionary - {{"orderManager", om}}); - lobby.GetWidget("CHAT_DISPLAY").ClearChat(); - lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true; - lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true; - lobby.GetWidget("DISCONNECT_BUTTON").Visible = true; - - // Inform whoever is willing to hear it that the player is connected to the lobby - if (ConnectedToLobby != null) - ConnectedToLobby(); - - if (Settings.Server.IsDedicated) - { - // Force spectator as a default - Game.orderManager.IssueOrder(Order.Command("spectator")); - } - - if (Game.Settings.Server.Extension != null) - Game.Settings.Server.Extension.OnLobbyUp(); - break; - } - }; - - modData.WidgetLoader.LoadWidget(new Dictionary(), Widget.RootWidget, "PERF_BG"); - Widget.OpenWindow("MAINMENU_BG"); - }else - { - JoinLocal(); - StartGame(modData.Manifest.ShellmapUid); - - Game.ConnectionStateChanged += om => + Widget.CloseWindow(); + switch( orderManager.Connection.ConnectionState ) { - Widget.CloseWindow(); - switch (om.Connection.ConnectionState) - { - case ConnectionState.PreConnecting: - Widget.OpenWindow("MAINMENU_BG"); - break; - case ConnectionState.Connecting: - Widget.OpenWindow("CONNECTING_BG", - new Dictionary { { "host", om.Host }, { "port", om.Port } }); - break; - case ConnectionState.NotConnected: - Widget.OpenWindow("CONNECTION_FAILED_BG", - new Dictionary { { "host", om.Host }, { "port", om.Port } }); - break; - case ConnectionState.Connected: - var lobby = Widget.OpenWindow("SERVER_LOBBY", - new Dictionary { { "orderManager", om } }); + case ConnectionState.PreConnecting: + Widget.OpenWindow("MAINMENU_BG"); + break; + case ConnectionState.Connecting: + Widget.OpenWindow( "CONNECTING_BG", + new Dictionary { { "host", orderManager.Host }, { "port", orderManager.Port } } ); + break; + case ConnectionState.NotConnected: + Widget.OpenWindow( "CONNECTION_FAILED_BG", + new Dictionary { { "host", orderManager.Host }, { "port", orderManager.Port } } ); + break; + case ConnectionState.Connected: + var lobby = Widget.OpenWindow( "SERVER_LOBBY", new Dictionary { { "orderManager", orderManager } } ); + lobby.GetWidget("CHAT_DISPLAY").ClearChat(); + lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true; + lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true; + lobby.GetWidget("DISCONNECT_BUTTON").Visible = true; + //r.GetWidget("INGAME_ROOT").GetWidget("CHAT_DISPLAY").ClearChat(); + break; + } + }; - // Inform whoever is willing to hear it that the player is connected to the lobby - if (ConnectedToLobby != null) - ConnectedToLobby(); - - if (Settings.Server.IsDedicated) - { - // Force spectator as a default - Game.orderManager.IssueOrder(Order.Command("spectator")); - } - - if (Game.Settings.Server.Extension != null) - Game.Settings.Server.Extension.OnLobbyUp(); - break; - } - }; - - modData.WidgetLoader.LoadWidget(new Dictionary(), Widget.RootWidget, "PERF_BG"); - Widget.OpenWindow("MAINMENU_BG"); - } - - if (Settings.Server.IsDedicated) - { - // Auto-host - var map = Game.modData.AvailableMaps.FirstOrDefault(m => m.Value.Selectable).Key; - Server.Server.ServerMain(Game.modData, Settings, map); - Game.JoinServer(IPAddress.Loopback.ToString(), Settings.Server.ListenPort); - } + modData.WidgetLoader.LoadWidget( new Dictionary(), Widget.RootWidget, "PERF_BG" ); + Widget.OpenWindow("MAINMENU_BG"); Game.orderManager.LastTickTime = Environment.TickCount; } @@ -415,9 +322,6 @@ namespace OpenRA public static void RejoinLobby(World world) { - if (Game.IsHost && Game.Settings.Server.Extension != null) - Game.Settings.Server.Extension.OnRejoinLobby(world); - var map = orderManager.LobbyInfo.GlobalSettings.Map; var host = orderManager.Host; var port = orderManager.Port; diff --git a/OpenRA.Game/GameRules/Rules.cs b/OpenRA.Game/GameRules/Rules.cs index 4f038c2b69..43d898bb45 100755 --- a/OpenRA.Game/GameRules/Rules.cs +++ b/OpenRA.Game/GameRules/Rules.cs @@ -28,8 +28,7 @@ namespace OpenRA public static void LoadRules(Manifest m, Map map) { // Added support to extend the list of rules (add it to m.LocalRules) - // Should only be used to add ITraitNoSync traits! (otherwise BOOM) - Info = LoadYamlRules(m.Rules.Concat(m.LocalRules).ToArray(), map.Rules, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y)); + Info = LoadYamlRules(m.Rules, map.Rules, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y)); Weapons = LoadYamlRules(m.Weapons, new List(), (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value)); Voices = LoadYamlRules(m.Voices, new List(), (k, _) => new VoiceInfo(k.Value)); Music = LoadYamlRules(m.Music, new List(), (k, _) => new MusicInfo(k.Key, k.Value)); diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index f0d87c2a07..76f55a3df2 100755 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -27,13 +27,6 @@ namespace OpenRA.GameRules public bool AdvertiseOnline = true; public string MasterServer = "http://master.open-ra.org/"; public bool AllowCheats = false; - public string ExtensionDll = ""; - public string ExtensionClass = ""; - - /* not storeable */ - public IServerExtension Extension { get; set; } - public string ExtensionYaml { get; set; } - public bool IsDedicated { get; set; } } public class DebugSettings @@ -50,9 +43,6 @@ namespace OpenRA.GameRules public int2 FullscreenSize = new int2(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); public int2 WindowedSize = new int2(1024, 768); public readonly int2 MinResolution = new int2(800, 600); - public readonly string RenderEngine = "OpenRA.Gl.dll"; - public readonly string NullRenderEngine = "OpenRA.Renderer.Null.dll"; - public bool UseNullRenderer { get; set; } } public class SoundSettings @@ -115,11 +105,6 @@ namespace OpenRA.GameRules {"Debug", Debug} }; - // Should we run in dedicated mode (use the server extension) - Server.IsDedicated = args.GetValue("Server.IsDedicated", false); - if (Server.IsDedicated) - Graphics.UseNullRenderer = args.GetValue("Graphics.UseNullRenderer", false); - // Override fieldloader to ignore invalid entries var err1 = FieldLoader.UnknownFieldAction; var err2 = FieldLoader.InvalidValueAction; diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs index ec22049049..c3122a37b3 100644 --- a/OpenRA.Game/Graphics/Renderer.cs +++ b/OpenRA.Game/Graphics/Renderer.cs @@ -133,11 +133,7 @@ namespace OpenRA.Graphics internal static void Initialize( OpenRA.FileFormats.Graphics.WindowMode windowMode ) { var resolution = GetResolution( windowMode ); - - if (Game.Settings.Graphics.UseNullRenderer) - device = CreateDevice(Assembly.LoadFile(Path.GetFullPath(Game.Settings.Graphics.NullRenderEngine)), resolution.Width, resolution.Height, windowMode, false); - else - device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( Game.Settings.Graphics.RenderEngine ) ), resolution.Width, resolution.Height, windowMode, false ); + device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRA.Gl.dll" ) ), resolution.Width, resolution.Height, windowMode, false ); } static Size GetResolution(WindowMode windowmode) diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs index 860cd174b2..c55745a605 100755 --- a/OpenRA.Game/Network/SyncReport.cs +++ b/OpenRA.Game/Network/SyncReport.cs @@ -38,7 +38,6 @@ namespace OpenRA.Network report.Traits.Clear(); foreach (var a in orderManager.world.Queries.WithTraitMultiple()) { - if (a.Trait is ITraitNotSynced ) continue; var sync = Sync.CalculateSyncHash(a.Trait); if (sync != 0) report.Traits.Add(new TraitReport() diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index b68f39f984..25ad5f708e 100755 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -36,14 +36,9 @@ namespace OpenRA.Network switch (order.OrderString) { - case "Chat": + case "Chat": { var client = orderManager.LobbyInfo.ClientWithIndex(clientId); - - if (Game.IsHost && Game.Settings.Server.Extension != null && !Game.Settings.Server.Extension.OnIngameChat(client, order.TargetString, false)) - break; - - if (client != null) { var player = world != null ? world.FindPlayerByClient(client) : null; @@ -54,7 +49,6 @@ namespace OpenRA.Network Game.AddChatLine(Color.White, "(player {0})".F(clientId), order.TargetString); break; } - case "Disconnected": /* reports that the target player disconnected */ { var client = orderManager.LobbyInfo.ClientWithIndex(clientId); @@ -68,9 +62,6 @@ namespace OpenRA.Network { var client = orderManager.LobbyInfo.ClientWithIndex(clientId); - if (Game.IsHost && Game.Settings.Server.Extension != null && !Game.Settings.Server.Extension.OnIngameChat(client, order.TargetString, true)) - break; - if (client != null) { if (world == null) @@ -125,10 +116,6 @@ namespace OpenRA.Network var targetPlayer = order.Player.World.players[order.TargetLocation.X]; var newStance = (Stance)order.TargetLocation.Y; - if (Game.IsHost && Game.Settings.Server.Extension != null) - Game.Settings.Server.Extension.OnIngameSetStance(order.Player, targetPlayer, newStance); - - SetPlayerStance(world, order.Player, targetPlayer, newStance); // automatically declare war reciprocally diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 24ad6daeff..6c4c1c4ba8 100755 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -29,7 +29,7 @@ namespace OpenRA .ToList(); // Namespaces from each mod assembly - foreach (var a in manifest.Assemblies.Concat(manifest.LocalAssemblies)) + foreach (var a in manifest.Assemblies) { var asm = Assembly.LoadFile(Path.GetFullPath(a)); asms.AddRange(asm.GetNamespaces().Select(ns => Pair.New(asm, ns))); diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 374a043b92..a0f2651b23 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -1,4 +1,4 @@ - + Debug @@ -208,8 +208,6 @@ - - diff --git a/OpenRA.Game/Server/Connection.cs b/OpenRA.Game/Server/Connection.cs index dfb6df2941..e9621a05eb 100644 --- a/OpenRA.Game/Server/Connection.cs +++ b/OpenRA.Game/Server/Connection.cs @@ -15,20 +15,20 @@ using System.Net.Sockets; namespace OpenRA.Server { - public class Connection + class Connection { - internal Socket socket; - internal List data = new List(); - internal ReceiveState State = ReceiveState.Header; - internal int ExpectLength = 8; - internal int Frame = 0; + public Socket socket; + public List data = new List(); + public ReceiveState State = ReceiveState.Header; + public int ExpectLength = 8; + public int Frame = 0; - internal int MostRecentFrame = 0; + public int MostRecentFrame = 0; /* client data */ - public int PlayerIndex { get; internal set; } + public int PlayerIndex; - internal byte[] PopBytes(int n) + public byte[] PopBytes(int n) { var result = data.GetRange(0, n); data.RemoveRange(0, n); @@ -65,7 +65,7 @@ namespace OpenRA.Server return true; } - internal void ReadData() + public void ReadData() { if (ReadDataInner()) while (data.Count >= ExpectLength) diff --git a/OpenRA.Game/Server/IServerExtension.cs b/OpenRA.Game/Server/IServerExtension.cs deleted file mode 100644 index 9cdd3b0330..0000000000 --- a/OpenRA.Game/Server/IServerExtension.cs +++ /dev/null @@ -1,84 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2010 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 LICENSE. - */ -#endregion - -using System.Drawing; -using OpenRA.Network; -using OpenRA.Traits; - -namespace OpenRA.Server -{ - public interface IServerExtension - { - /// - /// Return true to use the built-in handling - /// - bool OnReadyUp(Connection conn, Session.Client client); - void OnStartGame(); - /// - /// Return true to use the built-in handling - /// - bool OnNickChange(Connection conn, Session.Client client, string newName); - - /// - /// Return true to use the built-in handling - /// - bool OnRaceChange(Connection conn, Session.Client client, string newRace); - - /// - /// Return true to use the built-in handling - /// - bool OnSlotChange(Connection conn, Session.Client client, Session.Slot slot, Map map); - - /// - /// Return true to use the built-in handling - /// - bool OnTeamChange(Connection conn, Session.Client getClient, int team); - - /// - /// Return true to use the built-in handling - /// - bool OnSpawnpointChange(Connection conn, Session.Client getClient, int spawnPoint); - - /// - /// Return true to use the built-in handling - /// - bool OnColorChange(Connection conn, Session.Client getClient, Color fromArgb, Color color); - - /// - /// Return true to use the built-in handling - /// - bool OnChat(Connection conn, string message, bool teamChat); - - void OnServerStart(); - void OnServerStop(bool forced); - void OnLoadMap(Map map); - - /// - /// Return false to drop the connection - /// - bool OnValidateConnection(bool gameStarted, Connection newConn); - - void OnLobbySync(Session lobbyInfo, bool gameStarted); - /// - /// Return true to use the built-in handling - /// - bool OnPingMasterServer(Session lobbyInfo, bool gameStarted); - - /// - /// Return true to use the built-in handling - /// - bool OnIngameChat(Session.Client client, string message, bool teamChat); - - void OnIngameSetStance(Player player, Player stanceForPlayer, Stance newStance); - - void OnLobbyUp(); - void OnRejoinLobby(World world); - } -} diff --git a/OpenRA.Game/Server/NullServerExtension.cs b/OpenRA.Game/Server/NullServerExtension.cs deleted file mode 100644 index 06c1497080..0000000000 --- a/OpenRA.Game/Server/NullServerExtension.cs +++ /dev/null @@ -1,40 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2010 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 LICENSE. - */ -#endregion - -using System.Drawing; -using OpenRA.Network; -using OpenRA.Traits; - -namespace OpenRA.Server -{ - public class NullServerExtension : IServerExtension - { - public virtual bool OnReadyUp(Connection conn, Session.Client client) { return true; } - public virtual void OnStartGame() { } - public virtual bool OnNickChange(Connection conn, Session.Client client, string newName) { return true; } - public virtual bool OnRaceChange(Connection conn, Session.Client client, string newRace) { return true; } - public virtual bool OnSlotChange(Connection conn, Session.Client client, Session.Slot slot, Map map) { return true; } - public virtual bool OnTeamChange(Connection conn, Session.Client getClient, int team) { return true; } - public virtual bool OnSpawnpointChange(Connection conn, Session.Client getClient, int spawnPoint) { return true; } - public virtual bool OnColorChange(Connection conn, Session.Client getClient, Color fromArgb, Color color) { return true; } - public virtual bool OnChat(Connection conn, string message, bool teamChat) { return true; } - public virtual void OnServerStart() { } - public virtual void OnServerStop(bool forced) { } - // Good spot to manipulate number of spectators! ie set Server.MaxSpectators - public virtual void OnLoadMap(Map map) { } - public virtual bool OnValidateConnection(bool gameStarted, Connection newConn) { return true; } - public virtual void OnLobbySync(Session lobbyInfo, bool gameStarted) { } - public virtual bool OnPingMasterServer(Session lobbyInfo, bool gameStarted) { return true; } - public virtual bool OnIngameChat(Session.Client client, string message, bool teamChat) { return true; } - public virtual void OnIngameSetStance(Player player, Player stanceForPlayer, Stance newStance) { } - public virtual void OnLobbyUp() { } - public virtual void OnRejoinLobby(World world) { } - } -} diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index c0d762d0c5..ec15ee70e0 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -25,17 +25,12 @@ namespace OpenRA.Server { static class Server { - public static Connection[] Connections - { - get { return conns.ToArray(); } - } - static List conns = new List(); static TcpListener listener = null; static Dictionary> inFlightFrames = new Dictionary>(); static Session lobbyInfo; - internal static bool GameStarted = false; + static bool GameStarted = false; static string Name; static int ExternalPort; static int randomSeed; @@ -62,20 +57,7 @@ namespace OpenRA.Server try { listener.Stop(); } catch { } - E(e => e.OnServerStop(true)); } - - public static void E(Action f) - { - E(g => { f(g); return true; }); - } - - public static bool E(Func f) - { - return Game.Settings.Server.Extension == null || - f(Game.Settings.Server.Extension); - } - public static void ServerMain(ModData modData, Settings settings, string map) { Log.AddChannel("server", "server.log"); @@ -83,7 +65,6 @@ namespace OpenRA.Server isInitialPing = true; Server.masterServerUrl = settings.Server.MasterServer; isInternetServer = settings.Server.AdvertiseOnline; - listener = new TcpListener(IPAddress.Any, settings.Server.ListenPort); Name = settings.Server.Name; ExternalPort = settings.Server.ExternalPort; @@ -113,8 +94,6 @@ namespace OpenRA.Server throw new InvalidOperationException( "Unable to start server: port is already in use" ); } - E(e => e.OnServerStart()); - new Thread( _ => { for( ; ; ) @@ -140,7 +119,6 @@ namespace OpenRA.Server { listener.Stop(); GameStarted = false; - E(e => e.OnServerStop(false)); break; } } @@ -169,8 +147,6 @@ namespace OpenRA.Server .Select((s, i) => { s.Index = i; return s; }) .ToList(); - E(e => e.OnLoadMap(Map)); - // Generate slots for spectators for (int i = 0; i < MaxSpectators; i++) lobbyInfo.Slots.Add(new Session.Slot @@ -217,17 +193,7 @@ namespace OpenRA.Server return; } - var newConn = new Connection { socket = newSocket }; - - - if (!E(e => e.OnValidateConnection(GameStarted, newConn))) - { - DropClient(newConn, new Exception() ); - - return; - } - try { if (GameStarted) @@ -338,7 +304,7 @@ namespace OpenRA.Server catch (NotImplementedException) { } } - public static void SyncClientToPlayerReference(Session.Client c, PlayerReference pr) + static void SyncClientToPlayerReference(Session.Client c, PlayerReference pr) { if (pr == null) return; @@ -351,7 +317,7 @@ namespace OpenRA.Server c.Country = pr.Race; } - public static bool InterpretCommand(Connection conn, string cmd) + static bool InterpretCommand(Connection conn, string cmd) { var dict = new Dictionary> { @@ -371,12 +337,9 @@ namespace OpenRA.Server SyncLobbyInfo(); - if (Game.Settings.Server.Extension== null || Game.Settings.Server.Extension.OnReadyUp(conn, client)) - { - if (conns.Count > 0 && conns.All(c => GetClient(c).State == Session.ClientState.Ready)) - InterpretCommand(conn, "startgame"); - } - + if (conns.Count > 0 && conns.All(c => GetClient(c).State == Session.ClientState.Ready)) + InterpretCommand(conn, "startgame"); + return true; }}, { "startgame", @@ -390,8 +353,6 @@ namespace OpenRA.Server DispatchOrders(null, 0, new ServerOrder("StartGame", "").Serialize()); - E(e => e.OnStartGame()); - PingMasterServer(); return true; }}, @@ -399,10 +360,7 @@ namespace OpenRA.Server s => { Log.Write("server", "Player@{0} is now known as {1}", conn.socket.RemoteEndPoint, s); - - if (E(e => e.OnNickChange(conn, GetClient(conn), s))) - GetClient(conn).Name = s; - + GetClient(conn).Name = s; SyncLobbyInfo(); return true; }}, @@ -421,7 +379,6 @@ namespace OpenRA.Server { "race", s => { - if (E(e => e.OnRaceChange(conn, GetClient(conn), s))) GetClient(conn).Country = s; SyncLobbyInfo(); @@ -436,12 +393,9 @@ namespace OpenRA.Server var cl = GetClient(conn); - if (E(e => e.OnSlotChange(conn, cl, slotData, Map))) - { cl.Slot = slotData.Index; - SyncClientToPlayerReference(cl, slotData.MapPlayer != null - ? Map.Players[slotData.MapPlayer] : null); - } + + SyncClientToPlayerReference(cl, slotData.MapPlayer != null ? Map.Players[slotData.MapPlayer] : null); SyncLobbyInfo(); return true; @@ -451,10 +405,8 @@ namespace OpenRA.Server { int team; if (!int.TryParse(s, out team)) { Log.Write("server", "Invalid team: {0}", s ); return false; } - if (E(e => e.OnTeamChange(conn, GetClient(conn), team))) - { - GetClient(conn).Team = team; - } + + GetClient(conn).Team = team; SyncLobbyInfo(); return true; }}, @@ -473,10 +425,8 @@ namespace OpenRA.Server SendChatTo( conn, "You can't be at the same spawn point as another player" ); return true; } - if (E(e => e.OnSpawnpointChange(conn, GetClient(conn), spawnPoint))) - { - GetClient(conn).SpawnPoint = spawnPoint; - } + + GetClient(conn).SpawnPoint = spawnPoint; SyncLobbyInfo(); return true; }}, @@ -484,14 +434,8 @@ namespace OpenRA.Server s => { var c = s.Split(',').Select(cc => int.Parse(cc)).ToArray(); - var c1 = Color.FromArgb(c[0], c[1], c[2]); - var c2 = Color.FromArgb(c[3], c[4], c[5]); - - if (E(e => e.OnColorChange(conn, GetClient(conn), c1, c2))) - { - GetClient(conn).Color1 = c1; - GetClient(conn).Color2 = c2; - } + GetClient(conn).Color1 = Color.FromArgb(c[0],c[1],c[2]); + GetClient(conn).Color2 = Color.FromArgb(c[3],c[4],c[5]); SyncLobbyInfo(); return true; }}, @@ -507,14 +451,10 @@ namespace OpenRA.Server return false; var cl = GetClient(conn); + cl.Slot = slot; + + SyncClientToPlayerReference(cl, slotData.MapPlayer != null ? Map.Players[slotData.MapPlayer] : null); - if (E(e => e.OnSlotChange(conn, cl, slotData, Map))) - { - cl.Slot = slot; - SyncClientToPlayerReference(cl, slotData.MapPlayer != null - ? Map.Players[slotData.MapPlayer] : null); - } - SyncLobbyInfo(); return true; }}, @@ -673,7 +613,7 @@ namespace OpenRA.Server case "Command": { if (GameStarted) - SendChatTo(conn, "Cannot change state when game started."); + SendChatTo(conn, "Cannot change state when game started. ({0})".F(so.Data)); else if (GetClient(conn).State == Session.ClientState.Ready && !(so.Data == "ready" || so.Data == "startgame")) SendChatTo(conn, "Cannot change state when marked as ready."); else if (!InterpretCommand(conn, so.Data)) @@ -686,11 +626,9 @@ namespace OpenRA.Server case "Chat": case "TeamChat": - case "Disconnected": - if (E(e => e.OnChat(conn, so.Data, so.Name == "TeamChat"))) - foreach (var c in conns.Except(conn).ToArray()) - DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize()); - break; + foreach (var c in conns.Except(conn).ToArray()) + DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize()); + break; } } @@ -717,8 +655,6 @@ namespace OpenRA.Server static void SyncLobbyInfo() { - E(e => e.OnLobbySync(lobbyInfo, GameStarted)); - if (!GameStarted) /* don't do this while the game is running, it breaks things. */ DispatchOrders(null, 0, new ServerOrder("SyncInfo", lobbyInfo.Serialize()).Serialize()); @@ -732,9 +668,6 @@ namespace OpenRA.Server { if (isBusy || !isInternetServer) return; - if (!E(e => e.OnPingMasterServer(lobbyInfo, GameStarted))) - return; - lastPing = Environment.TickCount; isBusy = true; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 16318dd43b..feb13bb90d 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -210,8 +210,6 @@ namespace OpenRA.Traits public interface IPostRenderSelection { void RenderAfterWorld(WorldRenderer wr, Actor self); } public interface IPreRenderSelection { void RenderBeforeWorld(WorldRenderer wr, Actor self); } - public interface ITraitNotSynced{} // Traits marked with NotSynced arent sync-checked - public struct Target // a target: either an actor, or a fixed location. { Actor actor; diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 68cf59886b..5209b36f67 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -199,11 +199,7 @@ namespace OpenRA // hash all the traits that tick foreach (var x in traitDict.ActorsWithTraitMultiple(this)) - { - if (x.Trait is ITraitNotSynced) continue; - ret += n++*(int) x.Actor.ActorID*Sync.CalculateSyncHash(x.Trait); - } // Hash the shared rng ret += SharedRandom.Last;