Changes to new Gold Ledger system (#3)

Changes new gold system to use separate gold/platinum with DivRem instead of relying on doubles.
This commit is contained in:
Kamron Batman 2018-02-20 22:47:16 -08:00 committed by GitHub
parent 1030bb7675
commit d8ed7c1da9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 438 deletions

View file

@ -134,9 +134,8 @@ namespace Server.Items
{
if (owner.NetState != null && !owner.NetState.NewSecureTrading)
{
var total = Worth / Math.Max(1.0, Account.CurrencyThreshold);
var plat = (int)Math.Truncate(total);
var gold = (int)((total - plat) * Account.CurrencyThreshold);
int gold;
int plat = Math.DivRem(Worth, AccountGold.CurrencyThreshold, out gold);
tradeInfo.Plat += plat;
tradeInfo.Gold += gold;
@ -268,4 +267,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -103,9 +103,8 @@ namespace Server.Items
{
if (owner.NetState != null && !owner.NetState.NewSecureTrading)
{
var total = Amount / Math.Max(1.0, Account.CurrencyThreshold);
var plat = (int)Math.Truncate(total);
var gold = (int)((total - plat) * Account.CurrencyThreshold);
int gold;
int plat = Math.DivRem(Amount, AccountGold.CurrencyThreshold, out gold);
tradeInfo.Plat += plat;
tradeInfo.Gold += gold;
@ -148,4 +147,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}