-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
TryGetValue is now being used when getting WeaponInfo instances #14111
TryGetValue is now being used when getting WeaponInfo instances #14111
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. Just a couple of small requests:
OpenRA.Mods.Cnc/Traits/MadTank.cs
Outdated
DetonationWeaponInfo = rules.Weapons[DetonationWeapon.ToLowerInvariant()]; | ||
WeaponInfo thumpDamageWeapon; | ||
WeaponInfo detonationWeapon; | ||
var thumpDmgWeapToLower = ThumpDamageWeapon.ToLowerInvariant(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: avoid removing arbitrary letters from variable names. Saving 5 characters on a throwaway local variable isn't worth the hit to readability. thumpDamageWeaponToLower
and detonationWeaponToLower
are fine. If you really want to use shorter names then thumpName
and detonationName
would also be fine considering the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest using (ThumpDamageWeapon ?? string.Empty).ToLowerInvariant()
here and in the other cases where the weapons aren't optional to avoid a NullReferenceException
if the mod yaml overrides it to be empty (which translates to a null value).
Can you please also squash the commits once you're done? |
e010dd5
to
532d0fa
Compare
….Weapons Removed invalid spacing at the end of the line 36 in ThrowsShrapnel Prevented NullReferenceException in cases where weapons aren't optional
532d0fa
to
459ae19
Compare
Fixed up everything and squashed my commits. I'm using now the more verbose variant for the local variables for more consistency with the rest of the code. |
A YamlException is thrown if TryGetValue fails. Closes #13692.