fix: Cleans up LINQ calls. (#965)
- [X] Removes several `ToList()` uses with `PooledRefQueue` - [X] Adds a `PeekRandom` to PooledRefQueue - [X] Updates EV/BS so they dispel each other in a more efficient manner. - [X] Fixes Firebomb so it works like a normal firefield. - [X] Fixes field spells so they aren't unnecessarily using a Point3D ref more than necessary. - [X] Removes extra allocation in campfire by using reverse loop. - [X] Removes other LINQ calls that aren't needed.
This commit is contained in:
parent
daf89686d1
commit
23532db603
40 changed files with 585 additions and 447 deletions
|
|
@ -1,5 +1,3 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace Server.Engines.Quests.Naturalist
|
||||
{
|
||||
public class NestArea
|
||||
|
|
@ -38,7 +36,22 @@ namespace Server.Engines.Quests.Naturalist
|
|||
m_Rects = rects;
|
||||
}
|
||||
|
||||
public static int NonSpecialCount => m_Areas.Count(area => !area.Special);
|
||||
public static int NonSpecialCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var area in m_Areas)
|
||||
{
|
||||
if (!area.Special)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Special { get; }
|
||||
|
||||
|
|
@ -60,7 +73,15 @@ namespace Server.Engines.Quests.Naturalist
|
|||
|
||||
public static NestArea Find(Point3D p)
|
||||
{
|
||||
return m_Areas.FirstOrDefault(area => area.Contains(p));
|
||||
foreach (var area in m_Areas)
|
||||
{
|
||||
if (area.Contains(p))
|
||||
{
|
||||
return area;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static NestArea GetByID(int id)
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ namespace Server.Misc
|
|||
|
||||
pm.ToTTotalMonsterFame += (int)(bc.Fame * (1 + Math.Sqrt(pm.Luck) / 100));
|
||||
|
||||
// This is the Exponentional regression with only 2 datapoints.
|
||||
// This is the Exponential regression with only 2 data points.
|
||||
// A log. func would also work, but it didn't make as much sense.
|
||||
// This function isn't OSI exact being that I don't know OSI's func they used ;p
|
||||
var x = pm.ToTTotalMonsterFame;
|
||||
|
|
@ -269,10 +269,8 @@ namespace Server.Mobiles
|
|||
{
|
||||
if (pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)
|
||||
{
|
||||
SayTo(
|
||||
pm,
|
||||
1070980
|
||||
); // Congratulations! You have turned in enough minor treasures to earn a greater reward.
|
||||
// Congratulations! You have turned in enough minor treasures to earn a greater reward.
|
||||
SayTo(pm, 1070980);
|
||||
|
||||
pm.CloseGump<ToTTurnInGump>(); // Sanity
|
||||
|
||||
|
|
@ -285,18 +283,16 @@ namespace Server.Mobiles
|
|||
{
|
||||
if (pm.ToTItemsTurnedIn == 0)
|
||||
{
|
||||
SayTo(
|
||||
pm,
|
||||
1071013
|
||||
); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
|
||||
// Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
|
||||
SayTo(pm, 1071013);
|
||||
}
|
||||
else
|
||||
{
|
||||
SayTo(
|
||||
pm,
|
||||
1070981,
|
||||
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
|
||||
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
);
|
||||
}
|
||||
|
||||
var buttons = ToTTurnInGump.FindRedeemableItems(pm);
|
||||
|
|
@ -342,34 +338,26 @@ namespace Server.Gumps
|
|||
{
|
||||
private readonly Mobile m_Collector;
|
||||
|
||||
public ToTTurnInGump(Mobile collector, List<ItemTileButtonInfo> buttons) : base(
|
||||
1071012,
|
||||
buttons.ToList<ImageTileButtonInfo>()
|
||||
) // Click a minor artifact to give it to Ihara Soko.
|
||||
=>
|
||||
m_Collector = collector;
|
||||
// Click a minor artifact to give it to Ihara Soko.
|
||||
public ToTTurnInGump(Mobile collector, List<ImageTileButtonInfo> buttons)
|
||||
: base(1071012, buttons) => m_Collector = collector;
|
||||
|
||||
public static List<ItemTileButtonInfo> FindRedeemableItems(Mobile m)
|
||||
public static List<ImageTileButtonInfo> FindRedeemableItems(Mobile m)
|
||||
{
|
||||
var pack = m.Backpack;
|
||||
if (pack == null)
|
||||
{
|
||||
return new List<ItemTileButtonInfo>();
|
||||
return new List<ImageTileButtonInfo>();
|
||||
}
|
||||
|
||||
var buttons = new List<ItemTileButtonInfo>();
|
||||
var buttons = new List<ImageTileButtonInfo>();
|
||||
|
||||
var items = pack.FindItemsByType(TreasuresOfTokuno.LesserArtifactsTotal);
|
||||
|
||||
for (var i = 0; i < items.Length; i++)
|
||||
{
|
||||
var item = items[i];
|
||||
if (item is ChestOfHeirlooms heirlooms && !heirlooms.Locked)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item is ChestOfHeirlooms ofHeirlooms && ofHeirlooms.TrapLevel != 10)
|
||||
if (item is ChestOfHeirlooms heirlooms && (!heirlooms.Locked || heirlooms.TrapLevel != 10))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
@ -400,10 +388,8 @@ namespace Server.Gumps
|
|||
|
||||
if (++pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)
|
||||
{
|
||||
m_Collector.SayTo(
|
||||
pm,
|
||||
1070980
|
||||
); // Congratulations! You have turned in enough minor treasures to earn a greater reward.
|
||||
// Congratulations! You have turned in enough minor treasures to earn a greater reward.
|
||||
m_Collector.SayTo(pm, 1070980);
|
||||
|
||||
pm.CloseGump<ToTTurnInGump>(); // Sanity
|
||||
|
||||
|
|
@ -416,9 +402,9 @@ namespace Server.Gumps
|
|||
{
|
||||
m_Collector.SayTo(
|
||||
pm,
|
||||
1070981,
|
||||
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
|
||||
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
);
|
||||
|
||||
var buttons = FindRedeemableItems(pm);
|
||||
|
||||
|
|
@ -440,19 +426,17 @@ namespace Server.Gumps
|
|||
|
||||
if (pm.ToTItemsTurnedIn == 0)
|
||||
{
|
||||
m_Collector.SayTo(
|
||||
pm,
|
||||
1071013
|
||||
); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
|
||||
// Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
|
||||
m_Collector.SayTo(pm, 1071013);
|
||||
}
|
||||
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward
|
||||
) // This case should ALWAYS be true with this gump, jsut a sanity check
|
||||
// This case should ALWAYS be true with this gump, just a sanity check
|
||||
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward)
|
||||
{
|
||||
m_Collector.SayTo(
|
||||
pm,
|
||||
1070981,
|
||||
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
|
||||
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -611,11 +595,9 @@ namespace Server.Gumps
|
|||
pm.ToTItemsTurnedIn -= TreasuresOfTokuno.ItemsPerReward;
|
||||
m_Collector.SayTo(
|
||||
pm,
|
||||
1070984,
|
||||
item.Name == null || item.Name.Length <= 0
|
||||
? $"#{item.LabelNumber}"
|
||||
: item.Name
|
||||
); // You have earned the gratitude of the Empire. I have placed the ~1_OBJTYPE~ in your backpack.
|
||||
1070984, // You have earned the gratitude of the Empire. I have placed the ~1_OBJTYPE~ in your backpack.
|
||||
item.Name?.Length > 0 ? item.Name : $"#{item.LabelNumber}"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -634,19 +616,17 @@ namespace Server.Gumps
|
|||
|
||||
if (pm.ToTItemsTurnedIn == 0)
|
||||
{
|
||||
m_Collector.SayTo(
|
||||
pm,
|
||||
1071013
|
||||
); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
|
||||
// Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item.
|
||||
m_Collector.SayTo(pm, 1071013);
|
||||
}
|
||||
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward
|
||||
) // This and above case should ALWAYS be FALSE with this gump, jsut a sanity check
|
||||
// This and above case should ALWAYS be FALSE with this gump, jsut a sanity check
|
||||
else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward)
|
||||
{
|
||||
m_Collector.SayTo(
|
||||
pm,
|
||||
1070981,
|
||||
1070981, // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
$"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"
|
||||
); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward.
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue