Move skirmish bot creation to the server.
This commit is contained in:
33
OpenRA.Mods.Common/ServerTraits/SkirmishLogic.cs
Normal file
33
OpenRA.Mods.Common/ServerTraits/SkirmishLogic.cs
Normal file
@@ -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<IBotInfo>().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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IBotInfo>().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 });
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ LoadScreen: CncLoadScreen
|
||||
|
||||
ServerTraits:
|
||||
LobbyCommands
|
||||
SkirmishLogic
|
||||
PlayerPinger
|
||||
MasterServerPinger
|
||||
LobbySettingsNotification
|
||||
|
||||
@@ -165,6 +165,7 @@ LoadScreen: LogoStripeLoadScreen
|
||||
|
||||
ServerTraits:
|
||||
LobbyCommands
|
||||
SkirmishLogic
|
||||
PlayerPinger
|
||||
MasterServerPinger
|
||||
LobbySettingsNotification
|
||||
|
||||
@@ -182,6 +182,7 @@ LoadScreen: LogoStripeLoadScreen
|
||||
|
||||
ServerTraits:
|
||||
LobbyCommands
|
||||
SkirmishLogic
|
||||
PlayerPinger
|
||||
MasterServerPinger
|
||||
LobbySettingsNotification
|
||||
|
||||
@@ -219,6 +219,7 @@ LoadScreen: LogoStripeLoadScreen
|
||||
|
||||
ServerTraits:
|
||||
LobbyCommands
|
||||
SkirmishLogic
|
||||
PlayerPinger
|
||||
MasterServerPinger
|
||||
LobbySettingsNotification
|
||||
|
||||
Reference in New Issue
Block a user