Skip to content

Rename the Radar Dome in Soviets08a to avoid a crash#21251

Merged
PunkPun merged 2 commits into
OpenRA:bleedfrom
abcdefg30:sovs08aRadar
Dec 15, 2023
Merged

Rename the Radar Dome in Soviets08a to avoid a crash#21251
PunkPun merged 2 commits into
OpenRA:bleedfrom
abcdefg30:sovs08aRadar

Conversation

@abcdefg30

Copy link
Copy Markdown
Member

Closes #21250. The issue is that the name Radar conflicts with the

binding. We should add a lint rule to catch this and throw a better exception.

@abcdefg30 abcdefg30 added this to the Next Release milestone Dec 12, 2023
@abcdefg30

Copy link
Copy Markdown
Member Author

Added a lint check. Seems like Soviets08a was the only mission to run into this issue.

@RoosterDragon RoosterDragon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions since you'll need to squash for the style error either way.

Comment thread OpenRA.Mods.Common/Lint/CheckActors.cs Outdated
foreach (var actor in actorTypes)
if (!map.Rules.Actors.Keys.Contains(actor.ToLowerInvariant()))
emitError($"Actor `{actor}` is not defined by any rule.");
var scriptBindings = Game.ModData.ObjectCreator.GetTypesImplementing<ScriptGlobal>().SelectMany(t => Utility.GetCustomAttributes<ScriptGlobalAttribute>(t, true)).ToArray();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider .Select(x => x.Name).ToHashSet() for fast Contains check inside the loop. (I'm not sure if there's many bindings but just in case)

Comment thread OpenRA.Mods.Common/Lint/CheckActors.cs Outdated
foreach (var actor in map.ActorDefinitions)
{
var name = actor.Value.Value;
if (!map.Rules.Actors.Keys.Contains(name.ToLowerInvariant()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ContainsKey? (previous code but since we're here)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference? Will change to ContainsKey regardless since it feels more natural.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContainsKey does a fast lookup in the dictionary. Keys.Contains does a slow linear search over the keys collection.

… names

Only scripted maps will have the need to use named actors, so we can
assume that there will be a Lua script used in maps with such actors.
@abcdefg30

Copy link
Copy Markdown
Member Author

Updated.

@PunkPun PunkPun merged commit da507b2 into OpenRA:bleed Dec 15, 2023
@PunkPun

PunkPun commented Dec 15, 2023

Copy link
Copy Markdown
Member

Changelog

@abcdefg30 abcdefg30 deleted the sovs08aRadar branch December 16, 2023 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Soviet 08a mission crashes on startup

3 participants