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:
parent
7aa8fd3df1
commit
179cb50557
588 changed files with 10843 additions and 16177 deletions
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
|
@ -259,7 +258,7 @@ namespace Server.Multis
|
|||
}
|
||||
|
||||
int xOffset = 0, yOffset = 0;
|
||||
Movement.Movement.Offset(m_Facing, ref xOffset, ref yOffset);
|
||||
Movement.Offset(m_Facing, ref xOffset, ref yOffset);
|
||||
|
||||
if (TillerMan != null)
|
||||
{
|
||||
|
|
@ -1458,11 +1457,10 @@ namespace Server.Multis
|
|||
else
|
||||
{
|
||||
List<IEntity> toMove = GetMovingEntities();
|
||||
|
||||
SafeAdd(TillerMan, toMove);
|
||||
SafeAdd(Hold, toMove);
|
||||
SafeAdd(PPlank, toMove);
|
||||
SafeAdd(SPlank, toMove);
|
||||
if (TillerMan != null) toMove.Add(TillerMan);
|
||||
if (Hold != null) toMove.Add(Hold);
|
||||
if (PPlank != null) toMove.Add(PPlank);
|
||||
if (SPlank != null) toMove.Add(SPlank);
|
||||
|
||||
// Packet must be sent before actual locations are changed
|
||||
foreach (NetState ns in Map.GetClientsInRange(Location, GetMaxUpdateRange()))
|
||||
|
|
@ -1470,7 +1468,7 @@ namespace Server.Multis
|
|||
Mobile m = ns.Mobile;
|
||||
|
||||
if (ns.HighSeas && m.CanSee(this) && m.InRange(Location, GetUpdateRange(m)))
|
||||
ns.Send(new MoveBoatHS(m, this, d, clientSpeed, toMove, xOffset, yOffset));
|
||||
BoatPackets.SendMoveBoatHS(ns, m, this, d, clientSpeed, toMove, xOffset, yOffset);
|
||||
}
|
||||
|
||||
foreach (IEntity e in toMove)
|
||||
|
|
@ -1502,12 +1500,6 @@ namespace Server.Multis
|
|||
return true;
|
||||
}
|
||||
|
||||
private static void SafeAdd(Item item, List<IEntity> toMove)
|
||||
{
|
||||
if (item != null)
|
||||
toMove.Add(item);
|
||||
}
|
||||
|
||||
public void Teleport(int xOffset, int yOffset, int zOffset)
|
||||
{
|
||||
List<IEntity> toMove = GetMovingEntities();
|
||||
|
|
@ -1534,9 +1526,9 @@ namespace Server.Multis
|
|||
return list;
|
||||
|
||||
MultiComponentList mcl = Components;
|
||||
IPooledEnumerable eable = map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height));
|
||||
|
||||
foreach (IEntity o in map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height))
|
||||
)
|
||||
foreach (IEntity o in eable)
|
||||
{
|
||||
if (o == this || o is TillerMan || o is Hold || o is Plank)
|
||||
continue;
|
||||
|
|
@ -1553,6 +1545,8 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
@ -1595,11 +1589,11 @@ namespace Server.Multis
|
|||
|
||||
List<IEntity> toMove = GetMovingEntities();
|
||||
|
||||
toMove.Add(PPlank);
|
||||
toMove.Add(SPlank);
|
||||
if (PPlank != null) toMove.Add(PPlank);
|
||||
if (SPlank != null) toMove.Add(SPlank);
|
||||
|
||||
int xOffset = 0, yOffset = 0;
|
||||
Movement.Movement.Offset(facing, ref xOffset, ref yOffset);
|
||||
Movement.Offset(facing, ref xOffset, ref yOffset);
|
||||
|
||||
if (TillerMan != null)
|
||||
TillerMan.Location = new Point3D(X + xOffset * TillerManDistance + (facing == Direction.North ? 1 : 0),
|
||||
|
|
@ -1616,9 +1610,7 @@ namespace Server.Multis
|
|||
IEntity e = toMove[i];
|
||||
|
||||
if (e is Item item)
|
||||
{
|
||||
item.Location = Rotate(item.Location, count);
|
||||
}
|
||||
else if (e is Mobile m)
|
||||
{
|
||||
m.Direction = m.Direction - old + facing & Direction.Mask;
|
||||
|
|
@ -1734,8 +1726,6 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
#region High Seas
|
||||
|
||||
public override bool AllowsRelativeDrop => true;
|
||||
|
||||
/*
|
||||
|
|
@ -1753,137 +1743,5 @@ namespace Server.Multis
|
|||
return base.GetWorldPacketFor( state );
|
||||
}
|
||||
*/
|
||||
|
||||
public sealed class MoveBoatHS : Packet
|
||||
{
|
||||
public MoveBoatHS(Mobile beholder, BaseBoat boat, Direction d, int speed, List<IEntity> ents, int xOffset,
|
||||
int yOffset)
|
||||
: base(0xF6)
|
||||
{
|
||||
EnsureCapacity(3 + 15 + ents.Count * 10);
|
||||
|
||||
m_Stream.Write(boat.Serial);
|
||||
m_Stream.Write((byte)speed);
|
||||
m_Stream.Write((byte)d);
|
||||
m_Stream.Write((byte)boat.Facing);
|
||||
m_Stream.Write((short)(boat.X + xOffset));
|
||||
m_Stream.Write((short)(boat.Y + yOffset));
|
||||
m_Stream.Write((short)boat.Z);
|
||||
m_Stream.Write((short)0); // count placeholder
|
||||
|
||||
int count = 0;
|
||||
|
||||
foreach (IEntity ent in ents)
|
||||
{
|
||||
if (!beholder.CanSee(ent))
|
||||
continue;
|
||||
|
||||
m_Stream.Write(ent.Serial);
|
||||
m_Stream.Write((short)(ent.X + xOffset));
|
||||
m_Stream.Write((short)(ent.Y + yOffset));
|
||||
m_Stream.Write((short)ent.Z);
|
||||
++count;
|
||||
}
|
||||
|
||||
m_Stream.Seek(16, SeekOrigin.Begin);
|
||||
m_Stream.Write((short)count);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DisplayBoatHS : Packet
|
||||
{
|
||||
public DisplayBoatHS(Mobile beholder, BaseBoat boat)
|
||||
: base(0xF7)
|
||||
{
|
||||
List<IEntity> ents = boat.GetMovingEntities();
|
||||
|
||||
SafeAdd(boat.TillerMan, ents);
|
||||
SafeAdd(boat.Hold, ents);
|
||||
SafeAdd(boat.PPlank, ents);
|
||||
SafeAdd(boat.SPlank, ents);
|
||||
|
||||
ents.Add(boat);
|
||||
|
||||
EnsureCapacity(3 + 2 + ents.Count * 26);
|
||||
|
||||
m_Stream.Write((short)0); // count placeholder
|
||||
|
||||
int count = 0;
|
||||
|
||||
foreach (IEntity ent in ents)
|
||||
{
|
||||
if (!beholder.CanSee(ent))
|
||||
continue;
|
||||
|
||||
// Embedded WorldItemHS packets
|
||||
m_Stream.Write((byte)0xF3);
|
||||
m_Stream.Write((short)0x1);
|
||||
|
||||
if (ent is BaseMulti bm)
|
||||
{
|
||||
m_Stream.Write((byte)0x02);
|
||||
m_Stream.Write(bm.Serial);
|
||||
// TODO: Mask no longer needed, merge with Item case?
|
||||
m_Stream.Write((ushort)(bm.ItemID & 0x3FFF));
|
||||
m_Stream.Write((byte)0);
|
||||
|
||||
m_Stream.Write((short)bm.Amount);
|
||||
m_Stream.Write((short)bm.Amount);
|
||||
|
||||
m_Stream.Write((short)(bm.X & 0x7FFF));
|
||||
m_Stream.Write((short)(bm.Y & 0x3FFF));
|
||||
m_Stream.Write((sbyte)bm.Z);
|
||||
|
||||
m_Stream.Write((byte)bm.Light);
|
||||
m_Stream.Write((short)bm.Hue);
|
||||
m_Stream.Write((byte)bm.GetPacketFlags());
|
||||
}
|
||||
else if (ent is Mobile m)
|
||||
{
|
||||
m_Stream.Write((byte)0x01);
|
||||
m_Stream.Write(m.Serial);
|
||||
m_Stream.Write((short)m.Body);
|
||||
m_Stream.Write((byte)0);
|
||||
|
||||
m_Stream.Write((short)1);
|
||||
m_Stream.Write((short)1);
|
||||
|
||||
m_Stream.Write((short)(m.X & 0x7FFF));
|
||||
m_Stream.Write((short)(m.Y & 0x3FFF));
|
||||
m_Stream.Write((sbyte)m.Z);
|
||||
|
||||
m_Stream.Write((byte)m.Direction);
|
||||
m_Stream.Write((short)m.Hue);
|
||||
m_Stream.Write((byte)m.GetPacketFlags());
|
||||
}
|
||||
else if (ent is Item item)
|
||||
{
|
||||
m_Stream.Write((byte)0x00);
|
||||
m_Stream.Write(item.Serial);
|
||||
m_Stream.Write((ushort)(item.ItemID & 0xFFFF));
|
||||
m_Stream.Write((byte)0);
|
||||
|
||||
m_Stream.Write((short)item.Amount);
|
||||
m_Stream.Write((short)item.Amount);
|
||||
|
||||
m_Stream.Write((short)(item.X & 0x7FFF));
|
||||
m_Stream.Write((short)(item.Y & 0x3FFF));
|
||||
m_Stream.Write((sbyte)item.Z);
|
||||
|
||||
m_Stream.Write((byte)item.Light);
|
||||
m_Stream.Write((short)item.Hue);
|
||||
m_Stream.Write((byte)item.GetPacketFlags());
|
||||
}
|
||||
|
||||
m_Stream.Write((short)0x00);
|
||||
++count;
|
||||
}
|
||||
|
||||
m_Stream.Seek(3, SeekOrigin.Begin);
|
||||
m_Stream.Write((short)count);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Server.Multis
|
|||
AddButton(20, 125, 4005, 4007, 1);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 2)
|
||||
m_Boat.EndDryDock(m_From);
|
||||
|
|
|
|||
127
Projects/Scripts/Multis/Boats/Packets.cs
Normal file
127
Projects/Scripts/Multis/Boats/Packets.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
using System.Collections.Generic;
|
||||
using Server.Buffers;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public static class BoatPackets
|
||||
{
|
||||
public static void SendMoveBoatHS(NetState ns, Mobile beholder, BaseBoat boat, Direction d, int speed,
|
||||
IReadOnlyCollection<IEntity> ents, int xOffset,
|
||||
int yOffset)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
int length = 18 + ents.Count * 10;
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0xF6); // Packet ID
|
||||
writer.Position += 2; // Dynamic Length
|
||||
|
||||
writer.Write(boat.Serial);
|
||||
writer.Write((byte)speed);
|
||||
writer.Write((byte)d);
|
||||
writer.Write((byte)boat.Facing);
|
||||
writer.Write((short)(boat.X + xOffset));
|
||||
writer.Write((short)(boat.Y + yOffset));
|
||||
writer.Write((short)boat.Z);
|
||||
writer.Position += 2; // count
|
||||
|
||||
ushort count = 0;
|
||||
foreach (IEntity ent in ents)
|
||||
{
|
||||
if (!beholder.CanSee(ent))
|
||||
continue;
|
||||
|
||||
writer.Write(ent.Serial);
|
||||
writer.Write((short)(ent.X + xOffset));
|
||||
writer.Write((short)(ent.Y + yOffset));
|
||||
writer.Write((short)ent.Z);
|
||||
count++;
|
||||
}
|
||||
|
||||
writer.Position = 16;
|
||||
writer.Write(count);
|
||||
writer.Position = 1;
|
||||
writer.Write((ushort)writer.WrittenCount);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public static void SendDisplayBoatHS(NetState ns, Mobile beholder, BaseBoat boat)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
List<IEntity> ents = boat.GetMovingEntities();
|
||||
if (boat.TillerMan != null) ents.Add(boat.TillerMan);
|
||||
if (boat.Hold != null) ents.Add(boat.Hold);
|
||||
if (boat.PPlank != null) ents.Add(boat.PPlank);
|
||||
if (boat.SPlank != null) ents.Add(boat.SPlank);
|
||||
ents.Add(boat);
|
||||
|
||||
int length = 5 + ents.Count * 26;
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0xF7); // Packet ID
|
||||
writer.Position += 4; // Dynamic Length & Count
|
||||
|
||||
ushort count = 0;
|
||||
|
||||
foreach (IEntity ent in ents)
|
||||
{
|
||||
if (!beholder.CanSee(ent))
|
||||
continue;
|
||||
|
||||
writer.Write((byte)0xF3);
|
||||
writer.Write((short)0x1);
|
||||
|
||||
if (ent is Mobile m)
|
||||
{
|
||||
writer.Write((byte)0x01);
|
||||
writer.Write(m.Serial);
|
||||
writer.Write((short)m.Body);
|
||||
writer.Position++;
|
||||
|
||||
writer.Write((short)1);
|
||||
writer.Write((short)1);
|
||||
|
||||
writer.Write((short)(m.X & 0x7FFF));
|
||||
writer.Write((short)(m.Y & 0x3FFF));
|
||||
writer.Write((sbyte)m.Z);
|
||||
|
||||
writer.Write((byte)m.Direction);
|
||||
writer.Write((short)m.Hue);
|
||||
writer.Write((byte)m.GetPacketFlags());
|
||||
}
|
||||
else if (ent is Item item)
|
||||
{
|
||||
writer.Position++;
|
||||
writer.Write(item.Serial);
|
||||
writer.Write((ushort)(item.ItemID & 0xFFFF));
|
||||
writer.Position++;
|
||||
|
||||
writer.Write((short)item.Amount);
|
||||
writer.Write((short)item.Amount);
|
||||
|
||||
writer.Write((short)(item.X & 0x7FFF));
|
||||
writer.Write((short)(item.Y & 0x3FFF));
|
||||
writer.Write((sbyte)item.Z);
|
||||
|
||||
writer.Write((byte)item.Light);
|
||||
writer.Write((short)item.Hue);
|
||||
writer.Write((byte)item.GetPacketFlags());
|
||||
}
|
||||
|
||||
writer.Position += 2;
|
||||
count++;
|
||||
}
|
||||
|
||||
writer.Position = 3;
|
||||
writer.Write(count);
|
||||
writer.Position = 1;
|
||||
writer.Write((ushort)writer.WrittenCount);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
using Server.Prompts;
|
||||
|
||||
namespace Server.Multis
|
||||
{
|
||||
public class RenameBoatPrompt : Prompt
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ namespace Server.Misc
|
|||
if (map == null)
|
||||
return false;
|
||||
|
||||
object surface = map.GetTopSurface(from.Location);
|
||||
ITile surface = map.GetTopSurface(from.Location);
|
||||
|
||||
if (surface is LandTile tile)
|
||||
{
|
||||
|
|
@ -175,4 +175,4 @@ namespace Server.Misc
|
|||
from.Location = new Point3D(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Server.Multis
|
|||
{
|
||||
public class DynamicDecay
|
||||
{
|
||||
private static Dictionary<DecayLevel, DecayStageInfo> m_Stages;
|
||||
private static readonly Dictionary<DecayLevel, DecayStageInfo> m_Stages;
|
||||
|
||||
static DynamicDecay()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Server.Multis
|
|||
|
||||
public const int MaximumBarkeepCount = 2;
|
||||
|
||||
private static Dictionary<Mobile, List<BaseHouse>> m_Table = new Dictionary<Mobile, List<BaseHouse>>();
|
||||
private static readonly Dictionary<Mobile, List<BaseHouse>> m_Table = new Dictionary<Mobile, List<BaseHouse>>();
|
||||
|
||||
private DecayLevel m_LastDecayLevel;
|
||||
|
||||
|
|
@ -148,10 +148,7 @@ namespace Server.Multis
|
|||
newest = check;
|
||||
}
|
||||
|
||||
if (this == newest)
|
||||
return DecayType.AutoRefresh;
|
||||
|
||||
return DecayType.ManualRefresh;
|
||||
return this == newest ? DecayType.AutoRefresh : DecayType.ManualRefresh;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,43 +215,13 @@ namespace Server.Multis
|
|||
|
||||
public virtual bool IsActive => true;
|
||||
|
||||
public bool HasPersonalVendors
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (PlayerVendor vendor in PlayerVendors)
|
||||
if (!(vendor is RentedVendor))
|
||||
return true;
|
||||
public bool HasPersonalVendors => PlayerVendors.Any(vendor => !(vendor is RentedVendor));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasRentedVendors
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (PlayerVendor vendor in PlayerVendors)
|
||||
if (vendor is RentedVendor)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool HasRentedVendors => PlayerVendors.OfType<RentedVendor>().Any();
|
||||
|
||||
#region Mondain's Legacy
|
||||
|
||||
public bool HasAddonContainers
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (Item item in Addons)
|
||||
if (item is BaseAddonContainer)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool HasAddonContainers => Addons.OfType<BaseAddonContainer>().Any();
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -364,9 +331,7 @@ namespace Server.Multis
|
|||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
count += GetLockdowns();
|
||||
int count = GetLockdowns();
|
||||
|
||||
if (Secures != null)
|
||||
for (int i = 0; i < Secures.Count; ++i)
|
||||
|
|
@ -385,26 +350,7 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
public int SecureCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (Secures != null)
|
||||
for (int i = 0; i < Secures.Count; i++)
|
||||
{
|
||||
SecureInfo info = Secures[i];
|
||||
|
||||
if (info.Item.Deleted)
|
||||
continue;
|
||||
if (!(info.Item is StrongBox))
|
||||
count += 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
public int SecureCount => Secures?.Where(info => !info.Item.Deleted).Count(info => !(info.Item is StrongBox)) ?? 0;
|
||||
|
||||
public List<Item> Addons{ get; set; }
|
||||
|
||||
|
|
@ -542,11 +488,9 @@ namespace Server.Multis
|
|||
{
|
||||
HousePlacementEntry hpe = GetAosEntry();
|
||||
|
||||
if (hpe == null)
|
||||
return 0;
|
||||
public virtual int GetAosMaxSecures() => (int)(GetAosEntry()?.Storage ?? 0 * BonusStorageScalar);
|
||||
|
||||
return (int)(hpe.Lockdowns * BonusStorageScalar);
|
||||
}
|
||||
public virtual int GetAosMaxLockdowns() => (int)(GetAosEntry()?.Lockdowns ?? 0 * BonusStorageScalar);
|
||||
|
||||
public virtual int GetAosCurSecures(out int fromSecures, out int fromVendors, out int fromLockdowns,
|
||||
out int fromMovingCrate)
|
||||
|
|
@ -560,22 +504,14 @@ namespace Server.Multis
|
|||
|
||||
if (list != null)
|
||||
{
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
SecureInfo si = list[i];
|
||||
|
||||
fromSecures += si.Item.TotalItems;
|
||||
}
|
||||
|
||||
fromSecures += list.Sum(si => si.Item.TotalItems);
|
||||
fromLockdowns += list.Count;
|
||||
}
|
||||
|
||||
fromLockdowns += GetLockdowns();
|
||||
|
||||
if (!NewVendorSystem)
|
||||
foreach (PlayerVendor vendor in PlayerVendors)
|
||||
if (vendor.Backpack != null)
|
||||
fromVendors += vendor.Backpack.TotalItems;
|
||||
fromVendors += PlayerVendors.Where(vendor => vendor.Backpack != null).Sum(vendor => vendor.Backpack.TotalItems);
|
||||
|
||||
if (MovingCrate != null)
|
||||
{
|
||||
|
|
@ -589,18 +525,17 @@ namespace Server.Multis
|
|||
return fromSecures + fromVendors + fromLockdowns + fromMovingCrate;
|
||||
}
|
||||
|
||||
public bool InRange(IPoint2D from, int range)
|
||||
{
|
||||
if (Region == null)
|
||||
return false;
|
||||
public bool InRange(IPoint2D from, int range) =>
|
||||
Region?.Area.Any(rect =>
|
||||
from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range)
|
||||
== true;
|
||||
|
||||
foreach (Rectangle3D rect in Region.Area)
|
||||
if (from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range &&
|
||||
from.Y < rect.End.Y + range)
|
||||
return true;
|
||||
public virtual int GetNewVendorSystemMaxVendors() =>
|
||||
(int)(GetAosEntry()?.Vendors ?? 0 * BonusStorageScalar);
|
||||
|
||||
return false;
|
||||
}
|
||||
public virtual bool CanPlaceNewVendor() =>
|
||||
!IsAosRules || (!NewVendorSystem ? CheckAosLockdowns(10) :
|
||||
PlayerVendors.Count + VendorRentalContracts.Count < GetNewVendorSystemMaxVendors());
|
||||
|
||||
public virtual int GetNewVendorSystemMaxVendors()
|
||||
{
|
||||
|
|
@ -651,25 +586,11 @@ namespace Server.Multis
|
|||
eable.Free();
|
||||
}
|
||||
|
||||
public List<Mobile> AvailableVendorsFor(Mobile m)
|
||||
{
|
||||
List<Mobile> list = new List<Mobile>();
|
||||
public List<Mobile> AvailableVendorsFor(Mobile m) =>
|
||||
PlayerVendors.Where(vendor => vendor.CanInteractWith(m, false)).Cast<Mobile>().ToList();
|
||||
|
||||
foreach (PlayerVendor vendor in PlayerVendors)
|
||||
if (vendor.CanInteractWith(m, false))
|
||||
list.Add(vendor);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool AreThereAvailableVendorsFor(Mobile m)
|
||||
{
|
||||
foreach (PlayerVendor vendor in PlayerVendors)
|
||||
if (vendor.CanInteractWith(m, false))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool AreThereAvailableVendorsFor(Mobile m) =>
|
||||
PlayerVendors.Any(vendor => vendor.CanInteractWith(m, false));
|
||||
|
||||
public void MoveAllToCrate()
|
||||
{
|
||||
|
|
@ -696,7 +617,7 @@ namespace Server.Multis
|
|||
|
||||
LockDowns.Clear();
|
||||
|
||||
foreach (Item item in VendorRentalContracts)
|
||||
foreach (VendorRentalContract item in VendorRentalContracts)
|
||||
if (!item.Deleted)
|
||||
{
|
||||
item.IsLockedDown = false;
|
||||
|
|
@ -811,25 +732,10 @@ namespace Server.Multis
|
|||
if (m_Trash != null && m_Trash.Map != Map.Internal)
|
||||
list.Add(m_Trash);
|
||||
|
||||
foreach (Item item in LockDowns)
|
||||
if (item.Parent == null && item.Map != Map.Internal)
|
||||
list.Add(item);
|
||||
|
||||
foreach (Item item in VendorRentalContracts)
|
||||
if (item.Parent == null && item.Map != Map.Internal)
|
||||
list.Add(item);
|
||||
|
||||
foreach (SecureInfo info in Secures)
|
||||
{
|
||||
Item item = info.Item;
|
||||
|
||||
if (item.Parent == null && item.Map != Map.Internal)
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
foreach (Item item in Addons)
|
||||
if (item.Parent == null && item.Map != Map.Internal)
|
||||
list.Add(item);
|
||||
list.AddRange(LockDowns.Where(item => item.Parent == null && item.Map != Map.Internal));
|
||||
list.AddRange(VendorRentalContracts.Cast<Item>().Where(item => item.Parent == null && item.Map != Map.Internal));
|
||||
list.AddRange(Secures.Select(info => info.Item).Where(item => item.Parent == null && item.Map != Map.Internal));
|
||||
list.AddRange(Addons.Where(item => item.Parent == null && item.Map != Map.Internal));
|
||||
|
||||
foreach (PlayerVendor mobile in PlayerVendors)
|
||||
{
|
||||
|
|
@ -839,9 +745,7 @@ namespace Server.Multis
|
|||
list.Add(mobile);
|
||||
}
|
||||
|
||||
foreach (Mobile mobile in PlayerBarkeepers)
|
||||
if (mobile.Map != Map.Internal)
|
||||
list.Add(mobile);
|
||||
list.AddRange(PlayerBarkeepers.Cast<Mobile>().Where(mobile => mobile.Map != Map.Internal));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -908,9 +812,7 @@ namespace Server.Multis
|
|||
// The item can't fit
|
||||
|
||||
if (item is TrashBarrel)
|
||||
{
|
||||
item.Delete(); // Trash barrels don't go to the moving crate
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLockdown(item, false);
|
||||
|
|
@ -995,9 +897,7 @@ namespace Server.Multis
|
|||
|
||||
public void DropToMovingCrate(Item item)
|
||||
{
|
||||
if (MovingCrate == null)
|
||||
MovingCrate = new MovingCrate(this);
|
||||
|
||||
MovingCrate ??= new MovingCrate(this);
|
||||
MovingCrate.DropItem(item);
|
||||
}
|
||||
|
||||
|
|
@ -1018,12 +918,11 @@ namespace Server.Multis
|
|||
return list;
|
||||
}
|
||||
|
||||
public List<Mobile> GetMobiles()
|
||||
{
|
||||
if (Map == null || Map == Map.Internal)
|
||||
return new List<Mobile>();
|
||||
public List<Mobile> GetMobiles() =>
|
||||
Map == null || Map == Map.Internal ? new List<Mobile>()
|
||||
: Region.GetMobiles().Where(IsInside).ToList();
|
||||
|
||||
List<Mobile> list = new List<Mobile>();
|
||||
public virtual bool CheckAosLockdowns(int need) => GetAosCurLockdowns() + need <= GetAosMaxLockdowns();
|
||||
|
||||
foreach (Mobile mobile in Region.GetMobiles())
|
||||
if (IsInside(mobile))
|
||||
|
|
@ -1046,14 +945,9 @@ namespace Server.Multis
|
|||
Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), Decay_OnTick);
|
||||
}
|
||||
|
||||
public virtual int GetAosCurLockdowns()
|
||||
{
|
||||
int v = 0;
|
||||
public virtual int GetAosCurLockdowns() => GetLockdowns() + Secures?.Count ?? 0 + (NewVendorSystem ? 0 : PlayerVendors.Count * 10);
|
||||
|
||||
v += GetLockdowns();
|
||||
|
||||
if (Secures != null)
|
||||
v += Secures.Count;
|
||||
public static bool CheckLockedDown(Item item) => FindHouseAt(item)?.HasLockedDownItem(item) == true;
|
||||
|
||||
if (!NewVendorSystem)
|
||||
v += PlayerVendors.Count * 10;
|
||||
|
|
@ -1114,31 +1008,15 @@ namespace Server.Multis
|
|||
|
||||
BaseHouse house = FindHouseAt(item);
|
||||
|
||||
if (house == null)
|
||||
return true;
|
||||
|
||||
SecureAccessResult res = house.CheckSecureAccess(m, item);
|
||||
|
||||
switch (res)
|
||||
return house == null || house.CheckSecureAccess(m, item) switch
|
||||
{
|
||||
case SecureAccessResult.Insecure: break;
|
||||
case SecureAccessResult.Accessible: return true;
|
||||
case SecureAccessResult.Inaccessible: return false;
|
||||
}
|
||||
|
||||
if (house.HasLockedDownItem(item))
|
||||
return house.IsCoOwner(m) && item is Container;
|
||||
|
||||
return true;
|
||||
SecureAccessResult.Accessible => true,
|
||||
SecureAccessResult.Inaccessible => false,
|
||||
_ => (!house.HasLockedDownItem(item) || house.IsCoOwner(m) && item is Container)
|
||||
};
|
||||
}
|
||||
|
||||
public static BaseHouse FindHouseAt(Mobile m)
|
||||
{
|
||||
if (m?.Deleted != false)
|
||||
return null;
|
||||
|
||||
return FindHouseAt(m.Location, m.Map, 16);
|
||||
}
|
||||
public static BaseHouse FindHouseAt(Mobile m) => m?.Deleted != false ? null : FindHouseAt(m.Location, m.Map, 16);
|
||||
|
||||
public static BaseHouse FindHouseAt(Item item) =>
|
||||
item?.Deleted != false ? null :
|
||||
|
|
@ -1168,7 +1046,7 @@ namespace Server.Multis
|
|||
|
||||
switch (res)
|
||||
{
|
||||
case SecureAccessResult.Insecure: break;
|
||||
// case SecureAccessResult.Insecure: break;
|
||||
case SecureAccessResult.Accessible: return true;
|
||||
case SecureAccessResult.Inaccessible: return false;
|
||||
}
|
||||
|
|
@ -1185,28 +1063,21 @@ namespace Server.Multis
|
|||
return IsCoOwner(from);
|
||||
if (item.Stackable)
|
||||
return true;
|
||||
if (item is BaseLight)
|
||||
return IsFriend(from);
|
||||
if (item is PotionKeg)
|
||||
return IsFriend(from);
|
||||
if (item is Dices)
|
||||
return true;
|
||||
if (item is RecallRune)
|
||||
return true;
|
||||
if (item is TreasureMap)
|
||||
return true;
|
||||
if (item is Clock)
|
||||
return true;
|
||||
if (item is BaseInstrument)
|
||||
return true;
|
||||
if (item is Dyes)
|
||||
return true;
|
||||
if (item is VendorRentalContract)
|
||||
return true;
|
||||
if (item is RewardBrazier)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return item switch
|
||||
{
|
||||
BaseLight _ => IsFriend(from),
|
||||
PotionKeg _ => IsFriend(from),
|
||||
Dices _ => true,
|
||||
RecallRune _ => true,
|
||||
TreasureMap _ => true,
|
||||
Clock _ => true,
|
||||
BaseInstrument _ => true,
|
||||
Dyes _ => true,
|
||||
VendorRentalContract _ => true,
|
||||
RewardBrazier _ => true,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
public virtual bool IsInside(Point3D p, int height)
|
||||
|
|
@ -1491,9 +1362,11 @@ namespace Server.Multis
|
|||
m_Trash = new TrashBarrel { Movable = false };
|
||||
m_Trash.MoveToWorld(from.Location, from.Map);
|
||||
|
||||
from.SendLocalizedMessage(502121); /* You have a new trash barrel.
|
||||
* Three minutes after you put something in the barrel, the trash will be emptied.
|
||||
* Be forewarned, this is permanent! */
|
||||
from.SendLocalizedMessage(502121);
|
||||
/* You have a new trash barrel.
|
||||
* Three minutes after you put something in the barrel, the trash will be emptied.
|
||||
* Be forewarned, this is permanent!
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1562,31 +1435,19 @@ namespace Server.Multis
|
|||
Item parentItem = item.Parent as Item;
|
||||
|
||||
if (checkIsInside && item.RootParent is Mobile)
|
||||
{
|
||||
m.SendLocalizedMessage(1005525); //That is not in your house
|
||||
}
|
||||
else if (checkIsInside && !IsInside(item.GetWorldLocation(), item.ItemData.Height))
|
||||
{
|
||||
m.SendLocalizedMessage(1005525); //That is not in your house
|
||||
}
|
||||
else if (Ethic.IsImbued(item))
|
||||
{
|
||||
m.SendLocalizedMessage(1005377); //You cannot lock that down
|
||||
}
|
||||
else if (HasSecureItem(rootItem))
|
||||
{
|
||||
m.SendLocalizedMessage(501737); // You need not lock down items in a secure container.
|
||||
}
|
||||
else if (parentItem != null && !HasLockedDownItem(parentItem))
|
||||
{
|
||||
m.SendLocalizedMessage(501736); // You must lockdown the container first!
|
||||
}
|
||||
else if (!(item is VendorRentalContract) && (IsAosRules
|
||||
? !CheckAosLockdowns(amt) || !CheckAosStorage(amt)
|
||||
: LockDownCount + amt > MaxLockDowns))
|
||||
{
|
||||
m.SendLocalizedMessage(1005379); //That would exceed the maximum lock down limit for this house
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLockdown(item, true);
|
||||
|
|
@ -1599,13 +1460,9 @@ namespace Server.Multis
|
|||
return true;
|
||||
}
|
||||
else if (item is HouseSign || item is Static)
|
||||
{
|
||||
m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1005526); // This is already locked down.
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendLocalizedMessage(1005377); //You cannot lock that down
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1644,25 +1501,17 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (NewVendorSystem && HasPersonalVendors)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062467); // You cannot trade this house while you still have personal vendors inside.
|
||||
}
|
||||
else if (DecayLevel == DecayLevel.DemolitionPending)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1005321); // This house has been marked for demolition, and it cannot be transferred.
|
||||
}
|
||||
else if (from == to)
|
||||
{
|
||||
from.SendLocalizedMessage(1005330); // You cannot transfer a house to yourself, silly.
|
||||
}
|
||||
else if (to.Player)
|
||||
{
|
||||
if (HasAccountHouse(to))
|
||||
{
|
||||
from.SendLocalizedMessage(501388); // You cannot transfer ownership to another house owner or co-owner!
|
||||
}
|
||||
else if (CheckTransferPosition(from, to))
|
||||
{
|
||||
from.SendLocalizedMessage(1005326); // Please wait while the other player verifies the transfer.
|
||||
|
|
@ -1709,25 +1558,17 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (NewVendorSystem && HasPersonalVendors)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062467); // You cannot trade this house while you still have personal vendors inside.
|
||||
}
|
||||
else if (DecayLevel == DecayLevel.DemolitionPending)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1005321); // This house has been marked for demolition, and it cannot be transferred.
|
||||
}
|
||||
else if (from == to)
|
||||
{
|
||||
from.SendLocalizedMessage(1005330); // You cannot transfer a house to yourself, silly.
|
||||
}
|
||||
else if (to.Player)
|
||||
{
|
||||
if (HasAccountHouse(to))
|
||||
{
|
||||
from.SendLocalizedMessage(501388); // You cannot transfer ownership to another house owner or co-owner!
|
||||
}
|
||||
else if (CheckTransferPosition(from, to))
|
||||
{
|
||||
NetState fromState = from.NetState, toState = to.NetState;
|
||||
|
|
@ -1735,20 +1576,14 @@ namespace Server.Multis
|
|||
if (fromState != null && toState != null)
|
||||
{
|
||||
if (from.HasTrade)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062071); // You cannot trade a house while you have other trades pending.
|
||||
}
|
||||
else if (to.HasTrade)
|
||||
{
|
||||
to.SendLocalizedMessage(
|
||||
1062071); // You cannot trade a house while you have other trades pending.
|
||||
}
|
||||
else if (!to.Alive)
|
||||
{
|
||||
// TODO: Check if the message is correct.
|
||||
from.SendLocalizedMessage(1062069); // You cannot transfer this house to that person.
|
||||
}
|
||||
else
|
||||
{
|
||||
Container c = fromState.AddTrade(toState);
|
||||
|
|
@ -1759,9 +1594,7 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(501384); // Only a player can own a house!
|
||||
}
|
||||
}
|
||||
|
||||
public void Release(Mobile m, Item item)
|
||||
|
|
@ -1778,13 +1611,9 @@ namespace Server.Multis
|
|||
(item as RewardBrazier)?.TurnOff();
|
||||
}
|
||||
else if (HasSecureItem(item))
|
||||
{
|
||||
ReleaseSecure(m, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1010416); // This is not locked down or secured.
|
||||
}
|
||||
}
|
||||
|
||||
public void AddSecure(Mobile m, Item item)
|
||||
|
|
@ -1793,17 +1622,11 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (!IsInside(item))
|
||||
{
|
||||
m.SendLocalizedMessage(1005525); // That is not in your house
|
||||
}
|
||||
else if (HasLockedDownItem(item))
|
||||
{
|
||||
m.SendLocalizedMessage(1010550); // This is already locked down and cannot be secured.
|
||||
}
|
||||
else if (!(item is Container))
|
||||
{
|
||||
LockDown(m, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
SecureInfo info = null;
|
||||
|
|
@ -1818,27 +1641,17 @@ namespace Server.Multis
|
|||
m.SendGump(new SetSecureLevelGump(m_Owner, info, this));
|
||||
}
|
||||
else if (item.Parent != null)
|
||||
{
|
||||
m.SendLocalizedMessage(1010423); // You cannot secure this, place it on the ground first.
|
||||
}
|
||||
// Mondain's Legacy mod
|
||||
else if (!(item is BaseAddonContainer) && !item.Movable)
|
||||
{
|
||||
m.SendLocalizedMessage(1010424); // You cannot secure this.
|
||||
}
|
||||
else if (!IsAosRules && SecureCount >= MaxSecures)
|
||||
{
|
||||
// The maximum number of secure items has been reached :
|
||||
m.SendLocalizedMessage(1008142, true, MaxSecures.ToString());
|
||||
}
|
||||
else if (IsAosRules ? !CheckAosLockdowns(1) : LockDownCount + 125 >= MaxLockDowns)
|
||||
{
|
||||
m.SendLocalizedMessage(1005379); // That would exceed the maximum lock down limit for this house
|
||||
}
|
||||
else if (IsAosRules && !CheckAosStorage(item.TotalItems))
|
||||
{
|
||||
m.SendLocalizedMessage(1061839); // This action would exceed the secure storage limit of the house.
|
||||
}
|
||||
else
|
||||
{
|
||||
info = new SecureInfo((Container)item, SecureLevel.Owner);
|
||||
|
|
@ -1908,15 +1721,7 @@ namespace Server.Multis
|
|||
item.IsLockedDown = false;
|
||||
item.IsSecure = false;
|
||||
|
||||
#region Mondain's Legacy
|
||||
|
||||
if (item is BaseAddonContainer)
|
||||
item.Movable = false;
|
||||
else
|
||||
|
||||
#endregion
|
||||
|
||||
item.Movable = true;
|
||||
item.Movable = !(item is BaseAddonContainer);
|
||||
item.SetLastMoved();
|
||||
item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501656); //[no longer secure]
|
||||
Secures.RemoveAt(i);
|
||||
|
|
@ -1982,33 +1787,24 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel)
|
||||
{
|
||||
from.SendLocalizedMessage(501346); // Uh oh...a bigger boot may be required!
|
||||
}
|
||||
else if (IsFriend(targ) && !Core.ML)
|
||||
{
|
||||
from.SendLocalizedMessage(501348); // You cannot eject a friend of the house!
|
||||
}
|
||||
else if (targ is PlayerVendor)
|
||||
{
|
||||
from.SendLocalizedMessage(501351); // You cannot eject a vendor.
|
||||
}
|
||||
else if (!IsInside(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501352); // You may not eject someone who is not in your house!
|
||||
}
|
||||
else if (targ is BaseCreature creature && creature.NoHouseRestrictions)
|
||||
{
|
||||
from.SendLocalizedMessage(501347); // You cannot eject that from the house!
|
||||
}
|
||||
else
|
||||
{
|
||||
targ.MoveToWorld(BanLocation, Map);
|
||||
|
||||
from.SendLocalizedMessage(1042840, targ.Name); // ~1_PLAYER NAME~ has been ejected from this house.
|
||||
targ.SendLocalizedMessage(501341); /* You have been ejected from this house.
|
||||
* If you persist in entering, you may be banned from the house.
|
||||
*/
|
||||
targ.SendLocalizedMessage(501341);
|
||||
/* You have been ejected from this house.
|
||||
* If you persist in entering, you may be banned from the house.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2050,38 +1846,22 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel)
|
||||
{
|
||||
from.SendLocalizedMessage(501354); // Uh oh...a bigger boot may be required.
|
||||
}
|
||||
else if (IsFriend(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501348); // You cannot eject a friend of the house!
|
||||
}
|
||||
else if (targ is PlayerVendor)
|
||||
{
|
||||
from.SendLocalizedMessage(501351); // You cannot eject a vendor.
|
||||
}
|
||||
else if (Bans.Count >= MaxBans)
|
||||
{
|
||||
from.SendLocalizedMessage(501355); // The ban limit for this house has been reached!
|
||||
}
|
||||
else if (IsBanned(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501356); // This person is already banned!
|
||||
}
|
||||
else if (!IsInside(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501352); // You may not eject someone who is not in your house!
|
||||
}
|
||||
else if (!Public && IsAosRules)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062521); // You cannot ban someone from a private house. Revoke their access instead.
|
||||
}
|
||||
else if (targ is BaseCreature bc && bc.NoHouseRestrictions)
|
||||
{
|
||||
from.SendLocalizedMessage(1062040); // You cannot ban that.
|
||||
}
|
||||
else
|
||||
{
|
||||
Bans.Add(targ);
|
||||
|
|
@ -2099,17 +1879,11 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (HasAccess(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(1060729); // That person already has access to this house.
|
||||
}
|
||||
else if (!targ.Player)
|
||||
{
|
||||
from.SendLocalizedMessage(1060712); // That is not a player.
|
||||
}
|
||||
else if (IsBanned(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501367); // This person is banned! Unban them first.
|
||||
}
|
||||
else
|
||||
{
|
||||
Access.Add(targ);
|
||||
|
|
@ -2124,33 +1898,19 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (IsOwner(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501360); // This person is already the house owner!
|
||||
}
|
||||
else if (Friends.Contains(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501361); // This person is a friend of the house. Remove them first.
|
||||
}
|
||||
else if (!targ.Player)
|
||||
{
|
||||
from.SendLocalizedMessage(501362); // That can't be a co-owner of the house.
|
||||
}
|
||||
else if (!Core.AOS && HasAccountHouse(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501364); // That person is already a house owner.
|
||||
}
|
||||
else if (IsBanned(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501367); // This person is banned! Unban them first.
|
||||
}
|
||||
else if (CoOwners.Count >= MaxCoOwners)
|
||||
{
|
||||
from.SendLocalizedMessage(501368); // Your co-owner list is full!
|
||||
}
|
||||
else if (CoOwners.Contains(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501369); // This person is already on your co-owner list!
|
||||
}
|
||||
else
|
||||
{
|
||||
CoOwners.Add(targ);
|
||||
|
|
@ -2196,29 +1956,17 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
if (IsOwner(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501370); // This person is already an owner of the house!
|
||||
}
|
||||
else if (CoOwners.Contains(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501369); // This person is already on your co-owner list!
|
||||
}
|
||||
else if (!targ.Player)
|
||||
{
|
||||
from.SendLocalizedMessage(501371); // That can't be a friend of the house.
|
||||
}
|
||||
else if (IsBanned(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501374); // This person is banned! Unban them first.
|
||||
}
|
||||
else if (Friends.Count >= MaxFriends)
|
||||
{
|
||||
from.SendLocalizedMessage(501375); // Your friends list is full!
|
||||
}
|
||||
else if (Friends.Contains(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(501376); // This person is already on your friends list!
|
||||
}
|
||||
else
|
||||
{
|
||||
Friends.Add(targ);
|
||||
|
|
@ -2801,21 +2549,7 @@ namespace Server.Multis
|
|||
AllHouses.Remove(this);
|
||||
}
|
||||
|
||||
public static bool HasHouse(Mobile m)
|
||||
{
|
||||
if (m == null || !m_Table.TryGetValue(m, out List<BaseHouse> list))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
BaseHouse h = list[i];
|
||||
|
||||
if (!h.Deleted)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static bool HasHouse(Mobile m) => m != null && m_Table.TryGetValue(m, out List<BaseHouse> list) && list.Any(h => !h.Deleted);
|
||||
|
||||
public static bool HasAccountHouse(Mobile m)
|
||||
{
|
||||
|
|
@ -2829,35 +2563,15 @@ namespace Server.Multis
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool IsOwner(Mobile m)
|
||||
{
|
||||
if (m == null)
|
||||
return false;
|
||||
public bool IsOwner(Mobile m) =>
|
||||
m != null && (m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster ||
|
||||
IsAosRules && AccountHandler.CheckAccount(m, m_Owner));
|
||||
|
||||
if (m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster)
|
||||
return true;
|
||||
public bool IsCoOwner(Mobile m) =>
|
||||
m != null && (IsOwner(m) || CoOwners?.Contains(m) == true ||
|
||||
!IsAosRules && AccountHandler.CheckAccount(m, m_Owner));
|
||||
|
||||
return IsAosRules && AccountHandler.CheckAccount(m, m_Owner);
|
||||
}
|
||||
|
||||
public bool IsCoOwner(Mobile m)
|
||||
{
|
||||
if (m == null || CoOwners == null)
|
||||
return false;
|
||||
|
||||
if (IsOwner(m) || CoOwners.Contains(m))
|
||||
return true;
|
||||
|
||||
return !IsAosRules && AccountHandler.CheckAccount(m, m_Owner);
|
||||
}
|
||||
|
||||
public bool IsGuildMember(Mobile m)
|
||||
{
|
||||
if (m == null || Owner?.Guild == null)
|
||||
return false;
|
||||
|
||||
return m.Guild == Owner.Guild;
|
||||
}
|
||||
public bool IsGuildMember(Mobile m) => Owner?.Guild != null && m?.Guild == Owner.Guild;
|
||||
|
||||
public void RemoveKeys(Mobile m)
|
||||
{
|
||||
|
|
@ -3069,10 +2783,11 @@ namespace Server.Multis
|
|||
return;
|
||||
|
||||
from.SendLocalizedMessage(501338); // You have transferred ownership of the house.
|
||||
to.SendLocalizedMessage(501339); /* You are now the owner of this house.
|
||||
* The house's co-owner, friend, ban, and access lists have been cleared.
|
||||
* You should double-check the security settings on any doors and teleporters in the house.
|
||||
*/
|
||||
to.SendLocalizedMessage(501339);
|
||||
/* You are now the owner of this house.
|
||||
* The house's co-owner, friend, ban, and access lists have been cleared.
|
||||
* You should double-check the security settings on any doors and teleporters in the house.
|
||||
*/
|
||||
|
||||
m_House.RemoveKeys(from);
|
||||
m_House.Owner = to;
|
||||
|
|
@ -100,18 +100,15 @@ namespace Server.Multis.Deeds
|
|||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
else if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1010433); /* House placement cancellation could result in a
|
||||
* 60 second delay in the return of your deed.
|
||||
*/
|
||||
from.SendLocalizedMessage(1010433);
|
||||
/* House placement cancellation could result in a
|
||||
* 60 second delay in the return of your deed.
|
||||
*/
|
||||
|
||||
from.Target = new HousePlacementTarget(this);
|
||||
}
|
||||
|
|
@ -125,13 +122,9 @@ namespace Server.Multis.Deeds
|
|||
return;
|
||||
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
else if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
|
||||
}
|
||||
else
|
||||
{
|
||||
Point3D center = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
|
||||
|
|
@ -3,8 +3,8 @@ using System.Buffers;
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -123,9 +123,7 @@ namespace Server.Multis
|
|||
{
|
||||
get
|
||||
{
|
||||
if (m_Current == null)
|
||||
SetInitialState();
|
||||
|
||||
if (m_Current == null) SetInitialState();
|
||||
return m_Current.Components;
|
||||
}
|
||||
}
|
||||
|
|
@ -187,7 +185,7 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
public static ComponentVerification Verification => m_Verification ?? (m_Verification = new ComponentVerification());
|
||||
public static ComponentVerification Verification => m_Verification ??= new ComponentVerification();
|
||||
|
||||
public bool IsFixture(Item item) => Fixtures.Contains(item);
|
||||
|
||||
|
|
@ -300,8 +298,7 @@ namespace Server.Multis
|
|||
|
||||
public void AddFixtures(Mobile from, MultiTileEntry[] list)
|
||||
{
|
||||
if (Fixtures == null)
|
||||
Fixtures = new List<Item>();
|
||||
Fixtures ??= new List<Item>();
|
||||
|
||||
uint keyValue = 0;
|
||||
|
||||
|
|
@ -394,13 +391,9 @@ namespace Server.Multis
|
|||
door = new GenericHouseDoor(facing, 0x29F5 + 8 * ((itemID - 0x2A05) / 8), sound, sound);
|
||||
}
|
||||
else if (itemID == 0x2D46)
|
||||
{
|
||||
door = new GenericHouseDoor(DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID == 0x2D48 || itemID == 0x2FE2)
|
||||
{
|
||||
door = new GenericHouseDoor(DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x2D63 && itemID < 0x2D70)
|
||||
{
|
||||
int mod = (itemID - 0x2D63) / 2 % 2;
|
||||
|
|
@ -411,9 +404,7 @@ namespace Server.Multis
|
|||
door = new GenericHouseDoor(facing, 0x2D63 + 4 * type + mod * 2, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID == 0x2FE4 || itemID == 0x31AE)
|
||||
{
|
||||
door = new GenericHouseDoor(DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x319C && itemID < 0x31AE)
|
||||
{
|
||||
//special case for 0x31aa <-> 0x31a8 (a9)
|
||||
|
|
@ -446,21 +437,13 @@ namespace Server.Multis
|
|||
};
|
||||
}
|
||||
else if (itemID >= 0x409B && itemID < 0x40A3)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x409B), itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x410C && itemID < 0x4114)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x410C), itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x41C2 && itemID < 0x41CA)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x41C2), itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x41CF && itemID < 0x41D7)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x41CF), itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x436E && itemID < 0x437E)
|
||||
{
|
||||
/* These ones had to be different...
|
||||
|
|
@ -472,25 +455,15 @@ namespace Server.Multis
|
|||
door = new GenericHouseDoor(facing, itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x46DD && itemID < 0x46E5)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x46DD), itemID, 0xEB, 0xF2, false);
|
||||
}
|
||||
else if (itemID >= 0x4D22 && itemID < 0x4D2A)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x4D22), itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x50C8 && itemID < 0x50D0)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x50C8), itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x50D0 && itemID < 0x50D8)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x50D0), itemID, 0xEA, 0xF1, false);
|
||||
}
|
||||
else if (itemID >= 0x5142 && itemID < 0x514A)
|
||||
{
|
||||
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x5142), itemID, 0xF0, 0xEF, false);
|
||||
}
|
||||
|
||||
if (door != null)
|
||||
{
|
||||
|
|
@ -530,7 +503,6 @@ namespace Server.Multis
|
|||
switch (door.Facing)
|
||||
{
|
||||
default:
|
||||
case DoorFacing.WestCW:
|
||||
linkFacing = DoorFacing.EastCCW;
|
||||
xOffset = 1;
|
||||
yOffset = 0;
|
||||
|
|
@ -618,7 +590,6 @@ namespace Server.Multis
|
|||
switch (type)
|
||||
{
|
||||
default:
|
||||
case FoundationType.DarkWood:
|
||||
corner = 0x0014;
|
||||
east = 0x0015;
|
||||
south = 0x0016;
|
||||
|
|
@ -768,20 +739,8 @@ namespace Server.Multis
|
|||
x += mcl.Center.X;
|
||||
y += mcl.Center.Y;
|
||||
|
||||
if (x >= 0 && x < mcl.Width && y >= 0 && y < mcl.Height)
|
||||
{
|
||||
StaticTile[] tiles = mcl.Tiles[x][y];
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
{
|
||||
StaticTile tile = tiles[i];
|
||||
|
||||
if (tile.Z == 7 && tile.Height == 20)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return x >= 0 && x < mcl.Width && y >= 0 && y < mcl.Height &&
|
||||
mcl.Tiles[x][y].Any(tile => tile.Z == 7 && tile.Height == 20);
|
||||
}
|
||||
|
||||
public void BeginCustomize(Mobile m)
|
||||
|
|
@ -799,12 +758,11 @@ namespace Server.Multis
|
|||
|
||||
foreach (Item item in GetItems()) item.Location = BanLocation;
|
||||
|
||||
foreach (Mobile mobile in GetMobiles())
|
||||
if (mobile != m)
|
||||
mobile.Location = BanLocation;
|
||||
foreach (Mobile mobile in GetMobiles().Where(mobile => mobile != m))
|
||||
mobile.Location = BanLocation;
|
||||
|
||||
DesignContext.Add(m, this);
|
||||
m.Send(new BeginHouseCustomization(this));
|
||||
HouseFoundationPackets.SendBeginHouseCustomization(m.NetState, Serial);
|
||||
|
||||
NetState ns = m.NetState;
|
||||
if (ns != null)
|
||||
|
|
@ -1073,19 +1031,15 @@ namespace Server.Multis
|
|||
{
|
||||
// Temporary Fix. We should be booting a client out of customization mode in the delete handler.
|
||||
if (from.AccessLevel >= AccessLevel.GameMaster && cost != 0)
|
||||
{
|
||||
from.SendMessage("{0} gold would have been {1} your bank if you were not a GM.", cost.ToString(),
|
||||
cost > 0 ? "withdrawn from" : "deposited into");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cost > 0)
|
||||
{
|
||||
if (Banker.Withdraw(from, cost))
|
||||
{
|
||||
from.SendLocalizedMessage(1060398,
|
||||
cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
|
|
@ -1142,7 +1096,7 @@ namespace Server.Multis
|
|||
DesignContext.Remove(from);
|
||||
|
||||
// Notify the client that customization has ended
|
||||
from.Send(new EndHouseCustomization(this));
|
||||
HouseFoundationPackets.SendEndHouseCustomization(from.NetState, Serial);
|
||||
|
||||
// Notify the core that the foundation has changed and should be resent to all clients
|
||||
Delta(ItemDelta.Update);
|
||||
|
|
@ -1283,8 +1237,7 @@ namespace Server.Multis
|
|||
|
||||
switch (dir)
|
||||
{
|
||||
default:
|
||||
case 0: // North
|
||||
default: // North
|
||||
{
|
||||
xStart = x;
|
||||
yStart = y + height;
|
||||
|
|
@ -1393,16 +1346,12 @@ namespace Server.Multis
|
|||
// Remove the component
|
||||
if (AllowStairSectioning)
|
||||
{
|
||||
if (DeleteStairs(mcl, itemID, x, y, z))
|
||||
fixState = true; // The client removes the entire set of stairs locally, resend state
|
||||
fixState |= DeleteStairs(mcl, itemID, x, y, z); // The client removes the entire set of stairs locally, resend state
|
||||
|
||||
mcl.Remove(itemID, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!DeleteStairs(mcl, itemID, x, y, z))
|
||||
mcl.Remove(itemID, x, y, z);
|
||||
}
|
||||
else if (!DeleteStairs(mcl, itemID, x, y, z))
|
||||
mcl.Remove(itemID, x, y, z);
|
||||
|
||||
// If needed, replace removed component with a dirt tile
|
||||
if (ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1)
|
||||
|
|
@ -1559,7 +1508,8 @@ namespace Server.Multis
|
|||
DesignContext.Remove(from);
|
||||
|
||||
// Notify the client that customization has ended
|
||||
from.Send(new EndHouseCustomization(context.Foundation));
|
||||
|
||||
HouseFoundationPackets.SendEndHouseCustomization(from.NetState, context.Foundation.Serial);
|
||||
|
||||
// Refresh client with current visible design state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
|
|
@ -1707,7 +1657,8 @@ namespace Server.Multis
|
|||
|
||||
public class DesignState
|
||||
{
|
||||
private Packet m_PacketCache;
|
||||
private int m_Revision;
|
||||
private byte[] m_Packet;
|
||||
|
||||
public DesignState(HouseFoundation foundation, MultiComponentList components)
|
||||
{
|
||||
|
|
@ -1759,27 +1710,23 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
public Packet PacketCache
|
||||
{
|
||||
get => m_PacketCache;
|
||||
set
|
||||
{
|
||||
if (m_PacketCache == value)
|
||||
return;
|
||||
|
||||
m_PacketCache?.Release();
|
||||
|
||||
m_PacketCache = value;
|
||||
}
|
||||
}
|
||||
|
||||
public HouseFoundation Foundation{ get; }
|
||||
|
||||
public MultiComponentList Components{ get; }
|
||||
|
||||
public MultiTileEntry[] Fixtures{ get; private set; }
|
||||
|
||||
public int Revision{ get; set; }
|
||||
public int Revision
|
||||
{
|
||||
get => m_Revision;
|
||||
set => m_Revision = value;
|
||||
}
|
||||
|
||||
public byte[] Packet
|
||||
{
|
||||
get => m_Packet;
|
||||
set => Interlocked.Exchange(ref m_Packet, value);
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
|
|
@ -1805,31 +1752,18 @@ namespace Server.Multis
|
|||
|
||||
public void OnRevised()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
Revision = ++Foundation.LastRevision;
|
||||
|
||||
m_PacketCache?.Release();
|
||||
|
||||
m_PacketCache = null;
|
||||
}
|
||||
Interlocked.Exchange(ref m_Revision, ++Foundation.LastRevision);
|
||||
}
|
||||
|
||||
public void SendGeneralInfoTo(NetState state)
|
||||
{
|
||||
state?.Send(new DesignStateGeneral(Foundation, this));
|
||||
HouseFoundationPackets.SendDesignStateGeneral(state, Foundation.Serial, Revision);
|
||||
}
|
||||
|
||||
public void SendDetailedInfoTo(NetState state)
|
||||
{
|
||||
if (state != null)
|
||||
lock (this)
|
||||
{
|
||||
if (m_PacketCache == null)
|
||||
DesignStateDetailed.SendDetails(state, Foundation, this);
|
||||
else
|
||||
state.Send(m_PacketCache);
|
||||
}
|
||||
HouseFoundationPackets.SendDesignDetails(state, Foundation, this);
|
||||
}
|
||||
|
||||
public void FreezeFixtures()
|
||||
|
|
@ -1875,68 +1809,36 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsFixture(int itemID)
|
||||
{
|
||||
if (itemID >= 0x675 && itemID < 0x6F5)
|
||||
return true;
|
||||
if (itemID >= 0x314 && itemID < 0x364)
|
||||
return true;
|
||||
if (itemID >= 0x824 && itemID < 0x834)
|
||||
return true;
|
||||
if (itemID >= 0x839 && itemID < 0x849)
|
||||
return true;
|
||||
if (itemID >= 0x84C && itemID < 0x85C)
|
||||
return true;
|
||||
if (itemID >= 0x866 && itemID < 0x876)
|
||||
return true;
|
||||
if (itemID >= 0x0E8 && itemID < 0x0F8)
|
||||
return true;
|
||||
if (itemID >= 0x1FED && itemID < 0x1FFD)
|
||||
return true;
|
||||
if (itemID >= 0x181D && itemID < 0x1829)
|
||||
return true;
|
||||
if (itemID >= 0x241F && itemID < 0x2421)
|
||||
return true;
|
||||
if (itemID >= 0x2423 && itemID < 0x2425)
|
||||
return true;
|
||||
if (itemID >= 0x2A05 && itemID < 0x2A1D)
|
||||
return true;
|
||||
if (itemID >= 0x319C && itemID < 0x31B0)
|
||||
return true;
|
||||
// ML doors
|
||||
if (itemID == 0x2D46 || itemID == 0x2D48 || itemID == 0x2FE2 || itemID == 0x2FE4)
|
||||
return true;
|
||||
if (itemID >= 0x2D63 && itemID < 0x2D70)
|
||||
return true;
|
||||
if (itemID >= 0x319C && itemID < 0x31AF)
|
||||
return true;
|
||||
if (itemID >= 0x367B && itemID < 0x369B)
|
||||
return true;
|
||||
// SA doors
|
||||
if (itemID >= 0x409B && itemID < 0x40A3)
|
||||
return true;
|
||||
if (itemID >= 0x410C && itemID < 0x4114)
|
||||
return true;
|
||||
if (itemID >= 0x41C2 && itemID < 0x41CA)
|
||||
return true;
|
||||
if (itemID >= 0x41CF && itemID < 0x41D7)
|
||||
return true;
|
||||
if (itemID >= 0x436E && itemID < 0x437E)
|
||||
return true;
|
||||
if (itemID >= 0x46DD && itemID < 0x46E5)
|
||||
return true;
|
||||
if (itemID >= 0x4D22 && itemID < 0x4D2A)
|
||||
return true;
|
||||
if (itemID >= 0x50C8 && itemID < 0x50D8)
|
||||
return true;
|
||||
if (itemID >= 0x5142 && itemID < 0x514A)
|
||||
return true;
|
||||
// TOL doors
|
||||
if (itemID >= 0x9AD7 && itemID < 0x9AE7)
|
||||
return true;
|
||||
|
||||
return itemID >= 0x9B3C && itemID < 0x9B4C;
|
||||
}
|
||||
public static bool IsFixture(int itemID) =>
|
||||
itemID >= 0x675 && itemID < 0x6F5 ||
|
||||
itemID >= 0x314 && itemID < 0x364 ||
|
||||
itemID >= 0x824 && itemID < 0x834 ||
|
||||
itemID >= 0x839 && itemID < 0x849 ||
|
||||
itemID >= 0x84C && itemID < 0x85C ||
|
||||
itemID >= 0x866 && itemID < 0x876 ||
|
||||
itemID >= 0x0E8 && itemID < 0x0F8 ||
|
||||
itemID >= 0x1FED && itemID < 0x1FFD ||
|
||||
itemID >= 0x181D && itemID < 0x1829 ||
|
||||
itemID >= 0x241F && itemID < 0x2421 ||
|
||||
itemID >= 0x2423 && itemID < 0x2425 ||
|
||||
itemID >= 0x2A05 && itemID < 0x2A1D ||
|
||||
itemID >= 0x319C && itemID < 0x31B0 ||
|
||||
itemID == 0x2D46 || itemID == 0x2D48 ||
|
||||
itemID == 0x2FE2 || itemID == 0x2FE4 ||
|
||||
itemID >= 0x2D63 && itemID < 0x2D70 ||
|
||||
itemID >= 0x319C && itemID < 0x31AF ||
|
||||
itemID >= 0x367B && itemID < 0x369B ||
|
||||
itemID >= 0x409B && itemID < 0x40A3 ||
|
||||
itemID >= 0x410C && itemID < 0x4114 ||
|
||||
itemID >= 0x41C2 && itemID < 0x41CA ||
|
||||
itemID >= 0x41CF && itemID < 0x41D7 ||
|
||||
itemID >= 0x436E && itemID < 0x437E ||
|
||||
itemID >= 0x46DD && itemID < 0x46E5 ||
|
||||
itemID >= 0x4D22 && itemID < 0x4D2A ||
|
||||
itemID >= 0x50C8 && itemID < 0x50D8 ||
|
||||
itemID >= 0x5142 && itemID < 0x514A ||
|
||||
itemID >= 0x9AD7 && itemID < 0x9AE7 ||
|
||||
itemID >= 0x9B3C && itemID < 0x9B4C;
|
||||
}
|
||||
|
||||
public class ConfirmCommitGump : Gump
|
||||
|
|
@ -2060,17 +1962,17 @@ namespace Server.Multis
|
|||
{
|
||||
Item item = fixtures[i];
|
||||
|
||||
state.Send(item.RemovePacket);
|
||||
Packets.SendRemoveEntity(state, item.Serial);
|
||||
}
|
||||
|
||||
if (foundation.Signpost != null)
|
||||
state.Send(foundation.Signpost.RemovePacket);
|
||||
Packets.SendRemoveEntity(state, foundation.Signpost.Serial);
|
||||
|
||||
if (foundation.SignHanger != null)
|
||||
state.Send(foundation.SignHanger.RemovePacket);
|
||||
Packets.SendRemoveEntity(state, foundation.SignHanger.Serial);
|
||||
|
||||
if (foundation.Sign != null)
|
||||
state.Send(foundation.Sign.RemovePacket);
|
||||
Packets.SendRemoveEntity(state, foundation.Sign.Serial);
|
||||
}
|
||||
|
||||
public static void Remove(Mobile from)
|
||||
|
|
@ -2102,9 +2004,7 @@ namespace Server.Multis
|
|||
}
|
||||
|
||||
context.Foundation.Signpost?.SendInfoTo(state);
|
||||
|
||||
context.Foundation.SignHanger?.SendInfoTo(state);
|
||||
|
||||
context.Foundation.Sign?.SendInfoTo(state);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Regions;
|
||||
using Server.Spells;
|
||||
|
||||
|
|
@ -157,8 +158,7 @@ namespace Server.Multis
|
|||
bool isFoundation = addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0;
|
||||
bool hasSurface = false;
|
||||
|
||||
if (isFoundation)
|
||||
hasFoundation = true;
|
||||
hasFoundation |= isFoundation;
|
||||
|
||||
int addTileZ = center.Z + addTile.Z;
|
||||
int addTileTop = addTileZ + addTile.Height;
|
||||
|
|
@ -333,29 +333,7 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < yard.Count; ++i)
|
||||
foreach (BaseHouse b in _houses)
|
||||
if (b.Contains(yard[i]))
|
||||
return HousePlacementResult.BadStatic; // Broke rule #3
|
||||
/*Point2D yardPoint = yard[i];
|
||||
|
||||
IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y );
|
||||
|
||||
foreach ( StaticTile[] tile in eable )
|
||||
{
|
||||
for ( int j = 0; j < tile.Length; ++j )
|
||||
{
|
||||
if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 )
|
||||
{
|
||||
eable.Free();
|
||||
return HousePlacementResult.BadStatic; // Broke rule #3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();*/
|
||||
|
||||
return HousePlacementResult.Valid;
|
||||
return yard.Any(t => _houses.Any(b => b.Contains(t))) ? HousePlacementResult.BadStatic : HousePlacementResult.Valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -611,9 +611,7 @@ namespace Server.Items
|
|||
case HousePlacementResult.Valid:
|
||||
{
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseHouse house = ConstructHouse(from);
|
||||
|
|
@ -624,17 +622,13 @@ namespace Server.Items
|
|||
house.Price = Cost;
|
||||
|
||||
if (from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
from.SendMessage("{0} gold would have been withdrawn from your bank if you were not a GM.",
|
||||
Cost.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Banker.Withdraw(from, Cost))
|
||||
{
|
||||
from.SendLocalizedMessage(1060398,
|
||||
Cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
|
||||
}
|
||||
else
|
||||
{
|
||||
house.RemoveKeys(from);
|
||||
|
|
@ -707,9 +701,7 @@ namespace Server.Items
|
|||
case HousePlacementResult.Valid:
|
||||
{
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1011576); // This is a valid location.
|
||||
|
|
@ -804,16 +796,13 @@ namespace Server.Items
|
|||
{
|
||||
m_Table.TryGetValue(house.GetType(), out object obj);
|
||||
|
||||
if (obj is HousePlacementEntry entry)
|
||||
return entry;
|
||||
|
||||
if (obj is List<HousePlacementEntry> list)
|
||||
return list.FirstOrDefault(e => e.MultiID == house.ItemID);
|
||||
|
||||
if (obj is Dictionary<int, HousePlacementEntry> table)
|
||||
return table[house.ItemID];
|
||||
|
||||
return null;
|
||||
return obj switch
|
||||
{
|
||||
HousePlacementEntry entry => entry,
|
||||
List<HousePlacementEntry> list => list.FirstOrDefault(e => e.MultiID == house.ItemID),
|
||||
Dictionary<int, HousePlacementEntry> table => table[house.ItemID],
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
private static void FillTable(HousePlacementEntry[] entries)
|
||||
|
|
@ -823,9 +812,7 @@ namespace Server.Items
|
|||
HousePlacementEntry e = entries[i];
|
||||
|
||||
if (!m_Table.TryGetValue(e.Type, out object obj))
|
||||
{
|
||||
m_Table[e.Type] = e;
|
||||
}
|
||||
else if (obj is HousePlacementEntry entry)
|
||||
{
|
||||
List<HousePlacementEntry> list = new List<HousePlacementEntry> { entry, e };
|
||||
|
|
@ -848,10 +835,7 @@ namespace Server.Items
|
|||
else
|
||||
list.Add(e);
|
||||
}
|
||||
else if (obj is Dictionary<int, HousePlacementEntry> table)
|
||||
{
|
||||
table[e.MultiID] = e;
|
||||
}
|
||||
else if (obj is Dictionary<int, HousePlacementEntry> table) table[e.MultiID] = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -581,4 +581,4 @@ namespace Server.Multis
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
|
|
@ -49,19 +50,8 @@ namespace Server.Multis
|
|||
public override void DropItem(Item dropped)
|
||||
{
|
||||
// 1. Try to stack the item
|
||||
foreach (Item item in Items)
|
||||
if (item is PackingBox)
|
||||
{
|
||||
List<Item> subItems = item.Items;
|
||||
|
||||
for (int i = 0; i < subItems.Count; i++)
|
||||
{
|
||||
Item subItem = subItems[i];
|
||||
|
||||
if (!(subItem is Container) && subItem.StackWith(null, dropped, false))
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Items.Any(item => item is PackingBox && item.Items.Any(subItem => !(subItem is Container) && subItem.StackWith(null, dropped, false))))
|
||||
return;
|
||||
|
||||
// 2. Try to drop the item into an existing container
|
||||
foreach (Item item in Items)
|
||||
|
|
@ -173,12 +163,7 @@ namespace Server.Multis
|
|||
m_InternalizeTimer = null;
|
||||
}
|
||||
|
||||
List<Item> toRemove = new List<Item>();
|
||||
foreach (Item item in Items)
|
||||
if (item is PackingBox && item.Items.Count == 0)
|
||||
toRemove.Add(item);
|
||||
|
||||
foreach (Item item in toRemove)
|
||||
foreach (Item item in Items.Where(item => item is PackingBox && item.Items.Count == 0))
|
||||
item.Delete();
|
||||
|
||||
if (TotalItems == 0)
|
||||
366
Projects/Scripts/Multis/Houses/Packets.cs
Normal file
366
Projects/Scripts/Multis/Houses/Packets.cs
Normal file
|
|
@ -0,0 +1,366 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Server.Buffers;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public static class HouseFoundationPackets
|
||||
{
|
||||
public static void SendBeginHouseCustomization(NetState ns, Serial house)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[17]);
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
writer.Write((ushort)17); // Dynamic Length
|
||||
|
||||
writer.Write((short)0x20); // House Customization
|
||||
writer.Write(house);
|
||||
writer.Write((byte)0x04); // Start customization
|
||||
writer.Position += 2;
|
||||
writer.Write(0xFFFFFFFF);
|
||||
writer.Write((byte)0xFF);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public static void SendEndHouseCustomization(NetState ns, Serial house)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[17]);
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
writer.Write((ushort)17); // Dynamic Length
|
||||
|
||||
writer.Write((short)0x20); // House Customization
|
||||
writer.Write(house);
|
||||
writer.Write((byte)0x05); // End customization
|
||||
writer.Position += 2;
|
||||
writer.Write(0xFFFFFFFF);
|
||||
writer.Write((byte)0xFF);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public static void SendDesignStateGeneral(NetState ns, Serial house, int revision)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[13]);
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
writer.Write((ushort)13); // Dynamic Length
|
||||
|
||||
writer.Write((short)0x1D); // Design
|
||||
writer.Write(house);
|
||||
writer.Write(revision);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
private const int MaxItemsPerStairBuffer = 750;
|
||||
|
||||
private static ConcurrentQueue<SendQueueEntry> m_SendQueue;
|
||||
private static AutoResetEvent m_Sync;
|
||||
|
||||
static HouseFoundationPackets()
|
||||
{
|
||||
m_SendQueue = new ConcurrentQueue<SendQueueEntry>();
|
||||
m_Sync = new AutoResetEvent(false);
|
||||
Task.Run(ProcessDesignStates);
|
||||
}
|
||||
|
||||
public static void ProcessDesignStates()
|
||||
{
|
||||
while (!Core.Closing)
|
||||
{
|
||||
m_Sync.WaitOne();
|
||||
|
||||
int count = m_SendQueue.Count;
|
||||
|
||||
while (count > 0 && m_SendQueue.TryDequeue(out SendQueueEntry sqe))
|
||||
try
|
||||
{
|
||||
byte[] packet = sqe.m_DesignState.Packet;
|
||||
|
||||
if (packet == null)
|
||||
{
|
||||
packet = CreateDesignDetailsPacket(sqe.m_Serial, sqe.m_Revision, sqe.m_xMin, sqe.m_yMin, sqe.m_xMax,
|
||||
sqe.m_yMax, sqe.m_Tiles);
|
||||
sqe.m_DesignState.Packet = packet;
|
||||
return;
|
||||
}
|
||||
|
||||
sqe.m_NetState.Send(packet);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
|
||||
try
|
||||
{
|
||||
using StreamWriter op = new StreamWriter("dsd_exceptions.txt", true);
|
||||
op.WriteLine(e);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
count = m_SendQueue.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] CreateDesignDetailsPacket(Serial serial, int revision, int xMin, int yMin, int xMax, int yMax,
|
||||
MultiTileEntry[] tiles)
|
||||
{
|
||||
ArrayBufferWriter<byte> bufferWriter = new ArrayBufferWriter<byte>(0x10000);
|
||||
|
||||
SpanWriter headWriter = new SpanWriter(stackalloc byte[18]);
|
||||
headWriter.Write((byte)0xD8); // Packet ID
|
||||
headWriter.Position += 2; // Dynamic Length
|
||||
|
||||
headWriter.Write((byte)0x03); // Compression Type
|
||||
headWriter.Position++;
|
||||
headWriter.Write(serial);
|
||||
headWriter.Write(revision);
|
||||
headWriter.Write((short)tiles.Length);
|
||||
headWriter.Position += 3; // Buffer/Plane count
|
||||
|
||||
int bufferLength = 1; // includes plane count
|
||||
|
||||
int width = xMax - xMin + 1;
|
||||
int height = yMax - yMin + 1;
|
||||
|
||||
Span<bool> planeUsed = stackalloc bool[9];
|
||||
Span<byte> planeBuffers = stackalloc byte[9216];
|
||||
Span<byte> stairBuffers = stackalloc byte[MaxItemsPerStairBuffer * 30];
|
||||
|
||||
int totalStairsUsed = 0;
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
{
|
||||
MultiTileEntry mte = tiles[i];
|
||||
int x = mte.m_OffsetX - xMin;
|
||||
int y = mte.m_OffsetY - yMin;
|
||||
int z = mte.m_OffsetZ;
|
||||
bool floor = TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Height <= 0;
|
||||
int plane, size;
|
||||
|
||||
switch (z)
|
||||
{
|
||||
case 0:
|
||||
plane = 0;
|
||||
break;
|
||||
case 7:
|
||||
plane = 1;
|
||||
break;
|
||||
case 27:
|
||||
plane = 2;
|
||||
break;
|
||||
case 47:
|
||||
plane = 3;
|
||||
break;
|
||||
case 67:
|
||||
plane = 4;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
int stairBufferIndex = totalStairsUsed / MaxItemsPerStairBuffer;
|
||||
Span<byte> stairBuffer = stairBuffers.Slice(stairBufferIndex, MaxItemsPerStairBuffer);
|
||||
|
||||
int byteIndex = totalStairsUsed % MaxItemsPerStairBuffer * 5;
|
||||
|
||||
stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8);
|
||||
stairBuffer[byteIndex++] = (byte)mte.m_ItemID;
|
||||
|
||||
stairBuffer[byteIndex++] = (byte)mte.m_OffsetX;
|
||||
stairBuffer[byteIndex++] = (byte)mte.m_OffsetY;
|
||||
stairBuffer[byteIndex] = (byte)mte.m_OffsetZ;
|
||||
|
||||
++totalStairsUsed;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (plane == 0)
|
||||
size = height;
|
||||
else if (floor)
|
||||
{
|
||||
size = height - 2;
|
||||
x -= 1;
|
||||
y -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = height - 1;
|
||||
plane += 4;
|
||||
}
|
||||
|
||||
int index = (x * size + y) * 2;
|
||||
|
||||
if (x < 0 || y < 0 || y >= size || index + 1 >= 0x400)
|
||||
{
|
||||
int stairBufferIndex = totalStairsUsed / MaxItemsPerStairBuffer;
|
||||
Span<byte> stairBuffer = stairBuffers.Slice(stairBufferIndex, MaxItemsPerStairBuffer);
|
||||
|
||||
int byteIndex = totalStairsUsed % MaxItemsPerStairBuffer * 5;
|
||||
|
||||
stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8);
|
||||
stairBuffer[byteIndex++] = (byte)mte.m_ItemID;
|
||||
|
||||
stairBuffer[byteIndex++] = (byte)mte.m_OffsetX;
|
||||
stairBuffer[byteIndex++] = (byte)mte.m_OffsetY;
|
||||
stairBuffer[byteIndex] = (byte)mte.m_OffsetZ;
|
||||
|
||||
++totalStairsUsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
planeUsed[plane] = true;
|
||||
planeBuffers[plane * 0x400 + index] = (byte)(mte.m_ItemID >> 8);
|
||||
planeBuffers[plane * 0x400 + index + 1] = (byte)mte.m_ItemID;
|
||||
}
|
||||
}
|
||||
|
||||
int planeCount = 0;
|
||||
int bound = (int)Compression.Compressor.CompressBound(0x400);
|
||||
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
if (!planeUsed[i])
|
||||
continue;
|
||||
|
||||
++planeCount;
|
||||
|
||||
int size;
|
||||
|
||||
if (i == 0)
|
||||
size = width * height * 2;
|
||||
else if (i < 5)
|
||||
size = (width - 1) * (height - 2) * 2;
|
||||
else
|
||||
size = width * (height - 1) * 2;
|
||||
|
||||
Span<byte> inflatedBuffer = planeBuffers.Slice(i * 0x400, 0x400);
|
||||
Span<byte> deflatedBuffer = bufferWriter.GetSpan(bound + 4);
|
||||
|
||||
ulong deflatedLength = (ulong)bound;
|
||||
ZLibError ce = Compression.Pack(deflatedBuffer.Slice(4), ref deflatedLength, inflatedBuffer, (ulong)size, ZLibQuality.Default);
|
||||
|
||||
if (ce != ZLibError.Okay)
|
||||
{
|
||||
Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
|
||||
size = 0;
|
||||
}
|
||||
|
||||
int length = (int)deflatedLength;
|
||||
|
||||
deflatedBuffer[0] = (byte)(0x20 | i);
|
||||
deflatedBuffer[1] = (byte)size;
|
||||
deflatedBuffer[2] = (byte)length;
|
||||
deflatedBuffer[3] = (byte)(((size >> 4) & 0xF0) | ((length >> 8) & 0xF));
|
||||
|
||||
bufferLength += 4 + length;
|
||||
bufferWriter.Advance(length + 4);
|
||||
}
|
||||
|
||||
int totalStairBuffersUsed = (totalStairsUsed + (MaxItemsPerStairBuffer - 1)) / MaxItemsPerStairBuffer;
|
||||
bound = (int)Compression.Compressor.CompressBound(MaxItemsPerStairBuffer);
|
||||
|
||||
for (int i = 0; i < totalStairBuffersUsed; ++i)
|
||||
{
|
||||
++planeCount;
|
||||
|
||||
int count = totalStairsUsed - i * MaxItemsPerStairBuffer;
|
||||
|
||||
if (count > MaxItemsPerStairBuffer)
|
||||
count = MaxItemsPerStairBuffer;
|
||||
|
||||
int size = count * 5;
|
||||
|
||||
Span<byte> inflatedBuffer = stairBuffers.Slice(i * MaxItemsPerStairBuffer, MaxItemsPerStairBuffer);
|
||||
Span<byte> deflatedBuffer = bufferWriter.GetSpan(bound + 4);
|
||||
|
||||
ulong deflatedLength = (ulong)bound;
|
||||
ZLibError ce = Compression.Pack(deflatedBuffer.Slice(4), ref deflatedLength, inflatedBuffer, (ulong)size, ZLibQuality.Default);
|
||||
|
||||
if (ce != ZLibError.Okay)
|
||||
{
|
||||
Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
|
||||
deflatedLength = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
int length = (int)deflatedLength;
|
||||
|
||||
deflatedBuffer[0] = (byte)(9 + i);
|
||||
deflatedBuffer[1] = (byte)size;
|
||||
deflatedBuffer[2] = (byte)length;
|
||||
deflatedBuffer[3] = (byte)(((size >> 4) & 0xF0) | ((length >> 8) & 0xF));
|
||||
|
||||
bufferLength += 4 + length;
|
||||
bufferWriter.Advance(length + 4);
|
||||
}
|
||||
|
||||
headWriter.Position = 15;
|
||||
|
||||
headWriter.Write((short)bufferLength); // Buffer length
|
||||
headWriter.Write((byte)planeCount); // Plane count
|
||||
|
||||
headWriter.Position = 1;
|
||||
int written = headWriter.WrittenCount + bufferWriter.WrittenCount;
|
||||
headWriter.Write((ushort)written);
|
||||
|
||||
byte[] packet = new byte[written];
|
||||
headWriter.CopyTo(packet);
|
||||
bufferWriter.WrittenSpan.CopyTo(packet.AsSpan(headWriter.WrittenCount));
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
private class SendQueueEntry
|
||||
{
|
||||
public NetState m_NetState;
|
||||
public DesignState m_DesignState;
|
||||
public int m_Revision;
|
||||
public uint m_Serial;
|
||||
public MultiTileEntry[] m_Tiles;
|
||||
public int m_xMin, m_yMin, m_xMax, m_yMax;
|
||||
|
||||
public SendQueueEntry(NetState ns, HouseFoundation foundation, DesignState state)
|
||||
{
|
||||
m_NetState = ns;
|
||||
m_Serial = foundation.Serial;
|
||||
m_Revision = state.Revision;
|
||||
m_DesignState = state;
|
||||
|
||||
MultiComponentList mcl = state.Components;
|
||||
|
||||
m_xMin = mcl.Min.X;
|
||||
m_yMin = mcl.Min.Y;
|
||||
m_xMax = mcl.Max.X;
|
||||
m_yMax = mcl.Max.Y;
|
||||
|
||||
m_Tiles = mcl.List;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendDesignDetails(NetState ns, HouseFoundation house, DesignState state)
|
||||
{
|
||||
m_SendQueue.Enqueue(new SendQueueEntry(ns, house, state));
|
||||
m_Sync.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue