You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's very easy to cause an error here and get an ArgumentOutOfRange Exception, we should have a check to see if it's within the Range to avoid crashes (and maybe in other possible places where rarity is used too?)
try
{
// Ensure mItem.Rarity is within the valid range of RarityTiers.
if (mItem.Rarity >= 0 && mItem.Rarity < Options.Instance.Items.RarityTiers.Count)
{
var rarityName = Options.Instance.Items.RarityTiers[mItem.Rarity];
_ = Strings.ItemDescription.Rarity.TryGetValue(rarityName, out var rarityLabel);
header.SetDescription(rarityLabel, rarityColor ?? Color.White);
}
else
{
// Log a warning if the rarity is invalid and set default values.
Log.Warn($"Invalid rarity index: {mItem.Rarity}. Defaulting to White rarity.");
header.SetDescription("Common", Color.White);
}
}
catch (Exception exception)
{
Log.Error(exception);
throw;
}
header.SizeToChildren(true, false);
I don't think all this is necessary to avoid the crash, the best would be to just use a Math.min
var rarityName = Options.Instance.Items.RarityTiers[Math.Min(mItem.Rarity, Options.....RarityTiers.Count)];
If the lowest is Rarity, ok, within the range, if not, it will be the highest possible. This way, the dev would have a visual indicator ingame to understand that something is not right with the rarities without crashing.
Description
It's very easy to cause an error here and get an ArgumentOutOfRange Exception, we should have a check to see if it's within the Range to avoid crashes (and maybe in other possible places where rarity is used too?)
Intersect-Engine/Intersect.Client/Interface/Game/DescriptionWindows/ItemDescriptionWindow.cs
Line 136 in a3e84ab
Steps to Reproduce
Version with bug
current
Last version that worked well
Unknown
Affected platforms
Windows
Did you find any workaround?
we must check if it is within the range before trying to obtain the value if is not on range, then set the lowest rarity
Relevant log output
No response
Duplicate Bug Check
The text was updated successfully, but these errors were encountered: