+ 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

@ -32,7 +32,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("")]
@ -47,7 +47,7 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.6.0.*")]
[assembly: AssemblyVersion("2.7.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the

View file

@ -33,7 +33,8 @@ namespace Server
SE,
ML,
SA,
HS
HS,
TOL
}
[Flags]
@ -54,38 +55,42 @@ namespace Server
[Flags]
public enum FeatureFlags
{
None = 0x00000000,
T2A = 0x00000001,
UOR = 0x00000002,
UOTD = 0x00000004,
LBR = 0x00000008,
AOS = 0x00000010,
SixthCharacterSlot = 0x00000020,
SE = 0x00000040,
ML = 0x00000080,
EigthAge = 0x00000100,
NinthAge = 0x00000200, /* Crystal/Shadow Custom House Tiles */
TenthAge = 0x00000400,
IncreasedStorage = 0x00000800, /* Increased Housing/Bank Storage */
SeventhCharacterSlot= 0x00001000,
RoleplayFaces = 0x00002000,
TrialAccount = 0x00004000,
LiveAccount = 0x00008000,
SA = 0x00010000,
HS = 0x00020000,
Gothic = 0x00040000,
Rustic = 0x00080000,
None = 0x00000000,
T2A = 0x00000001,
UOR = 0x00000002,
UOTD = 0x00000004,
LBR = 0x00000008,
AOS = 0x00000010,
SixthCharacterSlot = 0x00000020,
SE = 0x00000040,
ML = 0x00000080,
EigthAge = 0x00000100,
NinthAge = 0x00000200, /* Crystal/Shadow Custom House Tiles */
TenthAge = 0x00000400,
IncreasedStorage = 0x00000800, /* Increased Housing/Bank Storage */
SeventhCharacterSlot = 0x00001000,
RoleplayFaces = 0x00002000,
TrialAccount = 0x00004000,
LiveAccount = 0x00008000,
SA = 0x00010000,
HS = 0x00020000,
Gothic = 0x00040000,
Rustic = 0x00080000,
Jungle = 0x00100000,
Shadowguard = 0x00200000,
TOL = 0x00400000,
ExpansionNone = None,
ExpansionT2A = T2A,
ExpansionUOR = ExpansionT2A | UOR,
ExpansionUOTD = ExpansionUOR | UOTD,
ExpansionLBR = ExpansionUOTD | LBR,
ExpansionAOS = ExpansionLBR | AOS | LiveAccount,
ExpansionSE = ExpansionAOS | SE,
ExpansionML = ExpansionSE | ML | NinthAge,
ExpansionSA = ExpansionML | SA | Gothic | Rustic,
ExpansionHS = ExpansionSA | HS
ExpansionNone = None,
ExpansionT2A = T2A,
ExpansionUOR = ExpansionT2A | UOR,
ExpansionUOTD = ExpansionUOR | UOTD,
ExpansionLBR = ExpansionUOTD | LBR,
ExpansionAOS = ExpansionLBR | AOS | LiveAccount,
ExpansionSE = ExpansionAOS | SE,
ExpansionML = ExpansionSE | ML | NinthAge,
ExpansionSA = ExpansionML | SA | Gothic | Rustic,
ExpansionHS = ExpansionSA | HS,
ExpansionTOL = ExpansionHS | TOL | Jungle | Shadowguard
}
[Flags]
@ -109,92 +114,239 @@ namespace Server
NewMovementSystem = 0x00004000,
NewFeluccaAreas = 0x00008000,
ExpansionNone = ContextMenus, //
ExpansionT2A = ContextMenus, //
ExpansionUOR = ContextMenus, // None
ExpansionUOTD = ContextMenus, //
ExpansionLBR = ContextMenus, //
ExpansionAOS = ContextMenus | AOS,
ExpansionSE = ExpansionAOS | SE,
ExpansionML = ExpansionSE | ML,
ExpansionSA = ExpansionML,
ExpansionHS = ExpansionSA
ExpansionNone = ContextMenus, //
ExpansionT2A = ContextMenus, //
ExpansionUOR = ContextMenus, // None
ExpansionUOTD = ContextMenus, //
ExpansionLBR = ContextMenus, //
ExpansionAOS = ContextMenus | AOS,
ExpansionSE = ExpansionAOS | SE,
ExpansionML = ExpansionSE | ML,
ExpansionSA = ExpansionML,
ExpansionHS = ExpansionSA,
ExpansionTOL = ExpansionHS
}
[Flags]
public enum HousingFlags
{
None = 0x0,
AOS = 0x10,
SE = 0x40,
ML = 0x80,
Crystal = 0x200,
SA = 0x10000,
HS = 0x20000,
Gothic = 0x40000,
Rustic = 0x80000,
Jungle = 0x100000,
Shadowguard = 0x200000,
TOL = 0x400000,
HousingAOS = AOS,
HousingSE = HousingAOS | SE,
HousingML = HousingSE | ML | Crystal,
HousingSA = HousingML | SA | Gothic | Rustic,
HousingHS = HousingSA | HS,
HousingTOL = HousingHS | TOL | Jungle | Shadowguard
}
public class ExpansionInfo
{
public static ExpansionInfo[] Table { get { return m_Table; } }
private static ExpansionInfo[] m_Table = new ExpansionInfo[]
public static ExpansionInfo CoreExpansion { get { return GetInfo(Core.Expansion); } }
public static ExpansionInfo[] Table { get; private set; }
static ExpansionInfo()
{
Table = new[]
{
new ExpansionInfo( 0, "None", ClientFlags.None, FeatureFlags.ExpansionNone, CharacterListFlags.ExpansionNone, 0x0000 ),
new ExpansionInfo( 1, "The Second Age", ClientFlags.Felucca, FeatureFlags.ExpansionT2A, CharacterListFlags.ExpansionT2A, 0x0000 ),
new ExpansionInfo( 2, "Renaissance", ClientFlags.Trammel, FeatureFlags.ExpansionUOR, CharacterListFlags.ExpansionUOR, 0x0000 ),
new ExpansionInfo( 3, "Third Dawn", ClientFlags.Ilshenar, FeatureFlags.ExpansionUOTD, CharacterListFlags.ExpansionUOTD, 0x0000 ),
new ExpansionInfo( 4, "Blackthorn's Revenge", ClientFlags.Ilshenar, FeatureFlags.ExpansionLBR, CharacterListFlags.ExpansionLBR, 0x0000 ),
new ExpansionInfo( 5, "Age of Shadows", ClientFlags.Malas, FeatureFlags.ExpansionAOS, CharacterListFlags.ExpansionAOS, 0x0000 ),
new ExpansionInfo( 6, "Samurai Empire", ClientFlags.Tokuno, FeatureFlags.ExpansionSE, CharacterListFlags.ExpansionSE, 0x00C0 ), // 0x20 | 0x80
new ExpansionInfo( 7, "Mondain's Legacy", new ClientVersion( "5.0.0a" ), FeatureFlags.ExpansionML, CharacterListFlags.ExpansionML, 0x02C0 ), // 0x20 | 0x80 | 0x200
new ExpansionInfo( 8, "Stygian Abyss", ClientFlags.TerMur, FeatureFlags.ExpansionSA, CharacterListFlags.ExpansionSA, 0xD02C0 ), // 0x20 | 0x80 | 0x200 | 0x10000 | 0x40000 | 0x80000
new ExpansionInfo( 9, "High Seas", new ClientVersion( "7.0.9.0" ), FeatureFlags.ExpansionHS, CharacterListFlags.ExpansionHS, 0xD02C0 ) // 0x20 | 0x80 | 0x200 | 0x10000 | 0x40000 | 0x80000
new ExpansionInfo(
0,
"None",
ClientFlags.None,
FeatureFlags.ExpansionNone,
CharacterListFlags.ExpansionNone,
HousingFlags.None),
new ExpansionInfo(
1,
"The Second Age",
ClientFlags.Felucca,
FeatureFlags.ExpansionT2A,
CharacterListFlags.ExpansionT2A,
HousingFlags.None),
new ExpansionInfo(
2,
"Renaissance",
ClientFlags.Trammel,
FeatureFlags.ExpansionUOR,
CharacterListFlags.ExpansionUOR,
HousingFlags.None),
new ExpansionInfo(
3,
"Third Dawn",
ClientFlags.Ilshenar,
FeatureFlags.ExpansionUOTD,
CharacterListFlags.ExpansionUOTD,
HousingFlags.None),
new ExpansionInfo(
4,
"Blackthorn's Revenge",
ClientFlags.Ilshenar,
FeatureFlags.ExpansionLBR,
CharacterListFlags.ExpansionLBR,
HousingFlags.None),
new ExpansionInfo(
5,
"Age of Shadows",
ClientFlags.Malas,
FeatureFlags.ExpansionAOS,
CharacterListFlags.ExpansionAOS,
HousingFlags.HousingAOS),
new ExpansionInfo(
6,
"Samurai Empire",
ClientFlags.Tokuno,
FeatureFlags.ExpansionSE,
CharacterListFlags.ExpansionSE,
HousingFlags.HousingSE),
new ExpansionInfo(
7,
"Mondain's Legacy",
new ClientVersion("5.0.0a"),
FeatureFlags.ExpansionML,
CharacterListFlags.ExpansionML,
HousingFlags.HousingML),
new ExpansionInfo(
8,
"Stygian Abyss",
ClientFlags.TerMur,
FeatureFlags.ExpansionSA,
CharacterListFlags.ExpansionSA,
HousingFlags.HousingSA),
new ExpansionInfo(
9,
"High Seas",
new ClientVersion("7.0.9.0"),
FeatureFlags.ExpansionHS,
CharacterListFlags.ExpansionHS,
HousingFlags.HousingHS),
new ExpansionInfo(
10,
"Time of Legends",
new ClientVersion("7.0.45.65"),
FeatureFlags.ExpansionTOL,
CharacterListFlags.ExpansionTOL,
HousingFlags.HousingTOL)
};
private string m_Name;
private int m_ID, m_CustomHousingFlag;
private ClientFlags m_ClientFlags;
private FeatureFlags m_SupportedFeatures;
private CharacterListFlags m_CharListFlags;
private ClientVersion m_RequiredClient; // Used as an alternative to the flags
public string Name{ get{ return m_Name; } }
public int ID{ get{ return m_ID; } }
public ClientFlags ClientFlags{ get{ return m_ClientFlags; } }
public FeatureFlags SupportedFeatures{ get{ return m_SupportedFeatures; } }
public CharacterListFlags CharacterListFlags { get { return m_CharListFlags; } }
public int CustomHousingFlag { get{ return m_CustomHousingFlag; } }
public ClientVersion RequiredClient { get { return m_RequiredClient; } }
public ExpansionInfo( int id, string name, ClientFlags clientFlags, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag )
{
m_Name = name;
m_ID = id;
m_ClientFlags = clientFlags;
m_SupportedFeatures = supportedFeatures;
m_CharListFlags = charListFlags;
m_CustomHousingFlag = customHousingFlag;
}
public ExpansionInfo( int id, string name, ClientVersion requiredClient, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag )
public static FeatureFlags GetFeatures(Expansion ex)
{
m_Name = name;
m_ID = id;
m_SupportedFeatures = supportedFeatures;
m_CharListFlags = charListFlags;
m_CustomHousingFlag = customHousingFlag;
m_RequiredClient = requiredClient;
var info = GetInfo(ex);
if (info != null)
{
return info.SupportedFeatures;
}
switch (ex)
{
case Expansion.None:
return FeatureFlags.ExpansionNone;
case Expansion.T2A:
return FeatureFlags.ExpansionT2A;
case Expansion.UOR:
return FeatureFlags.ExpansionUOR;
case Expansion.UOTD:
return FeatureFlags.ExpansionUOTD;
case Expansion.LBR:
return FeatureFlags.ExpansionLBR;
case Expansion.AOS:
return FeatureFlags.ExpansionAOS;
case Expansion.SE:
return FeatureFlags.ExpansionSE;
case Expansion.ML:
return FeatureFlags.ExpansionML;
case Expansion.SA:
return FeatureFlags.ExpansionSA;
case Expansion.HS:
return FeatureFlags.ExpansionHS;
case Expansion.TOL:
return FeatureFlags.ExpansionTOL;
}
return FeatureFlags.ExpansionNone;
}
public static ExpansionInfo GetInfo( Expansion ex )
public static ExpansionInfo GetInfo(Expansion ex)
{
return GetInfo( (int)ex );
return GetInfo((int)ex);
}
public static ExpansionInfo GetInfo( int ex )
public static ExpansionInfo GetInfo(int ex)
{
int v = (int)ex;
var v = ex;
if( v < 0 || v >= m_Table.Length )
if (v < 0 || v >= Table.Length)
{
v = 0;
}
return m_Table[v];
return Table[v];
}
public static ExpansionInfo CurrentExpansion { get { return GetInfo( Core.Expansion ); } }
public int ID { get; private set; }
public string Name { get; set; }
public ClientFlags ClientFlags { get; set; }
public FeatureFlags SupportedFeatures { get; set; }
public CharacterListFlags CharacterListFlags { get; set; }
public ClientVersion RequiredClient { get; set; }
public HousingFlags CustomHousingFlag { get; set; }
public ExpansionInfo(
int id,
string name,
ClientFlags clientFlags,
FeatureFlags supportedFeatures,
CharacterListFlags charListFlags,
HousingFlags customHousingFlag)
: this(id, name, supportedFeatures, charListFlags, customHousingFlag)
{
ClientFlags = clientFlags;
}
public ExpansionInfo(
int id,
string name,
ClientVersion requiredClient,
FeatureFlags supportedFeatures,
CharacterListFlags charListFlags,
HousingFlags customHousingFlag)
: this(id, name, supportedFeatures, charListFlags, customHousingFlag)
{
RequiredClient = requiredClient;
}
private ExpansionInfo(
int id,
string name,
FeatureFlags supportedFeatures,
CharacterListFlags charListFlags,
HousingFlags customHousingFlag)
{
ID = id;
Name = name;
SupportedFeatures = supportedFeatures;
CharacterListFlags = charListFlags;
CustomHousingFlag = customHousingFlag;
}
public override string ToString()
{
return m_Name;
return Name;
}
}
}

View file

@ -22,9 +22,190 @@ using System;
namespace Server.Accounting
{
public interface IAccount : IComparable<IAccount>
public static class AccountGold
{
public static bool Enabled = false;
/// <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.
/// !!! WARNING !!!
/// The client is designed to perceive the currency threashold at 1,000,000,000
/// if you change this, it may cause unexpected results when using secure trading.
/// </summary>
public static int CurrencyThreshold = 1000000000;
/// <summary>
/// Enables or Disables automatic conversion of Gold and Checks to Bank Currency
/// when they are added to a bank box container.
/// </summary>
public static bool ConvertOnBank = true;
/// <summary>
/// Enables or Disables automatic conversion of Gold and Checks to Bank Currency
/// when they are added to a secure trade container.
/// </summary>
public static bool ConvertOnTrade = false;
}
public interface IGoldAccount
{
/// <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)]
double TotalCurrency { get; }
/// <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)]
int TotalGold { get; }
/// <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)]
int TotalPlat { get; }
/// <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>
bool DepositCurrency(double amount);
/// <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>
bool DepositGold(int amount);
/// <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>
bool DepositGold(long 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>
bool DepositPlat(int 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>
bool DepositPlat(long 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>
bool WithdrawCurrency(double amount);
/// <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>
bool WithdrawGold(int amount);
/// <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>
bool WithdrawGold(long 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>
bool WithdrawPlat(int 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>
bool WithdrawPlat(long 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>
void GetGoldBalance(out int gold, out double totalGold);
/// <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>
void GetGoldBalance(out long gold, out double totalGold);
/// <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>
void GetPlatBalance(out int plat, out double totalPlat);
/// <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>
void GetPlatBalance(out long plat, out double 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>
void GetBalance(out int gold, out double totalGold, out int plat, out double 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>
void GetBalance(out long gold, out double totalGold, out long plat, out double totalPlat);
}
public interface IAccount : IGoldAccount, IComparable<IAccount>
{
string Username { get; set; }
string Email { get; set; }
AccessLevel AccessLevel { get; set; }
int Length { get; }

View file

@ -19,6 +19,8 @@
***************************************************************************/
using System;
using Server.Accounting;
using Server.Network;
namespace Server.Items
@ -162,5 +164,15 @@ namespace Server.Items
else
return false;
}
public override int GetTotal(TotalType type)
{
if (AccountGold.Enabled && Owner != null && Owner.Account != null && type == TotalType.Gold)
{
return Owner.Account.TotalGold;
}
return base.GetTotal(type);
}
}
}

View file

@ -19,6 +19,8 @@
***************************************************************************/
using System;
using Server.Accounting;
using Server.Network;
namespace Server.Items
@ -48,6 +50,11 @@ namespace Server.Items
public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
{
if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck)
{
return true;
}
Mobile to;
if ( this.Trade.From.Container != this )
@ -74,34 +81,64 @@ namespace Server.Items
public override void OnItemAdded( Item item )
{
ClearChecks();
if ( !(item is VirtualCheck) )
{
ClearChecks();
}
}
public override void OnItemRemoved( Item item )
{
ClearChecks();
if ( !(item is VirtualCheck) )
{
ClearChecks();
}
}
public override void OnSubItemAdded( Item item )
{
ClearChecks();
if ( !(item is VirtualCheck) )
{
ClearChecks();
}
}
public override void OnSubItemRemoved( Item item )
{
ClearChecks();
if ( !(item is VirtualCheck) )
{
ClearChecks();
}
}
public void ClearChecks()
public void ClearChecks( )
{
if ( m_Trade != null )
{
m_Trade.From.Accepted = false;
m_Trade.To.Accepted = false;
if ( m_Trade.From != null && !m_Trade.From.IsDisposed )
{
m_Trade.From.Accepted = false;
}
if ( m_Trade.To != null && !m_Trade.To.IsDisposed )
{
m_Trade.To.Accepted = false;
}
m_Trade.Update();
}
}
public override bool IsChildVisibleTo( Mobile m, Item child )
{
if (child is VirtualCheck)
{
return AccountGold.Enabled && (m.NetState == null || !m.NetState.NewSecureTrading);
}
return base.IsChildVisibleTo(m, child);
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

View file

@ -0,0 +1,395 @@
#region Header
// **********
// ServUO - VirtualCheck.cs
// **********
#endregion
#region References
using System;
using System.Drawing;
using Server.Accounting;
using Server.Gumps;
using Server.Network;
#endregion
namespace Server
{
public sealed class VirtualCheck : Item
{
public static bool UseEditGump = false;
public override bool IsVirtualItem { get { return true; } }
public override bool DisplayWeight { get { return false; } }
public override bool DisplayLootType { get { return false; } }
public override double DefaultWeight { get { return 0; } }
public override string DefaultName { get { return "Offer Of Currency"; } }
public EditGump Editor { get; private set; }
private int _Plat;
[CommandProperty(AccessLevel.Administrator)]
public int Plat
{
get { return _Plat; }
set
{
_Plat = value;
InvalidateProperties();
}
}
private int _Gold;
[CommandProperty(AccessLevel.Administrator)]
public int Gold
{
get { return _Gold; }
set
{
_Gold = value;
InvalidateProperties();
}
}
public VirtualCheck()
: this(0, 0)
{ }
public VirtualCheck(int plat, int gold)
: base(0x14F0)
{
Plat = plat;
Gold = gold;
Movable = false;
}
public VirtualCheck(Serial serial)
: base(serial)
{ }
public override bool IsAccessibleTo(Mobile check)
{
var c = GetSecureTradeCont();
if (check == null || c == null)
{
return base.IsAccessibleTo(check);
}
return c.RootParent == check && IsChildOf(c);
}
public override void OnDoubleClickSecureTrade(Mobile from)
{
if (UseEditGump && IsAccessibleTo(from))
{
if (Editor == null || Editor.Check == null || Editor.Check.Deleted)
{
Editor = new EditGump(from, this);
Editor.Send();
}
else
{
Editor.Refresh(true);
}
}
else
{
if (Editor != null)
{
Editor.Close();
Editor = null;
}
base.OnDoubleClickSecureTrade(from);
}
}
public override void OnSingleClick(Mobile from)
{
LabelTo(from, "Offer: {0:#,0} platinum, {1:#,0} gold", Plat, Gold);
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(1060738, String.Format("{0:#,0} platinum, {1:#,0} gold", Plat, Gold)); // value: ~1_val~
}
public void UpdateTrade(Mobile user)
{
var c = GetSecureTradeCont();
if (c == null || c.Trade == null)
{
return;
}
if (user == c.Trade.From.Mobile)
{
c.Trade.UpdateFromCurrency();
}
else if (user == c.Trade.To.Mobile)
{
c.Trade.UpdateToCurrency();
}
c.ClearChecks();
}
public override void OnAfterDelete()
{
base.OnAfterDelete();
if (Editor != null)
{
Editor.Close();
Editor = null;
}
}
public override void Serialize(GenericWriter writer)
{ }
public override void Deserialize(GenericReader reader)
{
Delete();
}
public class EditGump : Gump
{
public enum Buttons
{
Close,
Clear,
Accept,
AllPlat,
AllGold
}
private int _Plat, _Gold;
public Mobile User { get; private set; }
public VirtualCheck Check { get; private set; }
public EditGump(Mobile user, VirtualCheck check)
: base(50, 50)
{
User = user;
Check = check;
_Plat = Check.Plat;
_Gold = Check.Gold;
Closable = true;
Disposable = true;
Dragable = true;
Resizable = false;
User.CloseGump(GetType());
CompileLayout();
}
public override void OnServerClose(NetState owner)
{
base.OnServerClose(owner);
if (Check != null && !Check.Deleted)
{
Check.UpdateTrade(User);
}
}
public void Close()
{
User.CloseGump(GetType());
if (Check != null && !Check.Deleted)
{
Check.UpdateTrade(User);
}
else
{
Check = null;
}
}
public void Send()
{
if (Check != null && !Check.Deleted)
{
User.SendGump(this);
}
else
{
Close();
}
}
public void Refresh(bool recompile)
{
if (Check == null || Check.Deleted)
{
Close();
return;
}
if (recompile)
{
CompileLayout();
}
Close();
Send();
}
private void CompileLayout()
{
if (Check == null || Check.Deleted)
{
return;
}
Entries.ForEach(e => e.Parent = null);
Entries.Clear();
AddPage(0);
AddBackground(0, 0, 400, 160, 3500);
// Title
AddImageTiled(25, 35, 350, 3, 96);
AddImage(10, 8, 113);
AddImage(360, 8, 113);
var title = String.Format(
"<BASEFONT COLOR=#{0:X}><CENTER>BANK OF {1}</CENTER>",
Color.DarkSlateGray.ToArgb(),
User.RawName.ToUpper());
AddHtml(40, 15, 320, 20, title, false, false);
// Platinum Row
AddBackground(15, 60, 175, 20, 9300);
AddBackground(20, 45, 165, 30, 9350);
AddItem(20, 45, 3826); // Plat
AddLabel(60, 50, 0, User.Account.TotalPlat.ToString("#,0"));
AddButton(195, 50, 95, 95, (int)Buttons.AllPlat, GumpButtonType.Reply, 0); // ->
AddBackground(210, 60, 175, 20, 9300);
AddBackground(215, 45, 165, 30, 9350);
AddTextEntry(225, 50, 145, 20, 0, 0, _Plat.ToString(), User.Account.TotalPlat.ToString().Length);
// Gold Row
AddBackground(15, 100, 175, 20, 9300);
AddBackground(20, 85, 165, 30, 9350);
AddItem(20, 85, 3823); // Gold
AddLabel(60, 90, 0, User.Account.TotalGold.ToString("#,0"));
AddButton(195, 90, 95, 95, (int)Buttons.AllGold, GumpButtonType.Reply, 0); // ->
AddBackground(210, 100, 175, 20, 9300);
AddBackground(215, 85, 165, 30, 9350);
AddTextEntry(225, 90, 145, 20, 0, 1, _Gold.ToString(), User.Account.TotalGold.ToString().Length);
// Buttons
AddButton(20, 128, 12006, 12007, (int)Buttons.Close, GumpButtonType.Reply, 0);
AddButton(215, 128, 12003, 12004, (int)Buttons.Clear, GumpButtonType.Reply, 0);
AddButton(305, 128, 12000, 12002, (int)Buttons.Accept, GumpButtonType.Reply, 0);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (Check == null || Check.Deleted || sender.Mobile != User)
{
Close();
return;
}
bool refresh = false, updated = false;
switch ((Buttons)info.ButtonID)
{
case Buttons.Close:
break;
case Buttons.Clear:
{
_Plat = _Gold = 0;
refresh = true;
}
break;
case Buttons.Accept:
{
var platText = info.GetTextEntry(0).Text;
var goldText = info.GetTextEntry(1).Text;
if (!Int32.TryParse(platText, out _Plat))
{
User.SendMessage("That is not a valid amount of platinum.");
refresh = true;
}
else if (!Int32.TryParse(goldText, out _Gold))
{
User.SendMessage("That is not a valid amount of gold.");
refresh = true;
}
else
{
var cur = User.Account.TotalCurrency;
var off = _Plat + (_Gold / Math.Max(1.0, AccountGold.CurrencyThreshold));
if (off > cur)
{
_Plat = User.Account.TotalPlat;
_Gold = User.Account.TotalGold;
User.SendMessage("You do not have that much currency.");
refresh = true;
}
else
{
Check.Plat = _Plat;
Check.Gold = _Gold;
updated = true;
}
}
}
break;
case Buttons.AllPlat:
{
_Plat = User.Account.TotalPlat;
refresh = true;
}
break;
case Buttons.AllGold:
{
_Gold = User.Account.TotalGold;
refresh = true;
}
break;
}
if (updated)
{
User.SendMessage("Your offer has been updated.");
}
if (refresh && Check != null && !Check.Deleted)
{
Refresh(true);
return;
}
Close();
}
}
}
}

View file

@ -233,6 +233,11 @@ namespace Server
get { return m_Expansion >= Expansion.HS; }
}
public static bool TOL
{
get { return m_Expansion >= Expansion.TOL; }
}
#endregion
public static string ExePath

View file

@ -1725,7 +1725,7 @@ namespace Server
public sealed class PooledEnumerable<T> : IPooledEnumerable<T>, IDisposable
{
private static readonly Queue<PooledEnumerable<T>> _Buffer = new Queue<PooledEnumerable<T>>(0x200);
private static readonly Queue<PooledEnumerable<T>> _Buffer = new Queue<PooledEnumerable<T>>(0x400);
public static PooledEnumerable<T> Instantiate(Map map, Rectangle2D bounds, PooledEnumeration.Selector<T> selector)
{
@ -1754,11 +1754,12 @@ namespace Server
}
private bool _IsDisposed;
private List<T> _Pool;
private List<T> _Pool = new List<T>(0x40);
public PooledEnumerable(IEnumerable<T> pool)
{
_Pool = new List<T>(pool);
_Pool.AddRange(pool);
}
IEnumerator IEnumerable.GetEnumerator()
@ -1780,6 +1781,11 @@ namespace Server
_Pool.Clear();
if (_Pool.Capacity > 0x100)
{
_Pool.Capacity = 0x100;
}
lock (((ICollection)_Buffer).SyncRoot)
{
_Buffer.Enqueue(this);

View file

@ -9660,6 +9660,45 @@ namespace Server
{
return true;
}
public bool OpenTrade(Mobile from)
{
return OpenTrade(from, null);
}
public virtual bool OpenTrade(Mobile from, Item offer)
{
if (!from.Player || !Player || !from.Alive || !Alive)
{
return false;
}
NetState ourState = m_NetState;
NetState theirState = from.m_NetState;
if (ourState == null || theirState == null)
{
return false;
}
SecureTradeContainer cont = theirState.FindTradeContainer(this);
if (!from.CheckTrade(this, offer, cont, true, true, 0, 0))
{
return false;
}
if (cont == null)
{
cont = theirState.AddTrade(ourState);
}
if (offer != null)
{
cont.DropItem(offer);
}
return true;
}
/// <summary>
/// Overridable. Event invoked when a Mobile (<paramref name="from" />) drops an <see cref="Item"><paramref name="dropped" /></see> onto the Mobile.
@ -9675,27 +9714,9 @@ namespace Server
return false;
}
else if( from.Player && this.Player && from.Alive && this.Alive && from.InRange( Location, 2 ) )
else if( from.InRange( Location, 2 ) )
{
NetState ourState = m_NetState;
NetState theirState = from.m_NetState;
if( ourState != null && theirState != null )
{
SecureTradeContainer cont = theirState.FindTradeContainer( this );
if( !from.CheckTrade( this, dropped, cont, true, true, 0, 0 ) )
return false;
if( cont == null )
cont = theirState.AddTrade( ourState );
cont.DropItem( dropped );
return true;
}
return false;
return OpenTrade( from, dropped );
}
else
{

View file

@ -165,7 +165,9 @@ namespace Server.Network {
set {
m_Version = value;
if ( value >= m_Version70331 ) {
if ( value >= m_Version704565 ) {
_ProtocolChanges = ProtocolChanges.Version704565;
} else if ( value >= m_Version70331 ) {
_ProtocolChanges = ProtocolChanges.Version70331;
} else if ( value >= m_Version70300 ) {
_ProtocolChanges = ProtocolChanges.Version70300;
@ -208,6 +210,7 @@ namespace Server.Network {
private static ClientVersion m_Version70160 = new ClientVersion( "7.0.16.0" );
private static ClientVersion m_Version70300 = new ClientVersion( "7.0.30.0" );
private static ClientVersion m_Version70331 = new ClientVersion( "7.0.33.1" );
private static ClientVersion m_Version704565 = new ClientVersion( "7.0.45.65" );
private ProtocolChanges _ProtocolChanges;
@ -225,6 +228,7 @@ namespace Server.Network {
NewCharacterCreation = 0x00000400,
ExtendedStatus = 0x00000800,
NewMobileIncoming = 0x00001000,
NewSecureTrading = 0x00002000,
Version400a = NewSpellbook,
Version407a = Version400a | DamagePacket,
@ -238,7 +242,8 @@ namespace Server.Network {
Version70130 = Version7090 | NewCharacterList,
Version70160 = Version70130 | NewCharacterCreation,
Version70300 = Version70160 | ExtendedStatus,
Version70331 = Version70300 | NewMobileIncoming
Version70331 = Version70300 | NewMobileIncoming,
Version704565 = Version70331 | NewSecureTrading
}
public bool NewSpellbook { get { return ((_ProtocolChanges & ProtocolChanges.NewSpellbook) != 0); } }
@ -254,6 +259,7 @@ namespace Server.Network {
public bool NewCharacterCreation { get { return ((_ProtocolChanges & ProtocolChanges.NewCharacterCreation) != 0); } }
public bool ExtendedStatus { get { return ((_ProtocolChanges & ProtocolChanges.ExtendedStatus) != 0); } }
public bool NewMobileIncoming { get { return ((_ProtocolChanges & ProtocolChanges.NewMobileIncoming) != 0); } }
public bool NewSecureTrading { get { return ((_ProtocolChanges & ProtocolChanges.NewSecureTrading) != 0); } }
public bool IsUOTDClient {
get {

View file

@ -376,6 +376,37 @@ namespace Server.Network
break;
}
case 3: // Update Gold
{
Serial serial = pvSrc.ReadInt32();
SecureTradeContainer cont = World.FindItem(serial) as SecureTradeContainer;
if (cont != null)
{
int gold = pvSrc.ReadInt32();
int plat = pvSrc.ReadInt32();
SecureTrade trade = cont.Trade;
if (trade != null)
{
if (trade.From.Mobile == state.Mobile)
{
trade.From.Gold = gold;
trade.From.Plat = plat;
trade.UpdateFromCurrency();
}
else if (trade.To.Mobile == state.Mobile)
{
trade.To.Gold = gold;
trade.To.Plat = plat;
trade.UpdateToCurrency();
}
}
}
}
break;
}
}

View file

@ -162,44 +162,62 @@ namespace Server.Network
public sealed class DisplaySecureTrade : Packet
{
public DisplaySecureTrade( Mobile them, Container first, Container second, string name ) : base( 0x6F )
public DisplaySecureTrade(Mobile them, Container first, Container second, string name)
: base(0x6F)
{
if ( name == null )
if (name == null)
{
name = "";
}
EnsureCapacity( 18 + name.Length );
EnsureCapacity(18 + name.Length);
m_Stream.Write( (byte) 0 ); // Display
m_Stream.Write( (int) them.Serial );
m_Stream.Write( (int) first.Serial );
m_Stream.Write( (int) second.Serial );
m_Stream.Write( (bool) true );
m_Stream.Write((byte)0); // Display
m_Stream.Write(them.Serial);
m_Stream.Write(first.Serial);
m_Stream.Write(second.Serial);
m_Stream.Write(true);
m_Stream.WriteAsciiFixed( name, 30 );
m_Stream.WriteAsciiFixed(name, 30);
}
}
public sealed class CloseSecureTrade : Packet
{
public CloseSecureTrade( Container cont ) : base( 0x6F )
public CloseSecureTrade(Container cont)
: base(0x6F)
{
EnsureCapacity( 8 );
EnsureCapacity(8);
m_Stream.Write( (byte) 1 ); // Close
m_Stream.Write( (int) cont.Serial );
m_Stream.Write((byte)1); // Close
m_Stream.Write(cont.Serial);
}
}
public enum TradeFlag : byte
{
Display = 0x0,
Close = 0x1,
Update = 0x2,
UpdateGold = 0x3,
UpdateLedger = 0x4
}
public sealed class UpdateSecureTrade : Packet
{
public UpdateSecureTrade( Container cont, bool first, bool second ) : base( 0x6F )
{
EnsureCapacity( 8 );
public UpdateSecureTrade(Container cont, bool first, bool second)
: this(cont, TradeFlag.Update, first ? 1 : 0, second ? 1 : 0)
{ }
m_Stream.Write( (byte) 2 ); // Update
m_Stream.Write( (int) cont.Serial );
m_Stream.Write( (int) (first ? 1 : 0) );
m_Stream.Write( (int) (second ? 1 : 0) );
public UpdateSecureTrade(Container cont, TradeFlag flag, int first, int second)
: base(0x6F)
{
EnsureCapacity(17);
m_Stream.Write((byte)flag);
m_Stream.Write(cont.Serial);
m_Stream.Write(first);
m_Stream.Write(second);
}
}
@ -2822,7 +2840,7 @@ namespace Server.Network
public SupportedFeatures( NetState ns ) : base( 0xB9, ns.ExtendedSupportedFeatures ? 5 : 3 )
{
FeatureFlags flags = ExpansionInfo.CurrentExpansion.SupportedFeatures;
FeatureFlags flags = ExpansionInfo.CoreExpansion.SupportedFeatures;
flags |= m_AdditionalFlags;
@ -4142,7 +4160,7 @@ namespace Server.Network
m_Stream.Write( (int) 0 );
}
CharacterListFlags flags = ExpansionInfo.CurrentExpansion.CharacterListFlags;
CharacterListFlags flags = ExpansionInfo.CoreExpansion.CharacterListFlags;
if ( count > 6 )
flags |= (CharacterListFlags.SeventhCharacterSlot | CharacterListFlags.SixthCharacterSlot); // 7th Character Slot - TODO: Is SixthCharacterSlot Required?
@ -4237,7 +4255,7 @@ namespace Server.Network
m_Stream.WriteAsciiFixed( ci.Building, 31 );
}
CharacterListFlags flags = ExpansionInfo.CurrentExpansion.CharacterListFlags;
CharacterListFlags flags = ExpansionInfo.CoreExpansion.CharacterListFlags;
if ( count > 6 )
flags |= (CharacterListFlags.SeventhCharacterSlot | CharacterListFlags.SixthCharacterSlot); // 7th Character Slot - TODO: Is SixthCharacterSlot Required?

View file

@ -55,7 +55,7 @@ namespace Server
{
List<string> list = new List<string>();
string path = Path.Combine( Core.BaseDirectory, "Data/Assemblies_4_0.cfg" );
string path = Path.Combine( Core.BaseDirectory, "Data/Assemblies.cfg" );
if( File.Exists( path ) )
{
@ -89,15 +89,16 @@ namespace Server
AppendCompilerOption( ref sb, "/d:MONO" );
#endif
//These three defines are deprecated
if( Core.Is64Bit )
AppendCompilerOption( ref sb, "/d:x64" );
AppendCompilerOption( ref sb, "/d:Framework_2_0" );
AppendCompilerOption( ref sb, "/d:Framework_4_0" );
#if NEWTIMERS
AppendCompilerOption(ref sb, "/d:NEWTIMERS");
#endif
#if NEWPARENT
AppendCompilerOption(ref sb, "/d:NEWPARENT");
#endif
return (sb == null ? null : sb.ToString());
}

View file

@ -18,75 +18,153 @@
*
***************************************************************************/
#region References
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Accounting;
using Server.Items;
using Server.Network;
#endregion
namespace Server
{
public class SecureTrade
{
private SecureTradeInfo m_From, m_To;
private readonly SecureTradeInfo m_From;
private readonly SecureTradeInfo m_To;
private bool m_Valid;
public SecureTradeInfo From
public SecureTrade(Mobile from, Mobile to)
{
get
m_Valid = true;
m_From = new SecureTradeInfo(this, from, new SecureTradeContainer(this));
m_To = new SecureTradeInfo(this, to, new SecureTradeContainer(this));
var from6017 = (from.NetState != null && from.NetState.ContainerGridLines);
var to6017 = (to.NetState != null && to.NetState.ContainerGridLines);
var from704565 = (from.NetState != null && from.NetState.NewSecureTrading);
var to704565 = (to.NetState != null && to.NetState.NewSecureTrading);
from.Send(new MobileStatus(from, to));
from.Send(new UpdateSecureTrade(m_From.Container, false, false));
if (from6017)
{
return m_From;
from.Send(new SecureTradeEquip6017(m_To.Container, to));
}
else
{
from.Send(new SecureTradeEquip(m_To.Container, to));
}
from.Send(new UpdateSecureTrade(m_From.Container, false, false));
if (from6017)
{
from.Send(new SecureTradeEquip6017(m_From.Container, from));
}
else
{
from.Send(new SecureTradeEquip(m_From.Container, from));
}
from.Send(new DisplaySecureTrade(to, m_From.Container, m_To.Container, to.Name));
from.Send(new UpdateSecureTrade(m_From.Container, false, false));
if (from.Account != null && from704565)
{
from.Send(
new UpdateSecureTrade(m_From.Container, TradeFlag.UpdateLedger, from.Account.TotalGold, from.Account.TotalPlat));
}
to.Send(new MobileStatus(to, from));
to.Send(new UpdateSecureTrade(m_To.Container, false, false));
if (to6017)
{
to.Send(new SecureTradeEquip6017(m_From.Container, from));
}
else
{
to.Send(new SecureTradeEquip(m_From.Container, from));
}
to.Send(new UpdateSecureTrade(m_To.Container, false, false));
if (to6017)
{
to.Send(new SecureTradeEquip6017(m_To.Container, to));
}
else
{
to.Send(new SecureTradeEquip(m_To.Container, to));
}
to.Send(new DisplaySecureTrade(from, m_To.Container, m_From.Container, from.Name));
to.Send(new UpdateSecureTrade(m_To.Container, false, false));
if (to.Account != null && to704565)
{
to.Send(new UpdateSecureTrade(m_To.Container, TradeFlag.UpdateLedger, to.Account.TotalGold, to.Account.TotalPlat));
}
}
public SecureTradeInfo To
{
get
{
return m_To;
}
}
public SecureTradeInfo From { get { return m_From; } }
public SecureTradeInfo To { get { return m_To; } }
public bool Valid
{
get
{
return m_Valid;
}
}
public bool Valid { get { return m_Valid; } }
public void Cancel()
{
if ( !m_Valid )
return;
List<Item> list = m_From.Container.Items;
for ( int i = list.Count - 1; i >= 0; --i )
if (!m_Valid)
{
if ( i < list.Count )
return;
}
var list = m_From.Container.Items;
for (var i = list.Count - 1; i >= 0; --i)
{
if (i < list.Count)
{
Item item = list[i];
var item = list[i];
item.OnSecureTrade( m_From.Mobile, m_To.Mobile, m_From.Mobile, false );
if (item == m_From.VirtualCheck)
{
continue;
}
if ( !item.Deleted )
m_From.Mobile.AddToBackpack( item );
item.OnSecureTrade(m_From.Mobile, m_To.Mobile, m_From.Mobile, false);
if (!item.Deleted)
{
m_From.Mobile.AddToBackpack(item);
}
}
}
list = m_To.Container.Items;
for ( int i = list.Count - 1; i >= 0; --i )
for (var i = list.Count - 1; i >= 0; --i)
{
if ( i < list.Count )
if (i < list.Count)
{
Item item = list[i];
var item = list[i];
item.OnSecureTrade( m_To.Mobile, m_From.Mobile, m_To.Mobile, false );
if (item == m_To.VirtualCheck)
{
continue;
}
if ( !item.Deleted )
m_To.Mobile.AddToBackpack( item );
item.OnSecureTrade(m_To.Mobile, m_From.Mobile, m_To.Mobile, false);
if (!item.Deleted)
{
m_To.Mobile.AddToBackpack(item);
}
}
}
@ -95,203 +173,336 @@ namespace Server
public void Close()
{
if ( !m_Valid )
if (!m_Valid)
{
return;
}
m_From.Mobile.Send( new CloseSecureTrade( m_From.Container ) );
m_To.Mobile.Send( new CloseSecureTrade( m_To.Container ) );
m_From.Mobile.Send(new CloseSecureTrade(m_From.Container));
m_To.Mobile.Send(new CloseSecureTrade(m_To.Container));
m_Valid = false;
NetState ns = m_From.Mobile.NetState;
var ns = m_From.Mobile.NetState;
if ( ns != null )
ns.RemoveTrade( this );
if (ns != null)
{
ns.RemoveTrade(this);
}
ns = m_To.Mobile.NetState;
if ( ns != null )
ns.RemoveTrade( this );
if (ns != null)
{
ns.RemoveTrade(this);
}
Timer.DelayCall( TimeSpan.Zero, delegate{ m_From.Container.Delete(); } );
Timer.DelayCall( TimeSpan.Zero, delegate{ m_To.Container.Delete(); } );
Timer.DelayCall(m_From.Dispose);
Timer.DelayCall(m_To.Dispose);
}
public void UpdateFromCurrency()
{
UpdateCurrency(m_From, m_To);
}
public void UpdateToCurrency()
{
UpdateCurrency(m_To, m_From);
}
private static void UpdateCurrency(SecureTradeInfo left, SecureTradeInfo right)
{
if (left.Mobile.NetState != null && left.Mobile.NetState.NewSecureTrading)
{
var plat = left.Mobile.Account.TotalPlat;
var gold = left.Mobile.Account.TotalGold;
left.Mobile.Send(new UpdateSecureTrade(left.Container, TradeFlag.UpdateLedger, gold, plat));
}
if (right.Mobile.NetState != null && right.Mobile.NetState.NewSecureTrading)
{
right.Mobile.Send(new UpdateSecureTrade(right.Container, TradeFlag.UpdateGold, left.Gold, left.Plat));
}
}
public void Update()
{
if ( !m_Valid )
return;
if ( m_From.Accepted && m_To.Accepted )
if (!m_Valid)
{
List<Item> list = m_From.Container.Items;
return;
}
bool allowed = true;
if (!m_From.IsDisposed && m_From.Accepted && !m_To.IsDisposed && m_To.Accepted)
{
var list = m_From.Container.Items;
for ( int i = list.Count - 1; allowed && i >= 0; --i )
var allowed = true;
for (var i = list.Count - 1; allowed && i >= 0; --i)
{
if ( i < list.Count )
if (i < list.Count)
{
Item item = list[i];
var item = list[i];
if ( !item.AllowSecureTrade( m_From.Mobile, m_To.Mobile, m_To.Mobile, true ) )
if (item == m_From.VirtualCheck)
{
continue;
}
if (!item.AllowSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true))
{
allowed = false;
}
}
}
list = m_To.Container.Items;
for ( int i = list.Count - 1; allowed && i >= 0; --i )
for (var i = list.Count - 1; allowed && i >= 0; --i)
{
if ( i < list.Count )
if (i < list.Count)
{
Item item = list[i];
var item = list[i];
if ( !item.AllowSecureTrade( m_To.Mobile, m_From.Mobile, m_From.Mobile, true ) )
if (item == m_To.VirtualCheck)
{
continue;
}
if (!item.AllowSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true))
{
allowed = false;
}
}
}
if ( !allowed )
if (AccountGold.Enabled)
{
if (m_From.Mobile.Account != null)
{
var cur = m_From.Mobile.Account.TotalCurrency;
var off = m_From.Plat + (m_From.Gold / Math.Max(1.0, AccountGold.CurrencyThreshold));
if (off > cur)
{
allowed = false;
m_From.Mobile.SendMessage("You do not have enough currency to complete this trade.");
}
}
if (m_To.Mobile.Account != null)
{
var cur = m_To.Mobile.Account.TotalCurrency;
var off = m_To.Plat + (m_To.Gold / Math.Max(1.0, AccountGold.CurrencyThreshold));
if (off > cur)
{
allowed = false;
m_To.Mobile.SendMessage("You do not have enough currency to complete this trade.");
}
}
}
if (!allowed)
{
m_From.Accepted = false;
m_To.Accepted = false;
m_From.Mobile.Send( new UpdateSecureTrade( m_From.Container, m_From.Accepted, m_To.Accepted ) );
m_To.Mobile.Send( new UpdateSecureTrade( m_To.Container, m_To.Accepted, m_From.Accepted ) );
m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));
return;
}
if (AccountGold.Enabled && m_From.Mobile.Account != null && m_To.Mobile.Account != null)
{
HandleAccountGoldTrade();
}
list = m_From.Container.Items;
for ( int i = list.Count - 1; i >= 0; --i )
for (var i = list.Count - 1; i >= 0; --i)
{
if ( i < list.Count )
if (i < list.Count)
{
Item item = list[i];
var item = list[i];
item.OnSecureTrade( m_From.Mobile, m_To.Mobile, m_To.Mobile, true );
if (item == m_From.VirtualCheck)
{
continue;
}
if ( !item.Deleted )
m_To.Mobile.AddToBackpack( item );
item.OnSecureTrade(m_From.Mobile, m_To.Mobile, m_To.Mobile, true);
if (!item.Deleted)
{
m_To.Mobile.AddToBackpack(item);
}
}
}
list = m_To.Container.Items;
for ( int i = list.Count - 1; i >= 0; --i )
for (var i = list.Count - 1; i >= 0; --i)
{
if ( i < list.Count )
if (i < list.Count)
{
Item item = list[i];
var item = list[i];
item.OnSecureTrade( m_To.Mobile, m_From.Mobile, m_From.Mobile, true );
if (item == m_To.VirtualCheck)
{
continue;
}
if ( !item.Deleted )
m_From.Mobile.AddToBackpack( item );
item.OnSecureTrade(m_To.Mobile, m_From.Mobile, m_From.Mobile, true);
if (!item.Deleted)
{
m_From.Mobile.AddToBackpack(item);
}
}
}
Close();
}
else
else if (!m_From.IsDisposed && !m_To.IsDisposed)
{
m_From.Mobile.Send( new UpdateSecureTrade( m_From.Container, m_From.Accepted, m_To.Accepted ) );
m_To.Mobile.Send( new UpdateSecureTrade( m_To.Container, m_To.Accepted, m_From.Accepted ) );
m_From.Mobile.Send(new UpdateSecureTrade(m_From.Container, m_From.Accepted, m_To.Accepted));
m_To.Mobile.Send(new UpdateSecureTrade(m_To.Container, m_To.Accepted, m_From.Accepted));
}
}
public SecureTrade( Mobile from, Mobile to )
private void HandleAccountGoldTrade()
{
m_Valid = true;
int fromPlatSend = 0, fromGoldSend = 0, fromPlatRecv = 0, fromGoldRecv = 0;
int toPlatSend = 0, toGoldSend = 0, toPlatRecv = 0, toGoldRecv = 0;
m_From = new SecureTradeInfo( this, from, new SecureTradeContainer( this ) );
m_To = new SecureTradeInfo( this, to, new SecureTradeContainer( this ) );
if (m_From.Plat > 0 & m_From.Mobile.Account.WithdrawPlat(m_From.Plat))
{
fromPlatSend = m_From.Plat;
bool from6017 = ( from.NetState == null ? false : from.NetState.ContainerGridLines );
bool to6017 = ( to.NetState == null ? false : to.NetState.ContainerGridLines );
if (m_To.Mobile.Account.DepositPlat(m_From.Plat))
{
toPlatRecv = fromPlatSend;
}
}
from.Send( new MobileStatus( from, to ) );
from.Send( new UpdateSecureTrade( m_From.Container, false, false ) );
if ( from6017 )
from.Send( new SecureTradeEquip6017( m_To.Container, to ) );
else
from.Send( new SecureTradeEquip( m_To.Container, to ) );
from.Send( new UpdateSecureTrade( m_From.Container, false, false ) );
if ( from6017 )
from.Send( new SecureTradeEquip6017( m_From.Container, from ) );
else
from.Send( new SecureTradeEquip( m_From.Container, from ) );
from.Send( new DisplaySecureTrade( to, m_From.Container, m_To.Container, to.Name ) );
from.Send( new UpdateSecureTrade( m_From.Container, false, false ) );
if (m_From.Gold > 0 & m_From.Mobile.Account.WithdrawGold(m_From.Gold))
{
fromGoldSend = m_From.Gold;
to.Send( new MobileStatus( to, from ) );
to.Send( new UpdateSecureTrade( m_To.Container, false, false ) );
if ( to6017 )
to.Send( new SecureTradeEquip6017( m_From.Container, from ) );
else
to.Send( new SecureTradeEquip( m_From.Container, from ) );
to.Send( new UpdateSecureTrade( m_To.Container, false, false ) );
if ( to6017 )
to.Send( new SecureTradeEquip6017( m_To.Container, to ) );
else
to.Send( new SecureTradeEquip( m_To.Container, to ) );
to.Send( new DisplaySecureTrade( from, m_To.Container, m_From.Container, from.Name ) );
to.Send( new UpdateSecureTrade( m_To.Container, false, false ) );
if (m_To.Mobile.Account.DepositGold(m_From.Gold))
{
toGoldRecv = fromGoldSend;
}
}
if (m_To.Plat > 0 & m_To.Mobile.Account.WithdrawPlat(m_To.Plat))
{
toPlatSend = m_To.Plat;
if (m_From.Mobile.Account.DepositPlat(m_To.Plat))
{
fromPlatRecv = toPlatSend;
}
}
if (m_To.Gold > 0 & m_To.Mobile.Account.WithdrawGold(m_To.Gold))
{
toGoldSend = m_To.Gold;
if (m_From.Mobile.Account.DepositGold(m_To.Gold))
{
fromGoldRecv = toGoldSend;
}
}
HandleAccountGoldTrade(m_From.Mobile, m_To.Mobile, fromPlatSend, fromGoldSend, fromPlatRecv, fromGoldRecv);
HandleAccountGoldTrade(m_To.Mobile, m_From.Mobile, toPlatSend, toGoldSend, toPlatRecv, toGoldRecv);
}
private static void HandleAccountGoldTrade(
Mobile left,
Mobile right,
int platSend,
int goldSend,
int platRecv,
int goldRecv)
{
if (platSend > 0 || goldSend > 0)
{
if (platSend > 0 && goldSend > 0)
{
left.SendMessage("You traded {0:#,0} platinum and {1:#,0} gold to {2}.", platSend, goldSend, right.RawName);
}
else if (platSend > 0)
{
left.SendMessage("You traded {0:#,0} platinum to {1}.", platSend, right.RawName);
}
else if (goldSend > 0)
{
left.SendMessage("You traded {0:#,0} gold to {1}.", goldSend, right.RawName);
}
}
if (platRecv > 0 || goldRecv > 0)
{
if (platRecv > 0 && goldRecv > 0)
{
left.SendMessage("You received {0:#,0} platinum and {1:#,0} gold from {2}.", platRecv, goldRecv, right.RawName);
}
else if (platRecv > 0)
{
left.SendMessage("You received {0:#,0} platinum from {1}.", platRecv, right.RawName);
}
else if (goldRecv > 0)
{
left.SendMessage("You received {0:#,0} gold from {1}.", goldRecv, right.RawName);
}
}
}
}
public class SecureTradeInfo
public class SecureTradeInfo : IDisposable
{
private SecureTrade m_Owner;
private Mobile m_Mobile;
private SecureTradeContainer m_Container;
private bool m_Accepted;
public SecureTrade Owner { get; private set; }
public Mobile Mobile { get; private set; }
public SecureTradeContainer Container { get; private set; }
public VirtualCheck VirtualCheck { get; private set; }
public SecureTradeInfo( SecureTrade owner, Mobile m, SecureTradeContainer c )
public int Gold { get { return VirtualCheck.Gold; } set { VirtualCheck.Gold = value; } }
public int Plat { get { return VirtualCheck.Plat; } set { VirtualCheck.Plat = value; } }
public bool Accepted { get; set; }
public bool IsDisposed { get; private set; }
public SecureTradeInfo(SecureTrade owner, Mobile m, SecureTradeContainer c)
{
m_Owner = owner;
m_Mobile = m;
m_Container = c;
Owner = owner;
Mobile = m;
Container = c;
m_Mobile.AddItem( m_Container );
Mobile.AddItem(Container);
VirtualCheck = new VirtualCheck(0, 0);
Container.DropItem(VirtualCheck);
}
public SecureTrade Owner
public void Dispose()
{
get
{
return m_Owner;
}
}
VirtualCheck.Delete();
VirtualCheck = null;
public Mobile Mobile
{
get
{
return m_Mobile;
}
}
Container.Delete();
Container = null;
public SecureTradeContainer Container
{
get
{
return m_Container;
}
}
Mobile = null;
Owner = null;
public bool Accepted
{
get
{
return m_Accepted;
}
set
{
m_Accepted = value;
}
IsDisposed = true;
}
}
}

View file

@ -86,6 +86,8 @@
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
@ -145,6 +147,7 @@
<Compile Include="Items\Container.cs" />
<Compile Include="Items\Containers.cs" />
<Compile Include="Items\SecureTradeContainer.cs" />
<Compile Include="Items\VirtualCheck.cs" />
<Compile Include="Items\VirtualHair.cs" />
<Compile Include="KeywordList.cs" />
<Compile Include="Main.cs" />

View file

@ -22,6 +22,8 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Server.Network;
namespace Server
@ -689,7 +691,7 @@ namespace Server
}
[PropertyObject]
public class Skills : IEnumerable
public class Skills : IEnumerable<Skill>
{
private Mobile m_Owner;
private Skill[] m_Skills;
@ -1108,9 +1110,14 @@ namespace Server
ns.Send( new SkillChange( skill ) );
}
public IEnumerator GetEnumerator()
public IEnumerator<Skill> GetEnumerator()
{
return m_Skills.GetEnumerator();
return m_Skills.Where(s => s != null).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return m_Skills.Where(s => s != null).GetEnumerator();
}
}
}

View file

@ -521,6 +521,22 @@ namespace Server
#endregion
#region Get[Something]
public static double GetXMLDouble(string doubleString, double defaultValue)
{
try
{
return XmlConvert.ToDouble(doubleString);
}
catch
{
double val;
if (double.TryParse(doubleString, out val))
return val;
return defaultValue;
}
}
public static int GetXMLInt32( string intString, int defaultValue )
{
try