Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Accounting;
|
||||
|
|
@ -119,7 +118,7 @@ namespace Server.Multis
|
|||
{
|
||||
Mobile mob = acct[i];
|
||||
|
||||
if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster)
|
||||
if (mob?.AccessLevel >= AccessLevel.GameMaster)
|
||||
return DecayType.Ageless;
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +201,7 @@ namespace Server.Multis
|
|||
{
|
||||
m_LastDecayLevel = result;
|
||||
|
||||
if (Sign != null && !Sign.GettingProperties)
|
||||
if (Sign?.GettingProperties == false)
|
||||
Sign.InvalidateProperties();
|
||||
}
|
||||
|
||||
|
|
@ -1017,13 +1016,8 @@ namespace Server.Multis
|
|||
Point2D end = new Point2D(X + Components.Max.X + 1, Y + Components.Max.Y + 1);
|
||||
Rectangle2D rect = new Rectangle2D(start, end);
|
||||
|
||||
List<Item> list = new List<Item>();
|
||||
|
||||
IPooledEnumerable<Item> eable = Map.GetItemsInBounds(rect);
|
||||
|
||||
foreach (Item item in eable)
|
||||
if (item.Movable && IsInside(item))
|
||||
list.Add(item);
|
||||
List<Item> list = eable.Where(item => item.Movable && IsInside(item)).ToList();
|
||||
|
||||
eable.Free();
|
||||
|
||||
|
|
@ -1080,22 +1074,17 @@ namespace Server.Multis
|
|||
|
||||
public static bool CheckLockedDown(Item item)
|
||||
{
|
||||
BaseHouse house = FindHouseAt(item);
|
||||
|
||||
return house != null && house.HasLockedDownItem(item);
|
||||
return FindHouseAt(item)?.HasLockedDownItem(item) == true;
|
||||
}
|
||||
|
||||
public static bool CheckSecured(Item item)
|
||||
{
|
||||
BaseHouse house = FindHouseAt(item);
|
||||
|
||||
return house != null && house.HasSecureItem(item);
|
||||
return FindHouseAt(item)?.HasSecureItem(item) == true;
|
||||
}
|
||||
|
||||
public static bool CheckLockedDownOrSecured(Item item)
|
||||
{
|
||||
BaseHouse house = FindHouseAt(item);
|
||||
|
||||
return house != null && (house.HasSecureItem(item) || house.HasLockedDownItem(item));
|
||||
}
|
||||
|
||||
|
|
@ -1110,7 +1099,7 @@ namespace Server.Multis
|
|||
{
|
||||
BaseHouse house = exists[i];
|
||||
|
||||
if (house != null && !house.Deleted && house.Owner == m)
|
||||
if (house?.Deleted == false && house.Owner == m)
|
||||
list.Add(house);
|
||||
}
|
||||
}
|
||||
|
|
@ -1164,7 +1153,7 @@ namespace Server.Multis
|
|||
|
||||
public static BaseHouse FindHouseAt(Mobile m)
|
||||
{
|
||||
if (m == null || m.Deleted)
|
||||
if (m?.Deleted != false)
|
||||
return null;
|
||||
|
||||
return FindHouseAt(m.Location, m.Map, 16);
|
||||
|
|
@ -1172,10 +1161,8 @@ namespace Server.Multis
|
|||
|
||||
public static BaseHouse FindHouseAt(Item item)
|
||||
{
|
||||
if (item == null || item.Deleted)
|
||||
return null;
|
||||
|
||||
return FindHouseAt(item.GetWorldLocation(), item.Map, item.ItemData.Height);
|
||||
return item?.Deleted != false ? null :
|
||||
FindHouseAt(item.GetWorldLocation(), item.Map, item.ItemData.Height);
|
||||
}
|
||||
|
||||
public static BaseHouse FindHouseAt(Point3D loc, Map map, int height)
|
||||
|
|
@ -1196,18 +1183,12 @@ namespace Server.Multis
|
|||
|
||||
public bool IsInside(Mobile m)
|
||||
{
|
||||
if (m == null || m.Deleted || m.Map != Map)
|
||||
return false;
|
||||
|
||||
return IsInside(m.Location, 16);
|
||||
return m?.Deleted == false && m.Map == Map && IsInside(m.Location, 16);
|
||||
}
|
||||
|
||||
public bool IsInside(Item item)
|
||||
{
|
||||
if (item == null || item.Deleted || item.Map != Map)
|
||||
return false;
|
||||
|
||||
return IsInside(item.Location, item.ItemData.Height);
|
||||
return item?.Deleted == false && item.Map == Map && IsInside(item.Location, item.ItemData.Height);
|
||||
}
|
||||
|
||||
public bool CheckAccessibility(Item item, Mobile from)
|
||||
|
|
@ -1321,11 +1302,11 @@ namespace Server.Multis
|
|||
|
||||
UpdateRegion();
|
||||
|
||||
if (Sign != null && !Sign.Deleted)
|
||||
if (Sign?.Deleted == false)
|
||||
Sign.Map = Map;
|
||||
|
||||
if (Doors != null)
|
||||
foreach (Item item in Doors)
|
||||
foreach (BaseDoor item in Doors)
|
||||
item.Map = Map;
|
||||
|
||||
foreach (IEntity entity in GetHouseEntities())
|
||||
|
|
@ -1365,13 +1346,13 @@ namespace Server.Multis
|
|||
int y = base.Location.Y - oldLocation.Y;
|
||||
int z = base.Location.Z - oldLocation.Z;
|
||||
|
||||
if (Sign != null && !Sign.Deleted)
|
||||
if (Sign?.Deleted == false)
|
||||
Sign.Location = new Point3D(Sign.X + x, Sign.Y + y, Sign.Z + z);
|
||||
|
||||
UpdateRegion();
|
||||
|
||||
if (Doors != null)
|
||||
foreach (Item item in Doors)
|
||||
foreach (BaseDoor item in Doors)
|
||||
if (!item.Deleted)
|
||||
item.Location = new Point3D(item.X + x, item.Y + y, item.Z + z);
|
||||
|
||||
|
|
@ -1538,7 +1519,7 @@ namespace Server.Multis
|
|||
|
||||
for (int i = 0; Doors != null && i < Doors.Count; ++i)
|
||||
{
|
||||
BaseDoor door = Doors[i] as BaseDoor;
|
||||
BaseDoor door = Doors[i];
|
||||
Point3D p = door.Location;
|
||||
|
||||
if (door.Open)
|
||||
|
|
@ -1552,7 +1533,7 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
if (m_Trash == null || m_Trash.Deleted)
|
||||
if (m_Trash?.Deleted != false)
|
||||
{
|
||||
m_Trash = new TrashBarrel { Movable = false };
|
||||
m_Trash.MoveToWorld(from.Location, from.Map);
|
||||
|
|
@ -2028,7 +2009,7 @@ namespace Server.Multis
|
|||
|
||||
for (int i = 0; Doors != null && i < Doors.Count; ++i)
|
||||
{
|
||||
BaseDoor door = Doors[i] as BaseDoor;
|
||||
BaseDoor door = Doors[i];
|
||||
Point3D p = door.Location;
|
||||
|
||||
if (door.Open)
|
||||
|
|
@ -3012,36 +2993,27 @@ namespace Server.Multis
|
|||
if (m == null)
|
||||
return false;
|
||||
|
||||
if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access != null && Access.Contains(m))
|
||||
if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access?.Contains(m) == true)
|
||||
return true;
|
||||
|
||||
if (m is BaseCreature bc)
|
||||
{
|
||||
if (bc.NoHouseRestrictions)
|
||||
return true;
|
||||
if (!(m is BaseCreature bc))
|
||||
return false;
|
||||
|
||||
if (bc.Controlled || bc.Summoned)
|
||||
{
|
||||
m = bc.ControlMaster;
|
||||
if (bc.NoHouseRestrictions)
|
||||
return true;
|
||||
|
||||
if (m == null)
|
||||
m = bc.SummonMaster;
|
||||
if (!(bc.Controlled || bc.Summoned))
|
||||
return false;
|
||||
|
||||
if (m == null)
|
||||
return false;
|
||||
m = bc.ControlMaster ?? bc.SummonMaster;
|
||||
|
||||
if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access != null && Access.Contains(m))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return m != null && (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access?.Contains(m) == true);
|
||||
}
|
||||
|
||||
public bool HasLockedDownItem(Item check)
|
||||
{
|
||||
return check != null && LockDowns != null &&
|
||||
(LockDowns.Contains(check) || check is VendorRentalContract contract && VendorRentalContracts.Contains(contract));
|
||||
return LockDowns?.Contains(check) == true ||
|
||||
check is VendorRentalContract contract && VendorRentalContracts.Contains(contract);
|
||||
}
|
||||
|
||||
public bool HasSecureItem(Item item)
|
||||
|
|
@ -3049,15 +3021,11 @@ namespace Server.Multis
|
|||
if (item == null)
|
||||
return false;
|
||||
|
||||
if (Secures == null)
|
||||
return false;
|
||||
for (int i = 0; i < Secures?.Count; ++i)
|
||||
if (Secures[i].Item == item)
|
||||
return true;
|
||||
|
||||
bool contains = false;
|
||||
|
||||
for (int i = 0; !contains && i < Secures.Count; ++i)
|
||||
contains = Secures[i].Item == item;
|
||||
|
||||
return contains;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual Guildstone FindGuildstone()
|
||||
|
|
@ -3071,15 +3039,9 @@ namespace Server.Multis
|
|||
IPooledEnumerable<Guildstone> eable =
|
||||
map.GetItemsInBounds<Guildstone>(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height));
|
||||
|
||||
foreach (Guildstone item in eable)
|
||||
if (Contains(item))
|
||||
{
|
||||
eable.Free();
|
||||
return item;
|
||||
}
|
||||
|
||||
Guildstone item = eable.FirstOrDefault(Contains);
|
||||
eable.Free();
|
||||
return null;
|
||||
return item;
|
||||
}
|
||||
|
||||
private class TransferItem : Item
|
||||
|
|
@ -3144,7 +3106,7 @@ namespace Server.Multis
|
|||
if (!accepted)
|
||||
return true;
|
||||
|
||||
if (Deleted || m_House == null || m_House.Deleted || !m_House.IsOwner(from) || !from.CheckAlive() ||
|
||||
if (Deleted || m_House?.Deleted != false || !m_House.IsOwner(from) || !from.CheckAlive() ||
|
||||
!to.CheckAlive())
|
||||
return false;
|
||||
|
||||
|
|
@ -3164,7 +3126,7 @@ namespace Server.Multis
|
|||
|
||||
Delete();
|
||||
|
||||
if (m_House == null || m_House.Deleted || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive())
|
||||
if (m_House?.Deleted != false || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive())
|
||||
return;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
|
|
@ -466,13 +467,7 @@ namespace Server.Multis
|
|||
|
||||
public bool CheckKey(uint keyValue)
|
||||
{
|
||||
if (SPlank != null && SPlank.KeyValue == keyValue)
|
||||
return true;
|
||||
|
||||
if (PPlank != null && PPlank.KeyValue == keyValue)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return SPlank?.KeyValue == keyValue || PPlank?.KeyValue == keyValue;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
|
|
@ -751,7 +746,7 @@ namespace Server.Multis
|
|||
if (CheckDecay())
|
||||
return;
|
||||
|
||||
if (newName != null && newName.Length > 40)
|
||||
if (newName?.Length > 40)
|
||||
newName = newName.Substring(0, 40);
|
||||
|
||||
if (m_ShipName == newName)
|
||||
|
|
@ -899,7 +894,7 @@ namespace Server.Multis
|
|||
return false;
|
||||
}
|
||||
|
||||
if (MapItem == null || MapItem.Deleted)
|
||||
if (MapItem?.Deleted != false)
|
||||
{
|
||||
if (message)
|
||||
TillerMan?.Say(502513); // I have seen no map, sir.
|
||||
|
|
@ -1198,71 +1193,61 @@ namespace Server.Multis
|
|||
MultiComponentList newComponents = MultiData.GetComponents(itemID);
|
||||
|
||||
for (int x = 0; x < newComponents.Width; ++x)
|
||||
for (int y = 0; y < newComponents.Height; ++y)
|
||||
{
|
||||
int tx = p.X + newComponents.Min.X + x;
|
||||
int ty = p.Y + newComponents.Min.Y + y;
|
||||
|
||||
if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty))
|
||||
continue;
|
||||
|
||||
LandTile landTile = map.Tiles.GetLandTile(tx, ty);
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true);
|
||||
|
||||
bool hasWater = false;
|
||||
|
||||
if (landTile.Z == p.Z &&
|
||||
(landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311))
|
||||
hasWater = true;
|
||||
|
||||
int z = p.Z;
|
||||
|
||||
//int landZ = 0, landAvg = 0, landTop = 0;
|
||||
|
||||
//map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop );
|
||||
|
||||
//if ( !landTile.Ignored && top > landZ && landTop > z )
|
||||
// return false;
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
for (int y = 0; y < newComponents.Height; ++y)
|
||||
{
|
||||
StaticTile tile = tiles[i];
|
||||
bool isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2;
|
||||
int tx = p.X + newComponents.Min.X + x;
|
||||
int ty = p.Y + newComponents.Min.Y + y;
|
||||
|
||||
if (tile.Z == p.Z && isWater)
|
||||
hasWater = true;
|
||||
else if (tile.Z >= p.Z && !isWater)
|
||||
if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty))
|
||||
continue;
|
||||
|
||||
LandTile landTile = map.Tiles.GetLandTile(tx, ty);
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true);
|
||||
|
||||
bool hasWater = landTile.Z == p.Z &&
|
||||
(landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311);
|
||||
|
||||
// int z = p.Z;
|
||||
|
||||
//int landZ = 0, landAvg = 0, landTop = 0;
|
||||
|
||||
//map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop );
|
||||
|
||||
//if ( !landTile.Ignored && top > landZ && landTop > z )
|
||||
// return false;
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
{
|
||||
StaticTile tile = tiles[i];
|
||||
bool isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2;
|
||||
|
||||
if (tile.Z == p.Z && isWater)
|
||||
hasWater = true;
|
||||
else if (tile.Z >= p.Z && !isWater)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hasWater)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hasWater)
|
||||
return false;
|
||||
}
|
||||
|
||||
IPooledEnumerable<Item> eable = map.GetItemsInBounds(new Rectangle2D(p.X + newComponents.Min.X,
|
||||
p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height));
|
||||
|
||||
foreach (Item item in eable)
|
||||
bool canFit = eable.All(item =>
|
||||
{
|
||||
if (item is BaseMulti || item.ItemID > TileData.MaxItemValue || item.Z < p.Z || !item.Visible)
|
||||
continue;
|
||||
return true;
|
||||
|
||||
int x = item.X - p.X + newComponents.Min.X;
|
||||
int y = item.Y - p.Y + newComponents.Min.Y;
|
||||
|
||||
if (x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height &&
|
||||
newComponents.Tiles[x][y].Length == 0)
|
||||
continue;
|
||||
if (Contains(item))
|
||||
continue;
|
||||
|
||||
eable.Free();
|
||||
return false;
|
||||
}
|
||||
return x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height &&
|
||||
newComponents.Tiles[x][y].Length == 0 || Contains(item);
|
||||
});
|
||||
|
||||
eable.Free();
|
||||
|
||||
return true;
|
||||
return canFit;
|
||||
}
|
||||
|
||||
public Point3D Rotate(Point3D p, int count)
|
||||
|
|
@ -1282,22 +1267,11 @@ namespace Server.Multis
|
|||
|
||||
public override bool Contains(int x, int y)
|
||||
{
|
||||
if (base.Contains(x, y))
|
||||
return true;
|
||||
|
||||
if (TillerMan != null && x == TillerMan.X && y == TillerMan.Y)
|
||||
return true;
|
||||
|
||||
if (Hold != null && x == Hold.X && y == Hold.Y)
|
||||
return true;
|
||||
|
||||
if (PPlank != null && x == PPlank.X && y == PPlank.Y)
|
||||
return true;
|
||||
|
||||
if (SPlank != null && x == SPlank.X && y == SPlank.Y)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return base.Contains(x, y) ||
|
||||
TillerMan?.X == x && y == TillerMan.Y ||
|
||||
Hold?.X == x && Hold.Y == y ||
|
||||
PPlank?.X == x && PPlank.Y == y ||
|
||||
SPlank?.X == x && SPlank.Y == y;
|
||||
}
|
||||
|
||||
public static bool IsValidLocation(Point3D p, Map map)
|
||||
|
|
@ -1313,11 +1287,7 @@ namespace Server.Multis
|
|||
|
||||
public static Rectangle2D[] GetWrapFor(Map m)
|
||||
{
|
||||
if (m == Map.Ilshenar)
|
||||
return m_IlshWrap;
|
||||
if (m == Map.Tokuno)
|
||||
return m_TokunoWrap;
|
||||
return m_BritWrap;
|
||||
return m == Map.Ilshenar ? m_IlshWrap : m == Map.Tokuno ? m_TokunoWrap : m_BritWrap;
|
||||
}
|
||||
|
||||
public Direction GetMovementFor(int x, int y, out int maxSpeed)
|
||||
|
|
@ -1351,7 +1321,7 @@ namespace Server.Multis
|
|||
speed = Speed;
|
||||
clientSpeed = m_ClientSpeed;
|
||||
}
|
||||
else if (MapItem == null || MapItem.Deleted)
|
||||
else if (MapItem?.Deleted != false)
|
||||
{
|
||||
if (message)
|
||||
TillerMan?.Say(502513); // I have seen no map, sir.
|
||||
|
|
@ -1941,4 +1911,4 @@ namespace Server.Multis
|
|||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ namespace Server.Multis
|
|||
AddBackground(0, 0, 220, 170, 5054);
|
||||
AddBackground(10, 10, 200, 150, 3000);
|
||||
|
||||
AddHtmlLocalized(20, 20, 180, 80, 1018319, true, false); // Do you wish to dry dock this boat?
|
||||
AddHtmlLocalized(20, 20, 180, 80, 1018319, true); // Do you wish to dry dock this boat?
|
||||
|
||||
AddHtmlLocalized(55, 100, 140, 25, 1011011, false, false); // CONTINUE
|
||||
AddButton(20, 100, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(55, 100, 140, 25, 1011011); // CONTINUE
|
||||
AddButton(20, 100, 4005, 4007, 2);
|
||||
|
||||
AddHtmlLocalized(55, 125, 140, 25, 1011012, false, false); // CANCEL
|
||||
AddButton(20, 125, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(55, 125, 140, 25, 1011012); // CANCEL
|
||||
AddButton(20, 125, 4005, 4007, 1);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
|
|
@ -35,4 +35,4 @@ namespace Server.Multis
|
|||
m_Boat.EndDryDock(m_From);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Factions;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
|
|
@ -161,7 +162,7 @@ namespace Server.Items
|
|||
if (from is BaseFactionGuard)
|
||||
return false;
|
||||
|
||||
if ((from.Direction & Direction.Running) != 0 || Boat != null && !Boat.Contains(from))
|
||||
if ((from.Direction & Direction.Running) != 0 || Boat?.Contains(from) == false)
|
||||
return true;
|
||||
|
||||
Map map = Map;
|
||||
|
|
@ -222,16 +223,7 @@ namespace Server.Items
|
|||
|
||||
public bool CanClose()
|
||||
{
|
||||
Map map = Map;
|
||||
|
||||
if (map == null || Deleted)
|
||||
return false;
|
||||
|
||||
foreach (object o in GetObjectsInRange(0))
|
||||
if (o != this)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return Map != null && !Deleted && GetObjectsInRange(0).Cast<object>().All(o => o == this);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
|
@ -334,4 +326,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
|
|
@ -33,26 +34,17 @@ namespace Server.Multis
|
|||
|
||||
public bool IsItemValid(int itemID)
|
||||
{
|
||||
if (itemID <= 0 || itemID >= m_ItemTable.Length)
|
||||
return false;
|
||||
|
||||
return CheckValidity(m_ItemTable[itemID]);
|
||||
return itemID > 0 && itemID < m_ItemTable.Length && CheckValidity(m_ItemTable[itemID]);
|
||||
}
|
||||
|
||||
public bool IsMultiValid(int multiID)
|
||||
{
|
||||
if (multiID <= 0 || multiID >= m_MultiTable.Length)
|
||||
return false;
|
||||
|
||||
return CheckValidity(m_MultiTable[multiID]);
|
||||
return multiID > 0 && multiID < m_MultiTable.Length && CheckValidity(m_MultiTable[multiID]);
|
||||
}
|
||||
|
||||
public bool CheckValidity(int val)
|
||||
{
|
||||
if (val == -1)
|
||||
return false;
|
||||
|
||||
return val == 0 || ((int)ExpansionInfo.CoreExpansion.CustomHousingFlag & val) != 0;
|
||||
return val != -1 && (val == 0 || ((int)ExpansionInfo.CoreExpansion.CustomHousingFlag & val) != 0);
|
||||
}
|
||||
|
||||
private int[] CreateTable(int length)
|
||||
|
|
@ -172,10 +164,8 @@ namespace Server.Multis
|
|||
|
||||
while ((line = ip.ReadLine()) != null)
|
||||
{
|
||||
if (line.Length == 0)
|
||||
continue;
|
||||
|
||||
return line.Split('\t');
|
||||
if (line.Length > 0)
|
||||
return line.Split('\t');
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -212,16 +202,7 @@ namespace Server.Multis
|
|||
|
||||
public object this[string name] => this[Spreadsheet.GetColumnID(name)];
|
||||
|
||||
public object this[int id]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (id < 0)
|
||||
return null;
|
||||
|
||||
return Data[id];
|
||||
}
|
||||
}
|
||||
public object this[int id] => id < 0 ? null : Data[id];
|
||||
|
||||
public int GetInt32(string name)
|
||||
{
|
||||
|
|
@ -235,10 +216,7 @@ namespace Server.Multis
|
|||
|
||||
public int GetInt32(object obj)
|
||||
{
|
||||
if (obj is int i)
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
return Convert.ToInt32(obj);
|
||||
}
|
||||
|
||||
public string GetString(string name)
|
||||
|
|
@ -246,4 +224,4 @@ namespace Server.Multis
|
|||
return this[name] as string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Regions;
|
||||
using Server.Targeting;
|
||||
|
|
|
|||
|
|
@ -185,20 +185,11 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
public static ComponentVerification Verification
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Verification == null)
|
||||
m_Verification = new ComponentVerification();
|
||||
|
||||
return m_Verification;
|
||||
}
|
||||
}
|
||||
public static ComponentVerification Verification => m_Verification ?? (m_Verification = new ComponentVerification());
|
||||
|
||||
public bool IsFixture(Item item)
|
||||
{
|
||||
return Fixtures != null && Fixtures.Contains(item);
|
||||
return Fixtures.Contains(item);
|
||||
}
|
||||
|
||||
public override int GetMaxUpdateRange()
|
||||
|
|
@ -303,7 +294,7 @@ namespace Server.Multis
|
|||
{
|
||||
Item item = Fixtures[i];
|
||||
item.Delete();
|
||||
|
||||
|
||||
if (item is BaseDoor door)
|
||||
Doors.Remove(door);
|
||||
}
|
||||
|
|
@ -858,14 +849,7 @@ namespace Server.Multis
|
|||
{
|
||||
base.SendInfoTo(state, sendOplPacket);
|
||||
|
||||
DesignContext context = DesignContext.Find(state.Mobile);
|
||||
DesignState stateToSend;
|
||||
|
||||
if (context != null && context.Foundation == this)
|
||||
stateToSend = DesignState;
|
||||
else
|
||||
stateToSend = CurrentState;
|
||||
|
||||
DesignState stateToSend = DesignContext.Find(state.Mobile)?.Foundation == this ? DesignState : CurrentState;
|
||||
stateToSend.SendGeneralInfoTo(state);
|
||||
}
|
||||
|
||||
|
|
@ -985,19 +969,13 @@ namespace Server.Multis
|
|||
public static void Designer_Sync(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client requested state synchronization
|
||||
/* Client requested state synchronization
|
||||
* - Resend full house state
|
||||
*/
|
||||
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
|
||||
// Resend full house state
|
||||
design.SendDetailedInfoTo(state);
|
||||
}
|
||||
// Resend full house state
|
||||
DesignContext.Find(from)?.Foundation.DesignState.SendDetailedInfoTo(state);
|
||||
}
|
||||
|
||||
public static void Designer_Clear(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1005,9 +983,10 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client chose to clear the design
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client chose to clear the design
|
||||
* - Restore empty foundation
|
||||
* - Construct new design state from empty foundation
|
||||
* - Assign constructed state to foundation
|
||||
|
|
@ -1015,19 +994,18 @@ namespace Server.Multis
|
|||
* - Update client with new state
|
||||
*/
|
||||
|
||||
// Restore empty foundation : Construct new design state from empty foundation
|
||||
DesignState newDesign = new DesignState(context.Foundation, context.Foundation.GetEmptyFoundation());
|
||||
// Restore empty foundation : Construct new design state from empty foundation
|
||||
DesignState newDesign = new DesignState(context.Foundation, context.Foundation.GetEmptyFoundation());
|
||||
|
||||
// Restore empty foundation : Assign constructed state to foundation
|
||||
context.Foundation.DesignState = newDesign;
|
||||
// Restore empty foundation : Assign constructed state to foundation
|
||||
context.Foundation.DesignState = newDesign;
|
||||
|
||||
// Update revision
|
||||
newDesign.OnRevised();
|
||||
// Update revision
|
||||
newDesign.OnRevised();
|
||||
|
||||
// Update client with new state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
newDesign.SendDetailedInfoTo(state);
|
||||
}
|
||||
// Update client with new state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
newDesign.SendDetailedInfoTo(state);
|
||||
}
|
||||
|
||||
public static void Designer_Restore(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1035,9 +1013,10 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client chose to restore design to the last backup state
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client chose to restore design to the last backup state
|
||||
* - Restore backup
|
||||
* - Construct new design state from backup state
|
||||
* - Assign constructed state to foundation
|
||||
|
|
@ -1045,19 +1024,18 @@ namespace Server.Multis
|
|||
* - Update client with new state
|
||||
*/
|
||||
|
||||
// Restore backup : Construct new design state from backup state
|
||||
DesignState backupDesign = new DesignState(context.Foundation.BackupState);
|
||||
// Restore backup : Construct new design state from backup state
|
||||
DesignState backupDesign = new DesignState(context.Foundation.BackupState);
|
||||
|
||||
// Restore backup : Assign constructed state to foundation
|
||||
context.Foundation.DesignState = backupDesign;
|
||||
// Restore backup : Assign constructed state to foundation
|
||||
context.Foundation.DesignState = backupDesign;
|
||||
|
||||
// Update revision;
|
||||
backupDesign.OnRevised();
|
||||
// Update revision;
|
||||
backupDesign.OnRevised();
|
||||
|
||||
// Update client with new state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
backupDesign.SendDetailedInfoTo(state);
|
||||
}
|
||||
// Update client with new state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
backupDesign.SendDetailedInfoTo(state);
|
||||
}
|
||||
|
||||
public static void Designer_Backup(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1065,19 +1043,19 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client chose to backup design state
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client chose to backup design state
|
||||
* - Construct a copy of the current design state
|
||||
* - Assign constructed state to backup state field
|
||||
*/
|
||||
|
||||
// Construct a copy of the current design state
|
||||
DesignState copyState = new DesignState(context.Foundation.DesignState);
|
||||
// Construct a copy of the current design state
|
||||
DesignState copyState = new DesignState(context.Foundation.DesignState);
|
||||
|
||||
// Assign constructed state to backup state field
|
||||
context.Foundation.BackupState = copyState;
|
||||
}
|
||||
// Assign constructed state to backup state field
|
||||
context.Foundation.BackupState = copyState;
|
||||
}
|
||||
|
||||
public static void Designer_Revert(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1085,9 +1063,10 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client chose to revert design state to currently visible state
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client chose to revert design state to currently visible state
|
||||
* - Revert design state
|
||||
* - Construct a copy of the current visible state
|
||||
* - Freeze fixtures in constructed state
|
||||
|
|
@ -1097,25 +1076,24 @@ namespace Server.Multis
|
|||
* - Update client with new state
|
||||
*/
|
||||
|
||||
// Revert design state : Construct a copy of the current visible state
|
||||
DesignState copyState = new DesignState(context.Foundation.CurrentState);
|
||||
// Revert design state : Construct a copy of the current visible state
|
||||
DesignState copyState = new DesignState(context.Foundation.CurrentState);
|
||||
|
||||
// Revert design state : Freeze fixtures in constructed state
|
||||
copyState.FreezeFixtures();
|
||||
// Revert design state : Freeze fixtures in constructed state
|
||||
copyState.FreezeFixtures();
|
||||
|
||||
// Revert design state : Assign constructed state to foundation
|
||||
context.Foundation.DesignState = copyState;
|
||||
// Revert design state : Assign constructed state to foundation
|
||||
context.Foundation.DesignState = copyState;
|
||||
|
||||
// Revert design state : If a signpost is needed, add it
|
||||
context.Foundation.CheckSignpost();
|
||||
// Revert design state : If a signpost is needed, add it
|
||||
context.Foundation.CheckSignpost();
|
||||
|
||||
// Update revision
|
||||
copyState.OnRevised();
|
||||
// Update revision
|
||||
copyState.OnRevised();
|
||||
|
||||
// Update client with new state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
copyState.SendDetailedInfoTo(state);
|
||||
}
|
||||
// Update client with new state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
copyState.SendDetailedInfoTo(state);
|
||||
}
|
||||
|
||||
public void EndConfirmCommit(Mobile from)
|
||||
|
|
@ -1246,17 +1224,6 @@ namespace Server.Multis
|
|||
level = 1;
|
||||
|
||||
return (level - 1) * 20 + 7;
|
||||
|
||||
/*
|
||||
switch( level )
|
||||
{
|
||||
default:
|
||||
case 1: return 07;
|
||||
case 2: return 27;
|
||||
case 3: return 47;
|
||||
case 4: return 67;
|
||||
}
|
||||
* */
|
||||
}
|
||||
|
||||
public static int GetZLevel(int z, HouseFoundation house)
|
||||
|
|
@ -1269,21 +1236,10 @@ namespace Server.Multis
|
|||
return level;
|
||||
}
|
||||
|
||||
public static bool ValidPiece(int itemID)
|
||||
{
|
||||
return ValidPiece(itemID, false);
|
||||
}
|
||||
|
||||
public static bool ValidPiece(int itemID, bool roof)
|
||||
public static bool ValidPiece(int itemID, bool roof = false)
|
||||
{
|
||||
itemID &= TileData.MaxItemValue;
|
||||
|
||||
if (!roof && (TileData.ItemTable[itemID].Flags & TileFlag.Roof) != 0)
|
||||
return false;
|
||||
if (roof && (TileData.ItemTable[itemID].Flags & TileFlag.Roof) == 0)
|
||||
return false;
|
||||
|
||||
return Verification.IsItemValid(itemID);
|
||||
return roof != ((TileData.ItemTable[itemID].Flags & TileFlag.Roof) == 0) && Verification.IsItemValid(itemID);
|
||||
}
|
||||
|
||||
public static bool IsStairBlock(int id)
|
||||
|
|
@ -1432,9 +1388,10 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client chose to delete a component
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client chose to delete a component
|
||||
* - Read data detailing which component to delete
|
||||
* - Verify component is deletable
|
||||
* - Remove the component
|
||||
|
|
@ -1442,66 +1399,65 @@ namespace Server.Multis
|
|||
* - Update revision
|
||||
*/
|
||||
|
||||
// Read data detailing which component to delete
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
int z = pvSrc.ReadInt32();
|
||||
// Read data detailing which component to delete
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
int z = pvSrc.ReadInt32();
|
||||
|
||||
// Verify component is deletable
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
MultiComponentList mcl = design.Components;
|
||||
// Verify component is deletable
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
int ax = x + mcl.Center.X;
|
||||
int ay = y + mcl.Center.Y;
|
||||
int ax = x + mcl.Center.X;
|
||||
int ay = y + mcl.Center.Y;
|
||||
|
||||
if (z == 0 && ax >= 0 && ax < mcl.Width && ay >= 0 && ay < mcl.Height - 1)
|
||||
{
|
||||
/* Component is not deletable
|
||||
if (z == 0 && ax >= 0 && ax < mcl.Width && ay >= 0 && ay < mcl.Height - 1)
|
||||
{
|
||||
/* Component is not deletable
|
||||
* - Resend design state
|
||||
* - Return without further processing
|
||||
*/
|
||||
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
bool fixState = false;
|
||||
|
||||
// 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
|
||||
|
||||
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)
|
||||
{
|
||||
StaticTile[] tiles = mcl.Tiles[ax][ay];
|
||||
|
||||
bool hasBaseFloor = false;
|
||||
|
||||
for (int i = 0; !hasBaseFloor && i < tiles.Length; ++i)
|
||||
hasBaseFloor = tiles[i].Z == 7 && tiles[i].ID != 1;
|
||||
|
||||
if (!hasBaseFloor) mcl.Add(0x31F4, x, y, 7);
|
||||
}
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
|
||||
// Resend design state
|
||||
if (fixState)
|
||||
design.SendDetailedInfoTo(state);
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
bool fixState = false;
|
||||
|
||||
// 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
|
||||
|
||||
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)
|
||||
{
|
||||
StaticTile[] tiles = mcl.Tiles[ax][ay];
|
||||
|
||||
bool hasBaseFloor = false;
|
||||
|
||||
for (int i = 0; !hasBaseFloor && i < tiles.Length; ++i)
|
||||
hasBaseFloor = tiles[i].Z == 7 && tiles[i].ID != 1;
|
||||
|
||||
if (!hasBaseFloor) mcl.Add(0x31F4, x, y, 7);
|
||||
}
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
|
||||
// Resend design state
|
||||
if (fixState)
|
||||
design.SendDetailedInfoTo(state);
|
||||
}
|
||||
|
||||
public static void Designer_Stairs(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1509,9 +1465,10 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client chose to add stairs
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client chose to add stairs
|
||||
* - Read data detailing stair type and location
|
||||
* - Validate stair multi ID
|
||||
* - Add the stairs
|
||||
|
|
@ -1520,46 +1477,45 @@ namespace Server.Multis
|
|||
* - Update revision
|
||||
*/
|
||||
|
||||
// Read data detailing stair type and location
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
// Read data detailing stair type and location
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
|
||||
// Validate stair multi ID
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
// Validate stair multi ID
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
|
||||
if (!Verification.IsMultiValid(itemID))
|
||||
{
|
||||
/* Specified multi ID is not a stair
|
||||
if (!Verification.IsMultiValid(itemID))
|
||||
{
|
||||
/* Specified multi ID is not a stair
|
||||
* - Resend design state
|
||||
* - Return without further processing
|
||||
*/
|
||||
|
||||
TraceValidity(state, itemID);
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the stairs
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
// Add the stairs : Load data describing stair components
|
||||
MultiComponentList stairs = MultiData.GetComponents(itemID);
|
||||
|
||||
// Add the stairs : Insert described components
|
||||
int z = GetLevelZ(context.Level, context.Foundation);
|
||||
|
||||
for (int i = 0; i < stairs.List.Length; ++i)
|
||||
{
|
||||
MultiTileEntry entry = stairs.List[i];
|
||||
|
||||
if (entry.m_ItemID != 1)
|
||||
mcl.Add(entry.m_ItemID, x + entry.m_OffsetX, y + entry.m_OffsetY, z + entry.m_OffsetZ);
|
||||
}
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
TraceValidity(state, itemID);
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the stairs
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
// Add the stairs : Load data describing stair components
|
||||
MultiComponentList stairs = MultiData.GetComponents(itemID);
|
||||
|
||||
// Add the stairs : Insert described components
|
||||
int z = GetLevelZ(context.Level, context.Foundation);
|
||||
|
||||
for (int i = 0; i < stairs.List.Length; ++i)
|
||||
{
|
||||
MultiTileEntry entry = stairs.List[i];
|
||||
|
||||
if (entry.m_ItemID != 1)
|
||||
mcl.Add(entry.m_ItemID, x + entry.m_OffsetX, y + entry.m_OffsetY, z + entry.m_OffsetZ);
|
||||
}
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
}
|
||||
|
||||
private static void TraceValidity(NetState state, int itemID)
|
||||
|
|
@ -1582,41 +1538,41 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client chose to add a component
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client chose to add a component
|
||||
* - Read data detailing component graphic and location
|
||||
* - Add component
|
||||
* - Update revision
|
||||
*/
|
||||
|
||||
// Read data detailing component graphic and location
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
// Read data detailing component graphic and location
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
|
||||
// Add component
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
// Add component
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID))
|
||||
{
|
||||
TraceValidity(state, itemID);
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
int z = GetLevelZ(context.Level, context.Foundation);
|
||||
|
||||
if (y + mcl.Center.Y == mcl.Height - 1)
|
||||
z = 0; // Tiles placed on the far-south of the house are at 0 Z
|
||||
|
||||
mcl.Add(itemID, x, y, z);
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID))
|
||||
{
|
||||
TraceValidity(state, itemID);
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
int z = GetLevelZ(context.Level, context.Foundation);
|
||||
|
||||
if (y + mcl.Center.Y == mcl.Height - 1)
|
||||
z = 0; // Tiles placed on the far-south of the house are at 0 Z
|
||||
|
||||
mcl.Add(itemID, x, y, z);
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
}
|
||||
|
||||
public static void Designer_Close(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1624,9 +1580,10 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client closed his house design window
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client closed his house design window
|
||||
* - Remove design context
|
||||
* - Notify the client that customization has ended
|
||||
* - Refresh client with current visible design state
|
||||
|
|
@ -1635,31 +1592,30 @@ namespace Server.Multis
|
|||
* - Restore relocated entities
|
||||
*/
|
||||
|
||||
// Remove design context
|
||||
DesignContext.Remove(from);
|
||||
// Remove design context
|
||||
DesignContext.Remove(from);
|
||||
|
||||
// Notify the client that customization has ended
|
||||
from.Send(new EndHouseCustomization(context.Foundation));
|
||||
// Notify the client that customization has ended
|
||||
from.Send(new EndHouseCustomization(context.Foundation));
|
||||
|
||||
// Refresh client with current visible design state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
context.Foundation.CurrentState.SendDetailedInfoTo(state);
|
||||
// Refresh client with current visible design state
|
||||
context.Foundation.SendInfoTo(state);
|
||||
context.Foundation.CurrentState.SendDetailedInfoTo(state);
|
||||
|
||||
// If a signpost is needed, add it
|
||||
context.Foundation.CheckSignpost();
|
||||
// If a signpost is needed, add it
|
||||
context.Foundation.CheckSignpost();
|
||||
|
||||
// Eject all from house
|
||||
from.RevealingAction();
|
||||
// Eject all from house
|
||||
from.RevealingAction();
|
||||
|
||||
foreach (Item item in context.Foundation.GetItems())
|
||||
item.Location = context.Foundation.BanLocation;
|
||||
foreach (Item item in context.Foundation.GetItems())
|
||||
item.Location = context.Foundation.BanLocation;
|
||||
|
||||
foreach (Mobile mobile in context.Foundation.GetMobiles())
|
||||
mobile.Location = context.Foundation.BanLocation;
|
||||
foreach (Mobile mobile in context.Foundation.GetMobiles())
|
||||
mobile.Location = context.Foundation.BanLocation;
|
||||
|
||||
// Restore relocated entities
|
||||
context.Foundation.RestoreRelocatedEntities();
|
||||
}
|
||||
// Restore relocated entities
|
||||
context.Foundation.RestoreRelocatedEntities();
|
||||
}
|
||||
|
||||
public static void Designer_Level(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1667,9 +1623,10 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
/* Client is moving to a new floor level
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
/* Client is moving to a new floor level
|
||||
* - Read data detailing the target level
|
||||
* - Validate target level
|
||||
* - Update design context with new level
|
||||
|
|
@ -1678,39 +1635,31 @@ namespace Server.Multis
|
|||
*
|
||||
*/
|
||||
|
||||
// Read data detailing the target level
|
||||
int newLevel = pvSrc.ReadInt32();
|
||||
// Read data detailing the target level
|
||||
int newLevel = pvSrc.ReadInt32();
|
||||
|
||||
// Validate target level
|
||||
if (newLevel < 1 || newLevel > context.MaxLevels)
|
||||
newLevel = 1;
|
||||
// Validate target level
|
||||
if (newLevel < 1 || newLevel > context.MaxLevels)
|
||||
newLevel = 1;
|
||||
|
||||
// Update design context with new level
|
||||
context.Level = newLevel;
|
||||
// Update design context with new level
|
||||
context.Level = newLevel;
|
||||
|
||||
// Teleport mobile to new level
|
||||
from.Location = new Point3D(from.X, from.Y, context.Foundation.Z + GetLevelZ(newLevel, context.Foundation));
|
||||
// Teleport mobile to new level
|
||||
from.Location = new Point3D(from.X, from.Y, context.Foundation.Z + GetLevelZ(newLevel, context.Foundation));
|
||||
|
||||
// Update client
|
||||
context.Foundation.SendInfoTo(state);
|
||||
}
|
||||
// Update client
|
||||
context.Foundation.SendInfoTo(state);
|
||||
}
|
||||
|
||||
public static void QueryDesignDetails(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (World.FindItem(pvSrc.ReadUInt32()) is HouseFoundation foundation && from.Map == foundation.Map && from.InRange(foundation.GetWorldLocation(), 24) &&
|
||||
from.CanSee(foundation))
|
||||
{
|
||||
DesignState stateToSend;
|
||||
|
||||
if (context != null && context.Foundation == foundation)
|
||||
stateToSend = foundation.DesignState;
|
||||
else
|
||||
stateToSend = foundation.CurrentState;
|
||||
|
||||
DesignState stateToSend = DesignContext.Find(from)?.Foundation == foundation ? foundation.DesignState : foundation.CurrentState;
|
||||
stateToSend.SendDetailedInfoTo(state);
|
||||
}
|
||||
}
|
||||
|
|
@ -1720,46 +1669,46 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null && (Core.SE || from.AccessLevel >= AccessLevel.GameMaster))
|
||||
if (context == null || !Core.SE && from.AccessLevel < AccessLevel.GameMaster)
|
||||
return;
|
||||
|
||||
// Read data detailing component graphic and location
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
int z = pvSrc.ReadInt32();
|
||||
|
||||
// Add component
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID, true))
|
||||
{
|
||||
// Read data detailing component graphic and location
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
int z = pvSrc.ReadInt32();
|
||||
|
||||
// Add component
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID, true))
|
||||
{
|
||||
TraceValidity(state, itemID);
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
if (z < -3 || z > 12 || z % 3 != 0)
|
||||
z = -3;
|
||||
z += GetLevelZ(context.Level, context.Foundation);
|
||||
|
||||
MultiTileEntry[] list = mcl.List;
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
MultiTileEntry mte = list[i];
|
||||
|
||||
if (mte.m_OffsetX == x && mte.m_OffsetY == y &&
|
||||
GetZLevel(mte.m_OffsetZ, context.Foundation) == context.Level &&
|
||||
(TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0)
|
||||
mcl.Remove(mte.m_ItemID, x, y, mte.m_OffsetZ);
|
||||
}
|
||||
|
||||
mcl.Add(itemID, x, y, z);
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
TraceValidity(state, itemID);
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
if (z < -3 || z > 12 || z % 3 != 0)
|
||||
z = -3;
|
||||
z += GetLevelZ(context.Level, context.Foundation);
|
||||
|
||||
MultiTileEntry[] list = mcl.List;
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
MultiTileEntry mte = list[i];
|
||||
|
||||
if (mte.m_OffsetX == x && mte.m_OffsetY == y &&
|
||||
GetZLevel(mte.m_OffsetZ, context.Foundation) == context.Level &&
|
||||
(TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0)
|
||||
mcl.Remove(mte.m_ItemID, x, y, mte.m_OffsetZ);
|
||||
}
|
||||
|
||||
mcl.Add(itemID, x, y, z);
|
||||
|
||||
// Update revision
|
||||
design.OnRevised();
|
||||
}
|
||||
|
||||
public static void Designer_RoofDelete(NetState state, IEntity e, EncodedReader pvSrc)
|
||||
|
|
@ -1767,29 +1716,29 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
if (context != null
|
||||
) // No need to check for Core.SE if trying to remove something that shouldn't be able to be placed anyways
|
||||
// No need to check for Core.SE if trying to remove something that shouldn't be able to be placed anyways
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
// Read data detailing which component to delete
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
int z = pvSrc.ReadInt32();
|
||||
|
||||
// Verify component is deletable
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
if ((TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.Roof) == 0)
|
||||
{
|
||||
// Read data detailing which component to delete
|
||||
int itemID = pvSrc.ReadInt32();
|
||||
int x = pvSrc.ReadInt32();
|
||||
int y = pvSrc.ReadInt32();
|
||||
int z = pvSrc.ReadInt32();
|
||||
|
||||
// Verify component is deletable
|
||||
DesignState design = context.Foundation.DesignState;
|
||||
MultiComponentList mcl = design.Components;
|
||||
|
||||
if ((TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.Roof) == 0)
|
||||
{
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
mcl.Remove(itemID, x, y, z);
|
||||
|
||||
design.OnRevised();
|
||||
design.SendDetailedInfoTo(state);
|
||||
return;
|
||||
}
|
||||
|
||||
mcl.Remove(itemID, x, y, z);
|
||||
|
||||
design.OnRevised();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2022,10 +1971,8 @@ namespace Server.Multis
|
|||
// TOL doors
|
||||
if (itemID >= 0x9AD7 && itemID < 0x9AE7)
|
||||
return true;
|
||||
if (itemID >= 0x9B3C && itemID < 0x9B4C)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return itemID >= 0x9B3C && itemID < 0x9B4C;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2048,35 +1995,35 @@ namespace Server.Multis
|
|||
|
||||
AddAlphaRegion(10, 10, 300, 300);
|
||||
|
||||
AddHtmlLocalized(10, 10, 300, 20, 1062060, 32736, false, false); // <CENTER>COMMIT DESIGN</CENTER>
|
||||
AddHtmlLocalized(10, 10, 300, 20, 1062060, 32736); // <CENTER>COMMIT DESIGN</CENTER>
|
||||
|
||||
AddHtmlLocalized(10, 40, 300, 140, newPrice - oldPrice <= bankBalance ? 1061898 : 1061903, 1023, false, true);
|
||||
|
||||
AddHtmlLocalized(10, 190, 150, 20, 1061902, 32736, false, false); // Bank Balance:
|
||||
AddHtmlLocalized(10, 190, 150, 20, 1061902, 32736); // Bank Balance:
|
||||
AddLabel(170, 190, 55, bankBalance.ToString());
|
||||
|
||||
AddHtmlLocalized(10, 215, 150, 20, 1061899, 1023, false, false); // Old Value:
|
||||
AddHtmlLocalized(10, 215, 150, 20, 1061899, 1023); // Old Value:
|
||||
AddLabel(170, 215, 90, oldPrice.ToString());
|
||||
|
||||
AddHtmlLocalized(10, 235, 150, 20, 1061900, 1023, false, false); // Cost To Commit:
|
||||
AddHtmlLocalized(10, 235, 150, 20, 1061900, 1023); // Cost To Commit:
|
||||
AddLabel(170, 235, 90, newPrice.ToString());
|
||||
|
||||
if (newPrice - oldPrice < 0)
|
||||
{
|
||||
AddHtmlLocalized(10, 260, 150, 20, 1062059, 992, false, false); // Your Refund:
|
||||
AddHtmlLocalized(10, 260, 150, 20, 1062059, 992); // Your Refund:
|
||||
AddLabel(170, 260, 70, (oldPrice - newPrice).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized(10, 260, 150, 20, 1061901, 31744, false, false); // Your Cost:
|
||||
AddHtmlLocalized(10, 260, 150, 20, 1061901, 31744); // Your Cost:
|
||||
AddLabel(170, 260, 40, (newPrice - oldPrice).ToString());
|
||||
}
|
||||
|
||||
AddButton(10, 290, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(45, 290, 55, 20, 1011036, 32767, false, false); // OKAY
|
||||
AddButton(10, 290, 4005, 4007, 1);
|
||||
AddHtmlLocalized(45, 290, 55, 20, 1011036, 32767); // OKAY
|
||||
|
||||
AddButton(170, 290, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(195, 290, 55, 20, 1011012, 32767, false, false); // CANCEL
|
||||
AddButton(170, 290, 4005, 4007, 0);
|
||||
AddHtmlLocalized(195, 290, 55, 20, 1011012, 32767); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
|
|
@ -2114,13 +2061,12 @@ namespace Server.Multis
|
|||
|
||||
public static bool Check(Mobile m)
|
||||
{
|
||||
if (Find(m) != null)
|
||||
{
|
||||
m.SendLocalizedMessage(1062206); // You cannot do that while customizing a house.
|
||||
return false;
|
||||
}
|
||||
if (Find(m) == null)
|
||||
return true;
|
||||
|
||||
m.SendLocalizedMessage(1062206); // You cannot do that while customizing a house.
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Add(Mobile from, HouseFoundation foundation)
|
||||
|
|
@ -2523,7 +2469,7 @@ namespace Server.Multis
|
|||
|
||||
m_Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 4);
|
||||
}
|
||||
|
||||
|
||||
public void Write(uint value)
|
||||
{
|
||||
m_PrimBuffer[0] = (byte)(value >> 24);
|
||||
|
|
@ -2617,6 +2563,7 @@ namespace Server.Multis
|
|||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
@ -2669,4 +2616,4 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Regions;
|
||||
using Server.Spells;
|
||||
|
|
@ -325,13 +324,12 @@ namespace Server.Multis
|
|||
{
|
||||
_sectors.Add(sector);
|
||||
|
||||
if (sector.Multis != null)
|
||||
for (int j = 0; j < sector.Multis.Count; j++)
|
||||
if (sector.Multis[j] is BaseHouse)
|
||||
{
|
||||
BaseHouse _house = (BaseHouse)sector.Multis[j];
|
||||
if (!_houses.Contains(_house)) _houses.Add(_house);
|
||||
}
|
||||
for (int j = 0; j < sector.Multis?.Count; j++)
|
||||
if (sector.Multis[j] is BaseHouse)
|
||||
{
|
||||
BaseHouse _house = (BaseHouse)sector.Multis[j];
|
||||
if (!_houses.Contains(_house)) _houses.Add(_house);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Gumps;
|
||||
|
|
@ -72,19 +71,19 @@ namespace Server.Items
|
|||
AddImageTiled(10, 10, 250, 125, 2624);
|
||||
AddAlphaRegion(10, 10, 250, 125);
|
||||
|
||||
AddHtmlLocalized(10, 10, 250, 20, 1060239, LabelColor, false, false); // <CENTER>HOUSE PLACEMENT TOOL</CENTER>
|
||||
AddHtmlLocalized(10, 10, 250, 20, 1060239, LabelColor); // <CENTER>HOUSE PLACEMENT TOOL</CENTER>
|
||||
|
||||
AddButton(10, 110, 4017, 4019, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(45, 110, 150, 20, 3000363, LabelColor, false, false); // Close
|
||||
AddButton(10, 110, 4017, 4019, 0);
|
||||
AddHtmlLocalized(45, 110, 150, 20, 3000363, LabelColor); // Close
|
||||
|
||||
AddButton(10, 40, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(45, 40, 200, 20, 1060390, LabelColor, false, false); // Classic Houses
|
||||
AddButton(10, 40, 4005, 4007, 1);
|
||||
AddHtmlLocalized(45, 40, 200, 20, 1060390, LabelColor); // Classic Houses
|
||||
|
||||
AddButton(10, 60, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(45, 60, 200, 20, 1060391, LabelColor, false, false); // 2-Story Customizable Houses
|
||||
AddButton(10, 60, 4005, 4007, 2);
|
||||
AddHtmlLocalized(45, 60, 200, 20, 1060391, LabelColor); // 2-Story Customizable Houses
|
||||
|
||||
AddButton(10, 80, 4005, 4007, 3, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(45, 80, 200, 20, 1060392, LabelColor, false, false); // 3-Story Customizable Houses
|
||||
AddButton(10, 80, 4005, 4007, 3);
|
||||
AddHtmlLocalized(45, 80, 200, 20, 1060392, LabelColor); // 3-Story Customizable Houses
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
|
|
@ -135,15 +134,15 @@ namespace Server.Items
|
|||
AddImageTiled(10, 10, 500, 20, 2624);
|
||||
AddAlphaRegion(10, 10, 500, 20);
|
||||
|
||||
AddHtmlLocalized(10, 10, 500, 20, 1060239, LabelColor, false, false); // <CENTER>HOUSE PLACEMENT TOOL</CENTER>
|
||||
AddHtmlLocalized(10, 10, 500, 20, 1060239, LabelColor); // <CENTER>HOUSE PLACEMENT TOOL</CENTER>
|
||||
|
||||
AddImageTiled(10, 40, 500, 20, 2624);
|
||||
AddAlphaRegion(10, 40, 500, 20);
|
||||
|
||||
AddHtmlLocalized(50, 40, 225, 20, 1060235, LabelColor, false, false); // House Description
|
||||
AddHtmlLocalized(275, 40, 75, 20, 1060236, LabelColor, false, false); // Storage
|
||||
AddHtmlLocalized(350, 40, 75, 20, 1060237, LabelColor, false, false); // Lockdowns
|
||||
AddHtmlLocalized(425, 40, 75, 20, 1060034, LabelColor, false, false); // Cost
|
||||
AddHtmlLocalized(50, 40, 225, 20, 1060235, LabelColor); // House Description
|
||||
AddHtmlLocalized(275, 40, 75, 20, 1060236, LabelColor); // Storage
|
||||
AddHtmlLocalized(350, 40, 75, 20, 1060237, LabelColor); // Lockdowns
|
||||
AddHtmlLocalized(425, 40, 75, 20, 1060034, LabelColor); // Cost
|
||||
|
||||
AddImageTiled(10, 70, 500, 280, 2624);
|
||||
AddAlphaRegion(10, 70, 500, 280);
|
||||
|
|
@ -151,14 +150,14 @@ namespace Server.Items
|
|||
AddImageTiled(10, 360, 500, 20, 2624);
|
||||
AddAlphaRegion(10, 360, 500, 20);
|
||||
|
||||
AddHtmlLocalized(10, 360, 250, 20, 1060645, LabelColor, false, false); // Bank Balance:
|
||||
AddHtmlLocalized(10, 360, 250, 20, 1060645, LabelColor); // Bank Balance:
|
||||
AddLabel(250, 360, LabelHue, Banker.GetBalance(from).ToString());
|
||||
|
||||
AddImageTiled(10, 390, 500, 20, 2624);
|
||||
AddAlphaRegion(10, 390, 500, 20);
|
||||
|
||||
AddButton(10, 390, 4017, 4019, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(50, 390, 100, 20, 3000363, LabelColor, false, false); // Close
|
||||
AddButton(10, 390, 4017, 4019, 0);
|
||||
AddHtmlLocalized(50, 390, 100, 20, 3000363, LabelColor); // Close
|
||||
|
||||
for (int i = 0; i < entries.Length; ++i)
|
||||
{
|
||||
|
|
@ -170,7 +169,7 @@ namespace Server.Items
|
|||
if (page > 1)
|
||||
{
|
||||
AddButton(450, 390, 4005, 4007, 0, GumpButtonType.Page, page);
|
||||
AddHtmlLocalized(400, 390, 100, 20, 3000406, LabelColor, false, false); // Next
|
||||
AddHtmlLocalized(400, 390, 100, 20, 3000406, LabelColor); // Next
|
||||
}
|
||||
|
||||
AddPage(page);
|
||||
|
|
@ -178,7 +177,7 @@ namespace Server.Items
|
|||
if (page > 1)
|
||||
{
|
||||
AddButton(200, 390, 4014, 4016, 0, GumpButtonType.Page, page - 1);
|
||||
AddHtmlLocalized(250, 390, 100, 20, 3000405, LabelColor, false, false); // Previous
|
||||
AddHtmlLocalized(250, 390, 100, 20, 3000405, LabelColor); // Previous
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,8 +185,8 @@ namespace Server.Items
|
|||
|
||||
int y = 70 + index * 20;
|
||||
|
||||
AddButton(10, y, 4005, 4007, 1 + i, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(50, y, 225, 20, entry.Description, LabelColor, false, false);
|
||||
AddButton(10, y, 4005, 4007, 1 + i);
|
||||
AddHtmlLocalized(50, y, 225, 20, entry.Description, LabelColor);
|
||||
AddLabel(275, y, LabelHue, entry.Storage.ToString());
|
||||
AddLabel(350, y, LabelHue, entry.Lockdowns.ToString());
|
||||
AddLabel(425, y, LabelHue, entry.Cost.ToString());
|
||||
|
|
@ -809,9 +808,7 @@ namespace Server.Items
|
|||
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];
|
||||
|
|
|
|||
|
|
@ -23,10 +23,11 @@ namespace Server.Multis
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool RestrictDecay
|
||||
{
|
||||
get => Owner != null && Owner.RestrictDecay;
|
||||
get => Owner?.RestrictDecay == true;
|
||||
set
|
||||
{
|
||||
if (Owner != null) Owner.RestrictDecay = value;
|
||||
if (Owner != null)
|
||||
Owner.RestrictDecay = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,17 +40,14 @@ namespace Server.Multis
|
|||
|
||||
public string GetName()
|
||||
{
|
||||
if (Name == null)
|
||||
return "An Unnamed House";
|
||||
|
||||
return Name;
|
||||
return Name ?? "An Unnamed House";
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if (Owner != null && !Owner.Deleted)
|
||||
if (Owner?.Deleted == false)
|
||||
Owner.Delete();
|
||||
}
|
||||
|
||||
|
|
@ -152,12 +150,7 @@ namespace Server.Multis
|
|||
{
|
||||
if (okay && Owner != null && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||
{
|
||||
bool canClaim;
|
||||
|
||||
if (Owner.CoOwners == null || Owner.CoOwners.Count == 0)
|
||||
canClaim = Owner.IsFriend(from);
|
||||
else
|
||||
canClaim = Owner.IsCoOwner(from);
|
||||
bool canClaim = Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from) || Owner.IsFriend(from);
|
||||
|
||||
if (canClaim && !BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
|
|
@ -177,12 +170,7 @@ namespace Server.Multis
|
|||
if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null &&
|
||||
Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||
{
|
||||
bool canClaim = false;
|
||||
|
||||
if (Owner.CoOwners == null || Owner.CoOwners.Count == 0)
|
||||
canClaim = Owner.IsFriend(m);
|
||||
else
|
||||
canClaim = Owner.IsCoOwner(m);
|
||||
bool canClaim = Owner?.CoOwners.Count > 0 && Owner.IsCoOwner(m) || Owner.IsFriend(m);
|
||||
|
||||
if (canClaim && !BaseHouse.HasAccountHouse(m))
|
||||
m.SendGump(new WarningGump(501036, 32512, 1049719, 32512, 420, 280, okay => ClaimGump_Callback(m, okay)));
|
||||
|
|
@ -195,14 +183,14 @@ namespace Server.Multis
|
|||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
if (BaseHouse.NewVendorSystem && from.Alive && Owner != null && Owner.IsAosRules)
|
||||
{
|
||||
if (Owner.AreThereAvailableVendorsFor(from))
|
||||
list.Add(new VendorsEntry(this));
|
||||
if (!BaseHouse.NewVendorSystem || !from.Alive || Owner?.IsAosRules != true)
|
||||
return;
|
||||
|
||||
if (Owner.VendorInventories.Count > 0)
|
||||
list.Add(new ReclaimVendorInventoryEntry(this));
|
||||
}
|
||||
if (Owner.AreThereAvailableVendorsFor(from))
|
||||
list.Add(new VendorsEntry(this));
|
||||
|
||||
if (Owner.VendorInventories.Count > 0)
|
||||
list.Add(new ReclaimVendorInventoryEntry(this));
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -291,4 +279,4 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,7 @@ namespace Server.Items
|
|||
{
|
||||
public class HouseTeleporter : Item, ISecurable
|
||||
{
|
||||
[Constructible]
|
||||
public HouseTeleporter(int itemID) : this(itemID, null)
|
||||
{
|
||||
}
|
||||
|
||||
public HouseTeleporter(int itemID, Item target) : base(itemID)
|
||||
public HouseTeleporter(int itemID, Item target = null) : base(itemID)
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
|
|
@ -37,15 +32,13 @@ namespace Server.Items
|
|||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
if (house != null && (house.Public ? house.IsBanned(m) : !house.HasAccess(m)))
|
||||
return false;
|
||||
|
||||
return house != null && house.HasSecureAccess(m, Level);
|
||||
return (house == null || house.Public && !house.IsBanned(m) || house.HasAccess(m)) &&
|
||||
house?.HasSecureAccess(m, Level) == true;
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (Target != null && !Target.Deleted)
|
||||
if (Target?.Deleted == false)
|
||||
{
|
||||
if (CheckAccess(m))
|
||||
{
|
||||
|
|
@ -145,35 +138,35 @@ namespace Server.Items
|
|||
{
|
||||
Item target = m_Teleporter.Target;
|
||||
|
||||
if (target != null && !target.Deleted)
|
||||
{
|
||||
Mobile m = m_Mobile;
|
||||
if (target?.Deleted != false)
|
||||
return;
|
||||
|
||||
if (m.Location == m_Teleporter.Location && m.Map == m_Teleporter.Map)
|
||||
{
|
||||
Point3D p = target.GetWorldTop();
|
||||
Map map = target.Map;
|
||||
Mobile m = m_Mobile;
|
||||
|
||||
BaseCreature.TeleportPets(m, p, map);
|
||||
if (m.Location != m_Teleporter.Location || m.Map != m_Teleporter.Map)
|
||||
return;
|
||||
|
||||
m.MoveToWorld(p, map);
|
||||
Point3D p = target.GetWorldTop();
|
||||
Map map = target.Map;
|
||||
|
||||
if (!m.Hidden || m.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
Effects.PlaySound(target.Location, target.Map, 0x1FE);
|
||||
BaseCreature.TeleportPets(m, p, map);
|
||||
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(m_Teleporter.Location, m_Teleporter.Map, EffectItem.DefaultDuration),
|
||||
0x3728, 10, 10, 2023, 0);
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 10, 10,
|
||||
5023, 0);
|
||||
m.MoveToWorld(p, map);
|
||||
|
||||
new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m.Hidden && m.AccessLevel != AccessLevel.Player)
|
||||
return;
|
||||
|
||||
Effects.PlaySound(target.Location, target.Map, 0x1FE);
|
||||
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(m_Teleporter.Location, m_Teleporter.Map, EffectItem.DefaultDuration),
|
||||
0x3728, 10, 10, 2023, 0);
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 10, 10,
|
||||
5023, 0);
|
||||
|
||||
new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,12 +141,12 @@ namespace Server.Multis
|
|||
|
||||
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
|
||||
{
|
||||
return base.CheckLift(from, item, ref reject) && House != null && !House.Deleted && House.IsOwner(from);
|
||||
return House?.Deleted == false && base.CheckLift(from, item, ref reject) && House.IsOwner(from);
|
||||
}
|
||||
|
||||
public override bool CheckItemUse(Mobile from, Item item)
|
||||
{
|
||||
return base.CheckItemUse(from, item) && House != null && !House.Deleted && House.IsOwner(from);
|
||||
return House?.Deleted == false && base.CheckItemUse(from, item) && House.IsOwner(from);
|
||||
}
|
||||
|
||||
public override void OnItemRemoved(Item item)
|
||||
|
|
@ -197,7 +197,7 @@ namespace Server.Multis
|
|||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if (House != null && House.MovingCrate == this)
|
||||
if (House?.MovingCrate == this)
|
||||
House.MovingCrate = null;
|
||||
|
||||
m_InternalizeTimer?.Stop();
|
||||
|
|
@ -311,4 +311,4 @@ namespace Server.Multis
|
|||
MaxItems = -1; // reset to default
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue