Updates Packets & Randomizer (#43)

* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand.

* WIP - Rewriting packets.

* Cleanup and updates README

* Converts more packets

* Fixes header

* Converts Effects packets.

* Forgot the send command

* Adds the start of containers packets.

* Adds message packets with caching

* Extends the send methods

* Starts to add Acquire methods

* Converted the packets

* Cleanup

* Cleanup

* Adds more packets

* Adds more packets

* Fixes clearing arrays from pool. Adds Mobile Incoming

* Converts more packets.

* Moves more packets

* Moves more packets

* Test compression

* Merges

* Migrating to an idiomatic syntax that also supports compression, and proxying.

* Optimize the stack alloc. Changes attributes

* Converted container packets

* Visual Studio doesn't auto save files. I am still getting used to subpar IDEs.

* Adds static packet caching. Will profile later. Converts more packets

* Fixes packets and changes how compression is configured

* WIP - Adds basics for Gumps. Not finished though.

* Fix file

* Fixes formatting

* Changed SpanWriter to be more idiomatic.

* Fixes Span vs RawSpan and missing stackallocs

* Converts over some more gumps

* WIP - Deletes 32bit support.

* Drops RDRand32 support.

* Fixes gump compilation

* Converting gump components

* Removes old huffman compression function

* Revert signature for backwards compatibility

* WIP - Converting more gump components

* Creates ArraySet for the strings. Updates AppendTo to reference that.

* Converts the maining gump components

* Cleans up gump components

* Cleans up directives

* Cleans up ArraySet and moves it. Adds null-coalescing-assignment

* Cleanup, Target Packets, and C# 8 changes.

* Removed OPL Packet

* World packets

* Fixing packet uses

* Cleans up code. Fixes packet uses in various places.

* More cleanup for packets

* Code cleanup

* Converts more packet uses and cleans up more code

* More code cleanup

* Finishes fixing the packets in Item

* Updates secure trade packets

* Updates core and gets it to compile.

* Moved packets to scripts. Fixed account handler use of packets

* Code cleanup

* Updates chat packets

* Code cleanuo

* Adds party packets, but need to implement them.

* Party packets WIP

* Finishes party packets

* Rearrange movement namespaces and classes

* Finishes plant packets

* Code Formatting

* Fixes moving effects

* Code cleanup, eliminates equipinfo

* Adds more packets. Fixes bugs with various packets.

* Finishes mahjon packets

* Fixes mahjong packet

* Code cleanup

* Finishes mahjong packets

* Adds Map packets

* Add multifacet maps and charts

* Cleans up some packets with UTF8

* Optimizes packets

* Cleans up more packets. Moves the MessageHelper

* Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets.

* Updates protocol extensions packet receiver

* Fixes a few bugs. Fixes a few more packets.

* Code cleanup and fixing more packets

* Fixes packet effects

* Cleaned up more code

* Buff Icon cleanup

* Removed unused constructors

* Code Cleanup. Adds BoatHS Packets

* Moves house files. Updates house foundation packets.

* Deployment cleanup

* Fixes:

* Code cleanup

* More code cleanup

* More code cleanup

* Cleaned up BaseHouse

* Enforces styling

* Converts foreach to linq where possible.

* Dont need that

* Goals/Readme updates

* Removes 32bit support at the highest level. Turns on HRT by default.

* Code cleanup. Fixes extended features packet.

* Fixes various bugs

* Code cleanup

* Code cleanup

* Code cleanup. Fixes gump X/Y assignment.

* Code cleanup using |= operator

* More code cleanup

* Cleanup

* Fixes spacing issues. Thanks Visual Studio. You suck.

* Compiler error

* Fixes NPE from RunUO 2.7

* Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README

* Fixes more packets. Stupid trailing nulls.

* Fixes various bugs.

* Fixes for gumps

* Fixes more gump stuff. Going to split it out later since it is getting insane

* Recoded the gump writing

* WIP

* *Added output path of scripts project to dev branch
*Activated debugging in code
This commit is contained in:
Kamron Batman 2019-11-11 03:40:16 -08:00 committed by 3HMonkey
parent 7aa8fd3df1
commit 179cb50557
588 changed files with 10843 additions and 16177 deletions

View file

@ -8,7 +8,6 @@ using Server.Ethics;
using Server.Guilds;
using Server.Items;
using Server.Mobiles;
using Server.Prompts;
using Server.Targeting;
namespace Server.Factions
@ -133,21 +132,12 @@ namespace Server.Factions
public static void HandleAtrophy()
{
foreach (Faction f in Factions)
if (!f.State.IsAtrophyReady)
return;
if (Factions.Any(f => !f.State.IsAtrophyReady))
return;
List<PlayerState> activePlayers = new List<PlayerState>();
List<PlayerState> activePlayers = (from f in Factions from ps in f.Members where ps.KillPoints > 0 && ps.IsActive select ps).ToList();
foreach (Faction f in Factions)
foreach (PlayerState ps in f.Members)
if (ps.KillPoints > 0 && ps.IsActive)
activePlayers.Add(ps);
int distrib = 0;
foreach (Faction f in Factions)
distrib += f.State.CheckAtrophy();
int distrib = Factions.Sum(f => f.State.CheckAtrophy());
if (activePlayers.Count == 0)
return;
@ -158,12 +148,7 @@ namespace Server.Factions
public static void DistributePoints(int distrib)
{
List<PlayerState> activePlayers = new List<PlayerState>();
foreach (Faction f in Factions)
foreach (PlayerState ps in f.Members)
if (ps.KillPoints > 0 && ps.IsActive)
activePlayers.Add(ps);
List<PlayerState> activePlayers = (from f in Factions from ps in f.Members where ps.KillPoints > 0 && ps.IsActive select ps).ToList();
if (activePlayers.Count > 0)
for (int i = 0; i < distrib; ++i)
@ -187,13 +172,9 @@ namespace Server.Factions
return;
if (recvState == null || recvState.Faction != giveState.Faction)
{
from.SendLocalizedMessage(1042497); // Only faction mates can be honored this way.
}
else if (giveState.KillPoints < 5)
{
from.SendLocalizedMessage(1042499); // You must have at least five kill points to honor them.
}
else
{
recvState.LastHonorTime = DateTime.UtcNow;
@ -205,9 +186,7 @@ namespace Server.Factions
}
}
else
{
from.SendLocalizedMessage(1042496); // You may only honor another player.
}
}
public virtual void AddMember(Mobile mob)
@ -649,11 +628,7 @@ namespace Server.Factions
public static void FactionItemReset_OnCommand(CommandEventArgs e)
{
List<Item> items = new List<Item>();
foreach (Item item in World.Items.Values)
if (item is IFactionItem && !(item is HoodedShroudOfShadows))
items.Add(item);
List<Item> items = World.Items.Values.Where(item => item is IFactionItem && !(item is HoodedShroudOfShadows)).ToList();
int[] hues = new int[Factions.Count * 2];
@ -673,16 +648,7 @@ namespace Server.Factions
if (fci.FactionItemState != null || item.LootType != LootType.Blessed)
continue;
bool isHued = false;
for (int j = 0; j < hues.Length; ++j)
if (item.Hue == hues[j])
{
isHued = true;
break;
}
if (isHued)
if (hues.Any(t => item.Hue == t))
{
fci.FactionItemState = null;
++count;
@ -841,7 +807,7 @@ namespace Server.Factions
Silver += tithed;
silver = silver - tithed;
silver -= tithed;
if (silver > 0)
mob.AddToBackpack(new Silver(silver));
@ -887,19 +853,12 @@ namespace Server.Factions
Faction smallest = FindSmallestFaction();
if (smallest == null)
return true; // sanity
if ((Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
return false;
return true;
return smallest == null || (Members.Count + influx) * 100 / StabilityFactor <= smallest.Members.Count;
}
public static void HandleDeath(Mobile victim, Mobile killer)
{
if (killer == null)
killer = victim.FindMostRecentDamager(true);
killer ??= victim.FindMostRecentDamager(true);
PlayerState killerState = PlayerState.Find(killer);
Container killerPack = killer?.Backpack;
@ -941,7 +900,7 @@ namespace Server.Factions
int silver = killerState.Faction.AwardSilver(killer, bc.FactionSilverWorth);
if (silver > 0)
killer.SendLocalizedMessage(1042748,
killer?.SendLocalizedMessage(1042748,
silver.ToString("N0")); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature.
}
@ -982,7 +941,7 @@ namespace Server.Factions
{
if (victimState.KillPoints <= -6)
{
killer.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from.
killer?.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from.
#region Ethics
@ -1024,13 +983,12 @@ namespace Server.Factions
{
victimState.IsActive = true;
if (1 > Utility.Random(3))
killerState.IsActive = true;
killerState.IsActive |= 1 > Utility.Random(3);
int silver = killerState.Faction.AwardSilver(killer, award * 40);
if (silver > 0)
killer.SendLocalizedMessage(1042736,
killer?.SendLocalizedMessage(1042736,
$"{silver:N0} silver\t{victim.Name}"); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
}
@ -1039,9 +997,9 @@ namespace Server.Factions
int offset = award != 1 ? 0 : 2; // for pluralization
string args = $"{award}\t{victim.Name}\t{killer.Name}";
string args = $"{award}\t{victim.Name}\t{killer?.Name ?? ""}";
killer.SendLocalizedMessage(1042737 + offset,
killer?.SendLocalizedMessage(1042737 + offset,
args); // Thou hast been honored with ~1_KILL_POINTS~ kill point(s) for vanquishing ~2_DEAD_PLAYER~!
victim.SendLocalizedMessage(1042738 + offset,
args); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished!
@ -1073,7 +1031,7 @@ namespace Server.Factions
}
else
{
killer.SendLocalizedMessage(
killer?.SendLocalizedMessage(
1042231); // You have recently defeated this enemy and thus their death brings you no honor.
}
}
@ -1284,9 +1242,7 @@ namespace Server.Factions
AddResponse("They have been kicked from their faction.");
}
else
{
LogFailure("They are not in a faction.");
}
break;
}
@ -1300,9 +1256,7 @@ namespace Server.Factions
AddResponse("The account has been banned from joining factions.");
}
else
{
AddResponse("The account is already banned from joining factions.");
}
for (int i = 0; i < acct.Length; ++i)
{
@ -1322,9 +1276,7 @@ namespace Server.Factions
}
}
else
{
LogFailure("They have no assigned account.");
}
break;
}
@ -1333,9 +1285,7 @@ namespace Server.Factions
if (mob.Account is Account acct)
{
if (acct.GetTag("FactionBanned") == null)
{
AddResponse("The account is not already banned from joining factions.");
}
else
{
acct.RemoveTag("FactionBanned");
@ -1343,9 +1293,7 @@ namespace Server.Factions
}
}
else
{
LogFailure("They have no assigned account.");
}
break;
}

View file

@ -260,9 +260,7 @@ namespace Server.Factions
public void OnGivenSilverTo(Mobile mob)
{
if (SilverGiven == null)
SilverGiven = new List<SilverGivenEntry>();
SilverGiven ??= new List<SilverGivenEntry>();
SilverGiven.Add(new SilverGivenEntry(mob));
}

View file

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
@ -41,9 +42,7 @@ namespace Server
if (chance > Utility.Random(100))
{
int weight = 0;
foreach (WeightedItem item in _items) weight += item.Weight;
int weight = _items.Sum(item => item.Weight);
weight = Utility.Random(weight);
@ -177,4 +176,4 @@ namespace Server
public Item Construct() => Activator.CreateInstance(Type) as Item;
}
}
}
}

View file

@ -25,7 +25,9 @@ namespace Server
bool used = false;
foreach (Mobile mob in from.GetMobilesInRange(8))
IPooledEnumerable eable = from.GetMobilesInRange(8);
foreach (Mobile mob in eable)
if (mob.Player && !mob.Alive && from.InLOS(mob))
{
if (Faction.Find(mob) != ourFaction) continue;
@ -41,6 +43,8 @@ namespace Server
}
}
eable.Free();
if (used)
{
from.LocalOverheadMessage(MessageType.Regular, 2219, false, "The urn shatters as you invoke its power.");

View file

@ -113,10 +113,15 @@ namespace Server.Factions
return 502956; // You cannot place a trap on that.
if (Core.ML)
foreach (Item item in m.GetItemsInRange(p, 0))
{
IPooledEnumerable eable = m.GetItemsInRange(p, 0);
foreach (Item item in eable)
if (item is BaseFactionTrap trap && trap.Faction == Faction)
return 1075263; // There is already a trap belonging to your faction at this location.;
eable.Free();
}
switch (AllowedPlacing)
{
case AllowedPlacing.FactionStronghold:
@ -129,22 +134,12 @@ namespace Server.Factions
return 1010355; // This trap can only be placed in your stronghold
}
case AllowedPlacing.AnyFactionTown:
{
Town town = Town.FromRegion(Region.Find(p, m));
if (town != null)
return 0;
return 1010356; // This trap can only be placed in a faction town
}
return Town.FromRegion(Region.Find(p, m)) != null ? 0 : 1010356;
case AllowedPlacing.ControlledFactionTown:
{
Town town = Town.FromRegion(Region.Find(p, m));
if (town != null && town.Owner == Faction)
return 0;
return 1010357; // This trap can only be placed in a town your faction controls
return town != null && town.Owner == Faction ? 0 : 1010357;
}
}
@ -155,17 +150,16 @@ namespace Server.Factions
{
base.OnMovement(m, oldLocation);
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6))
if (Faction.Find(m) != null &&
(m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6) &&
Faction.Find(m) != null && (m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
}
public void PrivateOverheadLocalizedMessage(Mobile to, int number, int hue, string name, string args)
{
NetState ns = to?.NetState;
ns?.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, hue, 3, number, name, args));
Packets.SendMessageLocalized(ns, Serial, ItemID, MessageType.Regular, hue, 3, number, name, args);
}
public virtual bool CheckDecay()
@ -252,10 +246,7 @@ namespace Server.Factions
if (faction == null && mob is BaseFactionGuard guard)
faction = guard.Faction;
if (faction == null)
return false;
return faction != Faction;
return faction != null && faction != Faction;
}
}
}

View file

@ -23,7 +23,7 @@ namespace Server.Factions
public override void DoVisibleEffect()
{
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x36BD, 15, 10);
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x36BD, 15);
}
public override void DoAttackEffect(Mobile m)

View file

@ -8,6 +8,10 @@ namespace Server.Factions
{
}
public FactionSawTrap(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1041047; // faction saw trap
public override int AttackMessage => 1010544; // The blade cuts deep into your skin!
@ -19,7 +23,7 @@ namespace Server.Factions
public override void DoVisibleEffect()
{
Effects.SendLocationEffect(Location, Map, 0x11AD, 25, 10);
Effects.SendLocationEffect(Location, Map, 0x11AD, 25);
}
public override void DoAttackEffect(Mobile m)

View file

@ -313,7 +313,9 @@ namespace Server.Factions
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb);
}
foreach (Mobile m in m_Mobile.GetMobilesInRange(12))
IPooledEnumerable eable = m_Mobile.GetMobilesInRange(12);
foreach (Mobile m in eable)
if (m != m_Mobile && CanDispel(m))
{
double prio = m_Mobile.GetDistanceToSqrt(m);
@ -331,6 +333,8 @@ namespace Server.Factions
}
}
eable.Free();
return active ?? inactive;
}