fix: Fixes doors as decorations & optimizes them (#1392)

This commit is contained in:
Kamron Batman 2023-04-18 19:28:54 -07:00 committed by GitHub
parent 6c09e5a006
commit 79c6f0375c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1369 additions and 1578 deletions

View file

@ -1736,4 +1736,8 @@ public static class Utility
TypeCode.UInt64 => 64,
_ => 64
};
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsNullOrWhiteSpace(this ReadOnlySpan<char> span) =>
span == default || span.IsEmpty || span.IsWhiteSpace();
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Toolkit.HighPerformance;
using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro;
using Server.Engines.Spawners;
@ -414,7 +415,7 @@ namespace Server.Commands
item = m_Type.CreateInstance<Item>();
}
}
else if (m_Type.IsSubclassOf(typeofBaseDoor))
else if (m_Type.IsSubclassOf(typeofBaseDoor) && m_Params.Length > 0)
{
var facing = DoorFacing.WestCW;
@ -1059,7 +1060,7 @@ namespace Server.Commands
if (bd.Open)
{
p = new Point3D(bd.X - bd.Offset.X, bd.Y - bd.Offset.Y, bd.Z - bd.Offset.Z);
bdItemID = bd.ClosedID;
bdItemID = bd.ClosedId;
}
else
{
@ -1272,51 +1273,59 @@ namespace Server.Commands
var indexOf = line.IndexOfOrdinal(' ');
list.m_Type = AssemblyHandler.FindTypeByName(line[..indexOf++]);
list.m_Type = AssemblyHandler.FindTypeByName(indexOf > -1 ? line[..indexOf] : line);
indexOf++;
if (list.m_Type == null)
{
throw new ArgumentException($"Type not found for header: '{line}'");
}
line = line[indexOf..];
indexOf = line.IndexOfOrdinal('(');
if (indexOf >= 0)
var span = line.AsSpan(indexOf, line.Length - indexOf);
var argsStart = span.IndexOfOrdinal('(');
if (argsStart > -1)
{
list.m_ItemID = Utility.ToInt32(line.AsSpan()[..(indexOf - 1)]);
var parms = line[++indexOf..^(line.EndsWithOrdinal(")") ? 1 : 0)];
list.m_Params = parms.Split(';');
for (var i = 0; i < list.m_Params.Length; ++i)
var parms = span[(argsStart + 1)..^(line.EndsWithOrdinal(")") ? 1 : 0)];
if (parms.Length == 0)
{
list.m_Params[i] = list.m_Params[i].Trim();
list.m_Params = Array.Empty<string>();
}
else
{
list.m_Params = new string[parms.Count(';') + 1];
indexOf = 0;
foreach (var part in parms.Tokenize(';'))
{
list.m_Params[indexOf++] = part.Trim().ToString();
}
}
}
else
{
list.m_ItemID = Utility.ToInt32(line);
list.m_Params = m_EmptyParams;
}
list.m_ItemID = Utility.ToInt32(argsStart > -1 ? span[..argsStart] : span);
list.m_Entries = new List<DecorationEntry>();
while ((line = ip.ReadLine()) != null)
{
line = line.Trim();
span = line.AsSpan().Trim();
if (line.Length == 0)
if (span.Length == 0)
{
break;
}
if (line.StartsWithOrdinal("#"))
if (span.StartsWithOrdinal("#"))
{
continue;
}
list.m_Entries.Add(new DecorationEntry(line));
list.m_Entries.Add(new DecorationEntry(span));
}
return list;
@ -1325,21 +1334,21 @@ namespace Server.Commands
public class DecorationEntry
{
public DecorationEntry(string line)
public DecorationEntry(ReadOnlySpan<char> line)
{
Pop(out var x, ref line);
Pop(out var y, ref line);
Pop(out var z, ref line);
Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z));
Extra = line;
Extra = line.ToString();
}
public Point3D Location { get; }
public string Extra { get; }
public static void Pop(out string v, ref string line)
public static void Pop(out ReadOnlySpan<char> v, ref ReadOnlySpan<char> line)
{
var space = line.IndexOfOrdinal(' ');
@ -1351,7 +1360,7 @@ namespace Server.Commands
else
{
v = line;
line = "";
line = default;
}
}
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Toolkit.HighPerformance;
using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro;
using Server.Engines.Spawners;
@ -410,7 +411,7 @@ namespace Server.Commands
item = m_Type.CreateInstance<Item>();
}
}
else if (m_Type.IsSubclassOf(typeofBaseDoor))
else if (m_Type.IsSubclassOf(typeofBaseDoor) && m_Params.Length > 0)
{
var facing = DoorFacing.WestCW;
@ -1055,7 +1056,7 @@ namespace Server.Commands
if (bd.Open)
{
p = new Point3D(bd.X - bd.Offset.X, bd.Y - bd.Offset.Y, bd.Z - bd.Offset.Z);
bdItemID = bd.ClosedID;
bdItemID = bd.ClosedId;
}
else
{
@ -1258,51 +1259,60 @@ namespace Server.Commands
var indexOf = line.IndexOfOrdinal(' ');
list.m_Type = AssemblyHandler.FindTypeByName(line[..indexOf++]);
list.m_Type = AssemblyHandler.FindTypeByName(indexOf > -1 ? line[..indexOf] : line);
indexOf++;
if (list.m_Type == null)
{
throw new ArgumentException($"Type not found for header: '{line}'");
}
line = line[indexOf..];
indexOf = line.IndexOfOrdinal('(');
if (indexOf >= 0)
var span = line.AsSpan(indexOf, line.Length - indexOf);
var argsStart = span.IndexOfOrdinal('(');
if (argsStart > -1)
{
list.m_ItemID = Utility.ToInt32(line.AsSpan()[..(indexOf - 1)]);
var parms = line[++indexOf..^(line.EndsWithOrdinal(")") ? 1 : 0)];
list.m_Params = parms.Split(';');
for (var i = 0; i < list.m_Params.Length; ++i)
var parms = span[(argsStart + 1)..^(line.EndsWithOrdinal(")") ? 1 : 0)];
if (parms.Length == 0)
{
list.m_Params[i] = list.m_Params[i].Trim();
list.m_Params = Array.Empty<string>();
}
else
{
list.m_Params = new string[parms.Count(';') + 1];
indexOf = 0;
foreach (var part in parms.Tokenize(';'))
{
list.m_Params[indexOf++] = part.Trim().ToString();
}
}
}
else
{
list.m_ItemID = Utility.ToInt32(line);
list.m_Params = m_EmptyParams;
}
list.m_ItemID = Utility.ToInt32(argsStart > -1 ? span[..argsStart] : span);
list.m_Entries = new List<DecorationEntryMag>();
while ((line = ip.ReadLine()) != null)
{
line = line.Trim();
span = line.AsSpan().Trim();
if (line.Length == 0)
if (span.Length == 0)
{
break;
}
if (line.StartsWithOrdinal("#"))
if (span.StartsWithOrdinal("#"))
{
continue;
}
list.m_Entries.Add(new DecorationEntryMag(line));
list.m_Entries.Add(new DecorationEntryMag(span));
}
return list;
@ -1311,21 +1321,21 @@ namespace Server.Commands
public class DecorationEntryMag
{
public DecorationEntryMag(string line)
public DecorationEntryMag(ReadOnlySpan<char> line)
{
Pop(out var x, ref line);
Pop(out var y, ref line);
Pop(out var z, ref line);
Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z));
Extra = line;
Extra = line.ToString();
}
public Point3D Location { get; }
public string Extra { get; }
public void Pop(out string v, ref string line)
public void Pop(out ReadOnlySpan<char> v, ref ReadOnlySpan<char> line)
{
var space = line.IndexOfOrdinal(' ');

View file

@ -121,7 +121,7 @@ namespace Server.Engines.Doom
Door.Open = false;
}
if (Door.Link != null)
if (Door.Link?.Deleted == false)
{
Door.Link.Hue = hue;
Door.Link.Locked = lockDoors;

View file

@ -58,7 +58,7 @@ namespace Server.Engines.Doom
healerDoor.Locked = true;
healerDoor.KeyValue = Key.RandomValue();
if (healerDoor.Link != null)
if (healerDoor.Link?.Deleted == false)
{
healerDoor.Link.Locked = true;
healerDoor.Link.KeyValue = Key.RandomValue();

File diff suppressed because it is too large Load diff

View file

@ -1,436 +1,216 @@
namespace Server.Items
using ModernUO.Serialization;
namespace Server.Items;
public enum DoorFacing
{
public enum DoorFacing
WestCW,
EastCCW,
WestCCW,
EastCW,
SouthCW,
NorthCCW,
SouthCCW,
NorthCW,
// Sliding Doors
SouthSW,
SouthSE,
WestSS,
WestSN
}
[SerializationGenerator(0, false)]
public partial class IronGateShort : BaseDoor
{
[Constructible]
public IronGateShort(DoorFacing facing) : base(
0x84c + 2 * (int)facing,
0x84d + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class IronGate : BaseDoor
{
[Constructible]
public IronGate(DoorFacing facing) : base(
0x824 + 2 * (int)facing,
0x825 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class LightWoodGate : BaseDoor
{
[Constructible]
public LightWoodGate(DoorFacing facing) : base(
0x839 + 2 * (int)facing,
0x83A + 2 * (int)facing,
0xEB,
0xF2,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class DarkWoodGate : BaseDoor
{
[Constructible]
public DarkWoodGate(DoorFacing facing) : base(
0x866 + 2 * (int)facing,
0x867 + 2 * (int)facing,
0xEB,
0xF2,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class MetalDoor : BaseDoor
{
[Constructible]
public MetalDoor(DoorFacing facing) : base(
0x675 + 2 * (int)facing,
0x676 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class BarredMetalDoor : BaseDoor
{
[Constructible]
public BarredMetalDoor(DoorFacing facing) : base(
0x685 + 2 * (int)facing,
0x686 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class BarredMetalDoor2 : BaseDoor
{
[Constructible]
public BarredMetalDoor2(DoorFacing facing) : base(
0x1FED + 2 * (int)facing,
0x1FEE + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class RattanDoor : BaseDoor
{
[Constructible]
public RattanDoor(DoorFacing facing) : base(
0x695 + 2 * (int)facing,
0x696 + 2 * (int)facing,
0xEB,
0xF2,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class DarkWoodDoor : BaseDoor
{
[Constructible]
public DarkWoodDoor(DoorFacing facing) : base(
0x6A5 + 2 * (int)facing,
0x6A6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class MediumWoodDoor : BaseDoor
{
[Constructible]
public MediumWoodDoor(DoorFacing facing) : base(
0x6B5 + 2 * (int)facing,
0x6B6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class MetalDoor2 : BaseDoor
{
[Constructible]
public MetalDoor2(DoorFacing facing) : base(
0x6C5 + 2 * (int)facing,
0x6C6 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class LightWoodDoor : BaseDoor
{
[Constructible]
public LightWoodDoor(DoorFacing facing) : base(
0x6D5 + 2 * (int)facing,
0x6D6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class StrongWoodDoor : BaseDoor
{
[Constructible]
public StrongWoodDoor(DoorFacing facing) : base(
0x6E5 + 2 * (int)facing,
0x6E6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
WestCW,
EastCCW,
WestCCW,
EastCW,
SouthCW,
NorthCCW,
SouthCCW,
NorthCW,
// Sliding Doors
SouthSW,
SouthSE,
WestSS,
WestSN
}
public class IronGateShort : BaseDoor
{
[Constructible]
public IronGateShort(DoorFacing facing) : base(
0x84c + 2 * (int)facing,
0x84d + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
public IronGateShort(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class IronGate : BaseDoor
{
[Constructible]
public IronGate(DoorFacing facing) : base(
0x824 + 2 * (int)facing,
0x825 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
public IronGate(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class LightWoodGate : BaseDoor
{
[Constructible]
public LightWoodGate(DoorFacing facing) : base(
0x839 + 2 * (int)facing,
0x83A + 2 * (int)facing,
0xEB,
0xF2,
GetOffset(facing)
)
{
}
public LightWoodGate(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class DarkWoodGate : BaseDoor
{
[Constructible]
public DarkWoodGate(DoorFacing facing) : base(
0x866 + 2 * (int)facing,
0x867 + 2 * (int)facing,
0xEB,
0xF2,
GetOffset(facing)
)
{
}
public DarkWoodGate(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class MetalDoor : BaseDoor
{
[Constructible]
public MetalDoor(DoorFacing facing) : base(
0x675 + 2 * (int)facing,
0x676 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
public MetalDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class BarredMetalDoor : BaseDoor
{
[Constructible]
public BarredMetalDoor(DoorFacing facing) : base(
0x685 + 2 * (int)facing,
0x686 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
public BarredMetalDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class BarredMetalDoor2 : BaseDoor
{
[Constructible]
public BarredMetalDoor2(DoorFacing facing) : base(
0x1FED + 2 * (int)facing,
0x1FEE + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
public BarredMetalDoor2(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class RattanDoor : BaseDoor
{
[Constructible]
public RattanDoor(DoorFacing facing) : base(
0x695 + 2 * (int)facing,
0x696 + 2 * (int)facing,
0xEB,
0xF2,
GetOffset(facing)
)
{
}
public RattanDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class DarkWoodDoor : BaseDoor
{
[Constructible]
public DarkWoodDoor(DoorFacing facing) : base(
0x6A5 + 2 * (int)facing,
0x6A6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
public DarkWoodDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class MediumWoodDoor : BaseDoor
{
[Constructible]
public MediumWoodDoor(DoorFacing facing) : base(
0x6B5 + 2 * (int)facing,
0x6B6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
public MediumWoodDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class MetalDoor2 : BaseDoor
{
[Constructible]
public MetalDoor2(DoorFacing facing) : base(
0x6C5 + 2 * (int)facing,
0x6C6 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
}
public MetalDoor2(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class LightWoodDoor : BaseDoor
{
[Constructible]
public LightWoodDoor(DoorFacing facing) : base(
0x6D5 + 2 * (int)facing,
0x6D6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
public LightWoodDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class StrongWoodDoor : BaseDoor
{
[Constructible]
public StrongWoodDoor(DoorFacing facing) : base(
0x6E5 + 2 * (int)facing,
0x6E6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
public StrongWoodDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}

View file

@ -1,291 +1,219 @@
using System.Collections.Generic;
using ModernUO.Serialization;
using Server.ContextMenus;
using Server.Gumps;
using Server.Multis;
namespace Server.Items
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class MetalHouseDoor : BaseHouseDoor
{
public class MetalHouseDoor : BaseHouseDoor
[Constructible]
public MetalHouseDoor(DoorFacing facing) : base(
facing,
0x675 + 2 * (int)facing,
0x676 + 2 * (int)facing,
0xEC,
0xF3,
GetOffset(facing)
)
{
[Constructible]
public MetalHouseDoor(DoorFacing facing) : base(
}
}
[SerializationGenerator(0, false)]
public partial class DarkWoodHouseDoor : BaseHouseDoor
{
[Constructible]
public DarkWoodHouseDoor(DoorFacing facing) : base(
facing,
0x6A5 + 2 * (int)facing,
0x6A6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class GenericHouseDoor : BaseHouseDoor
{
[Constructible]
public GenericHouseDoor(DoorFacing facing, int baseItemID, int openedSound, int closedSound, bool autoAdjust = true)
: base(
facing,
0x675 + 2 * (int)facing,
0x676 + 2 * (int)facing,
0xEC,
0xF3,
baseItemID + (autoAdjust ? 2 * (int)facing : 0),
baseItemID + 1 + (autoAdjust ? 2 * (int)facing : 0),
openedSound,
closedSound,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(2, false)]
public abstract partial class BaseHouseDoor : BaseDoor, ISecurable
{
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private SecureLevel _level;
[SerializableField(1)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private DoorFacing _facing;
public BaseHouseDoor(DoorFacing facing, int closedID, int openedID, int openedSound, int closedSound, Point3D offset)
: base(closedID, openedID, openedSound, closedSound, offset)
{
_facing = facing;
_level = SecureLevel.Anyone;
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
SetSecureLevelEntry.AddTo(from, this, list);
}
public BaseHouse FindHouse()
{
Point3D loc;
if (Open)
{
loc = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z);
}
else
{
loc = Location;
}
public MetalHouseDoor(Serial serial) : base(serial)
return BaseHouse.FindHouseAt(loc, Map, 20);
}
public bool CheckAccess(Mobile m)
{
var house = FindHouse();
if (house == null)
{
return false;
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
if (!house.IsAosRules)
{
base.Serialize(writer);
writer.Write(0); // version
return true;
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
if (house.Public ? house.IsBanned(m) : !house.HasAccess(m))
{
base.Deserialize(reader);
return false;
}
var version = reader.ReadInt();
return house.HasSecureAccess(m, Level);
}
public override void OnOpened(Mobile from)
{
var house = FindHouse();
if (house?.IsFriend(from) == true && from.AccessLevel == AccessLevel.Player && house.RefreshDecay())
{
from.SendLocalizedMessage(1043293); // Your house's age and contents have been refreshed.
}
if (house?.Public == true && !house.IsFriend(from))
{
house.Visits++;
}
}
public class DarkWoodHouseDoor : BaseHouseDoor
public override bool UseLocks() => FindHouse()?.IsAosRules != true;
public override void Use(Mobile from)
{
[Constructible]
public DarkWoodHouseDoor(DoorFacing facing) : base(
facing,
0x6A5 + 2 * (int)facing,
0x6A6 + 2 * (int)facing,
0xEA,
0xF1,
GetOffset(facing)
)
if (!CheckAccess(from))
{
from.SendLocalizedMessage(1061637); // You are not allowed to access this.
}
public DarkWoodHouseDoor(Serial serial) : base(serial)
else
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
base.Use(from);
}
}
public class GenericHouseDoor : BaseHouseDoor
private void Deserialize(IGenericReader reader, int version)
{
[Constructible]
public GenericHouseDoor(DoorFacing facing, int baseItemID, int openedSound, int closedSound, bool autoAdjust = true)
: base(
facing,
baseItemID + (autoAdjust ? 2 * (int)facing : 0),
baseItemID + 1 + (autoAdjust ? 2 * (int)facing : 0),
openedSound,
closedSound,
GetOffset(facing)
)
{
}
public GenericHouseDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
_level = (SecureLevel)reader.ReadInt();
_facing = (DoorFacing)reader.ReadInt();
}
public abstract class BaseHouseDoor : BaseDoor, ISecurable
public override bool IsInside(Mobile from)
{
public BaseHouseDoor(DoorFacing facing, int closedID, int openedID, int openedSound, int closedSound, Point3D offset)
: base(closedID, openedID, openedSound, closedSound, offset)
int x, y, w, h;
const int r = 2;
const int bs = r * 2 + 1;
const int ss = r + 1;
switch (Facing)
{
Facing = facing;
Level = SecureLevel.Anyone;
}
public BaseHouseDoor(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public DoorFacing Facing { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level { get; set; }
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
SetSecureLevelEntry.AddTo(from, this, list);
}
public BaseHouse FindHouse()
{
Point3D loc;
if (Open)
{
loc = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z);
}
else
{
loc = Location;
}
return BaseHouse.FindHouseAt(loc, Map, 20);
}
public bool CheckAccess(Mobile m)
{
var house = FindHouse();
if (house == null)
{
return false;
}
if (!house.IsAosRules)
{
return true;
}
if (house.Public ? house.IsBanned(m) : !house.HasAccess(m))
{
return false;
}
return house.HasSecureAccess(m, Level);
}
public override void OnOpened(Mobile from)
{
var house = FindHouse();
if (house?.IsFriend(from) == true && from.AccessLevel == AccessLevel.Player && house.RefreshDecay())
{
from.SendLocalizedMessage(1043293); // Your house's age and contents have been refreshed.
}
if (house?.Public == true && !house.IsFriend(from))
{
house.Visits++;
}
}
public override bool UseLocks() => FindHouse()?.IsAosRules != true;
public override void Use(Mobile from)
{
if (!CheckAccess(from))
{
from.SendLocalizedMessage(1061637); // You are not allowed to access this.
}
else
{
base.Use(from);
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
writer.Write((int)Level);
writer.Write((int)Facing);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
if (version < 1)
{
Level = SecureLevel.Anyone;
}
Facing = (DoorFacing)reader.ReadInt();
break;
}
}
}
public override bool IsInside(Mobile from)
{
int x, y, w, h;
const int r = 2;
const int bs = r * 2 + 1;
const int ss = r + 1;
switch (Facing)
{
case DoorFacing.WestCW:
case DoorFacing.EastCCW:
case DoorFacing.WestCW:
case DoorFacing.EastCCW:
{
x = -r;
y = -r;
w = bs;
h = ss;
break;
}
case DoorFacing.EastCW:
case DoorFacing.WestCCW:
case DoorFacing.EastCW:
case DoorFacing.WestCCW:
{
x = -r;
y = 0;
w = bs;
h = ss;
break;
}
case DoorFacing.SouthCW:
case DoorFacing.NorthCCW:
case DoorFacing.SouthCW:
case DoorFacing.NorthCCW:
{
x = -r;
y = -r;
w = ss;
h = bs;
break;
}
case DoorFacing.NorthCW:
case DoorFacing.SouthCCW:
case DoorFacing.NorthCW:
case DoorFacing.SouthCCW:
{
x = 0;
y = -r;
w = ss;
h = bs;
break;
}
// No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until further information gained
// No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until further information gained
default: return false;
}
var rx = from.X - X;
var ry = from.Y - Y;
var az = (from.Z - Z).Abs();
return rx >= x && rx < x + w && ry >= y && ry < y + h && az <= 4;
default:
{
return false;
}
}
var rx = from.X - X;
var ry = from.Y - Y;
var az = (from.Z - Z).Abs();
return rx >= x && rx < x + w && ry >= y && ry < y + h && az <= 4;
}
}

View file

@ -1,58 +1,21 @@
namespace Server.Items
using ModernUO.Serialization;
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class PortcullisNS : BaseDoor
{
public class PortcullisNS : BaseDoor
[Constructible]
public PortcullisNS() : base(0x6F5, 0x6F5, 0xF0, 0xEF, new Point3D(0, 0, 20))
{
}
}
[SerializationGenerator(0, false)]
public partial class PortcullisEW : BaseDoor
{
[Constructible]
public PortcullisEW() : base(0x6F6, 0x6F6, 0xF0, 0xEF, new Point3D(0, 0, 20))
{
[Constructible]
public PortcullisNS() : base(0x6F5, 0x6F5, 0xF0, 0xEF, new Point3D(0, 0, 20))
{
}
public PortcullisNS(Serial serial) : base(serial)
{
}
public override bool UseChainedFunctionality => true;
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class PortcullisEW : BaseDoor
{
[Constructible]
public PortcullisEW() : base(0x6F6, 0x6F6, 0xF0, 0xEF, new Point3D(0, 0, 20))
{
}
public PortcullisEW(Serial serial) : base(serial)
{
}
public override bool UseChainedFunctionality => true;
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}

View file

@ -1,194 +1,93 @@
namespace Server.Items
using ModernUO.Serialization;
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class SecretStoneDoor1 : BaseDoor
{
public class SecretStoneDoor1 : BaseDoor
[Constructible]
public SecretStoneDoor1(DoorFacing facing) : base(
0xE8 + 2 * (int)facing,
0xE9 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class SecretDungeonDoor : BaseDoor
{
[Constructible]
public SecretDungeonDoor(DoorFacing facing) : base(
0x314 + 2 * (int)facing,
0x315 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class SecretStoneDoor2 : BaseDoor
{
[Constructible]
public SecretStoneDoor2(DoorFacing facing) : base(
0x324 + 2 * (int)facing,
0x325 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class SecretWoodenDoor : BaseDoor
{
[Constructible]
public SecretWoodenDoor(DoorFacing facing) : base(
0x334 + 2 * (int)facing,
0x335 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class SecretLightWoodDoor : BaseDoor
{
[Constructible]
public SecretLightWoodDoor(DoorFacing facing) : base(
0x344 + 2 * (int)facing,
0x345 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
}
[SerializationGenerator(0, false)]
public partial class SecretStoneDoor3 : BaseDoor
{
[Constructible]
public SecretStoneDoor3(DoorFacing facing) : base(
0x354 + 2 * (int)facing,
0x355 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
[Constructible]
public SecretStoneDoor1(DoorFacing facing) : base(
0xE8 + 2 * (int)facing,
0xE9 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
public SecretStoneDoor1(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class SecretDungeonDoor : BaseDoor
{
[Constructible]
public SecretDungeonDoor(DoorFacing facing) : base(
0x314 + 2 * (int)facing,
0x315 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
public SecretDungeonDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class SecretStoneDoor2 : BaseDoor
{
[Constructible]
public SecretStoneDoor2(DoorFacing facing) : base(
0x324 + 2 * (int)facing,
0x325 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
public SecretStoneDoor2(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class SecretWoodenDoor : BaseDoor
{
[Constructible]
public SecretWoodenDoor(DoorFacing facing) : base(
0x334 + 2 * (int)facing,
0x335 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
public SecretWoodenDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class SecretLightWoodDoor : BaseDoor
{
[Constructible]
public SecretLightWoodDoor(DoorFacing facing) : base(
0x344 + 2 * (int)facing,
0x345 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
public SecretLightWoodDoor(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
public class SecretStoneDoor3 : BaseDoor
{
[Constructible]
public SecretStoneDoor3(DoorFacing facing) : base(
0x354 + 2 * (int)facing,
0x355 + 2 * (int)facing,
0xED,
0xF4,
GetOffset(facing)
)
{
}
public SecretStoneDoor3(Serial serial) : base(serial)
{
}
public override void Serialize(IGenericWriter writer) // Default Serialize method
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader) // Default Deserialize method
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.BarredMetalDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.BarredMetalDoor2"
}

View file

@ -0,0 +1,75 @@
{
"version": 0,
"type": "Server.Items.BaseDoor",
"properties": [
{
"name": "KeyValue",
"type": "uint",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Open",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Locked",
"type": "bool",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "OpenedId",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "ClosedId",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "OpenedSound",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "ClosedSound",
"type": "int",
"rule": "PrimitiveTypeMigrationRule",
"ruleArguments": [
""
]
},
{
"name": "Offset",
"type": "Server.Point3D",
"rule": "PrimitiveUOTypeMigrationRule",
"ruleArguments": [
"Point3D"
]
},
{
"name": "Link",
"type": "Server.Items.BaseDoor",
"rule": "SerializableInterfaceMigrationRule"
}
]
}

View file

@ -0,0 +1,16 @@
{
"version": 2,
"type": "Server.Items.BaseHouseDoor",
"properties": [
{
"name": "Level",
"type": "Server.Multis.SecureLevel",
"rule": "EnumMigrationRule"
},
{
"name": "Facing",
"type": "Server.Items.DoorFacing",
"rule": "EnumMigrationRule"
}
]
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.DarkWoodDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.DarkWoodGate"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.DarkWoodHouseDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.GenericHouseDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.IronGate"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.IronGateShort"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.LightWoodDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.LightWoodGate"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.MediumWoodDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.MetalDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.MetalDoor2"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.MetalHouseDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.PortcullisEW"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.PortcullisNS"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.RattanDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SecretDungeonDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SecretLightWoodDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SecretStoneDoor1"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SecretStoneDoor2"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SecretStoneDoor3"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.SecretWoodenDoor"
}

View file

@ -0,0 +1,4 @@
{
"version": 0,
"type": "Server.Items.StrongWoodDoor"
}

View file

@ -561,7 +561,7 @@ namespace Server.Multis
}
else if (fixture is BaseHouseDoor door)
{
if (door.Link != null)
if (door.Link?.Deleted == false)
{
continue;
}
@ -572,70 +572,94 @@ namespace Server.Multis
switch (door.Facing)
{
default:
linkFacing = DoorFacing.EastCCW;
xOffset = 1;
yOffset = 0;
break;
{
linkFacing = DoorFacing.EastCCW;
xOffset = 1;
yOffset = 0;
break;
}
case DoorFacing.EastCCW:
linkFacing = DoorFacing.WestCW;
xOffset = -1;
yOffset = 0;
break;
{
linkFacing = DoorFacing.WestCW;
xOffset = -1;
yOffset = 0;
break;
}
case DoorFacing.WestCCW:
linkFacing = DoorFacing.EastCW;
xOffset = 1;
yOffset = 0;
break;
{
linkFacing = DoorFacing.EastCW;
xOffset = 1;
yOffset = 0;
break;
}
case DoorFacing.EastCW:
linkFacing = DoorFacing.WestCCW;
xOffset = -1;
yOffset = 0;
break;
{
linkFacing = DoorFacing.WestCCW;
xOffset = -1;
yOffset = 0;
break;
}
case DoorFacing.SouthCW:
linkFacing = DoorFacing.NorthCCW;
xOffset = 0;
yOffset = -1;
break;
{
linkFacing = DoorFacing.NorthCCW;
xOffset = 0;
yOffset = -1;
break;
}
case DoorFacing.NorthCCW:
linkFacing = DoorFacing.SouthCW;
xOffset = 0;
yOffset = 1;
break;
{
linkFacing = DoorFacing.SouthCW;
xOffset = 0;
yOffset = 1;
break;
}
case DoorFacing.SouthCCW:
linkFacing = DoorFacing.NorthCW;
xOffset = 0;
yOffset = -1;
break;
{
linkFacing = DoorFacing.NorthCW;
xOffset = 0;
yOffset = -1;
break;
}
case DoorFacing.NorthCW:
linkFacing = DoorFacing.SouthCCW;
xOffset = 0;
yOffset = 1;
break;
{
linkFacing = DoorFacing.SouthCCW;
xOffset = 0;
yOffset = 1;
break;
}
case DoorFacing.SouthSW:
linkFacing = DoorFacing.SouthSE;
xOffset = 1;
yOffset = 0;
break;
{
linkFacing = DoorFacing.SouthSE;
xOffset = 1;
yOffset = 0;
break;
}
case DoorFacing.SouthSE:
linkFacing = DoorFacing.SouthSW;
xOffset = -1;
yOffset = 0;
break;
{
linkFacing = DoorFacing.SouthSW;
xOffset = -1;
yOffset = 0;
break;
}
case DoorFacing.WestSN:
linkFacing = DoorFacing.WestSS;
xOffset = 0;
yOffset = 1;
break;
{
linkFacing = DoorFacing.WestSS;
xOffset = 0;
yOffset = 1;
break;
}
case DoorFacing.WestSS:
linkFacing = DoorFacing.WestSN;
xOffset = 0;
yOffset = -1;
break;
{
linkFacing = DoorFacing.WestSN;
xOffset = 0;
yOffset = -1;
break;
}
}
for (var j = i + 1; j < Fixtures.Count; ++j)
{
if (Fixtures[j] is BaseHouseDoor check && check.Link == null && check.Facing == linkFacing &&
if (Fixtures[j] is BaseHouseDoor check && check.Link?.Deleted == false && check.Facing == linkFacing &&
check.X - door.X == xOffset && check.Y - door.Y == yOffset && check.Z == door.Z)
{
check.Link = door;
@ -663,61 +687,79 @@ namespace Server.Multis
switch (type)
{
default:
corner = 0x0014;
east = 0x0015;
south = 0x0016;
post = 0x0017;
break;
{
corner = 0x0014;
east = 0x0015;
south = 0x0016;
post = 0x0017;
break;
}
case FoundationType.LightWood:
corner = 0x00BD;
east = 0x00BE;
south = 0x00BF;
post = 0x00C0;
break;
{
corner = 0x00BD;
east = 0x00BE;
south = 0x00BF;
post = 0x00C0;
break;
}
case FoundationType.Dungeon:
corner = 0x02FD;
east = 0x02FF;
south = 0x02FE;
post = 0x0300;
break;
{
corner = 0x02FD;
east = 0x02FF;
south = 0x02FE;
post = 0x0300;
break;
}
case FoundationType.Brick:
corner = 0x0041;
east = 0x0043;
south = 0x0042;
post = 0x0044;
break;
{
corner = 0x0041;
east = 0x0043;
south = 0x0042;
post = 0x0044;
break;
}
case FoundationType.Stone:
corner = 0x0065;
east = 0x0064;
south = 0x0063;
post = 0x0066;
break;
{
corner = 0x0065;
east = 0x0064;
south = 0x0063;
post = 0x0066;
break;
}
case FoundationType.ElvenGrey:
corner = 0x2DF7;
east = 0x2DF9;
south = 0x2DFA;
post = 0x2DF8;
break;
{
corner = 0x2DF7;
east = 0x2DF9;
south = 0x2DFA;
post = 0x2DF8;
break;
}
case FoundationType.ElvenNatural:
corner = 0x2DFB;
east = 0x2DFD;
south = 0x2DFE;
post = 0x2DFC;
break;
{
corner = 0x2DFB;
east = 0x2DFD;
south = 0x2DFE;
post = 0x2DFC;
break;
}
case FoundationType.Crystal:
corner = 0x3672;
east = 0x3671;
south = 0x3670;
post = 0x3673;
break;
{
corner = 0x3672;
east = 0x3671;
south = 0x3670;
post = 0x3673;
break;
}
case FoundationType.Shadow:
corner = 0x3676;
east = 0x3675;
south = 0x3674;
post = 0x3677;
break;
{
corner = 0x3676;
east = 0x3675;
south = 0x3674;
post = 0x3677;
break;
}
}
}