RunUO 2.4 will be the latest release supporting the 2.0 .NET Framework.
Framework_4_0 preprocessors have been removed. ScriptCompiler will set Framework_4_0 as legacy.
This commit is contained in:
parent
951f8b7d01
commit
e67faba4d8
20 changed files with 43 additions and 623 deletions
|
|
@ -668,11 +668,8 @@ namespace Server.Accounting
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
Enum.TryParse( Utility.GetText( node["accessLevel"], "Player" ), true, out m_AccessLevel );
|
Enum.TryParse( Utility.GetText( node["accessLevel"], "Player" ), true, out m_AccessLevel );
|
||||||
#else
|
|
||||||
m_AccessLevel = (AccessLevel)Enum.Parse( typeof( AccessLevel ), Utility.GetText( node["accessLevel"], "Player" ), true );
|
|
||||||
#endif
|
|
||||||
m_Flags = Utility.GetXMLInt32( Utility.GetText( node["flags"], "0" ), 0 );
|
m_Flags = Utility.GetXMLInt32( Utility.GetText( node["flags"], "0" ), 0 );
|
||||||
m_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.UtcNow );
|
m_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.UtcNow );
|
||||||
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.UtcNow );
|
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.UtcNow );
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ namespace Server.Commands
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SkillName skill;
|
SkillName skill;
|
||||||
#if Framework_4_0
|
|
||||||
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
|
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
|
||||||
{
|
{
|
||||||
arg.Mobile.Target = new SkillTarget( skill, arg.GetDouble( 1 ) );
|
arg.Mobile.Target = new SkillTarget( skill, arg.GetDouble( 1 ) );
|
||||||
|
|
@ -34,18 +33,6 @@ namespace Server.Commands
|
||||||
{
|
{
|
||||||
arg.Mobile.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
arg.Mobile.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
try
|
|
||||||
{
|
|
||||||
skill = (SkillName)Enum.Parse( typeof( SkillName ), arg.GetString( 0 ), true );
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
arg.Mobile.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
arg.Mobile.Target = new SkillTarget( skill, arg.GetDouble( 1 ) );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +61,6 @@ namespace Server.Commands
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SkillName skill;
|
SkillName skill;
|
||||||
#if Framework_4_0
|
|
||||||
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
|
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
|
||||||
{
|
{
|
||||||
arg.Mobile.Target = new SkillTarget( skill );
|
arg.Mobile.Target = new SkillTarget( skill );
|
||||||
|
|
@ -83,19 +69,6 @@ namespace Server.Commands
|
||||||
{
|
{
|
||||||
arg.Mobile.SendMessage( "You have specified an invalid skill to get." );
|
arg.Mobile.SendMessage( "You have specified an invalid skill to get." );
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
try
|
|
||||||
{
|
|
||||||
skill = (SkillName)Enum.Parse( typeof( SkillName ), arg.GetString( 0 ), true );
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
arg.Mobile.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
arg.Mobile.Target = new SkillTarget( skill );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,8 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
using Server;
|
using Server;
|
||||||
using Server.Items;
|
using Server.Items;
|
||||||
using Server.Targeting;
|
using Server.Targeting;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
using Server.Regions;
|
using Server.Regions;
|
||||||
using Server.Targeting;
|
using Server.Targeting;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
@ -5767,19 +5765,11 @@ namespace Server.Mobiles
|
||||||
// added array for wild creatures in house regions to be removed
|
// added array for wild creatures in house regions to be removed
|
||||||
List<BaseCreature> toRemove = new List<BaseCreature>();
|
List<BaseCreature> toRemove = new List<BaseCreature>();
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
Parallel.ForEach(World.Mobiles.Values, m => {
|
Parallel.ForEach(World.Mobiles.Values, m => {
|
||||||
#else
|
|
||||||
foreach ( Mobile m in World.Mobiles.Values ) {
|
|
||||||
#endif
|
|
||||||
if ( m is BaseMount && ((BaseMount)m).Rider != null )
|
if ( m is BaseMount && ((BaseMount)m).Rider != null )
|
||||||
{
|
{
|
||||||
((BaseCreature)m).OwnerAbandonTime = DateTime.MinValue;
|
((BaseCreature)m).OwnerAbandonTime = DateTime.MinValue;
|
||||||
#if Framework_4_0
|
|
||||||
return;
|
return;
|
||||||
#else
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m is BaseCreature )
|
if ( m is BaseCreature )
|
||||||
|
|
@ -5838,10 +5828,7 @@ namespace Server.Mobiles
|
||||||
c.RemoveStep = 0;
|
c.RemoveStep = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
#if Framework_4_0
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
foreach ( BaseCreature c in toRelease )
|
foreach ( BaseCreature c in toRelease )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -121,29 +121,13 @@ namespace Server.Misc
|
||||||
private static void ChangeSkill( Mobile from, string name, double value )
|
private static void ChangeSkill( Mobile from, string name, double value )
|
||||||
{
|
{
|
||||||
SkillName index;
|
SkillName index;
|
||||||
#if Framework_4_0
|
|
||||||
if( !Enum.TryParse( name, true, out index ) || (!Core.SE && (int)index > 51) || (!Core.AOS && (int)index > 48) )
|
if( !Enum.TryParse( name, true, out index ) || (!Core.SE && (int)index > 51) || (!Core.AOS && (int)index > 48) )
|
||||||
{
|
{
|
||||||
from.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
from.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
try
|
|
||||||
{
|
|
||||||
index = (SkillName)Enum.Parse( typeof( SkillName ), name, true );
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
from.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ( !Core.SE && (int)index > 51 ) || ( !Core.AOS && (int)index > 48 ) )
|
|
||||||
{
|
|
||||||
from.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Skill skill = from.Skills[index];
|
Skill skill = from.Skills[index];
|
||||||
|
|
||||||
if ( skill != null )
|
if ( skill != null )
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Server
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string[] split = line.Split( '\t' );
|
string[] split = line.Split( '\t' );
|
||||||
#if Framework_4_0
|
|
||||||
BodyType type;
|
BodyType type;
|
||||||
int bodyID;
|
int bodyID;
|
||||||
|
|
||||||
|
|
@ -68,21 +68,6 @@ namespace Server
|
||||||
Console.WriteLine( "Warning: Invalid bodyTable entry:" );
|
Console.WriteLine( "Warning: Invalid bodyTable entry:" );
|
||||||
Console.WriteLine( line );
|
Console.WriteLine( line );
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int bodyID = int.Parse( split[0] );
|
|
||||||
BodyType type = (BodyType)Enum.Parse( typeof( BodyType ), split[1], true );
|
|
||||||
|
|
||||||
if ( bodyID >= 0 && bodyID < m_Types.Length )
|
|
||||||
m_Types[bodyID] = type;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Console.WriteLine( "Warning: Invalid bodyTable entry:" );
|
|
||||||
Console.WriteLine( line );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
||||||
namespace Server
|
namespace Server
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,8 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
using Server.Items;
|
using Server.Items;
|
||||||
using Server.ContextMenus;
|
using Server.ContextMenus;
|
||||||
|
|
@ -3305,7 +3303,6 @@ namespace Server
|
||||||
|
|
||||||
public static void ProcessDeltaQueue()
|
public static void ProcessDeltaQueue()
|
||||||
{
|
{
|
||||||
#if Framework_4_0
|
|
||||||
_processing = true;
|
_processing = true;
|
||||||
|
|
||||||
if (m_DeltaQueue.Count >= 512) {
|
if (m_DeltaQueue.Count >= 512) {
|
||||||
|
|
@ -3317,17 +3314,6 @@ namespace Server
|
||||||
m_DeltaQueue.Clear();
|
m_DeltaQueue.Clear();
|
||||||
|
|
||||||
_processing = false;
|
_processing = false;
|
||||||
#else
|
|
||||||
int count = m_DeltaQueue.Count;
|
|
||||||
|
|
||||||
for (int i = 0; i < m_DeltaQueue.Count; ++i) {
|
|
||||||
m_DeltaQueue[i].ProcessDelta();
|
|
||||||
|
|
||||||
if (i >= count)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
m_DeltaQueue.Clear();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnDelete()
|
public virtual void OnDelete()
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,7 @@ using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
|
|
||||||
using Server;
|
using Server;
|
||||||
using Server.Accounting;
|
using Server.Accounting;
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
|
|
@ -157,11 +154,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
public static readonly bool Is64Bit = Environment.Is64BitProcess;
|
public static readonly bool Is64Bit = Environment.Is64BitProcess;
|
||||||
#else
|
|
||||||
public static readonly bool Is64Bit = (IntPtr.Size == 8); //Returns the size for the current /process/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private static bool m_MultiProcessor;
|
private static bool m_MultiProcessor;
|
||||||
private static int m_ProcessorCount;
|
private static int m_ProcessorCount;
|
||||||
|
|
@ -725,17 +718,10 @@ namespace Server
|
||||||
if( a == null )
|
if( a == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
Parallel.ForEach(a.GetTypes(), t =>
|
Parallel.ForEach(a.GetTypes(), t =>
|
||||||
{
|
{
|
||||||
VerifyType(t);
|
VerifyType(t);
|
||||||
});
|
});
|
||||||
#else
|
|
||||||
foreach (Type t in a.GetTypes())
|
|
||||||
{
|
|
||||||
VerifyType(t);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,8 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
using Server;
|
using Server;
|
||||||
using Server.Accounting;
|
using Server.Accounting;
|
||||||
using Server.Commands;
|
using Server.Commands;
|
||||||
|
|
@ -10061,18 +10059,7 @@ namespace Server
|
||||||
sendFacialHair = true;
|
sendFacialHair = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
Packet[][] cache = new Packet[2][] { new Packet[8], new Packet[8] };
|
Packet[][] cache = new Packet[2][] { new Packet[8], new Packet[8] };
|
||||||
#else
|
|
||||||
Packet[][] cache = m_MovingPacketCache;
|
|
||||||
|
|
||||||
/*if( sendMoving || sendNonlocalMoving || sendHealthbarPoison || sendHealthbarYellow )
|
|
||||||
{
|
|
||||||
for( int i = 0; i < cache.Length; ++i )
|
|
||||||
for( int j = 0; j < cache[i].Length; ++j )
|
|
||||||
Packet.Release( ref cache[i][j] );
|
|
||||||
}*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NetState ourState = m.m_NetState;
|
NetState ourState = m.m_NetState;
|
||||||
|
|
||||||
|
|
@ -10322,7 +10309,6 @@ namespace Server
|
||||||
|
|
||||||
public static void ProcessDeltaQueue()
|
public static void ProcessDeltaQueue()
|
||||||
{
|
{
|
||||||
#if Framework_4_0
|
|
||||||
_processing = true;
|
_processing = true;
|
||||||
|
|
||||||
if (m_DeltaQueue.Count >= 512) {
|
if (m_DeltaQueue.Count >= 512) {
|
||||||
|
|
@ -10335,13 +10321,6 @@ namespace Server
|
||||||
_processing = false;
|
_processing = false;
|
||||||
|
|
||||||
while (m_DeltaQueueR.Count > 0) m_DeltaQueueR.Dequeue().ProcessDelta();
|
while (m_DeltaQueueR.Count > 0) m_DeltaQueueR.Dequeue().ProcessDelta();
|
||||||
#else
|
|
||||||
int count = m_DeltaQueue.Count;
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
while (m_DeltaQueue.Count > 0 && index++ < count)
|
|
||||||
m_DeltaQueue.Dequeue().ProcessDelta();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
|
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,7 @@ using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
using Server;
|
using Server;
|
||||||
using Server.Accounting;
|
using Server.Accounting;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
@ -1051,11 +1049,9 @@ namespace Server.Network {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FlushAll() {
|
public static void FlushAll() {
|
||||||
#if Framework_4_0
|
|
||||||
if (m_Instances.Count >= 1024)
|
if (m_Instances.Count >= 1024)
|
||||||
Parallel.ForEach(m_Instances, ns => ns.Flush());
|
Parallel.ForEach(m_Instances, ns => ns.Flush());
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
for ( int i = 0; i < m_Instances.Count; ++i ) {
|
for ( int i = 0; i < m_Instances.Count; ++i ) {
|
||||||
m_Instances[i].Flush();
|
m_Instances[i].Flush();
|
||||||
}
|
}
|
||||||
|
|
@ -1174,11 +1170,10 @@ namespace Server.Network {
|
||||||
public static void CheckAllAlive() {
|
public static void CheckAllAlive() {
|
||||||
try {
|
try {
|
||||||
long curTicks = Core.TickCount;
|
long curTicks = Core.TickCount;
|
||||||
#if Framework_4_0
|
|
||||||
if (m_Instances.Count >= 1024)
|
if (m_Instances.Count >= 1024)
|
||||||
Parallel.ForEach(m_Instances, ns => ns.CheckAlive(curTicks));
|
Parallel.ForEach(m_Instances, ns => ns.CheckAlive(curTicks));
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
for ( int i = 0; i < m_Instances.Count; ++i ) {
|
for ( int i = 0; i < m_Instances.Count; ++i ) {
|
||||||
m_Instances[i].CheckAlive(curTicks);
|
m_Instances[i].CheckAlive(curTicks);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
#endif
|
|
||||||
using Server.Accounting;
|
using Server.Accounting;
|
||||||
using Server.Targeting;
|
using Server.Targeting;
|
||||||
using Server.Items;
|
using Server.Items;
|
||||||
|
|
@ -3357,13 +3355,8 @@ namespace Server.Network
|
||||||
return new MobileIncomingOld(beholder, beheld);
|
return new MobileIncomingOld(beholder, beheld);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
||||||
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
||||||
#else
|
|
||||||
private static int[] m_DupedLayers = new int[256];
|
|
||||||
private static int m_Version;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public Mobile m_Beheld;
|
public Mobile m_Beheld;
|
||||||
|
|
||||||
|
|
@ -3371,12 +3364,8 @@ namespace Server.Network
|
||||||
{
|
{
|
||||||
m_Beheld = beheld;
|
m_Beheld = beheld;
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
int m_Version = ++(m_VersionTL.Value);
|
int m_Version = ++(m_VersionTL.Value);
|
||||||
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
||||||
#else
|
|
||||||
++m_Version;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
List<Item> eq = beheld.Items;
|
List<Item> eq = beheld.Items;
|
||||||
int count = eq.Count;
|
int count = eq.Count;
|
||||||
|
|
@ -3474,13 +3463,8 @@ namespace Server.Network
|
||||||
|
|
||||||
public sealed class MobileIncomingSA : Packet
|
public sealed class MobileIncomingSA : Packet
|
||||||
{
|
{
|
||||||
#if Framework_4_0
|
|
||||||
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
||||||
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
||||||
#else
|
|
||||||
private static int[] m_DupedLayers = new int[256];
|
|
||||||
private static int m_Version;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public Mobile m_Beheld;
|
public Mobile m_Beheld;
|
||||||
|
|
||||||
|
|
@ -3488,12 +3472,8 @@ namespace Server.Network
|
||||||
{
|
{
|
||||||
m_Beheld = beheld;
|
m_Beheld = beheld;
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
int m_Version = ++(m_VersionTL.Value);
|
int m_Version = ++(m_VersionTL.Value);
|
||||||
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
||||||
#else
|
|
||||||
++m_Version;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
List<Item> eq = beheld.Items;
|
List<Item> eq = beheld.Items;
|
||||||
int count = eq.Count;
|
int count = eq.Count;
|
||||||
|
|
@ -3609,13 +3589,8 @@ namespace Server.Network
|
||||||
// Pre-7.0.0.0 Mobile Incoming
|
// Pre-7.0.0.0 Mobile Incoming
|
||||||
public sealed class MobileIncomingOld : Packet
|
public sealed class MobileIncomingOld : Packet
|
||||||
{
|
{
|
||||||
#if Framework_4_0
|
|
||||||
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
||||||
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
||||||
#else
|
|
||||||
private static int[] m_DupedLayers = new int[256];
|
|
||||||
private static int m_Version;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public Mobile m_Beheld;
|
public Mobile m_Beheld;
|
||||||
|
|
||||||
|
|
@ -3623,12 +3598,8 @@ namespace Server.Network
|
||||||
{
|
{
|
||||||
m_Beheld = beheld;
|
m_Beheld = beheld;
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
int m_Version = ++(m_VersionTL.Value);
|
int m_Version = ++(m_VersionTL.Value);
|
||||||
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
||||||
#else
|
|
||||||
++m_Version;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
List<Item> eq = beheld.Items;
|
List<Item> eq = beheld.Items;
|
||||||
int count = eq.Count;
|
int count = eq.Count;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -158,8 +157,6 @@ namespace Server
|
||||||
return commitTask;
|
return commitTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Task SaveMobiles()
|
private Task SaveMobiles()
|
||||||
{
|
{
|
||||||
//Start the blocking consumer; this runs in background.
|
//Start the blocking consumer; this runs in background.
|
||||||
|
|
@ -313,5 +310,4 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
@ -31,17 +31,10 @@ namespace Server
|
||||||
{
|
{
|
||||||
int processorCount = Core.ProcessorCount;
|
int processorCount = Core.ProcessorCount;
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
if (processorCount > 2)
|
if (processorCount > 2)
|
||||||
{
|
{
|
||||||
return new DualSaveStrategy(); // return new DynamicSaveStrategy();
|
return new DualSaveStrategy(); // return new DynamicSaveStrategy(); (4.0 or return new ParallelSaveStrategy(processorCount); (2.0)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (processorCount > 16)
|
|
||||||
{
|
|
||||||
return new DualSaveStrategy(); // return new ParallelSaveStrategy(processorCount);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new DualSaveStrategy();
|
return new DualSaveStrategy();
|
||||||
|
|
|
||||||
|
|
@ -1139,7 +1139,7 @@ namespace Server
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Type type = typeof(T);
|
Type type = typeof(T);
|
||||||
#if Framework_4_0
|
|
||||||
T tempVal;
|
T tempVal;
|
||||||
|
|
||||||
if( type.IsEnum && Enum.TryParse( s, true, out tempVal ) )
|
if( type.IsEnum && Enum.TryParse( s, true, out tempVal ) )
|
||||||
|
|
@ -1152,19 +1152,6 @@ namespace Server
|
||||||
Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", type, attribute, xml.Name );
|
Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", type, attribute, xml.Name );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
try
|
|
||||||
{
|
|
||||||
value = (T)Enum.Parse(type, s, true);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", type, attribute, xml.Name );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ReadMap( XmlElement xml, string attribute, ref Map value )
|
public static bool ReadMap( XmlElement xml, string attribute, ref Map value )
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,7 @@ namespace Server
|
||||||
{
|
{
|
||||||
List<string> list = new List<string>();
|
List<string> list = new List<string>();
|
||||||
|
|
||||||
#if Framework_4_0
|
|
||||||
string path = Path.Combine( Core.BaseDirectory, "Data/Assemblies_4_0.cfg" );
|
string path = Path.Combine( Core.BaseDirectory, "Data/Assemblies_4_0.cfg" );
|
||||||
#else
|
|
||||||
string path = Path.Combine( Core.BaseDirectory, "Data/Assemblies.cfg" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( File.Exists( path ) )
|
if( File.Exists( path ) )
|
||||||
{
|
{
|
||||||
|
|
@ -93,14 +89,13 @@ namespace Server
|
||||||
AppendCompilerOption( ref sb, "/d:MONO" );
|
AppendCompilerOption( ref sb, "/d:MONO" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//These two defines are legacy, ie, depreciated.
|
//These three defines are legacy, ie, depreciated.
|
||||||
if( Core.Is64Bit )
|
if( Core.Is64Bit )
|
||||||
AppendCompilerOption( ref sb, "/d:x64" );
|
AppendCompilerOption( ref sb, "/d:x64" );
|
||||||
|
|
||||||
AppendCompilerOption( ref sb, "/d:Framework_2_0" );
|
AppendCompilerOption( ref sb, "/d:Framework_2_0" );
|
||||||
#if Framework_4_0
|
|
||||||
AppendCompilerOption( ref sb, "/d:Framework_4_0" );
|
AppendCompilerOption( ref sb, "/d:Framework_4_0" );
|
||||||
#endif
|
|
||||||
|
|
||||||
return (sb == null ? null : sb.ToString());
|
return (sb == null ? null : sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,7 @@ namespace Server
|
||||||
|
|
||||||
public abstract string ReadString();
|
public abstract string ReadString();
|
||||||
public abstract DateTime ReadDateTime();
|
public abstract DateTime ReadDateTime();
|
||||||
#if Framework_4_0
|
|
||||||
public abstract DateTimeOffset ReadDateTimeOffset();
|
public abstract DateTimeOffset ReadDateTimeOffset();
|
||||||
#endif
|
|
||||||
public abstract TimeSpan ReadTimeSpan();
|
public abstract TimeSpan ReadTimeSpan();
|
||||||
public abstract DateTime ReadDeltaTime();
|
public abstract DateTime ReadDeltaTime();
|
||||||
public abstract decimal ReadDecimal();
|
public abstract decimal ReadDecimal();
|
||||||
|
|
@ -85,7 +83,7 @@ namespace Server
|
||||||
|
|
||||||
public abstract List<BaseGuild> ReadStrongGuildList();
|
public abstract List<BaseGuild> ReadStrongGuildList();
|
||||||
public abstract List<T> ReadStrongGuildList<T>() where T : BaseGuild;
|
public abstract List<T> ReadStrongGuildList<T>() where T : BaseGuild;
|
||||||
#if Framework_4_0
|
|
||||||
public abstract HashSet<Item> ReadItemSet();
|
public abstract HashSet<Item> ReadItemSet();
|
||||||
public abstract HashSet<T> ReadItemSet<T>() where T: Item;
|
public abstract HashSet<T> ReadItemSet<T>() where T: Item;
|
||||||
|
|
||||||
|
|
@ -94,7 +92,7 @@ namespace Server
|
||||||
|
|
||||||
public abstract HashSet<BaseGuild> ReadGuildSet();
|
public abstract HashSet<BaseGuild> ReadGuildSet();
|
||||||
public abstract HashSet<T> ReadGuildSet<T>() where T : BaseGuild;
|
public abstract HashSet<T> ReadGuildSet<T>() where T : BaseGuild;
|
||||||
#endif
|
|
||||||
public abstract Race ReadRace();
|
public abstract Race ReadRace();
|
||||||
|
|
||||||
public abstract bool End();
|
public abstract bool End();
|
||||||
|
|
@ -110,9 +108,7 @@ namespace Server
|
||||||
|
|
||||||
public abstract void Write( string value );
|
public abstract void Write( string value );
|
||||||
public abstract void Write( DateTime value );
|
public abstract void Write( DateTime value );
|
||||||
#if Framework_4_0
|
|
||||||
public abstract void Write( DateTimeOffset value );
|
public abstract void Write( DateTimeOffset value );
|
||||||
#endif
|
|
||||||
public abstract void Write( TimeSpan value );
|
public abstract void Write( TimeSpan value );
|
||||||
public abstract void Write( decimal value );
|
public abstract void Write( decimal value );
|
||||||
public abstract void Write( long value );
|
public abstract void Write( long value );
|
||||||
|
|
@ -162,37 +158,37 @@ namespace Server
|
||||||
|
|
||||||
public abstract void WriteItemList<T>( List<T> list ) where T : Item;
|
public abstract void WriteItemList<T>( List<T> list ) where T : Item;
|
||||||
public abstract void WriteItemList<T>( List<T> list, bool tidy ) where T : Item;
|
public abstract void WriteItemList<T>( List<T> list, bool tidy ) where T : Item;
|
||||||
#if Framework_4_0
|
|
||||||
public abstract void Write( HashSet<Item> list );
|
public abstract void Write( HashSet<Item> list );
|
||||||
public abstract void Write( HashSet<Item> list, bool tidy );
|
public abstract void Write( HashSet<Item> list, bool tidy );
|
||||||
|
|
||||||
public abstract void WriteItemSet<T>( HashSet<T> set ) where T : Item;
|
public abstract void WriteItemSet<T>( HashSet<T> set ) where T : Item;
|
||||||
public abstract void WriteItemSet<T>( HashSet<T> set, bool tidy ) where T : Item;
|
public abstract void WriteItemSet<T>( HashSet<T> set, bool tidy ) where T : Item;
|
||||||
#endif
|
|
||||||
public abstract void Write( List<Mobile> list );
|
public abstract void Write( List<Mobile> list );
|
||||||
public abstract void Write( List<Mobile> list, bool tidy );
|
public abstract void Write( List<Mobile> list, bool tidy );
|
||||||
|
|
||||||
public abstract void WriteMobileList<T>( List<T> list ) where T : Mobile;
|
public abstract void WriteMobileList<T>( List<T> list ) where T : Mobile;
|
||||||
public abstract void WriteMobileList<T>( List<T> list, bool tidy ) where T : Mobile;
|
public abstract void WriteMobileList<T>( List<T> list, bool tidy ) where T : Mobile;
|
||||||
#if Framework_4_0
|
|
||||||
public abstract void Write( HashSet<Mobile> list );
|
public abstract void Write( HashSet<Mobile> list );
|
||||||
public abstract void Write( HashSet<Mobile> list, bool tidy );
|
public abstract void Write( HashSet<Mobile> list, bool tidy );
|
||||||
|
|
||||||
public abstract void WriteMobileSet<T>( HashSet<T> set ) where T : Mobile;
|
public abstract void WriteMobileSet<T>( HashSet<T> set ) where T : Mobile;
|
||||||
public abstract void WriteMobileSet<T>( HashSet<T> set, bool tidy ) where T : Mobile;
|
public abstract void WriteMobileSet<T>( HashSet<T> set, bool tidy ) where T : Mobile;
|
||||||
#endif
|
|
||||||
public abstract void Write( List<BaseGuild> list );
|
public abstract void Write( List<BaseGuild> list );
|
||||||
public abstract void Write( List<BaseGuild> list, bool tidy );
|
public abstract void Write( List<BaseGuild> list, bool tidy );
|
||||||
|
|
||||||
public abstract void WriteGuildList<T>( List<T> list ) where T : BaseGuild;
|
public abstract void WriteGuildList<T>( List<T> list ) where T : BaseGuild;
|
||||||
public abstract void WriteGuildList<T>( List<T> list, bool tidy ) where T : BaseGuild;
|
public abstract void WriteGuildList<T>( List<T> list, bool tidy ) where T : BaseGuild;
|
||||||
#if Framework_4_0
|
|
||||||
public abstract void Write( HashSet<BaseGuild> list );
|
public abstract void Write( HashSet<BaseGuild> list );
|
||||||
public abstract void Write( HashSet<BaseGuild> list, bool tidy );
|
public abstract void Write( HashSet<BaseGuild> list, bool tidy );
|
||||||
|
|
||||||
public abstract void WriteGuildSet<T>( HashSet<T> set ) where T : BaseGuild;
|
public abstract void WriteGuildSet<T>( HashSet<T> set ) where T : BaseGuild;
|
||||||
public abstract void WriteGuildSet<T>( HashSet<T> set, bool tidy ) where T : BaseGuild;
|
public abstract void WriteGuildSet<T>( HashSet<T> set, bool tidy ) where T : BaseGuild;
|
||||||
#endif
|
|
||||||
// Compiler won't notice their 'where' to differentiate the generic methods.
|
// Compiler won't notice their 'where' to differentiate the generic methods.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -369,13 +365,13 @@ namespace Server
|
||||||
{
|
{
|
||||||
Write( value.Ticks );
|
Write( value.Ticks );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( DateTimeOffset value )
|
public override void Write( DateTimeOffset value )
|
||||||
{
|
{
|
||||||
Write( value.Ticks );
|
Write( value.Ticks );
|
||||||
Write( value.Offset.Ticks );
|
Write( value.Offset.Ticks );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override void WriteDeltaTime( DateTime value )
|
public override void WriteDeltaTime( DateTime value )
|
||||||
{
|
{
|
||||||
long ticks = value.Ticks;
|
long ticks = value.Ticks;
|
||||||
|
|
@ -736,7 +732,7 @@ namespace Server
|
||||||
for( int i = 0; i < list.Count; ++i )
|
for( int i = 0; i < list.Count; ++i )
|
||||||
Write( list[i] );
|
Write( list[i] );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( HashSet<Item> set )
|
public override void Write( HashSet<Item> set )
|
||||||
{
|
{
|
||||||
Write( set, false );
|
Write( set, false );
|
||||||
|
|
@ -774,7 +770,7 @@ namespace Server
|
||||||
Write( item );
|
Write( item );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override void Write( List<Mobile> list )
|
public override void Write( List<Mobile> list )
|
||||||
{
|
{
|
||||||
Write( list, false );
|
Write( list, false );
|
||||||
|
|
@ -820,7 +816,7 @@ namespace Server
|
||||||
for( int i = 0; i < list.Count; ++i )
|
for( int i = 0; i < list.Count; ++i )
|
||||||
Write( list[i] );
|
Write( list[i] );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( HashSet<Mobile> set )
|
public override void Write( HashSet<Mobile> set )
|
||||||
{
|
{
|
||||||
Write( set, false );
|
Write( set, false );
|
||||||
|
|
@ -858,7 +854,7 @@ namespace Server
|
||||||
Write( mob );
|
Write( mob );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override void Write( List<BaseGuild> list )
|
public override void Write( List<BaseGuild> list )
|
||||||
{
|
{
|
||||||
Write( list, false );
|
Write( list, false );
|
||||||
|
|
@ -904,7 +900,7 @@ namespace Server
|
||||||
for( int i = 0; i < list.Count; ++i )
|
for( int i = 0; i < list.Count; ++i )
|
||||||
Write( list[i] );
|
Write( list[i] );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( HashSet<BaseGuild> set )
|
public override void Write( HashSet<BaseGuild> set )
|
||||||
{
|
{
|
||||||
Write( set, false );
|
Write( set, false );
|
||||||
|
|
@ -942,7 +938,6 @@ namespace Server
|
||||||
Write( guild );
|
Write( guild );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class BinaryFileReader : GenericReader
|
public sealed class BinaryFileReader : GenericReader
|
||||||
|
|
@ -1015,7 +1010,7 @@ namespace Server
|
||||||
{
|
{
|
||||||
return new DateTime( m_File.ReadInt64() );
|
return new DateTime( m_File.ReadInt64() );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override DateTimeOffset ReadDateTimeOffset()
|
public override DateTimeOffset ReadDateTimeOffset()
|
||||||
{
|
{
|
||||||
long ticks = m_File.ReadInt64();
|
long ticks = m_File.ReadInt64();
|
||||||
|
|
@ -1023,7 +1018,7 @@ namespace Server
|
||||||
|
|
||||||
return new DateTimeOffset( ticks, offset );
|
return new DateTimeOffset( ticks, offset );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override TimeSpan ReadTimeSpan()
|
public override TimeSpan ReadTimeSpan()
|
||||||
{
|
{
|
||||||
return new TimeSpan( m_File.ReadInt64() );
|
return new TimeSpan( m_File.ReadInt64() );
|
||||||
|
|
@ -1237,7 +1232,7 @@ namespace Server
|
||||||
return new List<T>();
|
return new List<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override HashSet<Item> ReadItemSet()
|
public override HashSet<Item> ReadItemSet()
|
||||||
{
|
{
|
||||||
return ReadItemSet<Item>();
|
return ReadItemSet<Item>();
|
||||||
|
|
@ -1268,7 +1263,7 @@ namespace Server
|
||||||
return new HashSet<T>();
|
return new HashSet<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override List<Mobile> ReadStrongMobileList()
|
public override List<Mobile> ReadStrongMobileList()
|
||||||
{
|
{
|
||||||
return ReadStrongMobileList<Mobile>();
|
return ReadStrongMobileList<Mobile>();
|
||||||
|
|
@ -1294,7 +1289,7 @@ namespace Server
|
||||||
return new List<T>();
|
return new List<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override HashSet<Mobile> ReadMobileSet()
|
public override HashSet<Mobile> ReadMobileSet()
|
||||||
{
|
{
|
||||||
return ReadMobileSet<Mobile>();
|
return ReadMobileSet<Mobile>();
|
||||||
|
|
@ -1325,7 +1320,7 @@ namespace Server
|
||||||
return new HashSet<T>();
|
return new HashSet<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override List<BaseGuild> ReadStrongGuildList()
|
public override List<BaseGuild> ReadStrongGuildList()
|
||||||
{
|
{
|
||||||
return ReadStrongGuildList<BaseGuild>();
|
return ReadStrongGuildList<BaseGuild>();
|
||||||
|
|
@ -1351,7 +1346,7 @@ namespace Server
|
||||||
return new List<T>();
|
return new List<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override HashSet<BaseGuild> ReadGuildSet()
|
public override HashSet<BaseGuild> ReadGuildSet()
|
||||||
{
|
{
|
||||||
return ReadGuildSet<BaseGuild>();
|
return ReadGuildSet<BaseGuild>();
|
||||||
|
|
@ -1382,7 +1377,7 @@ namespace Server
|
||||||
return new HashSet<T>();
|
return new HashSet<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override Race ReadRace()
|
public override Race ReadRace()
|
||||||
{
|
{
|
||||||
return Race.Races[ReadByte()];
|
return Race.Races[ReadByte()];
|
||||||
|
|
@ -1572,14 +1567,14 @@ namespace Server
|
||||||
m_Bin.Write( value.Ticks );
|
m_Bin.Write( value.Ticks );
|
||||||
OnWrite();
|
OnWrite();
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( DateTimeOffset value )
|
public override void Write( DateTimeOffset value )
|
||||||
{
|
{
|
||||||
m_Bin.Write( value.Ticks );
|
m_Bin.Write( value.Ticks );
|
||||||
m_Bin.Write( value.Offset.Ticks );
|
m_Bin.Write( value.Offset.Ticks );
|
||||||
OnWrite();
|
OnWrite();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override void Write( TimeSpan value )
|
public override void Write( TimeSpan value )
|
||||||
{
|
{
|
||||||
m_Bin.Write( value.Ticks );
|
m_Bin.Write( value.Ticks );
|
||||||
|
|
@ -1872,7 +1867,7 @@ namespace Server
|
||||||
for( int i = 0; i < list.Count; ++i )
|
for( int i = 0; i < list.Count; ++i )
|
||||||
Write( list[i] );
|
Write( list[i] );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( HashSet<Item> set )
|
public override void Write( HashSet<Item> set )
|
||||||
{
|
{
|
||||||
Write( set, false );
|
Write( set, false );
|
||||||
|
|
@ -1910,7 +1905,7 @@ namespace Server
|
||||||
Write( item );
|
Write( item );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override void Write( List<Mobile> list )
|
public override void Write( List<Mobile> list )
|
||||||
{
|
{
|
||||||
Write( list, false );
|
Write( list, false );
|
||||||
|
|
@ -1956,7 +1951,7 @@ namespace Server
|
||||||
for( int i = 0; i < list.Count; ++i )
|
for( int i = 0; i < list.Count; ++i )
|
||||||
Write( list[i] );
|
Write( list[i] );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( HashSet<Mobile> set )
|
public override void Write( HashSet<Mobile> set )
|
||||||
{
|
{
|
||||||
Write( set, false );
|
Write( set, false );
|
||||||
|
|
@ -1994,7 +1989,7 @@ namespace Server
|
||||||
Write( mob );
|
Write( mob );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public override void Write( List<BaseGuild> list )
|
public override void Write( List<BaseGuild> list )
|
||||||
{
|
{
|
||||||
Write( list, false );
|
Write( list, false );
|
||||||
|
|
@ -2040,7 +2035,7 @@ namespace Server
|
||||||
for( int i = 0; i < list.Count; ++i )
|
for( int i = 0; i < list.Count; ++i )
|
||||||
Write( list[i] );
|
Write( list[i] );
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public override void Write( HashSet<BaseGuild> set )
|
public override void Write( HashSet<BaseGuild> set )
|
||||||
{
|
{
|
||||||
Write( set, false );
|
Write( set, false );
|
||||||
|
|
@ -2078,7 +2073,6 @@ namespace Server
|
||||||
Write( guild );
|
Write( guild );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ISerializable
|
public interface ISerializable
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
#if Framework_4_0
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
|
||||||
using Server.Diagnostics;
|
using Server.Diagnostics;
|
||||||
|
|
||||||
namespace Server
|
namespace Server
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ namespace Server
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
|
||||||
public static DateTimeOffset GetXMLDateTimeOffset( string dateTimeOffsetString, DateTimeOffset defaultValue )
|
public static DateTimeOffset GetXMLDateTimeOffset( string dateTimeOffsetString, DateTimeOffset defaultValue )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -570,7 +570,7 @@ namespace Server
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
public static TimeSpan GetXMLTimeSpan( string timeSpanString, TimeSpan defaultValue )
|
public static TimeSpan GetXMLTimeSpan( string timeSpanString, TimeSpan defaultValue )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
384
Server/World.cs
384
Server/World.cs
|
|
@ -281,7 +281,7 @@ namespace Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Type[] m_SerialTypeArray = new Type[1] { typeof(Serial) };
|
private static readonly Type[] m_SerialTypeArray = new Type[1] { typeof(Serial) };
|
||||||
#if Framework_4_0
|
|
||||||
private static List<Tuple<ConstructorInfo, string>> ReadTypes( BinaryReader tdbReader )
|
private static List<Tuple<ConstructorInfo, string>> ReadTypes( BinaryReader tdbReader )
|
||||||
{
|
{
|
||||||
int count = tdbReader.ReadInt32();
|
int count = tdbReader.ReadInt32();
|
||||||
|
|
@ -662,388 +662,6 @@ namespace Server {
|
||||||
|
|
||||||
Console.WriteLine( "done ({1} items, {2} mobiles) ({0:F2} seconds)", watch.Elapsed.TotalSeconds, m_Items.Count, m_Mobiles.Count );
|
Console.WriteLine( "done ({1} items, {2} mobiles) ({0:F2} seconds)", watch.Elapsed.TotalSeconds, m_Items.Count, m_Mobiles.Count );
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
private static List<object[]> ReadTypes( BinaryReader tdbReader )
|
|
||||||
{
|
|
||||||
int count = tdbReader.ReadInt32();
|
|
||||||
|
|
||||||
List<object[]> types = new List<object[]>(count);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
string typeName = tdbReader.ReadString();
|
|
||||||
|
|
||||||
Type t = ScriptCompiler.FindTypeByFullName(typeName);
|
|
||||||
|
|
||||||
if (t == null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("failed");
|
|
||||||
|
|
||||||
if (!Core.Service)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Error: Type '{0}' was not found. Delete all of those types? (y/n)", typeName);
|
|
||||||
|
|
||||||
if (Console.ReadKey(true).Key == ConsoleKey.Y)
|
|
||||||
{
|
|
||||||
types.Add(null);
|
|
||||||
Console.Write("World: Loading...");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("Types will not be deleted. An exception will be thrown.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Error: Type '{0}' was not found.", typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception(String.Format("Bad type '{0}'", typeName));
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstructorInfo ctor = t.GetConstructor(m_SerialTypeArray);
|
|
||||||
|
|
||||||
if (ctor != null)
|
|
||||||
{
|
|
||||||
types.Add(new object[] { ctor, typeName });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception(String.Format("Type '{0}' does not have a serialization constructor", t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Load() {
|
|
||||||
if ( m_Loaded )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_Loaded = true;
|
|
||||||
m_LoadingType = null;
|
|
||||||
|
|
||||||
Console.Write( "World: Loading..." );
|
|
||||||
|
|
||||||
Stopwatch watch = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
m_Loading = true;
|
|
||||||
|
|
||||||
_addQueue = new Queue<IEntity>();
|
|
||||||
_deleteQueue = new Queue<IEntity>();
|
|
||||||
|
|
||||||
int mobileCount = 0, itemCount = 0, guildCount = 0;
|
|
||||||
|
|
||||||
object[] ctorArgs = new object[1];
|
|
||||||
|
|
||||||
List<ItemEntry> items = new List<ItemEntry>();
|
|
||||||
List<MobileEntry> mobiles = new List<MobileEntry>();
|
|
||||||
List<GuildEntry> guilds = new List<GuildEntry>();
|
|
||||||
|
|
||||||
if ( File.Exists( MobileIndexPath ) && File.Exists( MobileTypesPath ) ) {
|
|
||||||
using ( FileStream idx = new FileStream( MobileIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryReader idxReader = new BinaryReader( idx );
|
|
||||||
|
|
||||||
using ( FileStream tdb = new FileStream( MobileTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryReader tdbReader = new BinaryReader( tdb );
|
|
||||||
|
|
||||||
List<object[]> types = ReadTypes( tdbReader );
|
|
||||||
|
|
||||||
mobileCount = idxReader.ReadInt32();
|
|
||||||
|
|
||||||
m_Mobiles = new Dictionary<Serial, Mobile>( mobileCount );
|
|
||||||
|
|
||||||
for ( int i = 0; i < mobileCount; ++i ) {
|
|
||||||
int typeID = idxReader.ReadInt32();
|
|
||||||
int serial = idxReader.ReadInt32();
|
|
||||||
long pos = idxReader.ReadInt64();
|
|
||||||
int length = idxReader.ReadInt32();
|
|
||||||
|
|
||||||
object[] objs = types[typeID];
|
|
||||||
|
|
||||||
if ( objs == null )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Mobile m = null;
|
|
||||||
ConstructorInfo ctor = ( ConstructorInfo ) objs[0];
|
|
||||||
string typeName = ( string ) objs[1];
|
|
||||||
|
|
||||||
try {
|
|
||||||
ctorArgs[0] = ( Serial ) serial;
|
|
||||||
m = ( Mobile ) ( ctor.Invoke( ctorArgs ) );
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m != null ) {
|
|
||||||
mobiles.Add( new MobileEntry( m, typeID, typeName, pos, length ) );
|
|
||||||
AddMobile( m );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tdbReader.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
idxReader.Close();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_Mobiles = new Dictionary<Serial, Mobile>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( File.Exists( ItemIndexPath ) && File.Exists( ItemTypesPath ) ) {
|
|
||||||
using ( FileStream idx = new FileStream( ItemIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryReader idxReader = new BinaryReader( idx );
|
|
||||||
|
|
||||||
using ( FileStream tdb = new FileStream( ItemTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryReader tdbReader = new BinaryReader( tdb );
|
|
||||||
|
|
||||||
List<object[]> types = ReadTypes( tdbReader );
|
|
||||||
|
|
||||||
itemCount = idxReader.ReadInt32();
|
|
||||||
|
|
||||||
m_Items = new Dictionary<Serial, Item>( itemCount );
|
|
||||||
|
|
||||||
for ( int i = 0; i < itemCount; ++i ) {
|
|
||||||
int typeID = idxReader.ReadInt32();
|
|
||||||
int serial = idxReader.ReadInt32();
|
|
||||||
long pos = idxReader.ReadInt64();
|
|
||||||
int length = idxReader.ReadInt32();
|
|
||||||
|
|
||||||
object[] objs = types[typeID];
|
|
||||||
|
|
||||||
if ( objs == null )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Item item = null;
|
|
||||||
ConstructorInfo ctor = ( ConstructorInfo ) objs[0];
|
|
||||||
string typeName = ( string ) objs[1];
|
|
||||||
|
|
||||||
try {
|
|
||||||
ctorArgs[0] = ( Serial ) serial;
|
|
||||||
item = ( Item ) ( ctor.Invoke( ctorArgs ) );
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( item != null ) {
|
|
||||||
items.Add( new ItemEntry( item, typeID, typeName, pos, length ) );
|
|
||||||
AddItem( item );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tdbReader.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
idxReader.Close();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_Items = new Dictionary<Serial, Item>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( File.Exists( GuildIndexPath ) ) {
|
|
||||||
using ( FileStream idx = new FileStream( GuildIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryReader idxReader = new BinaryReader( idx );
|
|
||||||
|
|
||||||
guildCount = idxReader.ReadInt32();
|
|
||||||
|
|
||||||
CreateGuildEventArgs createEventArgs = new CreateGuildEventArgs( -1 );
|
|
||||||
for ( int i = 0; i < guildCount; ++i ) {
|
|
||||||
idxReader.ReadInt32();//no typeid for guilds
|
|
||||||
int id = idxReader.ReadInt32();
|
|
||||||
long pos = idxReader.ReadInt64();
|
|
||||||
int length = idxReader.ReadInt32();
|
|
||||||
|
|
||||||
createEventArgs.Id = id;
|
|
||||||
EventSink.InvokeCreateGuild(createEventArgs);
|
|
||||||
BaseGuild guild = createEventArgs.Guild;
|
|
||||||
if ( guild != null )
|
|
||||||
guilds.Add( new GuildEntry( guild, pos, length ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
idxReader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool failedMobiles = false, failedItems = false, failedGuilds = false;
|
|
||||||
Type failedType = null;
|
|
||||||
Serial failedSerial = Serial.Zero;
|
|
||||||
Exception failed = null;
|
|
||||||
int failedTypeID = 0;
|
|
||||||
|
|
||||||
if ( File.Exists( MobileDataPath ) ) {
|
|
||||||
using ( FileStream bin = new FileStream( MobileDataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryFileReader reader = new BinaryFileReader( new BinaryReader( bin ) );
|
|
||||||
|
|
||||||
for ( int i = 0; i < mobiles.Count; ++i ) {
|
|
||||||
MobileEntry entry = mobiles[i];
|
|
||||||
Mobile m = entry.Mobile;
|
|
||||||
|
|
||||||
if ( m != null ) {
|
|
||||||
reader.Seek( entry.Position, SeekOrigin.Begin );
|
|
||||||
|
|
||||||
try {
|
|
||||||
m_LoadingType = entry.TypeName;
|
|
||||||
m.Deserialize( reader );
|
|
||||||
|
|
||||||
if ( reader.Position != ( entry.Position + entry.Length ) )
|
|
||||||
throw new Exception( String.Format( "***** Bad serialize on {0} *****", m.GetType() ) );
|
|
||||||
} catch ( Exception e ) {
|
|
||||||
mobiles.RemoveAt( i );
|
|
||||||
|
|
||||||
failed = e;
|
|
||||||
failedMobiles = true;
|
|
||||||
failedType = m.GetType();
|
|
||||||
failedTypeID = entry.TypeID;
|
|
||||||
failedSerial = m.Serial;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !failedMobiles && File.Exists( ItemDataPath ) ) {
|
|
||||||
using ( FileStream bin = new FileStream( ItemDataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryFileReader reader = new BinaryFileReader( new BinaryReader( bin ) );
|
|
||||||
|
|
||||||
for ( int i = 0; i < items.Count; ++i ) {
|
|
||||||
ItemEntry entry = items[i];
|
|
||||||
Item item = entry.Item;
|
|
||||||
|
|
||||||
if ( item != null ) {
|
|
||||||
reader.Seek( entry.Position, SeekOrigin.Begin );
|
|
||||||
|
|
||||||
try {
|
|
||||||
m_LoadingType = entry.TypeName;
|
|
||||||
item.Deserialize( reader );
|
|
||||||
|
|
||||||
if ( reader.Position != ( entry.Position + entry.Length ) )
|
|
||||||
throw new Exception( String.Format( "***** Bad serialize on {0} *****", item.GetType() ) );
|
|
||||||
} catch ( Exception e ) {
|
|
||||||
items.RemoveAt( i );
|
|
||||||
|
|
||||||
failed = e;
|
|
||||||
failedItems = true;
|
|
||||||
failedType = item.GetType();
|
|
||||||
failedTypeID = entry.TypeID;
|
|
||||||
failedSerial = item.Serial;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_LoadingType = null;
|
|
||||||
|
|
||||||
if ( !failedMobiles && !failedItems && File.Exists( GuildDataPath ) ) {
|
|
||||||
using ( FileStream bin = new FileStream( GuildDataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
|
|
||||||
BinaryFileReader reader = new BinaryFileReader( new BinaryReader( bin ) );
|
|
||||||
|
|
||||||
for ( int i = 0; i < guilds.Count; ++i ) {
|
|
||||||
GuildEntry entry = guilds[i];
|
|
||||||
BaseGuild g = entry.Guild;
|
|
||||||
|
|
||||||
if ( g != null ) {
|
|
||||||
reader.Seek( entry.Position, SeekOrigin.Begin );
|
|
||||||
|
|
||||||
try {
|
|
||||||
g.Deserialize( reader );
|
|
||||||
|
|
||||||
if ( reader.Position != ( entry.Position + entry.Length ) )
|
|
||||||
throw new Exception( String.Format( "***** Bad serialize on Guild {0} *****", g.Id ) );
|
|
||||||
} catch ( Exception e ) {
|
|
||||||
guilds.RemoveAt( i );
|
|
||||||
|
|
||||||
failed = e;
|
|
||||||
failedGuilds = true;
|
|
||||||
failedType = typeof( BaseGuild );
|
|
||||||
failedTypeID = g.Id;
|
|
||||||
failedSerial = g.Id;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( failedItems || failedMobiles || failedGuilds ) {
|
|
||||||
Console.WriteLine( "An error was encountered while loading a saved object" );
|
|
||||||
|
|
||||||
Console.WriteLine( " - Type: {0}", failedType );
|
|
||||||
Console.WriteLine( " - Serial: {0}", failedSerial );
|
|
||||||
|
|
||||||
if ( !Core.Service ) {
|
|
||||||
Console.WriteLine( "Delete the object? (y/n)" );
|
|
||||||
|
|
||||||
if ( Console.ReadKey( true ).Key == ConsoleKey.Y ) {
|
|
||||||
if ( failedType != typeof( BaseGuild ) ) {
|
|
||||||
Console.WriteLine( "Delete all objects of that type? (y/n)" );
|
|
||||||
|
|
||||||
if ( Console.ReadKey( true ).Key == ConsoleKey.Y ) {
|
|
||||||
if ( failedMobiles ) {
|
|
||||||
for ( int i = 0; i < mobiles.Count; ) {
|
|
||||||
if ( mobiles[i].TypeID == failedTypeID )
|
|
||||||
mobiles.RemoveAt( i );
|
|
||||||
else
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
} else if ( failedItems ) {
|
|
||||||
for ( int i = 0; i < items.Count; ) {
|
|
||||||
if ( items[i].TypeID == failedTypeID )
|
|
||||||
items.RemoveAt( i );
|
|
||||||
else
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveIndex<MobileEntry>( mobiles, MobileIndexPath );
|
|
||||||
SaveIndex<ItemEntry>( items, ItemIndexPath );
|
|
||||||
SaveIndex<GuildEntry>( guilds, GuildIndexPath );
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine( "After pressing return an exception will be thrown and the server will terminate." );
|
|
||||||
Console.ReadLine();
|
|
||||||
} else {
|
|
||||||
Console.WriteLine( "An exception will be thrown and the server will terminate." );
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception( String.Format( "Load failed (items={0}, mobiles={1}, guilds={2}, type={3}, serial={4})", failedItems, failedMobiles, failedGuilds, failedType, failedSerial ), failed );
|
|
||||||
}
|
|
||||||
|
|
||||||
EventSink.InvokeWorldLoad();
|
|
||||||
|
|
||||||
m_Loading = false;
|
|
||||||
|
|
||||||
ProcessSafetyQueues();
|
|
||||||
|
|
||||||
foreach ( Item item in m_Items.Values ) {
|
|
||||||
if ( item.Parent == null )
|
|
||||||
item.UpdateTotals();
|
|
||||||
|
|
||||||
item.ClearProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ( Mobile m in m_Mobiles.Values ) {
|
|
||||||
m.UpdateRegion(); // Is this really needed?
|
|
||||||
m.UpdateTotals();
|
|
||||||
|
|
||||||
m.ClearProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
watch.Stop();
|
|
||||||
|
|
||||||
Console.WriteLine( "done ({1} items, {2} mobiles) ({0:F2} seconds)", watch.Elapsed.TotalSeconds, m_Items.Count, m_Mobiles.Count );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private static void ProcessSafetyQueues() {
|
private static void ProcessSafetyQueues() {
|
||||||
while ( _addQueue.Count > 0 ) {
|
while ( _addQueue.Count > 0 ) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue