fix(core): Removes some uses of Linq (#421)
- [X] Removes some uses of linq - [X] Creates struct based enumerator for Skills - [X] Creates a struct based enumerator for TypeCache - [X] Changes HarvestDefinition to an init array instead of List - [X] Changes HeritageTokenGump Response from List to Array
This commit is contained in:
parent
52356866ed
commit
b921c38879
50 changed files with 1006 additions and 507 deletions
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Server.Items;
|
||||
|
|
@ -230,7 +229,14 @@ namespace Server.Commands
|
|||
|
||||
// Handle optional constructors
|
||||
var paramList = ctor.GetParameters();
|
||||
var totalParams = paramList.Count(t => !t.HasDefaultValue);
|
||||
var totalParams = 0;
|
||||
for (var j = 0; j < paramList.Length; j++)
|
||||
{
|
||||
if (!paramList[j].HasDefaultValue)
|
||||
{
|
||||
totalParams++;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.Length >= totalParams && args.Length <= paramList.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -160,11 +159,11 @@ namespace Server.Gumps
|
|||
|
||||
for (var i = 0; i < asms.Length; ++i)
|
||||
{
|
||||
types = AssemblyHandler.GetTypeCache(asms[i]).Types.ToArray();
|
||||
types = AssemblyHandler.GetTypeCache(asms[i]).Types;
|
||||
Match(match, types, results);
|
||||
}
|
||||
|
||||
types = AssemblyHandler.GetTypeCache(Core.Assembly).Types.ToArray();
|
||||
types = AssemblyHandler.GetTypeCache(Core.Assembly).Types;
|
||||
Match(match, types, results);
|
||||
|
||||
results.Sort(new TypeNameComparer());
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Server.Items;
|
||||
using Server.Json;
|
||||
|
|
@ -79,67 +78,69 @@ namespace Server.Commands
|
|||
|
||||
if (ce.Matched.Count > 0)
|
||||
{
|
||||
var objects = new CAGObject[ce.Matched.Count];
|
||||
|
||||
for (var i = 0; i < ce.Matched.Count; i++)
|
||||
{
|
||||
var cte = ce.Matched[i];
|
||||
if (cte.Object is Item item)
|
||||
{
|
||||
var itemID = item.ItemID;
|
||||
|
||||
if (item is BaseAddon addon && addon.Components.Count == 1)
|
||||
{
|
||||
itemID = addon.Components[0].ItemID;
|
||||
}
|
||||
|
||||
if (itemID > TileData.MaxItemValue)
|
||||
{
|
||||
itemID = 1;
|
||||
}
|
||||
|
||||
int? hue = item.Hue & 0x7FFF;
|
||||
|
||||
if ((hue & 0x4000) != 0)
|
||||
{
|
||||
hue = 0;
|
||||
}
|
||||
|
||||
objects[i] = new CAGObject
|
||||
{
|
||||
Type = cte.Type,
|
||||
ItemID = itemID,
|
||||
Hue = hue == 0 ? null : hue
|
||||
};
|
||||
}
|
||||
|
||||
if (cte.Object is Mobile m)
|
||||
{
|
||||
var itemID = ShrinkTable.Lookup(m, 1);
|
||||
|
||||
int? hue = m.Hue & 0x7FFF;
|
||||
|
||||
if ((hue & 0x4000) != 0)
|
||||
{
|
||||
hue = 0;
|
||||
}
|
||||
|
||||
objects[i] = new CAGObject
|
||||
{
|
||||
Type = cte.Type,
|
||||
ItemID = itemID,
|
||||
Hue = hue == 0 ? null : hue
|
||||
};
|
||||
}
|
||||
|
||||
throw new InvalidCastException(
|
||||
$"Categorization Type Entry: {cte.Type.Name} is not a valid type."
|
||||
);
|
||||
}
|
||||
|
||||
list.Add(
|
||||
new CAGJson
|
||||
{
|
||||
Category = category,
|
||||
Objects = ce.Matched.Select(
|
||||
cte =>
|
||||
{
|
||||
if (cte.Object is Item item)
|
||||
{
|
||||
var itemID = item.ItemID;
|
||||
|
||||
if (item is BaseAddon addon && addon.Components.Count == 1)
|
||||
{
|
||||
itemID = addon.Components[0].ItemID;
|
||||
}
|
||||
|
||||
if (itemID > TileData.MaxItemValue)
|
||||
{
|
||||
itemID = 1;
|
||||
}
|
||||
|
||||
int? hue = item.Hue & 0x7FFF;
|
||||
|
||||
if ((hue & 0x4000) != 0)
|
||||
{
|
||||
hue = 0;
|
||||
}
|
||||
|
||||
return new CAGObject
|
||||
{
|
||||
Type = cte.Type,
|
||||
ItemID = itemID,
|
||||
Hue = hue == 0 ? null : hue
|
||||
};
|
||||
}
|
||||
|
||||
if (cte.Object is Mobile m)
|
||||
{
|
||||
var itemID = ShrinkTable.Lookup(m, 1);
|
||||
|
||||
int? hue = m.Hue & 0x7FFF;
|
||||
|
||||
if ((hue & 0x4000) != 0)
|
||||
{
|
||||
hue = 0;
|
||||
}
|
||||
|
||||
return new CAGObject
|
||||
{
|
||||
Type = cte.Type,
|
||||
ItemID = itemID,
|
||||
Hue = hue == 0 ? null : hue
|
||||
};
|
||||
}
|
||||
|
||||
throw new InvalidCastException(
|
||||
$"Categorization Type Entry: {cte.Type.Name} is not a valid type."
|
||||
);
|
||||
}
|
||||
)
|
||||
.ToArray()
|
||||
Objects = objects
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Server.Engines.Quests.Haven;
|
||||
using Server.Engines.Quests.Necro;
|
||||
using Server.Engines.Spawners;
|
||||
|
|
@ -1130,10 +1129,13 @@ namespace Server.Commands
|
|||
{
|
||||
eable = map.GetItemsInRange(new Point3D(x, y, z), 0);
|
||||
|
||||
if (eable.Any(item => item.Z == z && item.ItemID == itemID))
|
||||
foreach (var item in eable)
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
if (item.Z == z && item.ItemID == itemID)
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Server.Engines.Quests.Haven;
|
||||
using Server.Engines.Quests.Necro;
|
||||
using Server.Engines.Spawners;
|
||||
|
|
@ -1127,10 +1126,13 @@ namespace Server.Commands
|
|||
{
|
||||
eable = map.GetItemsInRange(new Point3D(x, y, z), 0);
|
||||
|
||||
if (eable.Any(item => item.Z == z && item.ItemID == itemID))
|
||||
foreach (var item in eable)
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
if (item.Z == z && item.ItemID == itemID)
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue