diff --git a/OpenRA.Mods.Common/ServerTraits/SkirmishLogic.cs b/OpenRA.Mods.Common/ServerTraits/SkirmishLogic.cs new file mode 100644 index 0000000000..0fa7e18075 --- /dev/null +++ b/OpenRA.Mods.Common/ServerTraits/SkirmishLogic.cs @@ -0,0 +1,33 @@ +#region Copyright & License Information +/* + * Copyright (c) The OpenRA Developers and Contributors + * 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, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Linq; +using OpenRA.Server; +using OpenRA.Traits; +using S = OpenRA.Server.Server; + +namespace OpenRA.Mods.Common.Server +{ + public class SkirmishLogic : ServerTrait, IClientJoined + { + public void ClientJoined(S server, Connection conn) + { + if (server.Type != ServerType.Skirmish) + return; + + var slot = server.LobbyInfo.FirstEmptyBotSlot(); + var bot = server.Map.PlayerActorInfo.TraitInfos().Select(t => t.Type).FirstOrDefault(); + var botController = server.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); + if (slot != null && bot != null) + server.InterpretCommand($"slot_bot {slot} {botController.Index} {bot}", conn); + } + } +} diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 4d0ac90b38..ace279b627 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -98,7 +98,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic Session.MapStatus mapStatus; bool chatEnabled; - bool addBotOnMapLoad; bool disableTeamChat; bool insufficientPlayerSpawns; bool teamChat; @@ -552,10 +551,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic }); } - // Add a bot on the first lobbyinfo update - if (skirmishMode) - addBotOnMapLoad = true; - if (logicArgs.TryGetValue("ChatLineSound", out var yaml)) chatLineSound = yaml.Value; if (logicArgs.TryGetValue("PlayerJoinedSound", out yaml)) @@ -647,22 +642,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic return; map = modData.MapCache[uid]; + + // Tell the server that we have the map if (map.Status == MapStatus.Available) - { - // Tell the server that we have the map orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")); - if (addBotOnMapLoad) - { - var slot = orderManager.LobbyInfo.FirstEmptyBotSlot(); - var bot = map.PlayerActorInfo.TraitInfos().Select(t => t.Type).FirstOrDefault(); - var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); - if (slot != null && bot != null) - orderManager.IssueOrder(Order.Command($"slot_bot {slot} {botController.Index} {bot}")); - - addBotOnMapLoad = false; - } - } + // We don't have the map else if (map.Status != MapStatus.DownloadAvailable && Game.Settings.Game.AllowDownloading) modData.MapCache.QueryRemoteMapDetails(services.MapRepository, new[] { uid }); } diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 1291193f05..b64a0e6664 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -178,6 +178,7 @@ LoadScreen: CncLoadScreen ServerTraits: LobbyCommands + SkirmishLogic PlayerPinger MasterServerPinger LobbySettingsNotification diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index e29d1421b0..6904218e2f 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -165,6 +165,7 @@ LoadScreen: LogoStripeLoadScreen ServerTraits: LobbyCommands + SkirmishLogic PlayerPinger MasterServerPinger LobbySettingsNotification diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 9f4cc4e057..c599f88bb9 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -182,6 +182,7 @@ LoadScreen: LogoStripeLoadScreen ServerTraits: LobbyCommands + SkirmishLogic PlayerPinger MasterServerPinger LobbySettingsNotification diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index 295aa1774d..b645347350 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -219,6 +219,7 @@ LoadScreen: LogoStripeLoadScreen ServerTraits: LobbyCommands + SkirmishLogic PlayerPinger MasterServerPinger LobbySettingsNotification