Throw a lint error or an exception when no player owns the world

This commit is contained in:
abcdefg30
2017-05-10 16:51:56 +02:00
committed by reaperrr
parent ac4fef6630
commit 434ea9ca88
2 changed files with 22 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Network;
@@ -25,16 +26,24 @@ namespace OpenRA.Mods.Common.Traits
{
var players = new MapPlayers(w.Map.PlayerDefinitions).Players;
var worldPlayers = new List<Player>();
var worldOwnerFound = false;
// Create the unplayable map players -- neutral, shellmap, scripted, etc.
foreach (var kv in players.Where(p => !p.Value.Playable))
{
var player = new Player(w, null, kv.Value);
worldPlayers.Add(player);
if (kv.Value.OwnsWorld)
{
worldOwnerFound = true;
w.SetWorldOwner(player);
}
}
if (!worldOwnerFound)
throw new InvalidOperationException("Map {0} does not define a player actor owning the world.".F(w.Map.Title));
Player localPlayer = null;
// Create the regular playable players.