From 50066ec238807894777ce354646b987fc806b00a Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 25 Aug 2010 21:44:54 +1200 Subject: [PATCH] merge CreateMapPlayers into CreateMPPlayers --- OpenRA.Mods.RA/CreateMPPlayers.cs | 17 ++++++++++ OpenRA.Mods.RA/CreateMapPlayers.cs | 48 ---------------------------- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 3 +- mods/cnc/system.yaml | 1 - mods/ra/maps/shellmap/map.yaml | 1 - mods/ra/system.yaml | 1 - 6 files changed, 18 insertions(+), 53 deletions(-) delete mode 100644 OpenRA.Mods.RA/CreateMapPlayers.cs diff --git a/OpenRA.Mods.RA/CreateMPPlayers.cs b/OpenRA.Mods.RA/CreateMPPlayers.cs index 0ee321409f..a7ec278c5e 100644 --- a/OpenRA.Mods.RA/CreateMPPlayers.cs +++ b/OpenRA.Mods.RA/CreateMPPlayers.cs @@ -21,6 +21,18 @@ namespace OpenRA.Mods.RA public void CreatePlayers(World w) { var playerIndex = 0; + var mapPlayerIndex = -1; // todo: unhack this, but people still rely on it. + + // create the unplayable map players -- neutral, shellmap, scripted, etc. + foreach (var kv in w.Map.Players.Where(p => !p.Value.Playable)) + { + var player = new Player(w, kv.Value, mapPlayerIndex--); + w.AddPlayer(player); + if (kv.Value.OwnsWorld) + w.WorldActor.Owner = player; + } + + // create the players which are bound through slots. foreach (var slot in Game.LobbyInfo.Slots) { var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.Slot == slot.Index); @@ -57,6 +69,11 @@ namespace OpenRA.Mods.RA { if (p == q) return Stance.Ally; + if (p.PlayerRef.Allies.Contains(q.InternalName)) + return Stance.Ally; + if (p.PlayerRef.Enemies.Contains(q.InternalName)) + return Stance.Enemy; + // Hack: All map players are neutral wrt everyone else if (p.Index < 0 || q.Index < 0) return Stance.Neutral; diff --git a/OpenRA.Mods.RA/CreateMapPlayers.cs b/OpenRA.Mods.RA/CreateMapPlayers.cs deleted file mode 100644 index ada279b796..0000000000 --- a/OpenRA.Mods.RA/CreateMapPlayers.cs +++ /dev/null @@ -1,48 +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.Collections.Generic; -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - public class CreateMapPlayersInfo : TraitInfo { } - - public class CreateMapPlayers : ICreatePlayers - { - public Dictionary Players = new Dictionary(); - - public void CreatePlayers(World w) - { - int mapPlayerIndex = -1; - - foreach (var kv in w.Map.Players) - { - if (kv.Value.Playable) - continue; // these will be created another way. - - var player = new Player(w, kv.Value, mapPlayerIndex--); - w.AddPlayer(player); - Players.Add(kv.Key,player); - if (kv.Value.OwnsWorld) - w.WorldActor.Owner = player; - } - - foreach(var p in Players) - { - // foreach(var q in w.Map.Players[p.Key].Allies) - // p.Value.Stances[Players[q]] = Stance.Ally; - - // foreach(var q in w.Map.Players[p.Key].Enemies) - // p.Value.Stances[Players[q]] = Stance.Enemy; - } - } - } -} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 93f9aa0a07..9e543b728f 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -235,7 +235,6 @@ - diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml index 8ac9394485..85fd966b25 100644 --- a/mods/cnc/system.yaml +++ b/mods/cnc/system.yaml @@ -115,7 +115,6 @@ World: Type:Crater Types:cr1,cr2,cr3,cr4,cr5,cr6 Depths:5,5,5,5,5,5 - CreateMapPlayers: SpawnMapActors: CreateMPPlayers: SpawnMPUnits: diff --git a/mods/ra/maps/shellmap/map.yaml b/mods/ra/maps/shellmap/map.yaml index 8e174aee7e..8a1b1cb905 100644 --- a/mods/ra/maps/shellmap/map.yaml +++ b/mods/ra/maps/shellmap/map.yaml @@ -1235,6 +1235,5 @@ Smudges: Rules: World: DefaultShellmapScript: - -CreateMPPlayers: -SpawnMPUnits: -MPStartLocations: diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml index 537e7fed6c..c3cbde64d0 100644 --- a/mods/ra/system.yaml +++ b/mods/ra/system.yaml @@ -172,7 +172,6 @@ World: Type:Crater Types:cr1,cr2,cr3,cr4,cr5,cr6 Depths:5,5,5,5,5,5 - CreateMapPlayers: SpawnMapActors: CreateMPPlayers: MPStartLocations: