+ RunUO 2.7 with initial TOL expansion support.

This commit is contained in:
VitaNex 2016-01-27 02:59:11 +00:00
parent 64272798c3
commit 7af0579875
41 changed files with 3181 additions and 499 deletions

View file

@ -1,12 +1,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security;
using System.Security.Cryptography;
using System.Text;
using System.Xml;
using Server;
using Server.Commands;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Multis;
@ -19,10 +22,140 @@ namespace Server.Accounting
public static readonly TimeSpan YoungDuration = TimeSpan.FromHours( 40.0 );
public static readonly TimeSpan InactiveDuration = TimeSpan.FromDays( 180.0 );
public static readonly TimeSpan EmptyInactiveDuration = TimeSpan.FromDays( 30.0 );
private string m_Username, m_PlainPassword, m_CryptPassword, m_NewCryptPassword;
public static readonly TimeSpan EmptyInactiveDuration = TimeSpan.FromDays(30.0);
public static void Configure()
{
CommandSystem.Register("ConvertCurrency", AccessLevel.Owner, ConvertCurrency);
}
private static void ConvertCurrency(CommandEventArgs e)
{
e.Mobile.SendMessage(
"Converting All Banked Gold from {0} to {1}. Please wait...",
AccountGold.Enabled ? "checks and coins" : "account treasury",
AccountGold.Enabled ? "account treasury" : "checks and coins");
NetState.Pause();
double found = 0.0, converted = 0.0;
try
{
BankBox box;
List<Gold> gold;
List<BankCheck> checks;
long share = 0, shared;
int diff;
foreach (var a in Accounts.GetAccounts().OfType<Account>().Where(a => a.Count > 0))
{
try
{
if (!AccountGold.Enabled)
{
share = (int)Math.Truncate((a.TotalCurrency / a.Count) * CurrencyThreshold);
found += a.TotalCurrency * CurrencyThreshold;
}
foreach (var m in a.m_Mobiles.Where(m => m != null))
{
box = m.FindBankNoCreate();
if (box == null)
{
continue;
}
if (AccountGold.Enabled)
{
foreach (var o in checks = box.FindItemsByType<BankCheck>())
{
found += o.Worth;
if (!a.DepositGold(o.Worth))
{
break;
}
converted += o.Worth;
o.Delete();
}
checks.Clear();
checks.TrimExcess();
foreach (var o in gold = box.FindItemsByType<Gold>())
{
found += o.Amount;
if (!a.DepositGold(o.Amount))
{
break;
}
converted += o.Amount;
o.Delete();
}
gold.Clear();
gold.TrimExcess();
}
else
{
shared = share;
while (shared > 0)
{
if (shared > 60000)
{
diff = (int)Math.Min(10000000, shared);
if (a.WithdrawGold(diff))
{
box.DropItem(new BankCheck(diff));
}
else
{
break;
}
}
else
{
diff = (int)Math.Min(60000, shared);
if (a.WithdrawGold(diff))
{
box.DropItem(new Gold(diff));
}
else
{
break;
}
}
converted += diff;
shared -= diff;
}
}
box.UpdateTotals();
}
}
catch
{ }
}
}
catch
{ }
NetState.Resume();
e.Mobile.SendMessage("Operation complete: {0:#,0} of {1:#,0} Gold has been converted in total.", converted, found);
}
private string m_Username, m_Email, m_PlainPassword, m_CryptPassword, m_NewCryptPassword;
private AccessLevel m_AccessLevel;
private int m_Flags;
private DateTime m_Created, m_LastLogin;
@ -115,6 +248,15 @@ namespace Server.Accounting
set { m_Username = value; }
}
/// <summary>
/// Account email address.
/// </summary>
public string Email
{
get { return m_Email; }
set { m_Email = value; }
}
/// <summary>
/// Account password. Plain text. Case sensitive validation. May be null.
/// </summary>
@ -673,6 +815,8 @@ namespace Server.Accounting
m_Flags = Utility.GetXMLInt32( Utility.GetText( node["flags"], "0" ), 0 );
m_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.UtcNow );
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.UtcNow );
TotalCurrency = Utility.GetXMLDouble( Utility.GetText(node["totalCurrency"], "0" ), 0 );
m_Mobiles = LoadMobiles( node );
m_Comments = LoadComments( node );
@ -1100,6 +1244,10 @@ namespace Server.Accounting
xml.WriteEndElement();
}
xml.WriteStartElement("totalCurrency");
xml.WriteString(XmlConvert.ToString(TotalCurrency));
xml.WriteEndElement();
xml.WriteEndElement();
}
@ -1203,5 +1351,242 @@ namespace Server.Accounting
throw new ArgumentException();
}
#region Gold Account
/// <summary>
/// This amount specifies the value at which point Gold turns to Platinum.
/// By default, when 1,000,000,000 Gold is accumulated, it will transform
/// into 1 Platinum.
/// </summary>
public static int CurrencyThreshold
{
get { return AccountGold.CurrencyThreshold; }
set { AccountGold.CurrencyThreshold = value; }
}
/// <summary>
/// This amount represents the total amount of currency owned by the player.
/// It is cumulative of both Gold and Platinum, the absolute total amount of
/// Gold owned by the player can be found by multiplying this value by the
/// CurrencyThreshold value.
/// </summary>
[CommandProperty(AccessLevel.Administrator, true)]
public double TotalCurrency { get; private set; }
/// <summary>
/// This amount represents the current amount of Gold owned by the player.
/// The value does not include the value of Platinum and ranges from
/// 0 to 999,999,999 by default.
/// </summary>
[CommandProperty(AccessLevel.Administrator)]
public int TotalGold
{
get { return (int)Math.Floor((TotalCurrency - Math.Truncate(TotalCurrency)) * Math.Max(1.0, CurrencyThreshold)); }
}
/// <summary>
/// This amount represents the current amount of Platinum owned by the player.
/// The value does not include the value of Gold and ranges from
/// 0 to 2,147,483,647 by default.
/// One Platinum represents the value of CurrencyThreshold in Gold.
/// </summary>
[CommandProperty(AccessLevel.Administrator)]
public int TotalPlat { get { return (int)Math.Truncate(TotalCurrency); } }
/// <summary>
/// Attempts to deposit the given amount of Gold and Platinum into this account.
/// </summary>
/// <param name="amount">Amount to deposit.</param>
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
public bool DepositCurrency(double amount)
{
if (amount <= 0)
{
return false;
}
TotalCurrency += amount;
return true;
}
/// <summary>
/// Attempts to deposit the given amount of Gold into this account.
/// If the given amount is greater than the CurrencyThreshold,
/// Platinum will be deposited to offset the difference.
/// </summary>
/// <param name="amount">Amount to deposit.</param>
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
public bool DepositGold(int amount)
{
return DepositCurrency(amount / Math.Max(1.0, CurrencyThreshold));
}
/// <summary>
/// Attempts to deposit the given amount of Gold into this account.
/// If the given amount is greater than the CurrencyThreshold,
/// Platinum will be deposited to offset the difference.
/// </summary>
/// <param name="amount">Amount to deposit.</param>
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
public bool DepositGold(long amount)
{
return DepositCurrency(amount / Math.Max(1.0, CurrencyThreshold));
}
/// <summary>
/// Attempts to deposit the given amount of Platinum into this account.
/// </summary>
/// <param name="amount">Amount to deposit.</param>
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
public bool DepositPlat(int amount)
{
return DepositCurrency(amount);
}
/// <summary>
/// Attempts to deposit the given amount of Platinum into this account.
/// </summary>
/// <param name="amount">Amount to deposit.</param>
/// <returns>True if successful, false if amount given is less than or equal to zero.</returns>
public bool DepositPlat(long amount)
{
return DepositCurrency(amount);
}
/// <summary>
/// Attempts to withdraw the given amount of Platinum and Gold from this account.
/// </summary>
/// <param name="amount">Amount to withdraw.</param>
/// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawCurrency(double amount)
{
if (amount <= 0)
{
return true;
}
if (amount > TotalCurrency)
{
return false;
}
TotalCurrency -= amount;
return true;
}
/// <summary>
/// Attempts to withdraw the given amount of Gold from this account.
/// If the given amount is greater than the CurrencyThreshold,
/// Platinum will be withdrawn to offset the difference.
/// </summary>
/// <param name="amount">Amount to withdraw.</param>
/// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawGold(int amount)
{
return WithdrawCurrency(amount / Math.Max(1.0, CurrencyThreshold));
}
/// <summary>
/// Attempts to withdraw the given amount of Gold from this account.
/// If the given amount is greater than the CurrencyThreshold,
/// Platinum will be withdrawn to offset the difference.
/// </summary>
/// <param name="amount">Amount to withdraw.</param>
/// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawGold(long amount)
{
return WithdrawCurrency(amount / Math.Max(1.0, CurrencyThreshold));
}
/// <summary>
/// Attempts to withdraw the given amount of Platinum from this account.
/// </summary>
/// <param name="amount">Amount to withdraw.</param>
/// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawPlat(int amount)
{
return WithdrawCurrency(amount);
}
/// <summary>
/// Attempts to withdraw the given amount of Platinum from this account.
/// </summary>
/// <param name="amount">Amount to withdraw.</param>
/// <returns>True if successful, false if balance was too low.</returns>
public bool WithdrawPlat(long amount)
{
return WithdrawCurrency(amount);
}
/// <summary>
/// Gets the total balance of Gold for this account.
/// </summary>
/// <param name="gold">Gold value, Platinum exclusive</param>
/// <param name="totalGold">Gold value, Platinum inclusive</param>
public void GetGoldBalance(out int gold, out double totalGold)
{
gold = TotalGold;
totalGold = TotalCurrency * Math.Max(1.0, CurrencyThreshold);
}
/// <summary>
/// Gets the total balance of Gold for this account.
/// </summary>
/// <param name="gold">Gold value, Platinum exclusive</param>
/// <param name="totalGold">Gold value, Platinum inclusive</param>
public void GetGoldBalance(out long gold, out double totalGold)
{
gold = TotalGold;
totalGold = TotalCurrency * Math.Max(1.0, CurrencyThreshold);
}
/// <summary>
/// Gets the total balance of Platinum for this account.
/// </summary>
/// <param name="plat">Platinum value, Gold exclusive</param>
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
public void GetPlatBalance(out int plat, out double totalPlat)
{
plat = TotalPlat;
totalPlat = TotalCurrency;
}
/// <summary>
/// Gets the total balance of Platinum for this account.
/// </summary>
/// <param name="plat">Platinum value, Gold exclusive</param>
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
public void GetPlatBalance(out long plat, out double totalPlat)
{
plat = TotalPlat;
totalPlat = TotalCurrency;
}
/// <summary>
/// Gets the total balance of Gold and Platinum for this account.
/// </summary>
/// <param name="gold">Gold value, Platinum exclusive</param>
/// <param name="totalGold">Gold value, Platinum inclusive</param>
/// <param name="plat">Platinum value, Gold exclusive</param>
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
public void GetBalance(out int gold, out double totalGold, out int plat, out double totalPlat)
{
GetGoldBalance(out gold, out totalGold);
GetPlatBalance(out plat, out totalPlat);
}
/// <summary>
/// Gets the total balance of Gold and Platinum for this account.
/// </summary>
/// <param name="gold">Gold value, Platinum exclusive</param>
/// <param name="totalGold">Gold value, Platinum inclusive</param>
/// <param name="plat">Platinum value, Gold exclusive</param>
/// <param name="totalPlat">Platinum value, Gold inclusive</param>
public void GetBalance(out long gold, out double totalGold, out long plat, out double totalPlat)
{
GetGoldBalance(out gold, out totalGold);
GetPlatBalance(out plat, out totalPlat);
}
#endregion
}
}

View file

@ -1,5 +1,6 @@
using System;
using Server;
using Server.Accounting;
using Server.Items;
using Server.Multis;
using Server.Multis.Deeds;
@ -114,6 +115,23 @@ namespace Server.Gumps
toGive = new BankCheck( m_House.Price );
}
if (AccountGold.Enabled && toGive is BankCheck)
{
var worth = ((BankCheck)toGive).Worth;
if (m_Mobile.Account != null && m_Mobile.Account.DepositGold(worth))
{
toGive.Delete();
m_Mobile.SendLocalizedMessage(1060397, worth.ToString("#,0"));
// ~1_AMOUNT~ gold has been deposited into your bank box.
m_House.RemoveKeys(m_Mobile);
m_House.Delete();
return;
}
}
if ( toGive != null )
{
BankBox box = m_Mobile.BankBox;

View file

@ -1,6 +1,7 @@
using System;
using System.Globalization;
using Server;
using Server.Accounting;
using Server.Items;
using Server.Mobiles;
using Server.Network;
@ -79,30 +80,131 @@ namespace Server.Items
list.Add( 1060738, worth ); // value: ~1_val~
}
public override void OnSingleClick( Mobile from )
#if NEWPARENT
public override void OnAdded(IEntity parent)
#else
public override void OnAdded(object parent)
#endif
{
from.Send( new MessageLocalizedAffix( Serial, ItemID, MessageType.Label, 0x3B2, 3, 1041361, "", AffixType.Append, String.Concat( " ", m_Worth.ToString() ), "" ) ); // A bank check:
base.OnAdded(parent);
if (!AccountGold.Enabled)
{
return;
}
Mobile owner = null;
SecureTradeInfo tradeInfo = null;
Container root = parent as Container;
while (root != null && root.Parent is Container)
{
root = (Container)root.Parent;
}
parent = root ?? parent;
if (parent is SecureTradeContainer && AccountGold.ConvertOnTrade)
{
var trade = (SecureTradeContainer)parent;
if (trade.Trade.From.Container == trade)
{
tradeInfo = trade.Trade.From;
owner = tradeInfo.Mobile;
}
else if (trade.Trade.To.Container == trade)
{
tradeInfo = trade.Trade.To;
owner = tradeInfo.Mobile;
}
}
else if (parent is BankBox && AccountGold.ConvertOnBank)
{
owner = ((BankBox)parent).Owner;
}
if (owner == null || owner.Account == null || !owner.Account.DepositGold(Worth))
{
return;
}
if (tradeInfo != null)
{
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);
tradeInfo.Plat += plat;
tradeInfo.Gold += gold;
}
if (tradeInfo.VirtualCheck != null)
{
tradeInfo.VirtualCheck.UpdateTrade(tradeInfo.Mobile);
}
}
owner.SendLocalizedMessage(1042763, Worth.ToString("#,0"));
Delete();
((Container)parent).UpdateTotals();
}
public override void OnDoubleClick( Mobile from )
public override void OnSingleClick(Mobile from)
{
BankBox box = from.FindBankNoCreate();
from.Send(
new MessageLocalizedAffix(
Serial,
ItemID,
MessageType.Label,
0x3B2,
3,
1041361,
"",
AffixType.Append,
String.Concat(" ", m_Worth.ToString()),
"")); // A bank check:
}
if ( box != null && IsChildOf( box ) )
public override void OnDoubleClick(Mobile from)
{
// This probably isn't OSI accurate, but we can't just make the quests redundant.
// Double-clicking the BankCheck in your pack will now credit your account.
var box = AccountGold.Enabled ? from.Backpack : from.FindBankNoCreate();
if (box == null || !IsChildOf(box))
{
Delete();
from.SendLocalizedMessage(AccountGold.Enabled ? 1080058 : 1047026);
// This must be in your backpack to use it. : That must be in your bank box to use it.
return;
}
int deposited = 0;
Delete();
int toAdd = m_Worth;
var deposited = 0;
var toAdd = m_Worth;
if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(toAdd))
{
deposited = toAdd;
toAdd = 0;
}
if (toAdd > 0)
{
Gold gold;
while ( toAdd > 60000 )
while (toAdd > 60000)
{
gold = new Gold( 60000 );
gold = new Gold(60000);
if ( box.TryDropItem( from, gold, false ) )
if (box.TryDropItem(from, gold, false))
{
toAdd -= 60000;
deposited += 60000;
@ -111,18 +213,18 @@ namespace Server.Items
{
gold.Delete();
from.AddToBackpack( new BankCheck( toAdd ) );
from.AddToBackpack(new BankCheck(toAdd));
toAdd = 0;
break;
}
}
if ( toAdd > 0 )
if (toAdd > 0)
{
gold = new Gold( toAdd );
gold = new Gold(toAdd);
if ( box.TryDropItem( from, gold, false ) )
if (box.TryDropItem(from, gold, false))
{
deposited += toAdd;
}
@ -130,39 +232,39 @@ namespace Server.Items
{
gold.Delete();
from.AddToBackpack( new BankCheck( toAdd ) );
}
}
// Gold was deposited in your account:
from.SendLocalizedMessage( 1042672, true, " " + deposited.ToString() );
PlayerMobile pm = from as PlayerMobile;
if ( pm != null )
{
QuestSystem qs = pm.Quest;
if ( qs is Necro.DarkTidesQuest )
{
QuestObjective obj = qs.FindObjective( typeof( Necro.CashBankCheckObjective ) );
if ( obj != null && !obj.Completed )
obj.Complete();
}
if ( qs is Haven.UzeraanTurmoilQuest )
{
QuestObjective obj = qs.FindObjective( typeof( Haven.CashBankCheckObjective ) );
if ( obj != null && !obj.Completed )
obj.Complete();
from.AddToBackpack(new BankCheck(toAdd));
}
}
}
else
// Gold was deposited in your account:
from.SendLocalizedMessage(1042672, true, deposited.ToString("#,0"));
var pm = from as PlayerMobile;
if (pm != null)
{
from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it.
var qs = pm.Quest;
if (qs is Necro.DarkTidesQuest)
{
var obj = qs.FindObjective(typeof(Necro.CashBankCheckObjective));
if (obj != null && !obj.Completed)
{
obj.Complete();
}
}
if (qs is Haven.UzeraanTurmoilQuest)
{
var obj = qs.FindObjective(typeof(Engines.Quests.Haven.CashBankCheckObjective));
if (obj != null && !obj.Completed)
{
obj.Complete();
}
}
}
}
}

View file

@ -1,5 +1,7 @@
using System;
using Server.Accounting;
namespace Server.Items
{
public class Gold : Item
@ -47,6 +49,81 @@ namespace Server.Items
UpdateTotal( this, TotalType.Gold, newValue - oldValue );
}
#if NEWPARENT
public override void OnAdded(IEntity parent)
#else
public override void OnAdded(object parent)
#endif
{
base.OnAdded(parent);
if (!AccountGold.Enabled)
{
return;
}
Mobile owner = null;
SecureTradeInfo tradeInfo = null;
Container root = parent as Container;
while (root != null && root.Parent is Container)
{
root = (Container)root.Parent;
}
parent = root ?? parent;
if (parent is SecureTradeContainer && AccountGold.ConvertOnTrade)
{
var trade = (SecureTradeContainer)parent;
if (trade.Trade.From.Container == trade)
{
tradeInfo = trade.Trade.From;
owner = tradeInfo.Mobile;
}
else if (trade.Trade.To.Container == trade)
{
tradeInfo = trade.Trade.To;
owner = tradeInfo.Mobile;
}
}
else if (parent is BankBox && AccountGold.ConvertOnBank)
{
owner = ((BankBox)parent).Owner;
}
if (owner == null || owner.Account == null || !owner.Account.DepositGold(Amount))
{
return;
}
if (tradeInfo != null)
{
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);
tradeInfo.Plat += plat;
tradeInfo.Gold += gold;
}
if (tradeInfo.VirtualCheck != null)
{
tradeInfo.VirtualCheck.UpdateTrade(tradeInfo.Mobile);
}
}
owner.SendLocalizedMessage(1042763, Amount.ToString("#,0"));
Delete();
((Container)parent).UpdateTotals();
}
public override int GetTotal( TotalType type )
{
int baseTotal = base.GetTotal( type );
@ -57,8 +134,6 @@ namespace Server.Items
return baseTotal;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

View file

@ -1,16 +1,23 @@
using System;
using Server.Accounting;
using Server.Network;
namespace Server
{
public class CurrentExpansion
{
private static readonly Expansion Expansion = Expansion.HS;
private static readonly Expansion Expansion = Expansion.TOL;
public static void Configure()
{
Core.Expansion = Expansion;
AccountGold.Enabled = Core.TOL;
AccountGold.ConvertOnBank = true;
AccountGold.ConvertOnTrade = false;
VirtualCheck.UseEditGump = true;
bool Enabled = Core.AOS;
Mobile.InsuranceEnabled = Enabled;

View file

@ -1695,8 +1695,13 @@ namespace Server.Mobiles
list.Add( new CallbackEntry( RefuseTrades ? 1154112 : 1154113, new ContextCallback( ToggleTrades ) ) ); // Allow Trades / Refuse Trades
}
}
if ( from != this )
else
{
if (Core.TOL && from.InRange(this, 2))
{
list.Add(new CallbackEntry(1077728, () => OpenTrade(from))); // Trade
}
if ( Alive && Core.Expansion >= Expansion.AOS )
{
Party theirParty = from.Party as Party;
@ -2397,7 +2402,7 @@ namespace Server.Mobiles
msgNum = 1154111; // ~1_NAME~ is refusing all trades.
}
if ( msgNum == 0 )
if ( msgNum == 0 && item != null )
{
if ( cont != null )
{

View file

@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Accounting;
using Server.Items;
using Server.ContextMenus;
using Server.Misc;
@ -24,49 +27,88 @@ namespace Server.Mobiles
m_SBInfos.Add( new SBBanker() );
}
public static int GetBalance( Mobile from )
public static int GetBalance(Mobile m)
{
Item[] gold, checks;
double balance = 0;
return GetBalance( from, out gold, out checks );
if (AccountGold.Enabled && m.Account != null)
{
int goldStub;
m.Account.GetGoldBalance(out goldStub, out balance);
if (balance > Int32.MaxValue)
{
return Int32.MaxValue;
}
}
Container bank = m.FindBankNoCreate();
if (bank != null)
{
var gold = bank.FindItemsByType<Gold>();
var checks = bank.FindItemsByType<BankCheck>();
balance += gold.Aggregate(0.0, (c, t) => c + t.Amount);
balance += checks.Aggregate(0.0, (c, t) => c + t.Worth);
}
return (int)Math.Max(0, Math.Min(Int32.MaxValue, balance));
}
public static int GetBalance( Mobile from, out Item[] gold, out Item[] checks )
public static int GetBalance(Mobile m, out Item[] gold, out Item[] checks)
{
int balance = 0;
double balance = 0;
Container bank = from.FindBankNoCreate();
if ( bank != null )
if (AccountGold.Enabled && m.Account != null)
{
gold = bank.FindItemsByType( typeof( Gold ) );
checks = bank.FindItemsByType( typeof( BankCheck ) );
int goldStub;
m.Account.GetGoldBalance(out goldStub, out balance);
for ( int i = 0; i < gold.Length; ++i )
balance += gold[i].Amount;
if (balance > Int32.MaxValue)
{
gold = checks = new Item[0];
return Int32.MaxValue;
}
}
for ( int i = 0; i < checks.Length; ++i )
balance += ((BankCheck)checks[i]).Worth;
Container bank = m.FindBankNoCreate();
if (bank != null)
{
gold = bank.FindItemsByType(typeof(Gold));
checks = bank.FindItemsByType(typeof(BankCheck));
balance += gold.OfType<Gold>().Aggregate(0.0, (c, t) => c + t.Amount);
balance += checks.OfType<BankCheck>().Aggregate(0.0, (c, t) => c + t.Worth);
}
else
{
gold = checks = new Item[0];
}
return balance;
return (int)Math.Max(0, Math.Min(Int32.MaxValue, balance));
}
public static bool Withdraw( Mobile from, int amount )
public static bool Withdraw(Mobile from, int amount)
{
Item[] gold, checks;
int balance = GetBalance( from, out gold, out checks );
if ( balance < amount )
return false;
for ( int i = 0; amount > 0 && i < gold.Length; ++i )
// If for whatever reason the TOL checks fail, we should still try old methods for withdrawing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.WithdrawGold(amount))
{
if ( gold[i].Amount <= amount )
return true;
}
Item[] gold, checks;
var balance = GetBalance(from, out gold, out checks);
if (balance < amount)
{
return false;
}
for (var i = 0; amount > 0 && i < gold.Length; ++i)
{
if (gold[i].Amount <= amount)
{
amount -= gold[i].Amount;
gold[i].Delete();
@ -78,11 +120,11 @@ namespace Server.Mobiles
}
}
for ( int i = 0; amount > 0 && i < checks.Length; ++i )
for (var i = 0; amount > 0 && i < checks.Length; ++i)
{
BankCheck check = (BankCheck)checks[i];
var check = (BankCheck)checks[i];
if ( check.Worth <= amount )
if (check.Worth <= amount)
{
amount -= check.Worth;
check.Delete();
@ -97,41 +139,50 @@ namespace Server.Mobiles
return true;
}
public static bool Deposit( Mobile from, int amount )
public static bool Deposit(Mobile from, int amount)
{
BankBox box = from.FindBankNoCreate();
if ( box == null )
// If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
{
return true;
}
var box = from.FindBankNoCreate();
if (box == null)
{
return false;
}
List<Item> items = new List<Item>();
var items = new List<Item>();
while ( amount > 0 )
while (amount > 0)
{
Item item;
if ( amount < 5000 )
if (amount < 5000)
{
item = new Gold( amount );
item = new Gold(amount);
amount = 0;
}
else if ( amount <= 1000000 )
else if (amount <= 1000000)
{
item = new BankCheck( amount );
item = new BankCheck(amount);
amount = 0;
}
else
{
item = new BankCheck( 1000000 );
item = new BankCheck(1000000);
amount -= 1000000;
}
if ( box.TryDropItem( from, item, false ) )
if (box.TryDropItem(from, item, false))
{
items.Add( item );
items.Add(item);
}
else
{
item.Delete();
foreach ( Item curItem in items )
foreach (var curItem in items)
{
curItem.Delete();
}
@ -143,35 +194,44 @@ namespace Server.Mobiles
return true;
}
public static int DepositUpTo( Mobile from, int amount )
public static int DepositUpTo(Mobile from, int amount)
{
BankBox box = from.FindBankNoCreate();
if ( box == null )
return 0;
// If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
{
return amount;
}
int amountLeft = amount;
while ( amountLeft > 0 )
var box = from.FindBankNoCreate();
if (box == null)
{
return 0;
}
var amountLeft = amount;
while (amountLeft > 0)
{
Item item;
int amountGiven;
if ( amountLeft < 5000 )
if (amountLeft < 5000)
{
item = new Gold( amountLeft );
item = new Gold(amountLeft);
amountGiven = amountLeft;
}
else if ( amountLeft <= 1000000 )
else if (amountLeft <= 1000000)
{
item = new BankCheck( amountLeft );
item = new BankCheck(amountLeft);
amountGiven = amountLeft;
}
else
{
item = new BankCheck( 1000000 );
item = new BankCheck(1000000);
amountGiven = 1000000;
}
if ( box.TryDropItem( from, item, false ) )
if (box.TryDropItem(from, item, false))
{
amountLeft -= amountGiven;
}
@ -185,29 +245,29 @@ namespace Server.Mobiles
return amount - amountLeft;
}
public static void Deposit( Container cont, int amount )
public static void Deposit(Container cont, int amount)
{
while ( amount > 0 )
while (amount > 0)
{
Item item;
if ( amount < 5000 )
if (amount < 5000)
{
item = new Gold( amount );
item = new Gold(amount);
amount = 0;
}
else if ( amount <= 1000000 )
else if (amount <= 1000000)
{
item = new BankCheck( amount );
item = new BankCheck(amount);
amount = 0;
}
else
{
item = new BankCheck( 1000000 );
item = new BankCheck(1000000);
amount -= 1000000;
}
cont.DropItem( item );
cont.DropItem(item);
}
}

View file

@ -30,12 +30,12 @@ namespace Server.Multis
if ( val == -1 )
return false;
return ( val == 0 || (ExpansionInfo.CurrentExpansion.CustomHousingFlag & val) != 0 );
return ( val == 0 || ((int)ExpansionInfo.CoreExpansion.CustomHousingFlag & val) != 0 );
}
public ComponentVerification()
{
m_ItemTable = CreateTable( 0x10000 );
m_ItemTable = CreateTable( TileData.MaxItemValue );
m_MultiTable = CreateTable( 0x4000 );
LoadItems( "Data/Components/walls.txt", "South1", "South2", "South3", "Corner", "East1", "East2", "East3", "Post", "WindowS", "AltWindowS", "WindowE", "AltWindowE", "SecondAltWindowS", "SecondAltWindowE" );

View file

@ -1882,7 +1882,8 @@ namespace Server.Multis
return true;
else if( itemID >= 0x319C && itemID < 0x31B0 )
return true;
else if( itemID == 0x2D46 ||itemID == 0x2D48 || itemID == 0x2FE2 || itemID == 0x2FE4 ) //ML doors begin here. Note funkyness.
// ML doors
else if( itemID == 0x2D46 ||itemID == 0x2D48 || itemID == 0x2FE2 || itemID == 0x2FE4 )
return true;
else if( itemID >= 0x2D63 && itemID < 0x2D70 )
return true;
@ -1890,7 +1891,7 @@ namespace Server.Multis
return true;
else if( itemID >= 0x367B && itemID < 0x369B )
return true;
#region SA doors
// SA doors
else if( itemID >= 0x409B && itemID < 0x40A3 )
return true;
else if( itemID >= 0x410C && itemID < 0x4114 )
@ -1909,7 +1910,11 @@ namespace Server.Multis
return true;
else if( itemID >= 0x5142 && itemID < 0x514A )
return true;
#endregion
// TOL doors
else if ( itemID >= 0x9AD7 && itemID < 0x9AE7 )
return true;
else if ( itemID >= 0x9B3C && itemID < 0x9B4C )
return true;
return false;
}

View file

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("RunUO")]
[assembly: AssemblyProduct("RunUO")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]