Add a lint check for maps without playable player

This commit is contained in:
abcdefg30
2022-06-29 20:59:10 +02:00
committed by abcdefg30
parent 7439f8b20a
commit 8e1dce4bbe

View File

@@ -43,6 +43,7 @@ namespace OpenRA.Mods.Common.Lint
if (players.Players.Count > 64) if (players.Players.Count > 64)
emitError("Defining more than 64 players is not allowed."); emitError("Defining more than 64 players is not allowed.");
var playablePlayerFound = false;
var worldOwnerFound = false; var worldOwnerFound = false;
var playerNames = players.Players.Values.Select(p => p.Name).ToHashSet(); var playerNames = players.Players.Values.Select(p => p.Name).ToHashSet();
foreach (var player in players.Players.Values) foreach (var player in players.Players.Values)
@@ -55,6 +56,9 @@ namespace OpenRA.Mods.Common.Lint
if (!playerNames.Contains(enemy)) if (!playerNames.Contains(enemy))
emitError($"Enemies contains player {enemy} that is not in list."); emitError($"Enemies contains player {enemy} that is not in list.");
if (player.Playable)
playablePlayerFound = true;
if (player.OwnsWorld) if (player.OwnsWorld)
{ {
worldOwnerFound = true; worldOwnerFound = true;
@@ -71,6 +75,9 @@ namespace OpenRA.Mods.Common.Lint
} }
} }
if (!playablePlayerFound && visibility != MapVisibility.Shellmap)
emitError("Found no playable player.");
if (!worldOwnerFound) if (!worldOwnerFound)
emitError("Found no player owning the world."); emitError("Found no player owning the world.");