Revert "Updates Packets & Randomizer (#43)" (#61)

This reverts commit 179cb50557.
This commit is contained in:
Kamron Batman 2019-11-11 08:46:11 -08:00 committed by GitHub
parent 179cb50557
commit c2ecc76457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
588 changed files with 16260 additions and 10926 deletions

View file

@ -24,7 +24,7 @@ namespace Server.Multis
public const int MaximumBarkeepCount = 2;
private static readonly Dictionary<Mobile, List<BaseHouse>> m_Table = new Dictionary<Mobile, List<BaseHouse>>();
private static Dictionary<Mobile, List<BaseHouse>> m_Table = new Dictionary<Mobile, List<BaseHouse>>();
private DecayLevel m_LastDecayLevel;
@ -148,7 +148,10 @@ namespace Server.Multis
newest = check;
}
return this == newest ? DecayType.AutoRefresh : DecayType.ManualRefresh;
if (this == newest)
return DecayType.AutoRefresh;
return DecayType.ManualRefresh;
}
}
@ -215,13 +218,43 @@ namespace Server.Multis
public virtual bool IsActive => true;
public bool HasPersonalVendors => PlayerVendors.Any(vendor => !(vendor is RentedVendor));
public bool HasPersonalVendors
{
get
{
foreach (PlayerVendor vendor in PlayerVendors)
if (!(vendor is RentedVendor))
return true;
public bool HasRentedVendors => PlayerVendors.OfType<RentedVendor>().Any();
return false;
}
}
public bool HasRentedVendors
{
get
{
foreach (PlayerVendor vendor in PlayerVendors)
if (vendor is RentedVendor)
return true;
return false;
}
}
#region Mondain's Legacy
public bool HasAddonContainers => Addons.OfType<BaseAddonContainer>().Any();
public bool HasAddonContainers
{
get
{
foreach (Item item in Addons)
if (item is BaseAddonContainer)
return true;
return false;
}
}
#endregion
@ -331,7 +364,9 @@ namespace Server.Multis
{
get
{
int count = GetLockdowns();
int count = 0;
count += GetLockdowns();
if (Secures != null)
for (int i = 0; i < Secures.Count; ++i)
@ -350,7 +385,26 @@ namespace Server.Multis
}
}
public int SecureCount => Secures?.Where(info => !info.Item.Deleted).Count(info => !(info.Item is StrongBox)) ?? 0;
public int SecureCount
{
get
{
int count = 0;
if (Secures != null)
for (int i = 0; i < Secures.Count; i++)
{
SecureInfo info = Secures[i];
if (info.Item.Deleted)
continue;
if (!(info.Item is StrongBox))
count += 1;
}
return count;
}
}
public List<Item> Addons{ get; set; }
@ -488,9 +542,11 @@ namespace Server.Multis
{
HousePlacementEntry hpe = GetAosEntry();
public virtual int GetAosMaxSecures() => (int)(GetAosEntry()?.Storage ?? 0 * BonusStorageScalar);
if (hpe == null)
return 0;
public virtual int GetAosMaxLockdowns() => (int)(GetAosEntry()?.Lockdowns ?? 0 * BonusStorageScalar);
return (int)(hpe.Lockdowns * BonusStorageScalar);
}
public virtual int GetAosCurSecures(out int fromSecures, out int fromVendors, out int fromLockdowns,
out int fromMovingCrate)
@ -504,14 +560,22 @@ namespace Server.Multis
if (list != null)
{
fromSecures += list.Sum(si => si.Item.TotalItems);
for (int i = 0; i < list.Count; ++i)
{
SecureInfo si = list[i];
fromSecures += si.Item.TotalItems;
}
fromLockdowns += list.Count;
}
fromLockdowns += GetLockdowns();
if (!NewVendorSystem)
fromVendors += PlayerVendors.Where(vendor => vendor.Backpack != null).Sum(vendor => vendor.Backpack.TotalItems);
foreach (PlayerVendor vendor in PlayerVendors)
if (vendor.Backpack != null)
fromVendors += vendor.Backpack.TotalItems;
if (MovingCrate != null)
{
@ -525,17 +589,18 @@ namespace Server.Multis
return fromSecures + fromVendors + fromLockdowns + fromMovingCrate;
}
public bool InRange(IPoint2D from, int range) =>
Region?.Area.Any(rect =>
from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range)
== true;
public bool InRange(IPoint2D from, int range)
{
if (Region == null)
return false;
public virtual int GetNewVendorSystemMaxVendors() =>
(int)(GetAosEntry()?.Vendors ?? 0 * BonusStorageScalar);
foreach (Rectangle3D rect in Region.Area)
if (from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range &&
from.Y < rect.End.Y + range)
return true;
public virtual bool CanPlaceNewVendor() =>
!IsAosRules || (!NewVendorSystem ? CheckAosLockdowns(10) :
PlayerVendors.Count + VendorRentalContracts.Count < GetNewVendorSystemMaxVendors());
return false;
}
public virtual int GetNewVendorSystemMaxVendors()
{
@ -586,11 +651,25 @@ namespace Server.Multis
eable.Free();
}
public List<Mobile> AvailableVendorsFor(Mobile m) =>
PlayerVendors.Where(vendor => vendor.CanInteractWith(m, false)).Cast<Mobile>().ToList();
public List<Mobile> AvailableVendorsFor(Mobile m)
{
List<Mobile> list = new List<Mobile>();
public bool AreThereAvailableVendorsFor(Mobile m) =>
PlayerVendors.Any(vendor => vendor.CanInteractWith(m, false));
foreach (PlayerVendor vendor in PlayerVendors)
if (vendor.CanInteractWith(m, false))
list.Add(vendor);
return list;
}
public bool AreThereAvailableVendorsFor(Mobile m)
{
foreach (PlayerVendor vendor in PlayerVendors)
if (vendor.CanInteractWith(m, false))
return true;
return false;
}
public void MoveAllToCrate()
{
@ -617,7 +696,7 @@ namespace Server.Multis
LockDowns.Clear();
foreach (VendorRentalContract item in VendorRentalContracts)
foreach (Item item in VendorRentalContracts)
if (!item.Deleted)
{
item.IsLockedDown = false;
@ -732,10 +811,25 @@ namespace Server.Multis
if (m_Trash != null && m_Trash.Map != Map.Internal)
list.Add(m_Trash);
list.AddRange(LockDowns.Where(item => item.Parent == null && item.Map != Map.Internal));
list.AddRange(VendorRentalContracts.Cast<Item>().Where(item => item.Parent == null && item.Map != Map.Internal));
list.AddRange(Secures.Select(info => info.Item).Where(item => item.Parent == null && item.Map != Map.Internal));
list.AddRange(Addons.Where(item => item.Parent == null && item.Map != Map.Internal));
foreach (Item item in LockDowns)
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
foreach (Item item in VendorRentalContracts)
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
foreach (SecureInfo info in Secures)
{
Item item = info.Item;
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
}
foreach (Item item in Addons)
if (item.Parent == null && item.Map != Map.Internal)
list.Add(item);
foreach (PlayerVendor mobile in PlayerVendors)
{
@ -745,7 +839,9 @@ namespace Server.Multis
list.Add(mobile);
}
list.AddRange(PlayerBarkeepers.Cast<Mobile>().Where(mobile => mobile.Map != Map.Internal));
foreach (Mobile mobile in PlayerBarkeepers)
if (mobile.Map != Map.Internal)
list.Add(mobile);
return list;
}
@ -812,7 +908,9 @@ namespace Server.Multis
// The item can't fit
if (item is TrashBarrel)
{
item.Delete(); // Trash barrels don't go to the moving crate
}
else
{
SetLockdown(item, false);
@ -897,7 +995,9 @@ namespace Server.Multis
public void DropToMovingCrate(Item item)
{
MovingCrate ??= new MovingCrate(this);
if (MovingCrate == null)
MovingCrate = new MovingCrate(this);
MovingCrate.DropItem(item);
}
@ -918,11 +1018,12 @@ namespace Server.Multis
return list;
}
public List<Mobile> GetMobiles() =>
Map == null || Map == Map.Internal ? new List<Mobile>()
: Region.GetMobiles().Where(IsInside).ToList();
public List<Mobile> GetMobiles()
{
if (Map == null || Map == Map.Internal)
return new List<Mobile>();
public virtual bool CheckAosLockdowns(int need) => GetAosCurLockdowns() + need <= GetAosMaxLockdowns();
List<Mobile> list = new List<Mobile>();
foreach (Mobile mobile in Region.GetMobiles())
if (IsInside(mobile))
@ -945,9 +1046,14 @@ namespace Server.Multis
Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), Decay_OnTick);
}
public virtual int GetAosCurLockdowns() => GetLockdowns() + Secures?.Count ?? 0 + (NewVendorSystem ? 0 : PlayerVendors.Count * 10);
public virtual int GetAosCurLockdowns()
{
int v = 0;
public static bool CheckLockedDown(Item item) => FindHouseAt(item)?.HasLockedDownItem(item) == true;
v += GetLockdowns();
if (Secures != null)
v += Secures.Count;
if (!NewVendorSystem)
v += PlayerVendors.Count * 10;
@ -1008,15 +1114,31 @@ namespace Server.Multis
BaseHouse house = FindHouseAt(item);
return house == null || house.CheckSecureAccess(m, item) switch
if (house == null)
return true;
SecureAccessResult res = house.CheckSecureAccess(m, item);
switch (res)
{
SecureAccessResult.Accessible => true,
SecureAccessResult.Inaccessible => false,
_ => (!house.HasLockedDownItem(item) || house.IsCoOwner(m) && item is Container)
};
case SecureAccessResult.Insecure: break;
case SecureAccessResult.Accessible: return true;
case SecureAccessResult.Inaccessible: return false;
}
if (house.HasLockedDownItem(item))
return house.IsCoOwner(m) && item is Container;
return true;
}
public static BaseHouse FindHouseAt(Mobile m) => m?.Deleted != false ? null : FindHouseAt(m.Location, m.Map, 16);
public static BaseHouse FindHouseAt(Mobile m)
{
if (m?.Deleted != false)
return null;
return FindHouseAt(m.Location, m.Map, 16);
}
public static BaseHouse FindHouseAt(Item item) =>
item?.Deleted != false ? null :
@ -1046,7 +1168,7 @@ namespace Server.Multis
switch (res)
{
// case SecureAccessResult.Insecure: break;
case SecureAccessResult.Insecure: break;
case SecureAccessResult.Accessible: return true;
case SecureAccessResult.Inaccessible: return false;
}
@ -1063,21 +1185,28 @@ namespace Server.Multis
return IsCoOwner(from);
if (item.Stackable)
return true;
if (item is BaseLight)
return IsFriend(from);
if (item is PotionKeg)
return IsFriend(from);
if (item is Dices)
return true;
if (item is RecallRune)
return true;
if (item is TreasureMap)
return true;
if (item is Clock)
return true;
if (item is BaseInstrument)
return true;
if (item is Dyes)
return true;
if (item is VendorRentalContract)
return true;
if (item is RewardBrazier)
return true;
return item switch
{
BaseLight _ => IsFriend(from),
PotionKeg _ => IsFriend(from),
Dices _ => true,
RecallRune _ => true,
TreasureMap _ => true,
Clock _ => true,
BaseInstrument _ => true,
Dyes _ => true,
VendorRentalContract _ => true,
RewardBrazier _ => true,
_ => false
};
return false;
}
public virtual bool IsInside(Point3D p, int height)
@ -1362,11 +1491,9 @@ namespace Server.Multis
m_Trash = new TrashBarrel { Movable = false };
m_Trash.MoveToWorld(from.Location, from.Map);
from.SendLocalizedMessage(502121);
/* You have a new trash barrel.
* Three minutes after you put something in the barrel, the trash will be emptied.
* Be forewarned, this is permanent!
*/
from.SendLocalizedMessage(502121); /* You have a new trash barrel.
* Three minutes after you put something in the barrel, the trash will be emptied.
* Be forewarned, this is permanent! */
}
else
{
@ -1435,19 +1562,31 @@ namespace Server.Multis
Item parentItem = item.Parent as Item;
if (checkIsInside && item.RootParent is Mobile)
{
m.SendLocalizedMessage(1005525); //That is not in your house
}
else if (checkIsInside && !IsInside(item.GetWorldLocation(), item.ItemData.Height))
{
m.SendLocalizedMessage(1005525); //That is not in your house
}
else if (Ethic.IsImbued(item))
{
m.SendLocalizedMessage(1005377); //You cannot lock that down
}
else if (HasSecureItem(rootItem))
{
m.SendLocalizedMessage(501737); // You need not lock down items in a secure container.
}
else if (parentItem != null && !HasLockedDownItem(parentItem))
{
m.SendLocalizedMessage(501736); // You must lockdown the container first!
}
else if (!(item is VendorRentalContract) && (IsAosRules
? !CheckAosLockdowns(amt) || !CheckAosStorage(amt)
: LockDownCount + amt > MaxLockDowns))
{
m.SendLocalizedMessage(1005379); //That would exceed the maximum lock down limit for this house
}
else
{
SetLockdown(item, true);
@ -1460,9 +1599,13 @@ namespace Server.Multis
return true;
}
else if (item is HouseSign || item is Static)
{
m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1005526); // This is already locked down.
}
else
{
m.SendLocalizedMessage(1005377); //You cannot lock that down
}
return false;
}
@ -1501,17 +1644,25 @@ namespace Server.Multis
return;
if (NewVendorSystem && HasPersonalVendors)
{
from.SendLocalizedMessage(
1062467); // You cannot trade this house while you still have personal vendors inside.
}
else if (DecayLevel == DecayLevel.DemolitionPending)
{
from.SendLocalizedMessage(
1005321); // This house has been marked for demolition, and it cannot be transferred.
}
else if (from == to)
{
from.SendLocalizedMessage(1005330); // You cannot transfer a house to yourself, silly.
}
else if (to.Player)
{
if (HasAccountHouse(to))
{
from.SendLocalizedMessage(501388); // You cannot transfer ownership to another house owner or co-owner!
}
else if (CheckTransferPosition(from, to))
{
from.SendLocalizedMessage(1005326); // Please wait while the other player verifies the transfer.
@ -1558,17 +1709,25 @@ namespace Server.Multis
return;
if (NewVendorSystem && HasPersonalVendors)
{
from.SendLocalizedMessage(
1062467); // You cannot trade this house while you still have personal vendors inside.
}
else if (DecayLevel == DecayLevel.DemolitionPending)
{
from.SendLocalizedMessage(
1005321); // This house has been marked for demolition, and it cannot be transferred.
}
else if (from == to)
{
from.SendLocalizedMessage(1005330); // You cannot transfer a house to yourself, silly.
}
else if (to.Player)
{
if (HasAccountHouse(to))
{
from.SendLocalizedMessage(501388); // You cannot transfer ownership to another house owner or co-owner!
}
else if (CheckTransferPosition(from, to))
{
NetState fromState = from.NetState, toState = to.NetState;
@ -1576,14 +1735,20 @@ namespace Server.Multis
if (fromState != null && toState != null)
{
if (from.HasTrade)
{
from.SendLocalizedMessage(
1062071); // You cannot trade a house while you have other trades pending.
}
else if (to.HasTrade)
{
to.SendLocalizedMessage(
1062071); // You cannot trade a house while you have other trades pending.
}
else if (!to.Alive)
{
// TODO: Check if the message is correct.
from.SendLocalizedMessage(1062069); // You cannot transfer this house to that person.
}
else
{
Container c = fromState.AddTrade(toState);
@ -1594,7 +1759,9 @@ namespace Server.Multis
}
}
else
{
from.SendLocalizedMessage(501384); // Only a player can own a house!
}
}
public void Release(Mobile m, Item item)
@ -1611,9 +1778,13 @@ namespace Server.Multis
(item as RewardBrazier)?.TurnOff();
}
else if (HasSecureItem(item))
{
ReleaseSecure(m, item);
}
else
{
m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1010416); // This is not locked down or secured.
}
}
public void AddSecure(Mobile m, Item item)
@ -1622,11 +1793,17 @@ namespace Server.Multis
return;
if (!IsInside(item))
{
m.SendLocalizedMessage(1005525); // That is not in your house
}
else if (HasLockedDownItem(item))
{
m.SendLocalizedMessage(1010550); // This is already locked down and cannot be secured.
}
else if (!(item is Container))
{
LockDown(m, item);
}
else
{
SecureInfo info = null;
@ -1641,17 +1818,27 @@ namespace Server.Multis
m.SendGump(new SetSecureLevelGump(m_Owner, info, this));
}
else if (item.Parent != null)
{
m.SendLocalizedMessage(1010423); // You cannot secure this, place it on the ground first.
}
// Mondain's Legacy mod
else if (!(item is BaseAddonContainer) && !item.Movable)
{
m.SendLocalizedMessage(1010424); // You cannot secure this.
}
else if (!IsAosRules && SecureCount >= MaxSecures)
{
// The maximum number of secure items has been reached :
m.SendLocalizedMessage(1008142, true, MaxSecures.ToString());
}
else if (IsAosRules ? !CheckAosLockdowns(1) : LockDownCount + 125 >= MaxLockDowns)
{
m.SendLocalizedMessage(1005379); // That would exceed the maximum lock down limit for this house
}
else if (IsAosRules && !CheckAosStorage(item.TotalItems))
{
m.SendLocalizedMessage(1061839); // This action would exceed the secure storage limit of the house.
}
else
{
info = new SecureInfo((Container)item, SecureLevel.Owner);
@ -1721,7 +1908,15 @@ namespace Server.Multis
item.IsLockedDown = false;
item.IsSecure = false;
item.Movable = !(item is BaseAddonContainer);
#region Mondain's Legacy
if (item is BaseAddonContainer)
item.Movable = false;
else
#endregion
item.Movable = true;
item.SetLastMoved();
item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501656); //[no longer secure]
Secures.RemoveAt(i);
@ -1787,24 +1982,33 @@ namespace Server.Multis
return;
if (targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel)
{
from.SendLocalizedMessage(501346); // Uh oh...a bigger boot may be required!
}
else if (IsFriend(targ) && !Core.ML)
{
from.SendLocalizedMessage(501348); // You cannot eject a friend of the house!
}
else if (targ is PlayerVendor)
{
from.SendLocalizedMessage(501351); // You cannot eject a vendor.
}
else if (!IsInside(targ))
{
from.SendLocalizedMessage(501352); // You may not eject someone who is not in your house!
}
else if (targ is BaseCreature creature && creature.NoHouseRestrictions)
{
from.SendLocalizedMessage(501347); // You cannot eject that from the house!
}
else
{
targ.MoveToWorld(BanLocation, Map);
from.SendLocalizedMessage(1042840, targ.Name); // ~1_PLAYER NAME~ has been ejected from this house.
targ.SendLocalizedMessage(501341);
/* You have been ejected from this house.
* If you persist in entering, you may be banned from the house.
*/
targ.SendLocalizedMessage(501341); /* You have been ejected from this house.
* If you persist in entering, you may be banned from the house.
*/
}
}
@ -1846,22 +2050,38 @@ namespace Server.Multis
return;
if (targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel)
{
from.SendLocalizedMessage(501354); // Uh oh...a bigger boot may be required.
}
else if (IsFriend(targ))
{
from.SendLocalizedMessage(501348); // You cannot eject a friend of the house!
}
else if (targ is PlayerVendor)
{
from.SendLocalizedMessage(501351); // You cannot eject a vendor.
}
else if (Bans.Count >= MaxBans)
{
from.SendLocalizedMessage(501355); // The ban limit for this house has been reached!
}
else if (IsBanned(targ))
{
from.SendLocalizedMessage(501356); // This person is already banned!
}
else if (!IsInside(targ))
{
from.SendLocalizedMessage(501352); // You may not eject someone who is not in your house!
}
else if (!Public && IsAosRules)
{
from.SendLocalizedMessage(
1062521); // You cannot ban someone from a private house. Revoke their access instead.
}
else if (targ is BaseCreature bc && bc.NoHouseRestrictions)
{
from.SendLocalizedMessage(1062040); // You cannot ban that.
}
else
{
Bans.Add(targ);
@ -1879,11 +2099,17 @@ namespace Server.Multis
return;
if (HasAccess(targ))
{
from.SendLocalizedMessage(1060729); // That person already has access to this house.
}
else if (!targ.Player)
{
from.SendLocalizedMessage(1060712); // That is not a player.
}
else if (IsBanned(targ))
{
from.SendLocalizedMessage(501367); // This person is banned! Unban them first.
}
else
{
Access.Add(targ);
@ -1898,19 +2124,33 @@ namespace Server.Multis
return;
if (IsOwner(targ))
{
from.SendLocalizedMessage(501360); // This person is already the house owner!
}
else if (Friends.Contains(targ))
{
from.SendLocalizedMessage(501361); // This person is a friend of the house. Remove them first.
}
else if (!targ.Player)
{
from.SendLocalizedMessage(501362); // That can't be a co-owner of the house.
}
else if (!Core.AOS && HasAccountHouse(targ))
{
from.SendLocalizedMessage(501364); // That person is already a house owner.
}
else if (IsBanned(targ))
{
from.SendLocalizedMessage(501367); // This person is banned! Unban them first.
}
else if (CoOwners.Count >= MaxCoOwners)
{
from.SendLocalizedMessage(501368); // Your co-owner list is full!
}
else if (CoOwners.Contains(targ))
{
from.SendLocalizedMessage(501369); // This person is already on your co-owner list!
}
else
{
CoOwners.Add(targ);
@ -1956,17 +2196,29 @@ namespace Server.Multis
return;
if (IsOwner(targ))
{
from.SendLocalizedMessage(501370); // This person is already an owner of the house!
}
else if (CoOwners.Contains(targ))
{
from.SendLocalizedMessage(501369); // This person is already on your co-owner list!
}
else if (!targ.Player)
{
from.SendLocalizedMessage(501371); // That can't be a friend of the house.
}
else if (IsBanned(targ))
{
from.SendLocalizedMessage(501374); // This person is banned! Unban them first.
}
else if (Friends.Count >= MaxFriends)
{
from.SendLocalizedMessage(501375); // Your friends list is full!
}
else if (Friends.Contains(targ))
{
from.SendLocalizedMessage(501376); // This person is already on your friends list!
}
else
{
Friends.Add(targ);
@ -2549,7 +2801,21 @@ namespace Server.Multis
AllHouses.Remove(this);
}
public static bool HasHouse(Mobile m) => m != null && m_Table.TryGetValue(m, out List<BaseHouse> list) && list.Any(h => !h.Deleted);
public static bool HasHouse(Mobile m)
{
if (m == null || !m_Table.TryGetValue(m, out List<BaseHouse> list))
return false;
for (int i = 0; i < list.Count; ++i)
{
BaseHouse h = list[i];
if (!h.Deleted)
return true;
}
return false;
}
public static bool HasAccountHouse(Mobile m)
{
@ -2563,15 +2829,35 @@ namespace Server.Multis
return false;
}
public bool IsOwner(Mobile m) =>
m != null && (m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster ||
IsAosRules && AccountHandler.CheckAccount(m, m_Owner));
public bool IsOwner(Mobile m)
{
if (m == null)
return false;
public bool IsCoOwner(Mobile m) =>
m != null && (IsOwner(m) || CoOwners?.Contains(m) == true ||
!IsAosRules && AccountHandler.CheckAccount(m, m_Owner));
if (m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster)
return true;
public bool IsGuildMember(Mobile m) => Owner?.Guild != null && m?.Guild == Owner.Guild;
return IsAosRules && AccountHandler.CheckAccount(m, m_Owner);
}
public bool IsCoOwner(Mobile m)
{
if (m == null || CoOwners == null)
return false;
if (IsOwner(m) || CoOwners.Contains(m))
return true;
return !IsAosRules && AccountHandler.CheckAccount(m, m_Owner);
}
public bool IsGuildMember(Mobile m)
{
if (m == null || Owner?.Guild == null)
return false;
return m.Guild == Owner.Guild;
}
public void RemoveKeys(Mobile m)
{
@ -2783,11 +3069,10 @@ namespace Server.Multis
return;
from.SendLocalizedMessage(501338); // You have transferred ownership of the house.
to.SendLocalizedMessage(501339);
/* You are now the owner of this house.
* The house's co-owner, friend, ban, and access lists have been cleared.
* You should double-check the security settings on any doors and teleporters in the house.
*/
to.SendLocalizedMessage(501339); /* You are now the owner of this house.
* The house's co-owner, friend, ban, and access lists have been cleared.
* You should double-check the security settings on any doors and teleporters in the house.
*/
m_House.RemoveKeys(from);
m_House.Owner = to;

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Server.Items;
using Server.Network;
@ -258,7 +259,7 @@ namespace Server.Multis
}
int xOffset = 0, yOffset = 0;
Movement.Offset(m_Facing, ref xOffset, ref yOffset);
Movement.Movement.Offset(m_Facing, ref xOffset, ref yOffset);
if (TillerMan != null)
{
@ -1457,10 +1458,11 @@ namespace Server.Multis
else
{
List<IEntity> toMove = GetMovingEntities();
if (TillerMan != null) toMove.Add(TillerMan);
if (Hold != null) toMove.Add(Hold);
if (PPlank != null) toMove.Add(PPlank);
if (SPlank != null) toMove.Add(SPlank);
SafeAdd(TillerMan, toMove);
SafeAdd(Hold, toMove);
SafeAdd(PPlank, toMove);
SafeAdd(SPlank, toMove);
// Packet must be sent before actual locations are changed
foreach (NetState ns in Map.GetClientsInRange(Location, GetMaxUpdateRange()))
@ -1468,7 +1470,7 @@ namespace Server.Multis
Mobile m = ns.Mobile;
if (ns.HighSeas && m.CanSee(this) && m.InRange(Location, GetUpdateRange(m)))
BoatPackets.SendMoveBoatHS(ns, m, this, d, clientSpeed, toMove, xOffset, yOffset);
ns.Send(new MoveBoatHS(m, this, d, clientSpeed, toMove, xOffset, yOffset));
}
foreach (IEntity e in toMove)
@ -1500,6 +1502,12 @@ namespace Server.Multis
return true;
}
private static void SafeAdd(Item item, List<IEntity> toMove)
{
if (item != null)
toMove.Add(item);
}
public void Teleport(int xOffset, int yOffset, int zOffset)
{
List<IEntity> toMove = GetMovingEntities();
@ -1526,9 +1534,9 @@ namespace Server.Multis
return list;
MultiComponentList mcl = Components;
IPooledEnumerable eable = map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height));
foreach (IEntity o in eable)
foreach (IEntity o in map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height))
)
{
if (o == this || o is TillerMan || o is Hold || o is Plank)
continue;
@ -1545,8 +1553,6 @@ namespace Server.Multis
}
}
eable.Free();
return list;
}
@ -1589,11 +1595,11 @@ namespace Server.Multis
List<IEntity> toMove = GetMovingEntities();
if (PPlank != null) toMove.Add(PPlank);
if (SPlank != null) toMove.Add(SPlank);
toMove.Add(PPlank);
toMove.Add(SPlank);
int xOffset = 0, yOffset = 0;
Movement.Offset(facing, ref xOffset, ref yOffset);
Movement.Movement.Offset(facing, ref xOffset, ref yOffset);
if (TillerMan != null)
TillerMan.Location = new Point3D(X + xOffset * TillerManDistance + (facing == Direction.North ? 1 : 0),
@ -1610,7 +1616,9 @@ namespace Server.Multis
IEntity e = toMove[i];
if (e is Item item)
{
item.Location = Rotate(item.Location, count);
}
else if (e is Mobile m)
{
m.Direction = m.Direction - old + facing & Direction.Mask;
@ -1726,6 +1734,8 @@ namespace Server.Multis
}
}
#region High Seas
public override bool AllowsRelativeDrop => true;
/*
@ -1743,5 +1753,137 @@ namespace Server.Multis
return base.GetWorldPacketFor( state );
}
*/
public sealed class MoveBoatHS : Packet
{
public MoveBoatHS(Mobile beholder, BaseBoat boat, Direction d, int speed, List<IEntity> ents, int xOffset,
int yOffset)
: base(0xF6)
{
EnsureCapacity(3 + 15 + ents.Count * 10);
m_Stream.Write(boat.Serial);
m_Stream.Write((byte)speed);
m_Stream.Write((byte)d);
m_Stream.Write((byte)boat.Facing);
m_Stream.Write((short)(boat.X + xOffset));
m_Stream.Write((short)(boat.Y + yOffset));
m_Stream.Write((short)boat.Z);
m_Stream.Write((short)0); // count placeholder
int count = 0;
foreach (IEntity ent in ents)
{
if (!beholder.CanSee(ent))
continue;
m_Stream.Write(ent.Serial);
m_Stream.Write((short)(ent.X + xOffset));
m_Stream.Write((short)(ent.Y + yOffset));
m_Stream.Write((short)ent.Z);
++count;
}
m_Stream.Seek(16, SeekOrigin.Begin);
m_Stream.Write((short)count);
}
}
public sealed class DisplayBoatHS : Packet
{
public DisplayBoatHS(Mobile beholder, BaseBoat boat)
: base(0xF7)
{
List<IEntity> ents = boat.GetMovingEntities();
SafeAdd(boat.TillerMan, ents);
SafeAdd(boat.Hold, ents);
SafeAdd(boat.PPlank, ents);
SafeAdd(boat.SPlank, ents);
ents.Add(boat);
EnsureCapacity(3 + 2 + ents.Count * 26);
m_Stream.Write((short)0); // count placeholder
int count = 0;
foreach (IEntity ent in ents)
{
if (!beholder.CanSee(ent))
continue;
// Embedded WorldItemHS packets
m_Stream.Write((byte)0xF3);
m_Stream.Write((short)0x1);
if (ent is BaseMulti bm)
{
m_Stream.Write((byte)0x02);
m_Stream.Write(bm.Serial);
// TODO: Mask no longer needed, merge with Item case?
m_Stream.Write((ushort)(bm.ItemID & 0x3FFF));
m_Stream.Write((byte)0);
m_Stream.Write((short)bm.Amount);
m_Stream.Write((short)bm.Amount);
m_Stream.Write((short)(bm.X & 0x7FFF));
m_Stream.Write((short)(bm.Y & 0x3FFF));
m_Stream.Write((sbyte)bm.Z);
m_Stream.Write((byte)bm.Light);
m_Stream.Write((short)bm.Hue);
m_Stream.Write((byte)bm.GetPacketFlags());
}
else if (ent is Mobile m)
{
m_Stream.Write((byte)0x01);
m_Stream.Write(m.Serial);
m_Stream.Write((short)m.Body);
m_Stream.Write((byte)0);
m_Stream.Write((short)1);
m_Stream.Write((short)1);
m_Stream.Write((short)(m.X & 0x7FFF));
m_Stream.Write((short)(m.Y & 0x3FFF));
m_Stream.Write((sbyte)m.Z);
m_Stream.Write((byte)m.Direction);
m_Stream.Write((short)m.Hue);
m_Stream.Write((byte)m.GetPacketFlags());
}
else if (ent is Item item)
{
m_Stream.Write((byte)0x00);
m_Stream.Write(item.Serial);
m_Stream.Write((ushort)(item.ItemID & 0xFFFF));
m_Stream.Write((byte)0);
m_Stream.Write((short)item.Amount);
m_Stream.Write((short)item.Amount);
m_Stream.Write((short)(item.X & 0x7FFF));
m_Stream.Write((short)(item.Y & 0x3FFF));
m_Stream.Write((sbyte)item.Z);
m_Stream.Write((byte)item.Light);
m_Stream.Write((short)item.Hue);
m_Stream.Write((byte)item.GetPacketFlags());
}
m_Stream.Write((short)0x00);
++count;
}
m_Stream.Seek(3, SeekOrigin.Begin);
m_Stream.Write((short)count);
}
}
#endregion
}
}

View file

@ -29,7 +29,7 @@ namespace Server.Multis
AddButton(20, 125, 4005, 4007, 1);
}
public override void OnResponse(NetState sender, RelayInfo info)
public override void OnResponse(NetState state, RelayInfo info)
{
if (info.ButtonID == 2)
m_Boat.EndDryDock(m_From);

View file

@ -1,127 +0,0 @@
using System.Collections.Generic;
using Server.Buffers;
using Server.Multis;
namespace Server.Network
{
public static class BoatPackets
{
public static void SendMoveBoatHS(NetState ns, Mobile beholder, BaseBoat boat, Direction d, int speed,
IReadOnlyCollection<IEntity> ents, int xOffset,
int yOffset)
{
if (ns == null)
return;
int length = 18 + ents.Count * 10;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0xF6); // Packet ID
writer.Position += 2; // Dynamic Length
writer.Write(boat.Serial);
writer.Write((byte)speed);
writer.Write((byte)d);
writer.Write((byte)boat.Facing);
writer.Write((short)(boat.X + xOffset));
writer.Write((short)(boat.Y + yOffset));
writer.Write((short)boat.Z);
writer.Position += 2; // count
ushort count = 0;
foreach (IEntity ent in ents)
{
if (!beholder.CanSee(ent))
continue;
writer.Write(ent.Serial);
writer.Write((short)(ent.X + xOffset));
writer.Write((short)(ent.Y + yOffset));
writer.Write((short)ent.Z);
count++;
}
writer.Position = 16;
writer.Write(count);
writer.Position = 1;
writer.Write((ushort)writer.WrittenCount);
ns.Send(writer.Span);
}
public static void SendDisplayBoatHS(NetState ns, Mobile beholder, BaseBoat boat)
{
if (ns == null)
return;
List<IEntity> ents = boat.GetMovingEntities();
if (boat.TillerMan != null) ents.Add(boat.TillerMan);
if (boat.Hold != null) ents.Add(boat.Hold);
if (boat.PPlank != null) ents.Add(boat.PPlank);
if (boat.SPlank != null) ents.Add(boat.SPlank);
ents.Add(boat);
int length = 5 + ents.Count * 26;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0xF7); // Packet ID
writer.Position += 4; // Dynamic Length & Count
ushort count = 0;
foreach (IEntity ent in ents)
{
if (!beholder.CanSee(ent))
continue;
writer.Write((byte)0xF3);
writer.Write((short)0x1);
if (ent is Mobile m)
{
writer.Write((byte)0x01);
writer.Write(m.Serial);
writer.Write((short)m.Body);
writer.Position++;
writer.Write((short)1);
writer.Write((short)1);
writer.Write((short)(m.X & 0x7FFF));
writer.Write((short)(m.Y & 0x3FFF));
writer.Write((sbyte)m.Z);
writer.Write((byte)m.Direction);
writer.Write((short)m.Hue);
writer.Write((byte)m.GetPacketFlags());
}
else if (ent is Item item)
{
writer.Position++;
writer.Write(item.Serial);
writer.Write((ushort)(item.ItemID & 0xFFFF));
writer.Position++;
writer.Write((short)item.Amount);
writer.Write((short)item.Amount);
writer.Write((short)(item.X & 0x7FFF));
writer.Write((short)(item.Y & 0x3FFF));
writer.Write((sbyte)item.Z);
writer.Write((byte)item.Light);
writer.Write((short)item.Hue);
writer.Write((byte)item.GetPacketFlags());
}
writer.Position += 2;
count++;
}
writer.Position = 3;
writer.Write(count);
writer.Position = 1;
writer.Write((ushort)writer.WrittenCount);
ns.Send(writer.Span);
}
}
}

View file

@ -1,3 +1,5 @@
using Server.Prompts;
namespace Server.Multis
{
public class RenameBoatPrompt : Prompt

View file

@ -95,7 +95,7 @@ namespace Server.Misc
if (map == null)
return false;
ITile surface = map.GetTopSurface(from.Location);
object surface = map.GetTopSurface(from.Location);
if (surface is LandTile tile)
{
@ -175,4 +175,4 @@ namespace Server.Misc
from.Location = new Point3D(x, y, z);
}
}
}
}

View file

@ -100,15 +100,18 @@ namespace Server.Multis.Deeds
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
{
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
}
else
{
from.SendLocalizedMessage(1010433);
/* House placement cancellation could result in a
* 60 second delay in the return of your deed.
*/
from.SendLocalizedMessage(1010433); /* House placement cancellation could result in a
* 60 second delay in the return of your deed.
*/
from.Target = new HousePlacementTarget(this);
}
@ -122,9 +125,13 @@ namespace Server.Multis.Deeds
return;
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
else if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
{
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
}
else
{
Point3D center = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);

View file

@ -5,7 +5,7 @@ namespace Server.Multis
{
public class DynamicDecay
{
private static readonly Dictionary<DecayLevel, DecayStageInfo> m_Stages;
private static Dictionary<DecayLevel, DecayStageInfo> m_Stages;
static DynamicDecay()
{

View file

@ -3,8 +3,8 @@ using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
@ -123,7 +123,9 @@ namespace Server.Multis
{
get
{
if (m_Current == null) SetInitialState();
if (m_Current == null)
SetInitialState();
return m_Current.Components;
}
}
@ -185,7 +187,7 @@ namespace Server.Multis
}
}
public static ComponentVerification Verification => m_Verification ??= new ComponentVerification();
public static ComponentVerification Verification => m_Verification ?? (m_Verification = new ComponentVerification());
public bool IsFixture(Item item) => Fixtures.Contains(item);
@ -298,7 +300,8 @@ namespace Server.Multis
public void AddFixtures(Mobile from, MultiTileEntry[] list)
{
Fixtures ??= new List<Item>();
if (Fixtures == null)
Fixtures = new List<Item>();
uint keyValue = 0;
@ -391,9 +394,13 @@ namespace Server.Multis
door = new GenericHouseDoor(facing, 0x29F5 + 8 * ((itemID - 0x2A05) / 8), sound, sound);
}
else if (itemID == 0x2D46)
{
door = new GenericHouseDoor(DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false);
}
else if (itemID == 0x2D48 || itemID == 0x2FE2)
{
door = new GenericHouseDoor(DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x2D63 && itemID < 0x2D70)
{
int mod = (itemID - 0x2D63) / 2 % 2;
@ -404,7 +411,9 @@ namespace Server.Multis
door = new GenericHouseDoor(facing, 0x2D63 + 4 * type + mod * 2, 0xEA, 0xF1, false);
}
else if (itemID == 0x2FE4 || itemID == 0x31AE)
{
door = new GenericHouseDoor(DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x319C && itemID < 0x31AE)
{
//special case for 0x31aa <-> 0x31a8 (a9)
@ -437,13 +446,21 @@ namespace Server.Multis
};
}
else if (itemID >= 0x409B && itemID < 0x40A3)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x409B), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x410C && itemID < 0x4114)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x410C), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x41C2 && itemID < 0x41CA)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x41C2), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x41CF && itemID < 0x41D7)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x41CF), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x436E && itemID < 0x437E)
{
/* These ones had to be different...
@ -455,15 +472,25 @@ namespace Server.Multis
door = new GenericHouseDoor(facing, itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x46DD && itemID < 0x46E5)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x46DD), itemID, 0xEB, 0xF2, false);
}
else if (itemID >= 0x4D22 && itemID < 0x4D2A)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x4D22), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x50C8 && itemID < 0x50D0)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x50C8), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x50D0 && itemID < 0x50D8)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x50D0), itemID, 0xEA, 0xF1, false);
}
else if (itemID >= 0x5142 && itemID < 0x514A)
{
door = new GenericHouseDoor(GetSADoorFacing(itemID - 0x5142), itemID, 0xF0, 0xEF, false);
}
if (door != null)
{
@ -503,6 +530,7 @@ namespace Server.Multis
switch (door.Facing)
{
default:
case DoorFacing.WestCW:
linkFacing = DoorFacing.EastCCW;
xOffset = 1;
yOffset = 0;
@ -590,6 +618,7 @@ namespace Server.Multis
switch (type)
{
default:
case FoundationType.DarkWood:
corner = 0x0014;
east = 0x0015;
south = 0x0016;
@ -739,8 +768,20 @@ namespace Server.Multis
x += mcl.Center.X;
y += mcl.Center.Y;
return x >= 0 && x < mcl.Width && y >= 0 && y < mcl.Height &&
mcl.Tiles[x][y].Any(tile => tile.Z == 7 && tile.Height == 20);
if (x >= 0 && x < mcl.Width && y >= 0 && y < mcl.Height)
{
StaticTile[] tiles = mcl.Tiles[x][y];
for (int i = 0; i < tiles.Length; ++i)
{
StaticTile tile = tiles[i];
if (tile.Z == 7 && tile.Height == 20)
return true;
}
}
return false;
}
public void BeginCustomize(Mobile m)
@ -758,11 +799,12 @@ namespace Server.Multis
foreach (Item item in GetItems()) item.Location = BanLocation;
foreach (Mobile mobile in GetMobiles().Where(mobile => mobile != m))
mobile.Location = BanLocation;
foreach (Mobile mobile in GetMobiles())
if (mobile != m)
mobile.Location = BanLocation;
DesignContext.Add(m, this);
HouseFoundationPackets.SendBeginHouseCustomization(m.NetState, Serial);
m.Send(new BeginHouseCustomization(this));
NetState ns = m.NetState;
if (ns != null)
@ -1031,15 +1073,19 @@ namespace Server.Multis
{
// Temporary Fix. We should be booting a client out of customization mode in the delete handler.
if (from.AccessLevel >= AccessLevel.GameMaster && cost != 0)
{
from.SendMessage("{0} gold would have been {1} your bank if you were not a GM.", cost.ToString(),
cost > 0 ? "withdrawn from" : "deposited into");
}
else
{
if (cost > 0)
{
if (Banker.Withdraw(from, cost))
{
from.SendLocalizedMessage(1060398,
cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
}
else
{
from.SendLocalizedMessage(
@ -1096,7 +1142,7 @@ namespace Server.Multis
DesignContext.Remove(from);
// Notify the client that customization has ended
HouseFoundationPackets.SendEndHouseCustomization(from.NetState, Serial);
from.Send(new EndHouseCustomization(this));
// Notify the core that the foundation has changed and should be resent to all clients
Delta(ItemDelta.Update);
@ -1237,7 +1283,8 @@ namespace Server.Multis
switch (dir)
{
default: // North
default:
case 0: // North
{
xStart = x;
yStart = y + height;
@ -1346,12 +1393,16 @@ namespace Server.Multis
// Remove the component
if (AllowStairSectioning)
{
fixState |= DeleteStairs(mcl, itemID, x, y, z); // The client removes the entire set of stairs locally, resend state
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);
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)
@ -1508,8 +1559,7 @@ namespace Server.Multis
DesignContext.Remove(from);
// Notify the client that customization has ended
HouseFoundationPackets.SendEndHouseCustomization(from.NetState, context.Foundation.Serial);
from.Send(new EndHouseCustomization(context.Foundation));
// Refresh client with current visible design state
context.Foundation.SendInfoTo(state);
@ -1657,8 +1707,7 @@ namespace Server.Multis
public class DesignState
{
private int m_Revision;
private byte[] m_Packet;
private Packet m_PacketCache;
public DesignState(HouseFoundation foundation, MultiComponentList components)
{
@ -1710,23 +1759,27 @@ namespace Server.Multis
}
}
public Packet PacketCache
{
get => m_PacketCache;
set
{
if (m_PacketCache == value)
return;
m_PacketCache?.Release();
m_PacketCache = value;
}
}
public HouseFoundation Foundation{ get; }
public MultiComponentList Components{ get; }
public MultiTileEntry[] Fixtures{ get; private set; }
public int Revision
{
get => m_Revision;
set => m_Revision = value;
}
public byte[] Packet
{
get => m_Packet;
set => Interlocked.Exchange(ref m_Packet, value);
}
public int Revision{ get; set; }
public void Serialize(GenericWriter writer)
{
@ -1752,18 +1805,31 @@ namespace Server.Multis
public void OnRevised()
{
Interlocked.Exchange(ref m_Revision, ++Foundation.LastRevision);
lock (this)
{
Revision = ++Foundation.LastRevision;
m_PacketCache?.Release();
m_PacketCache = null;
}
}
public void SendGeneralInfoTo(NetState state)
{
HouseFoundationPackets.SendDesignStateGeneral(state, Foundation.Serial, Revision);
state?.Send(new DesignStateGeneral(Foundation, this));
}
public void SendDetailedInfoTo(NetState state)
{
if (state != null)
HouseFoundationPackets.SendDesignDetails(state, Foundation, this);
lock (this)
{
if (m_PacketCache == null)
DesignStateDetailed.SendDetails(state, Foundation, this);
else
state.Send(m_PacketCache);
}
}
public void FreezeFixtures()
@ -1809,36 +1875,68 @@ namespace Server.Multis
}
}
public static bool IsFixture(int itemID) =>
itemID >= 0x675 && itemID < 0x6F5 ||
itemID >= 0x314 && itemID < 0x364 ||
itemID >= 0x824 && itemID < 0x834 ||
itemID >= 0x839 && itemID < 0x849 ||
itemID >= 0x84C && itemID < 0x85C ||
itemID >= 0x866 && itemID < 0x876 ||
itemID >= 0x0E8 && itemID < 0x0F8 ||
itemID >= 0x1FED && itemID < 0x1FFD ||
itemID >= 0x181D && itemID < 0x1829 ||
itemID >= 0x241F && itemID < 0x2421 ||
itemID >= 0x2423 && itemID < 0x2425 ||
itemID >= 0x2A05 && itemID < 0x2A1D ||
itemID >= 0x319C && itemID < 0x31B0 ||
itemID == 0x2D46 || itemID == 0x2D48 ||
itemID == 0x2FE2 || itemID == 0x2FE4 ||
itemID >= 0x2D63 && itemID < 0x2D70 ||
itemID >= 0x319C && itemID < 0x31AF ||
itemID >= 0x367B && itemID < 0x369B ||
itemID >= 0x409B && itemID < 0x40A3 ||
itemID >= 0x410C && itemID < 0x4114 ||
itemID >= 0x41C2 && itemID < 0x41CA ||
itemID >= 0x41CF && itemID < 0x41D7 ||
itemID >= 0x436E && itemID < 0x437E ||
itemID >= 0x46DD && itemID < 0x46E5 ||
itemID >= 0x4D22 && itemID < 0x4D2A ||
itemID >= 0x50C8 && itemID < 0x50D8 ||
itemID >= 0x5142 && itemID < 0x514A ||
itemID >= 0x9AD7 && itemID < 0x9AE7 ||
itemID >= 0x9B3C && itemID < 0x9B4C;
public static bool IsFixture(int itemID)
{
if (itemID >= 0x675 && itemID < 0x6F5)
return true;
if (itemID >= 0x314 && itemID < 0x364)
return true;
if (itemID >= 0x824 && itemID < 0x834)
return true;
if (itemID >= 0x839 && itemID < 0x849)
return true;
if (itemID >= 0x84C && itemID < 0x85C)
return true;
if (itemID >= 0x866 && itemID < 0x876)
return true;
if (itemID >= 0x0E8 && itemID < 0x0F8)
return true;
if (itemID >= 0x1FED && itemID < 0x1FFD)
return true;
if (itemID >= 0x181D && itemID < 0x1829)
return true;
if (itemID >= 0x241F && itemID < 0x2421)
return true;
if (itemID >= 0x2423 && itemID < 0x2425)
return true;
if (itemID >= 0x2A05 && itemID < 0x2A1D)
return true;
if (itemID >= 0x319C && itemID < 0x31B0)
return true;
// ML doors
if (itemID == 0x2D46 || itemID == 0x2D48 || itemID == 0x2FE2 || itemID == 0x2FE4)
return true;
if (itemID >= 0x2D63 && itemID < 0x2D70)
return true;
if (itemID >= 0x319C && itemID < 0x31AF)
return true;
if (itemID >= 0x367B && itemID < 0x369B)
return true;
// SA doors
if (itemID >= 0x409B && itemID < 0x40A3)
return true;
if (itemID >= 0x410C && itemID < 0x4114)
return true;
if (itemID >= 0x41C2 && itemID < 0x41CA)
return true;
if (itemID >= 0x41CF && itemID < 0x41D7)
return true;
if (itemID >= 0x436E && itemID < 0x437E)
return true;
if (itemID >= 0x46DD && itemID < 0x46E5)
return true;
if (itemID >= 0x4D22 && itemID < 0x4D2A)
return true;
if (itemID >= 0x50C8 && itemID < 0x50D8)
return true;
if (itemID >= 0x5142 && itemID < 0x514A)
return true;
// TOL doors
if (itemID >= 0x9AD7 && itemID < 0x9AE7)
return true;
return itemID >= 0x9B3C && itemID < 0x9B4C;
}
}
public class ConfirmCommitGump : Gump
@ -1962,17 +2060,17 @@ namespace Server.Multis
{
Item item = fixtures[i];
Packets.SendRemoveEntity(state, item.Serial);
state.Send(item.RemovePacket);
}
if (foundation.Signpost != null)
Packets.SendRemoveEntity(state, foundation.Signpost.Serial);
state.Send(foundation.Signpost.RemovePacket);
if (foundation.SignHanger != null)
Packets.SendRemoveEntity(state, foundation.SignHanger.Serial);
state.Send(foundation.SignHanger.RemovePacket);
if (foundation.Sign != null)
Packets.SendRemoveEntity(state, foundation.Sign.Serial);
state.Send(foundation.Sign.RemovePacket);
}
public static void Remove(Mobile from)
@ -2004,7 +2102,9 @@ namespace Server.Multis
}
context.Foundation.Signpost?.SendInfoTo(state);
context.Foundation.SignHanger?.SendInfoTo(state);
context.Foundation.Sign?.SendInfoTo(state);
}
}

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Server.Regions;
using Server.Spells;
@ -158,7 +157,8 @@ namespace Server.Multis
bool isFoundation = addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0;
bool hasSurface = false;
hasFoundation |= isFoundation;
if (isFoundation)
hasFoundation = true;
int addTileZ = center.Z + addTile.Z;
int addTileTop = addTileZ + addTile.Height;
@ -333,7 +333,29 @@ namespace Server.Multis
}
}
return yard.Any(t => _houses.Any(b => b.Contains(t))) ? HousePlacementResult.BadStatic : HousePlacementResult.Valid;
for (int i = 0; i < yard.Count; ++i)
foreach (BaseHouse b in _houses)
if (b.Contains(yard[i]))
return HousePlacementResult.BadStatic; // Broke rule #3
/*Point2D yardPoint = yard[i];
IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y );
foreach ( StaticTile[] tile in eable )
{
for ( int j = 0; j < tile.Length; ++j )
{
if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 )
{
eable.Free();
return HousePlacementResult.BadStatic; // Broke rule #3
}
}
}
eable.Free();*/
return HousePlacementResult.Valid;
}
}
}

View file

@ -611,7 +611,9 @@ namespace Server.Items
case HousePlacementResult.Valid:
{
if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
{
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
}
else
{
BaseHouse house = ConstructHouse(from);
@ -622,13 +624,17 @@ namespace Server.Items
house.Price = Cost;
if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.SendMessage("{0} gold would have been withdrawn from your bank if you were not a GM.",
Cost.ToString());
}
else
{
if (Banker.Withdraw(from, Cost))
{
from.SendLocalizedMessage(1060398,
Cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
}
else
{
house.RemoveKeys(from);
@ -701,7 +707,9 @@ namespace Server.Items
case HousePlacementResult.Valid:
{
if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
{
from.SendLocalizedMessage(501271); // You already own a house, you may not place another!
}
else
{
from.SendLocalizedMessage(1011576); // This is a valid location.
@ -796,13 +804,16 @@ namespace Server.Items
{
m_Table.TryGetValue(house.GetType(), out object obj);
return obj switch
{
HousePlacementEntry entry => entry,
List<HousePlacementEntry> list => list.FirstOrDefault(e => e.MultiID == house.ItemID),
Dictionary<int, HousePlacementEntry> table => table[house.ItemID],
_ => null
};
if (obj is HousePlacementEntry entry)
return entry;
if (obj is List<HousePlacementEntry> list)
return list.FirstOrDefault(e => e.MultiID == house.ItemID);
if (obj is Dictionary<int, HousePlacementEntry> table)
return table[house.ItemID];
return null;
}
private static void FillTable(HousePlacementEntry[] entries)
@ -812,7 +823,9 @@ namespace Server.Items
HousePlacementEntry e = entries[i];
if (!m_Table.TryGetValue(e.Type, out object obj))
{
m_Table[e.Type] = e;
}
else if (obj is HousePlacementEntry entry)
{
List<HousePlacementEntry> list = new List<HousePlacementEntry> { entry, e };
@ -835,7 +848,10 @@ namespace Server.Items
else
list.Add(e);
}
else if (obj is Dictionary<int, HousePlacementEntry> table) table[e.MultiID] = e;
else if (obj is Dictionary<int, HousePlacementEntry> table)
{
table[e.MultiID] = e;
}
}
}
}

View file

@ -581,4 +581,4 @@ namespace Server.Multis
int version = reader.ReadInt();
}
}
}
}

View file

@ -1,366 +0,0 @@
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Server.Buffers;
using Server.Multis;
namespace Server.Network
{
public static class HouseFoundationPackets
{
public static void SendBeginHouseCustomization(NetState ns, Serial house)
{
if (ns == null)
return;
SpanWriter writer = new SpanWriter(stackalloc byte[17]);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)17); // Dynamic Length
writer.Write((short)0x20); // House Customization
writer.Write(house);
writer.Write((byte)0x04); // Start customization
writer.Position += 2;
writer.Write(0xFFFFFFFF);
writer.Write((byte)0xFF);
ns.Send(writer.Span);
}
public static void SendEndHouseCustomization(NetState ns, Serial house)
{
if (ns == null)
return;
SpanWriter writer = new SpanWriter(stackalloc byte[17]);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)17); // Dynamic Length
writer.Write((short)0x20); // House Customization
writer.Write(house);
writer.Write((byte)0x05); // End customization
writer.Position += 2;
writer.Write(0xFFFFFFFF);
writer.Write((byte)0xFF);
ns.Send(writer.Span);
}
public static void SendDesignStateGeneral(NetState ns, Serial house, int revision)
{
if (ns == null)
return;
SpanWriter writer = new SpanWriter(stackalloc byte[13]);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)13); // Dynamic Length
writer.Write((short)0x1D); // Design
writer.Write(house);
writer.Write(revision);
ns.Send(writer.Span);
}
private const int MaxItemsPerStairBuffer = 750;
private static ConcurrentQueue<SendQueueEntry> m_SendQueue;
private static AutoResetEvent m_Sync;
static HouseFoundationPackets()
{
m_SendQueue = new ConcurrentQueue<SendQueueEntry>();
m_Sync = new AutoResetEvent(false);
Task.Run(ProcessDesignStates);
}
public static void ProcessDesignStates()
{
while (!Core.Closing)
{
m_Sync.WaitOne();
int count = m_SendQueue.Count;
while (count > 0 && m_SendQueue.TryDequeue(out SendQueueEntry sqe))
try
{
byte[] packet = sqe.m_DesignState.Packet;
if (packet == null)
{
packet = CreateDesignDetailsPacket(sqe.m_Serial, sqe.m_Revision, sqe.m_xMin, sqe.m_yMin, sqe.m_xMax,
sqe.m_yMax, sqe.m_Tiles);
sqe.m_DesignState.Packet = packet;
return;
}
sqe.m_NetState.Send(packet);
}
catch (Exception e)
{
Console.WriteLine(e);
try
{
using StreamWriter op = new StreamWriter("dsd_exceptions.txt", true);
op.WriteLine(e);
}
catch
{
// ignored
}
}
finally
{
count = m_SendQueue.Count;
}
}
}
public static byte[] CreateDesignDetailsPacket(Serial serial, int revision, int xMin, int yMin, int xMax, int yMax,
MultiTileEntry[] tiles)
{
ArrayBufferWriter<byte> bufferWriter = new ArrayBufferWriter<byte>(0x10000);
SpanWriter headWriter = new SpanWriter(stackalloc byte[18]);
headWriter.Write((byte)0xD8); // Packet ID
headWriter.Position += 2; // Dynamic Length
headWriter.Write((byte)0x03); // Compression Type
headWriter.Position++;
headWriter.Write(serial);
headWriter.Write(revision);
headWriter.Write((short)tiles.Length);
headWriter.Position += 3; // Buffer/Plane count
int bufferLength = 1; // includes plane count
int width = xMax - xMin + 1;
int height = yMax - yMin + 1;
Span<bool> planeUsed = stackalloc bool[9];
Span<byte> planeBuffers = stackalloc byte[9216];
Span<byte> stairBuffers = stackalloc byte[MaxItemsPerStairBuffer * 30];
int totalStairsUsed = 0;
for (int i = 0; i < tiles.Length; ++i)
{
MultiTileEntry mte = tiles[i];
int x = mte.m_OffsetX - xMin;
int y = mte.m_OffsetY - yMin;
int z = mte.m_OffsetZ;
bool floor = TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Height <= 0;
int plane, size;
switch (z)
{
case 0:
plane = 0;
break;
case 7:
plane = 1;
break;
case 27:
plane = 2;
break;
case 47:
plane = 3;
break;
case 67:
plane = 4;
break;
default:
{
int stairBufferIndex = totalStairsUsed / MaxItemsPerStairBuffer;
Span<byte> stairBuffer = stairBuffers.Slice(stairBufferIndex, MaxItemsPerStairBuffer);
int byteIndex = totalStairsUsed % MaxItemsPerStairBuffer * 5;
stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8);
stairBuffer[byteIndex++] = (byte)mte.m_ItemID;
stairBuffer[byteIndex++] = (byte)mte.m_OffsetX;
stairBuffer[byteIndex++] = (byte)mte.m_OffsetY;
stairBuffer[byteIndex] = (byte)mte.m_OffsetZ;
++totalStairsUsed;
continue;
}
}
if (plane == 0)
size = height;
else if (floor)
{
size = height - 2;
x -= 1;
y -= 1;
}
else
{
size = height - 1;
plane += 4;
}
int index = (x * size + y) * 2;
if (x < 0 || y < 0 || y >= size || index + 1 >= 0x400)
{
int stairBufferIndex = totalStairsUsed / MaxItemsPerStairBuffer;
Span<byte> stairBuffer = stairBuffers.Slice(stairBufferIndex, MaxItemsPerStairBuffer);
int byteIndex = totalStairsUsed % MaxItemsPerStairBuffer * 5;
stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8);
stairBuffer[byteIndex++] = (byte)mte.m_ItemID;
stairBuffer[byteIndex++] = (byte)mte.m_OffsetX;
stairBuffer[byteIndex++] = (byte)mte.m_OffsetY;
stairBuffer[byteIndex] = (byte)mte.m_OffsetZ;
++totalStairsUsed;
}
else
{
planeUsed[plane] = true;
planeBuffers[plane * 0x400 + index] = (byte)(mte.m_ItemID >> 8);
planeBuffers[plane * 0x400 + index + 1] = (byte)mte.m_ItemID;
}
}
int planeCount = 0;
int bound = (int)Compression.Compressor.CompressBound(0x400);
for (int i = 0; i < 9; ++i)
{
if (!planeUsed[i])
continue;
++planeCount;
int size;
if (i == 0)
size = width * height * 2;
else if (i < 5)
size = (width - 1) * (height - 2) * 2;
else
size = width * (height - 1) * 2;
Span<byte> inflatedBuffer = planeBuffers.Slice(i * 0x400, 0x400);
Span<byte> deflatedBuffer = bufferWriter.GetSpan(bound + 4);
ulong deflatedLength = (ulong)bound;
ZLibError ce = Compression.Pack(deflatedBuffer.Slice(4), ref deflatedLength, inflatedBuffer, (ulong)size, ZLibQuality.Default);
if (ce != ZLibError.Okay)
{
Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
size = 0;
}
int length = (int)deflatedLength;
deflatedBuffer[0] = (byte)(0x20 | i);
deflatedBuffer[1] = (byte)size;
deflatedBuffer[2] = (byte)length;
deflatedBuffer[3] = (byte)(((size >> 4) & 0xF0) | ((length >> 8) & 0xF));
bufferLength += 4 + length;
bufferWriter.Advance(length + 4);
}
int totalStairBuffersUsed = (totalStairsUsed + (MaxItemsPerStairBuffer - 1)) / MaxItemsPerStairBuffer;
bound = (int)Compression.Compressor.CompressBound(MaxItemsPerStairBuffer);
for (int i = 0; i < totalStairBuffersUsed; ++i)
{
++planeCount;
int count = totalStairsUsed - i * MaxItemsPerStairBuffer;
if (count > MaxItemsPerStairBuffer)
count = MaxItemsPerStairBuffer;
int size = count * 5;
Span<byte> inflatedBuffer = stairBuffers.Slice(i * MaxItemsPerStairBuffer, MaxItemsPerStairBuffer);
Span<byte> deflatedBuffer = bufferWriter.GetSpan(bound + 4);
ulong deflatedLength = (ulong)bound;
ZLibError ce = Compression.Pack(deflatedBuffer.Slice(4), ref deflatedLength, inflatedBuffer, (ulong)size, ZLibQuality.Default);
if (ce != ZLibError.Okay)
{
Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
deflatedLength = 0;
size = 0;
}
int length = (int)deflatedLength;
deflatedBuffer[0] = (byte)(9 + i);
deflatedBuffer[1] = (byte)size;
deflatedBuffer[2] = (byte)length;
deflatedBuffer[3] = (byte)(((size >> 4) & 0xF0) | ((length >> 8) & 0xF));
bufferLength += 4 + length;
bufferWriter.Advance(length + 4);
}
headWriter.Position = 15;
headWriter.Write((short)bufferLength); // Buffer length
headWriter.Write((byte)planeCount); // Plane count
headWriter.Position = 1;
int written = headWriter.WrittenCount + bufferWriter.WrittenCount;
headWriter.Write((ushort)written);
byte[] packet = new byte[written];
headWriter.CopyTo(packet);
bufferWriter.WrittenSpan.CopyTo(packet.AsSpan(headWriter.WrittenCount));
return packet;
}
private class SendQueueEntry
{
public NetState m_NetState;
public DesignState m_DesignState;
public int m_Revision;
public uint m_Serial;
public MultiTileEntry[] m_Tiles;
public int m_xMin, m_yMin, m_xMax, m_yMax;
public SendQueueEntry(NetState ns, HouseFoundation foundation, DesignState state)
{
m_NetState = ns;
m_Serial = foundation.Serial;
m_Revision = state.Revision;
m_DesignState = state;
MultiComponentList mcl = state.Components;
m_xMin = mcl.Min.X;
m_yMin = mcl.Min.Y;
m_xMax = mcl.Max.X;
m_yMax = mcl.Max.Y;
m_Tiles = mcl.List;
}
}
public static void SendDesignDetails(NetState ns, HouseFoundation house, DesignState state)
{
m_SendQueue.Enqueue(new SendQueueEntry(ns, house, state));
m_Sync.Set();
}
}
}

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Items;
using Server.Network;
@ -50,8 +49,19 @@ namespace Server.Multis
public override void DropItem(Item dropped)
{
// 1. Try to stack the item
if (Items.Any(item => item is PackingBox && item.Items.Any(subItem => !(subItem is Container) && subItem.StackWith(null, dropped, false))))
return;
foreach (Item item in Items)
if (item is PackingBox)
{
List<Item> subItems = item.Items;
for (int i = 0; i < subItems.Count; i++)
{
Item subItem = subItems[i];
if (!(subItem is Container) && subItem.StackWith(null, dropped, false))
return;
}
}
// 2. Try to drop the item into an existing container
foreach (Item item in Items)
@ -163,7 +173,12 @@ namespace Server.Multis
m_InternalizeTimer = null;
}
foreach (Item item in Items.Where(item => item is PackingBox && item.Items.Count == 0))
List<Item> toRemove = new List<Item>();
foreach (Item item in Items)
if (item is PackingBox && item.Items.Count == 0)
toRemove.Add(item);
foreach (Item item in toRemove)
item.Delete();
if (TotalItems == 0)