fix: Stops creating blocked packets entirely (#944)

Optimizes larger servers where users are logging in and packets are being created for no reason.
This commit is contained in:
Kamron Batman 2022-02-27 00:13:49 -08:00 • committed by GitHub
parent 5db8b1354c
commit 941452de4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 5510 additions and 5537 deletions

View file

@ -103,7 +103,7 @@ namespace Server.Engines.Chat
public static void SendChatMessage(this NetState ns, string lang, int number, string param1, string param2)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -464,12 +464,7 @@ namespace Server.Engines.Harvest
var ns = from.NetState;
if (ns == null)
{
return;
}
if (number == 1043297 || ns.HighSeas)
if (number == 1043297 || ns?.HighSeas == true)
{
from.SendLocalizedMessage(number, name);
}

View file

@ -35,7 +35,7 @@ namespace Server.Engines.Help
public static void SendDisplayHelpTopic(this NetState ns, int topicID, bool display = true)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -48,7 +48,7 @@ namespace Server.Engines.PartySystem
public static void SendPartyMemberList(this NetState ns, Party p)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -64,7 +64,7 @@ namespace Server.Engines.PartySystem
public static void SendPartyRemoveMember(this NetState ns, Serial m, Party p = null)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -104,7 +104,7 @@ namespace Server.Engines.PartySystem
public static void SendPartyTextMessage(this NetState ns, Serial m, string text, bool toAll)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -134,7 +134,7 @@ namespace Server.Engines.PartySystem
public static void SendPartyInvitation(this NetState ns, Serial leader)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -47,7 +47,7 @@ namespace Server.Engines.VeteranRewards
public static void SendStatueAnimation(this NetState ns, Serial serial, int status, int anim, int frame)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -135,7 +135,7 @@ namespace Server.Items
public static void SendBookContent(this NetState ns, BaseBook book)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -183,7 +183,7 @@ namespace Server.Items
public static void SendBookCover(this NetState ns, Mobile from, BaseBook book)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -168,7 +168,7 @@ namespace Server.Network
public static void SendBBDisplayBoard(this NetState ns, BaseBulletinBoard board)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -203,7 +203,7 @@ namespace Server.Network
public static void SendBBMessage(this NetState ns, BaseBulletinBoard board, BulletinMessage msg, bool content = false)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -287,7 +287,7 @@ namespace Server.Engines.Mahjong
public static void SendMahjongJoinGame(this NetState ns, Serial game)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -303,7 +303,7 @@ namespace Server.Engines.Mahjong
public static void SendMahjongPlayersInfo(this NetState ns, MahjongGame game, Mobile to)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -361,7 +361,7 @@ namespace Server.Engines.Mahjong
public static void SendMahjongTileInfo(this NetState ns, MahjongTile tile, Mobile to)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -407,7 +407,7 @@ namespace Server.Engines.Mahjong
public static void SendMahjongTilesInfo(this NetState ns, MahjongGame game, Mobile to)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -460,7 +460,7 @@ namespace Server.Engines.Mahjong
public static void SendMahjongGeneralInfo(this NetState ns, MahjongGame game)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -503,7 +503,7 @@ namespace Server.Engines.Mahjong
public static void SendMahjongRelieve(this NetState ns, Serial game)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -65,7 +65,7 @@ namespace Server.Network
public static void SendMapDetails(this NetState ns, MapItem map)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -93,7 +93,7 @@ namespace Server.Network
public static void SendMapCommand(this NetState ns, MapItem map, int command, int x = 0, int y = 0, bool editable = false)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -23,7 +23,7 @@ namespace Server.Network
{
public static void SendCorpseEquip(this NetState ns, Mobile beholder, Corpse beheld)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -67,7 +67,7 @@ namespace Server.Network
public static void SendCorpseContent(this NetState ns, Mobile beholder, Corpse beheld)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -671,7 +671,7 @@ namespace Server.Items
// The client must know about the spellbook or it will crash!
var ns = to.NetState;
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -32,7 +32,7 @@ namespace Server.Items
public static void SendToggleSpecialAbility(this NetState ns, int abilityId, bool active)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -162,7 +162,7 @@ namespace Server
long ticks
)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -207,7 +207,7 @@ namespace Server
public static void SendRemoveBuffPacket(NetState ns, Serial mob, BuffIcon iconID)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -15,19 +15,21 @@ namespace Server
return true;
}
var lowerName = name.ToLowerInvariant().Replace(" ", "");
var lowerName = name?.ToLowerInvariant().Replace(" ", "");
foreach (var so in SkillInfo.Table)
if (!string.IsNullOrEmpty(lowerName))
{
if (lowerName == so.ProfessionSkillName.ToLowerInvariant())
foreach (var so in SkillInfo.Table)
{
skillName = (SkillName)so.SkillID;
return true;
if (lowerName == so.ProfessionSkillName.ToLowerInvariant())
{
skillName = (SkillName)so.SkillID;
return true;
}
}
}
return false;
}
static ProfessionInfo()

View file

@ -969,7 +969,7 @@ namespace Server.Mobiles
var ns = from.NetState;
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -29,7 +29,7 @@ namespace Server.Multis
public static void SendBeginHouseCustomization(this NetState ns, Serial house)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -50,7 +50,7 @@ namespace Server.Multis
public static void SendEndHouseCustomization(this NetState ns, Serial house)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -71,7 +71,7 @@ namespace Server.Multis
public static void SendDesignStateGeneral(this NetState ns, Serial house, int revision)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -102,7 +102,7 @@ namespace Server.Network
public static void SendServerPollInfo(this NetState ns)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -56,7 +56,7 @@ namespace Server.Network
public static void SendGuildMemberLocations(this NetState ns, Mobile from, Guild guild, bool sendLocations)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -116,7 +116,7 @@ namespace Server.Network
public static void SendPartyMemberLocations(this NetState ns, Mobile from, Party party)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -61,7 +61,7 @@ namespace Server.Network
this NetState ns, uint age, int clients, int items, int mobiles, long mem
)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}
@ -82,7 +82,7 @@ namespace Server.Network
this NetState ns, string name, int age, int clients, int items, int mobiles, int mem
)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}

View file

@ -28,7 +28,7 @@ namespace Server.Network
public static void SendArrow(this NetState ns, byte command, int x, int y, Serial s)
{
if (ns == null)
if (ns.CannotSendPackets())
{
return;
}