From 635d4282ec9d79242dd503af0c12bc22bbdc8c5a Mon Sep 17 00:00:00 2001 From: asayre Date: Mon, 2 Jan 2012 15:09:33 +0000 Subject: [PATCH] I love Tuples, you love tuples, everybody loves tuples! --- Server/World.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Server/World.cs b/Server/World.cs index 368967a4b..41534dfcb 100644 --- a/Server/World.cs +++ b/Server/World.cs @@ -288,13 +288,11 @@ namespace Server { private static readonly Type[] m_SerialTypeArray = new Type[1] { typeof(Serial) }; - //TODO, when fully migrated to .NET 4.0: - //private static List> ReadTypes( BinaryReader tdbReader ) - private static List ReadTypes( BinaryReader tdbReader ) + private static List> ReadTypes( BinaryReader tdbReader ) { int count = tdbReader.ReadInt32(); - List types = new List(count); + List> types = new List>( count ); for (int i = 0; i < count; ++i) { @@ -331,7 +329,7 @@ namespace Server { if (ctor != null) { - types.Add(new object[] { ctor, typeName }); + types.Add( new Tuple( ctor, typeName ) ); } else { @@ -373,7 +371,7 @@ namespace Server { using ( FileStream tdb = new FileStream( MobileTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { BinaryReader tdbReader = new BinaryReader( tdb ); - List types = ReadTypes( tdbReader ); + List> types = ReadTypes( tdbReader ); mobileCount = idxReader.ReadInt32(); @@ -385,14 +383,14 @@ namespace Server { long pos = idxReader.ReadInt64(); int length = idxReader.ReadInt32(); - object[] objs = types[typeID]; + Tuple objs = types[typeID]; if ( objs == null ) continue; Mobile m = null; - ConstructorInfo ctor = ( ConstructorInfo ) objs[0]; - string typeName = ( string ) objs[1]; + ConstructorInfo ctor = objs.Item1; + string typeName = objs.Item2; try { ctorArgs[0] = ( Serial ) serial; @@ -422,7 +420,7 @@ namespace Server { using ( FileStream tdb = new FileStream( ItemTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { BinaryReader tdbReader = new BinaryReader( tdb ); - List types = ReadTypes( tdbReader ); + List> types = ReadTypes( tdbReader ); itemCount = idxReader.ReadInt32(); @@ -434,14 +432,14 @@ namespace Server { long pos = idxReader.ReadInt64(); int length = idxReader.ReadInt32(); - object[] objs = types[typeID]; + Tuple objs = types[typeID]; if ( objs == null ) continue; Item item = null; - ConstructorInfo ctor = ( ConstructorInfo ) objs[0]; - string typeName = ( string ) objs[1]; + ConstructorInfo ctor = objs.Item1; + string typeName = objs.Item2; try { ctorArgs[0] = ( Serial ) serial;