revert forced 4.0 migration -- many users are still dependent on 2.0

This commit is contained in:
mark 2012-03-07 13:47:33 +00:00
parent 7b48ebb7e6
commit 4bcde77cc2
13 changed files with 531 additions and 46 deletions

View file

@ -1,7 +1,9 @@
System.dll
System.Core.dll
#Uncomment the following line for full C# 4.0 support.
#System.Core.dll
System.Web.dll
System.Xml.dll
System.Data.dll
System.Drawing.dll
System.Windows.Forms.dll
System.Windows.Forms.dll

View file

@ -665,9 +665,11 @@ namespace Server.Accounting
break;
}
}
#if Framework_4_0
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_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.Now );
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.Now );

View file

@ -25,7 +25,7 @@ namespace Server.Commands
else
{
SkillName skill;
#if Framework_4_0
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
{
arg.Mobile.Target = new SkillTarget( skill, arg.GetDouble( 1 ) );
@ -34,6 +34,18 @@ namespace Server.Commands
{
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
}
}
@ -62,7 +74,7 @@ namespace Server.Commands
else
{
SkillName skill;
#if Framework_4_0
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
{
arg.Mobile.Target = new SkillTarget( skill );
@ -71,6 +83,19 @@ namespace Server.Commands
{
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
}
}

View file

@ -121,13 +121,29 @@ namespace Server.Misc
private static void ChangeSkill( Mobile from, string name, double value )
{
SkillName index;
#if Framework_4_0
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.
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];
if ( skill != null )

View file

@ -55,7 +55,7 @@ namespace Server
continue;
string[] split = line.Split( '\t' );
#if Framework_4_0
BodyType type;
int bodyID;
@ -68,6 +68,21 @@ namespace Server
Console.WriteLine( "Warning: Invalid bodyTable entry:" );
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
}
}
}

View file

@ -28,7 +28,10 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
#if Framework_4_0
using System.Threading.Tasks;
#endif
using Server;
using Server.Accounting;
using Server.Gumps;
@ -109,7 +112,11 @@ namespace Server
public static Thread Thread { get { return m_Thread; } }
public static MultiTextWriter MultiConsoleOut { get { return m_MultiConOut; } }
#if Framework_4_0
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 int m_ProcessorCount;
@ -661,10 +668,17 @@ namespace Server
if( a == null )
return;
#if Framework_4_0
Parallel.ForEach(a.GetTypes(), t =>
{
VerifyType(t);
});
#else
foreach (Type t in a.GetTypes())
{
VerifyType(t);
}
#endif
}
}

View file

@ -18,6 +18,8 @@
*
***************************************************************************/
#if Framework_4_0
using System;
using System.Collections.Generic;
using System.Text;
@ -311,4 +313,5 @@ namespace Server
}
}
}
}
#endif

View file

@ -31,10 +31,17 @@ namespace Server
{
int processorCount = Core.ProcessorCount;
if (processorCount > 16)
#if Framework_4_0
if (processorCount > 2)
{
return new DynamicSaveStrategy();
}
#else
if (processorCount > 16)
{
return new ParallelSaveStrategy(processorCount);
}
#endif
else
{
return new DualSaveStrategy();

View file

@ -1139,7 +1139,7 @@ namespace Server
return false;
Type type = typeof(T);
#if Framework_4_0
T tempVal;
if( type.IsEnum && Enum.TryParse( s, true, out tempVal ) )
@ -1152,6 +1152,19 @@ namespace Server
Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", type, attribute, xml.Name );
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 )

View file

@ -89,13 +89,14 @@ namespace Server
AppendCompilerOption( ref sb, "/d:MONO" );
#endif
//These following defines are legacy, ie, depreciated.
//These two defines are legacy, ie, depreciated.
if( Core.Is64Bit )
AppendCompilerOption( ref sb, "/d:x64" );
AppendCompilerOption( ref sb, "/d:Framework_2_0" );
#if Framework_4_0
AppendCompilerOption( ref sb, "/d:Framework_4_0" );
#endif
return (sb == null ? null : sb.ToString());
}

View file

@ -38,7 +38,9 @@ namespace Server
public abstract string ReadString();
public abstract DateTime ReadDateTime();
#if Framework_4_0
public abstract DateTimeOffset ReadDateTimeOffset();
#endif
public abstract TimeSpan ReadTimeSpan();
public abstract DateTime ReadDeltaTime();
public abstract decimal ReadDecimal();
@ -83,7 +85,7 @@ namespace Server
public abstract List<BaseGuild> ReadStrongGuildList();
public abstract List<T> ReadStrongGuildList<T>() where T : BaseGuild;
#if Framework_4_0
public abstract HashSet<Item> ReadItemSet();
public abstract HashSet<T> ReadItemSet<T>() where T: Item;
@ -92,7 +94,7 @@ namespace Server
public abstract HashSet<BaseGuild> ReadGuildSet();
public abstract HashSet<T> ReadGuildSet<T>() where T : BaseGuild;
#endif
public abstract Race ReadRace();
public abstract bool End();
@ -108,7 +110,9 @@ namespace Server
public abstract void Write( string value );
public abstract void Write( DateTime value );
#if Framework_4_0
public abstract void Write( DateTimeOffset value );
#endif
public abstract void Write( TimeSpan value );
public abstract void Write( decimal value );
public abstract void Write( long value );
@ -158,37 +162,37 @@ namespace Server
public abstract void WriteItemList<T>( List<T> list ) 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, bool tidy );
public abstract void WriteItemSet<T>( HashSet<T> set ) 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, bool tidy );
public abstract void WriteMobileList<T>( List<T> list ) 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, bool tidy );
public abstract void WriteMobileSet<T>( HashSet<T> set ) 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, bool tidy );
public abstract void WriteGuildList<T>( List<T> list ) 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, bool tidy );
public abstract void WriteGuildSet<T>( HashSet<T> set ) where T : BaseGuild;
public abstract void WriteGuildSet<T>( HashSet<T> set, bool tidy ) where T : BaseGuild;
#endif
//Stupid compiler won't notice there 'where' to differentiate the generic methods.
}
@ -365,13 +369,13 @@ namespace Server
{
Write( value.Ticks );
}
#if Framework_4_0
public override void Write( DateTimeOffset value )
{
Write( value.Ticks );
Write( value.Offset.Ticks );
}
#endif
public override void WriteDeltaTime( DateTime value )
{
long ticks = value.Ticks;
@ -732,7 +736,7 @@ namespace Server
for( int i = 0; i < list.Count; ++i )
Write( list[i] );
}
#if Framework_4_0
public override void Write( HashSet<Item> set )
{
Write( set, false );
@ -770,7 +774,7 @@ namespace Server
Write( item );
}
}
#endif
public override void Write( List<Mobile> list )
{
Write( list, false );
@ -816,7 +820,7 @@ namespace Server
for( int i = 0; i < list.Count; ++i )
Write( list[i] );
}
#if Framework_4_0
public override void Write( HashSet<Mobile> set )
{
Write( set, false );
@ -854,7 +858,7 @@ namespace Server
Write( mob );
}
}
#endif
public override void Write( List<BaseGuild> list )
{
Write( list, false );
@ -900,7 +904,7 @@ namespace Server
for( int i = 0; i < list.Count; ++i )
Write( list[i] );
}
#if Framework_4_0
public override void Write( HashSet<BaseGuild> set )
{
Write( set, false );
@ -938,6 +942,7 @@ namespace Server
Write( guild );
}
}
#endif
}
public sealed class BinaryFileReader : GenericReader
@ -1010,7 +1015,7 @@ namespace Server
{
return new DateTime( m_File.ReadInt64() );
}
#if Framework_4_0
public override DateTimeOffset ReadDateTimeOffset()
{
long ticks = m_File.ReadInt64();
@ -1018,7 +1023,7 @@ namespace Server
return new DateTimeOffset( ticks, offset );
}
#endif
public override TimeSpan ReadTimeSpan()
{
return new TimeSpan( m_File.ReadInt64() );
@ -1232,7 +1237,7 @@ namespace Server
return new List<T>();
}
}
#if Framework_4_0
public override HashSet<Item> ReadItemSet()
{
return ReadItemSet<Item>();
@ -1263,7 +1268,7 @@ namespace Server
return new HashSet<T>();
}
}
#endif
public override List<Mobile> ReadStrongMobileList()
{
return ReadStrongMobileList<Mobile>();
@ -1289,7 +1294,7 @@ namespace Server
return new List<T>();
}
}
#if Framework_4_0
public override HashSet<Mobile> ReadMobileSet()
{
return ReadMobileSet<Mobile>();
@ -1320,7 +1325,7 @@ namespace Server
return new HashSet<T>();
}
}
#endif
public override List<BaseGuild> ReadStrongGuildList()
{
return ReadStrongGuildList<BaseGuild>();
@ -1346,7 +1351,7 @@ namespace Server
return new List<T>();
}
}
#if Framework_4_0
public override HashSet<BaseGuild> ReadGuildSet()
{
return ReadGuildSet<BaseGuild>();
@ -1377,7 +1382,7 @@ namespace Server
return new HashSet<T>();
}
}
#endif
public override Race ReadRace()
{
return Race.Races[ReadByte()];
@ -1559,14 +1564,14 @@ namespace Server
m_Bin.Write( value.Ticks );
OnWrite();
}
#if Framework_4_0
public override void Write( DateTimeOffset value )
{
m_Bin.Write( value.Ticks );
m_Bin.Write( value.Offset.Ticks );
OnWrite();
}
#endif
public override void Write( TimeSpan value )
{
m_Bin.Write( value.Ticks );
@ -1859,7 +1864,7 @@ namespace Server
for( int i = 0; i < list.Count; ++i )
Write( list[i] );
}
#if Framework_4_0
public override void Write( HashSet<Item> set )
{
Write( set, false );
@ -1897,7 +1902,7 @@ namespace Server
Write( item );
}
}
#endif
public override void Write( List<Mobile> list )
{
Write( list, false );
@ -1943,7 +1948,7 @@ namespace Server
for( int i = 0; i < list.Count; ++i )
Write( list[i] );
}
#if Framework_4_0
public override void Write( HashSet<Mobile> set )
{
Write( set, false );
@ -1981,7 +1986,7 @@ namespace Server
Write( mob );
}
}
#endif
public override void Write( List<BaseGuild> list )
{
Write( list, false );
@ -2027,7 +2032,7 @@ namespace Server
for( int i = 0; i < list.Count; ++i )
Write( list[i] );
}
#if Framework_4_0
public override void Write( HashSet<BaseGuild> set )
{
Write( set, false );
@ -2065,6 +2070,7 @@ namespace Server
Write( guild );
}
}
#endif
}
public interface ISerializable

View file

@ -554,7 +554,7 @@ namespace Server
return defaultValue;
}
}
#if Framework_4_0
public static DateTimeOffset GetXMLDateTimeOffset( string dateTimeOffsetString, DateTimeOffset defaultValue )
{
try
@ -571,7 +571,7 @@ namespace Server
return defaultValue;
}
}
#endif
public static TimeSpan GetXMLTimeSpan( string timeSpanString, TimeSpan defaultValue )
{
try

View file

@ -281,7 +281,7 @@ namespace Server {
}
private static readonly Type[] m_SerialTypeArray = new Type[1] { typeof(Serial) };
#if Framework_4_0
private static List<Tuple<ConstructorInfo, string>> ReadTypes( BinaryReader tdbReader )
{
int count = tdbReader.ReadInt32();
@ -661,6 +661,387 @@ namespace Server {
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;
BaseGuild guild = EventSink.InvokeCreateGuild( createEventArgs );
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() {
while ( _addQueue.Count > 0 ) {