Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Superseded] Added try/catch to CheckRevealFootprint #20080

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 15 additions & 8 deletions OpenRA.Mods.Common/Lint/CheckRevealFootprint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,23 @@ void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{
var ios = actorInfo.Value.TraitInfoOrDefault<IOccupySpaceInfo>();
foreach (var rsi in actorInfo.Value.TraitInfos<RevealsShroudInfo>())
try
{
if (rsi.Type != VisibilityType.Footprint)
continue;
var ios = actorInfo.Value.TraitInfoOrDefault<IOccupySpaceInfo>();
foreach (var rsi in actorInfo.Value.TraitInfos<RevealsShroudInfo>())
{
if (rsi.Type != VisibilityType.Footprint)
continue;

if (ios == null)
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{rsi.GetType()}` but has no IOccupySpace traits!");
else if (ios.OccupiedCells(actorInfo.Value, CPos.Zero).Count == 0)
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{rsi.GetType()}` but does not have any footprint cells!");
if (ios == null)
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{rsi.GetType()}` but has no IOccupySpace traits!");
else if (ios.OccupiedCells(actorInfo.Value, CPos.Zero).Count == 0)
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{rsi.GetType()}` but does not have any footprint cells!");
}
}
catch (Exception e)
{
emitError($"Actor type `{actorInfo.Key}` caused an exception: {e}");
}
}
}
Expand Down