From 731c64c1a70c93ca9ea7a408faa22da26a2f9f3f Mon Sep 17 00:00:00 2001 From: mgatland Date: Sun, 15 Aug 2010 22:23:34 +1200 Subject: [PATCH] add a bot player, make ai apply to the bot not the local player --- OpenRA.Game/Server/Server.cs | 6 ++++-- OpenRA.Mods.RA/World/HackyAI.cs | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index dbfa8f8639..e126082bae 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -66,7 +66,7 @@ namespace OpenRA.Server lobbyInfo.GlobalSettings.RandomSeed = randomSeed; lobbyInfo.GlobalSettings.Map = map; lobbyInfo.GlobalSettings.AllowCheats = settings.Server.AllowCheats; - + LoadMap(); // populates the Session's slots, too. Log.Write("server", "Initial mods: "); @@ -113,6 +113,8 @@ namespace OpenRA.Server } } } ) { IsBackground = true }.Start(); + + } static Session.Slot MakeSlotFromPlayerReference(PlayerReference pr) @@ -454,7 +456,7 @@ namespace OpenRA.Server SendChatTo( conn, "Only the host can change the map" ); return true; } - lobbyInfo.GlobalSettings.Map = s; + lobbyInfo.GlobalSettings.Map = s; LoadMap(); foreach(var client in lobbyInfo.Clients) diff --git a/OpenRA.Mods.RA/World/HackyAI.cs b/OpenRA.Mods.RA/World/HackyAI.cs index 7edd76c9b2..e8edb3b8ed 100644 --- a/OpenRA.Mods.RA/World/HackyAI.cs +++ b/OpenRA.Mods.RA/World/HackyAI.cs @@ -48,7 +48,15 @@ namespace OpenRA.Mods.RA public void GameStarted(World w) { - p = Game.world.LocalPlayer; + try + { + p = Game.world.players.First(c => c.Value.PlayerName.Equals("bot")).Value; + } + catch (Exception) + { + //Could not find a bot. + } + //p = Game.world.LocalPlayer; enabled = Game.IsHost && p != null; if (enabled) {