From 0ff2e583f43c7d68caafa8953deabb55ecd43178 Mon Sep 17 00:00:00 2001 From: tgarove <137084409+tgarove@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:15:06 -0400 Subject: [PATCH 1/2] support realm property for buying housing on home realm outside of primary instance add boolean RealmProperty "IgnoreHousingPrimaryInstanceRestriction" -- when set, allows players to buy houses in non-primary instances on their home realm --- Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs | 4 ++++ Source/ACE.Server/Entity/Landblock.cs | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs b/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs index 88315fd099..df00886407 100644 --- a/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs +++ b/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs @@ -80,6 +80,10 @@ all landblocks will use the parent realm instead. Any players with a homeworld u [Description("If enabled, classical instances will be active regardless of the character's location. This is not recommended for realms other than true solo-self-found realms, and is considered an advanced feature.")] [RealmPropertyBool(false)] ClassicalInstances_EnableForAllLandblocks_Dangerous = 13, + + [Description("If enabled, players can purchase houses in instances other than the primary instance.")] + [RealmPropertyBool(false)] + IgnoreHousingPrimaryInstanceRestriction = 14, } public static class RealmPropertyBoolExtensions diff --git a/Source/ACE.Server/Entity/Landblock.cs b/Source/ACE.Server/Entity/Landblock.cs index 32733c8a37..e4fa73b2b2 100644 --- a/Source/ACE.Server/Entity/Landblock.cs +++ b/Source/ACE.Server/Entity/Landblock.cs @@ -1492,7 +1492,13 @@ public ushort? ShortInstanceID public WorldRealm WorldRealm => WorldRealmID.HasValue ? RealmManager.GetRealm(WorldRealmID, includeRulesets: true) : null; public bool IsPrimaryForWorldRealm => ShortInstanceID == 0; - public bool IsHomeInstanceForPlayer(Player player) => IsPrimaryForWorldRealm && player.HomeRealm == WorldRealmID; + + public bool IsHomeInstanceForPlayer(Player player) + { + if (RealmRuleset.GetProperty(RealmPropertyBool.IgnoreHousingPrimaryInstanceRestriction)) + return player.HomeRealm == WorldRealmID; + return IsPrimaryForWorldRealm && player.HomeRealm == WorldRealmID; + } public class RealmShortcuts { From a9b60cb33932ac8de293dcb25b3da511a3d462e1 Mon Sep 17 00:00:00 2001 From: tgarove <137084409+tgarove@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:45:26 -0400 Subject: [PATCH 2/2] revise housing instance restriction override RealmProperty to preserve existing methods -- renamed to IgnoreHousingInstanceRestrictions RealmProperty IgnoreHousingInstanceRestrictions added. If true, players can buy houses in any instance on their home realm, rather than only in primary instance (0). --- .../Enum/Properties/RealmPropertyBool.cs | 2 +- Source/ACE.Server/Entity/Landblock.cs | 9 ++------- .../ACE.Server/WorldObjects/Player_House.cs | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs b/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs index df00886407..4d1e70712b 100644 --- a/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs +++ b/Source/ACE.Entity/Enum/Properties/RealmPropertyBool.cs @@ -83,7 +83,7 @@ all landblocks will use the parent realm instead. Any players with a homeworld u [Description("If enabled, players can purchase houses in instances other than the primary instance.")] [RealmPropertyBool(false)] - IgnoreHousingPrimaryInstanceRestriction = 14, + IgnoreHousingInstanceRestrictions = 14, } public static class RealmPropertyBoolExtensions diff --git a/Source/ACE.Server/Entity/Landblock.cs b/Source/ACE.Server/Entity/Landblock.cs index e4fa73b2b2..6d7e4fb613 100644 --- a/Source/ACE.Server/Entity/Landblock.cs +++ b/Source/ACE.Server/Entity/Landblock.cs @@ -1492,13 +1492,8 @@ public ushort? ShortInstanceID public WorldRealm WorldRealm => WorldRealmID.HasValue ? RealmManager.GetRealm(WorldRealmID, includeRulesets: true) : null; public bool IsPrimaryForWorldRealm => ShortInstanceID == 0; - - public bool IsHomeInstanceForPlayer(Player player) - { - if (RealmRuleset.GetProperty(RealmPropertyBool.IgnoreHousingPrimaryInstanceRestriction)) - return player.HomeRealm == WorldRealmID; - return IsPrimaryForWorldRealm && player.HomeRealm == WorldRealmID; - } + public bool IsHomeRealmForPlayer(Player player) => player.HomeRealm == WorldRealmID; + public bool IsHomeInstanceForPlayer(Player player) => IsPrimaryForWorldRealm && IsHomeRealmForPlayer(player); public class RealmShortcuts { diff --git a/Source/ACE.Server/WorldObjects/Player_House.cs b/Source/ACE.Server/WorldObjects/Player_House.cs index b9de0c9f64..16b0fd95e7 100644 --- a/Source/ACE.Server/WorldObjects/Player_House.cs +++ b/Source/ACE.Server/WorldObjects/Player_House.cs @@ -32,11 +32,20 @@ public void HandleActionBuyHouse(ObjectGuid slumlord_id, List item_ids) //Console.WriteLine($"\n{Name}.HandleActionBuyHouse()"); log.Info($"[HOUSE] {Name}.HandleActionBuyHouse()"); - if (!CurrentLandblock.IsHomeInstanceForPlayer(this)) - { - Session.Network.EnqueueSend(new GameMessageSystemChat("You may only purchase a house in your home realm.", ChatMessageType.Broadcast)); - log.Info($"[HOUSE] {Name}.HandleActionBuyHouse(): Failed pre-purchase requirement - Not in home realm instance"); - return; + if (RealmRuleset.GetProperty(RealmPropertyBool.IgnoreHousingInstanceRestrictions)){ + if (!CurrentLandblock.IsHomeRealmForPlayer(this)) + { + Session.Network.EnqueueSend(new GameMessageSystemChat("You may only purchase a house in your home realm.", ChatMessageType.Broadcast)); + log.Info($"[HOUSE] {Name}.HandleActionBuyHouse(): Failed pre-purchase requirement - Not in home realm"); + return; + } + }else{ + if (!CurrentLandblock.IsHomeInstanceForPlayer(this)) + { + Session.Network.EnqueueSend(new GameMessageSystemChat("You may only purchase a house in your home realm's primary instance.", ChatMessageType.Broadcast)); + log.Info($"[HOUSE] {Name}.HandleActionBuyHouse(): Failed pre-purchase requirement - Not in home realm instance"); + return; + } } // verify player doesn't already own a house