add a bot player, make ai apply to the bot not the local player

This commit is contained in:
mgatland
2010-08-15 22:23:34 +12:00
committed by alzeih
parent 19494c3262
commit 731c64c1a7
2 changed files with 13 additions and 3 deletions

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Server
lobbyInfo.GlobalSettings.RandomSeed = randomSeed; lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
lobbyInfo.GlobalSettings.Map = map; lobbyInfo.GlobalSettings.Map = map;
lobbyInfo.GlobalSettings.AllowCheats = settings.Server.AllowCheats; lobbyInfo.GlobalSettings.AllowCheats = settings.Server.AllowCheats;
LoadMap(); // populates the Session's slots, too. LoadMap(); // populates the Session's slots, too.
Log.Write("server", "Initial mods: "); Log.Write("server", "Initial mods: ");
@@ -113,6 +113,8 @@ namespace OpenRA.Server
} }
} }
} ) { IsBackground = true }.Start(); } ) { IsBackground = true }.Start();
} }
static Session.Slot MakeSlotFromPlayerReference(PlayerReference pr) static Session.Slot MakeSlotFromPlayerReference(PlayerReference pr)
@@ -454,7 +456,7 @@ namespace OpenRA.Server
SendChatTo( conn, "Only the host can change the map" ); SendChatTo( conn, "Only the host can change the map" );
return true; return true;
} }
lobbyInfo.GlobalSettings.Map = s; lobbyInfo.GlobalSettings.Map = s;
LoadMap(); LoadMap();
foreach(var client in lobbyInfo.Clients) foreach(var client in lobbyInfo.Clients)

View File

@@ -48,7 +48,15 @@ namespace OpenRA.Mods.RA
public void GameStarted(World w) 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; enabled = Game.IsHost && p != null;
if (enabled) if (enabled)
{ {