KrejwenBAN
Member
Hi,
I have a strange error with currency.
Below are my settings for silver and gold -> 1 gold equals 10 silver
I set the price for item to 500 silver. However, as the result I get 9 silver and 2147483647 gold. I tried to debug the problem and it looks like a source is in:
The amount is calculated but it is not save to the result structure. Or I missed something?
When I set the amount to 50 silver then everything works correctly.
Asset version 1.2.2
I have a strange error with currency.
Below are my settings for silver and gold -> 1 gold equals 10 silver
I set the price for item to 500 silver. However, as the result I get 9 silver and 2147483647 gold. I tried to debug the problem and it looks like a source is in:
C#:
public static ListSlice<CurrencyAmount> ConvertOverflow_S(Currency currency, double amount, ref CurrencyAmount[] result)
{
var index = 0;
var nextCurrency = currency;
amount = Math.Truncate(amount);// ToIntSafe(amount);
while (nextCurrency != null && amount > 0) {
var mod = amount % (currency.MaxAmount + 1);
var intMod = (int)mod;
if (intMod > 0) {
TypeUtility.ResizeIfNecessary(ref result, index + 1);
result[index] = (intMod, nextCurrency);
index++;
}
if (amount - intMod <= 0d) { break; }
if (nextCurrency.OverflowCurrency == null ||
!nextCurrency.TryGetExchangeRateTo(nextCurrency.OverflowCurrency, out var rate)) {
return MaxedOutAmount_S(nextCurrency, ref result);
}
amount -= mod;
amount *= rate;
nextCurrency = nextCurrency.OverflowCurrency;
}
return (result, 0, index);
}
The amount is calculated but it is not save to the result structure. Or I missed something?
When I set the amount to 50 silver then everything works correctly.
Asset version 1.2.2