Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: House lock downs and secure ownership bugs #940

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
47 changes: 38 additions & 9 deletions Projects/UOContent/Multis/Houses/BaseHouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ private void SetLockdown(Item i, bool locked, bool checkContains = false)

public bool LockDown(Mobile m, Item item, bool checkIsInside)
{
if (!IsCoOwner(m) || !IsActive)
if (!IsFriend(m) || !IsActive)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is right. Let's do some testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friends of the house have always been allowed to lock things down. This was tested via OSI and is at the link: https://uo.com/wiki/ultima-online-wiki/gameplay/houses-placing-a-house/house-ownership-4-managing-your-home/

{
return false;
}
Expand Down Expand Up @@ -2325,13 +2325,17 @@ public void EndConfirmTransfer(Mobile from, Mobile to)

public void Release(Mobile m, Item item)
{
if (!IsCoOwner(m) || !IsActive)
if (!IsFriend(m) || !IsActive)
{
return;
}

if (HasLockedDownItem(item))
{
/* How do we ensure that friends can only release things locked down
* by them and not things locked down by co-owners/owners? It's an\
* important step to prevent grief and separate security levels. */

item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501657); // [no longer locked down]
SetLockdown(item, false);
// TidyItemList( m_LockDowns );
Expand All @@ -2340,7 +2344,18 @@ public void Release(Mobile m, Item item)
}
else if (HasSecureItem(item))
{
ReleaseSecure(m, item);
/* We don't want friends of the house releasing secured containers. This is a co-owner/owner
* superpower. */

if (IsCoOwner(m))
{
ReleaseSecure(m, item);
}
else
{
m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1010418); // You did not lock this down, and you are not able to release this.
return;
}
}
else
{
Expand All @@ -2350,7 +2365,7 @@ public void Release(Mobile m, Item item)

public void AddSecure(Mobile m, Item item)
{
if (Secures == null || !IsOwner(m) || !IsActive)
if (Secures == null || !IsCoOwner(m) || !IsActive)
{
return;
}
Expand Down Expand Up @@ -2408,7 +2423,17 @@ public void AddSecure(Mobile m, Item item)
}
else
{
info = new SecureInfo((Container)item, SecureLevel.Owner);
/* There seems to be some confusion regarding security access on secured containers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The owner of the house should have access to everything.
This is both necessary and a problem since owners can hijack co-owner/friend property.
I am not sure this can be resolved.

Copy link
Contributor Author

@Arthrutus Arthrutus Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. House owners should automatically have access to everything. Perhaps we can make a new securelevel.HouseOwner and Co-Owners can become securelevel.Owners?

Copy link
Contributor Author

@Arthrutus Arthrutus Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to separate the security access levels and the house access levels. These are obviously not interchangeable. The security access levels only apply to each individual container in question and are applicable to the individual who secured said container, NOT the house owner (although they have access/control over it regardless).

For things like doors and teleporters, the house owner is automatically the owner.

* when a player secures a container (via "I wish to secure this"), they are considered
* the "owner" of that item. Thus, if the option "Owner only" is selected, then the
* player who secured the container AND the house owner both have access to it. I am not
* sure how to address this without throwing the whole thing into chaos.
*
* As it stands, the gump automatically assigns the house owner as the owner
* of the secured container. Thus, co-owners who secure a container and select
* "Owner Only" from the security gump will be unable to access or release the container. */

info = new SecureInfo((Container)item, SecureLevel.Owner);

item.IsLockedDown = false;
item.IsSecure = true;
Expand Down Expand Up @@ -2472,7 +2497,7 @@ public bool HasSecureAccess(Mobile m, SecureLevel level)

public void ReleaseSecure(Mobile m, Item item)
{
if (Secures == null || !IsOwner(m) || item is StrongBox || !IsActive)
if (Secures == null || !IsCoOwner(m) || item is StrongBox || !IsActive)
{
return;
}
Expand Down Expand Up @@ -2500,6 +2525,10 @@ public void ReleaseSecure(Mobile m, Item item)
Secures.RemoveAt(i);
return;
}
else // Added fallback incase the player is a co-owner who is trying to release a container secured by the owner.
{
m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1010418); // You did not lock this down, and you are not able to release this.
}
}

m.SendLocalizedMessage(501717); // This isn't secure...
Expand Down Expand Up @@ -2595,7 +2624,7 @@ public void Kick(Mobile from, Mobile targ)
/* You have been ejected from this house.
* If you persist in entering, you may be banned from the house.
*/
targ.SendLocalizedMessage(501341);
targ.SendLocalizedMessage(501341);
kamronbatman marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -2622,7 +2651,7 @@ public void RemoveAccess(Mobile from, Mobile targ)

public void RemoveBan(Mobile from, Mobile targ)
{
if (!IsCoOwner(from) || Bans == null)
if (!IsFriend(from) || Bans == null)
{
return;
}
Expand Down Expand Up @@ -3936,7 +3965,7 @@ protected override void OnTargetNotAccessible(Mobile from, object targeted)

protected override void OnTarget(Mobile from, object targeted)
{
if (!from.Alive || m_House.Deleted || !m_House.IsCoOwner(from))
if (!from.Alive || m_House.Deleted || !m_House.IsFriend(from))
{
return;
}
Expand Down
22 changes: 4 additions & 18 deletions Projects/UOContent/Regions/HouseRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,50 +295,36 @@ public override void OnSpeech(SpeechEventArgs e)
}
else if (e.HasKeyword(0x23)) // I wish to lock this down
{
if (isCoOwner)
{
from.SendLocalizedMessage(502097); // Lock what down?
from.Target = new LockdownTarget(false, House);
}
else
{
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
}
}
else if (e.HasKeyword(0x24)) // I wish to release this
{
if (isCoOwner)
{
from.SendLocalizedMessage(502100); // Choose the item you wish to release
from.Target = new LockdownTarget(true, House);
}
else
{
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
}
}
else if (e.HasKeyword(0x25)) // I wish to secure this
{
if (isOwner)
if (isCoOwner)
{
from.SendLocalizedMessage(502103); // Choose the item you wish to secure
from.Target = new SecureTarget(false, House);
}
else
{
from.SendLocalizedMessage(502094); // You must be in your house to do this.
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
}
}
else if (e.HasKeyword(0x26)) // I wish to unsecure this
{
if (isOwner)
if (isCoOwner)
{
from.SendLocalizedMessage(502106); // Choose the item you wish to unsecure
from.Target = new SecureTarget(true, House);
}
else
{
from.SendLocalizedMessage(502094); // You must be in your house to do this.
from.SendLocalizedMessage(1010587); // You are not a co-owner of this house.
}
}
else if (e.HasKeyword(0x27)) // I wish to place a strongbox
Expand Down