Skip to content

Commit

Permalink
Set House ParentLink on Load
Browse files Browse the repository at this point in the history
Adjusted some logging and added a parentlink for slumlord to house.
  • Loading branch information
LtRipley36706 committed Oct 28, 2024
1 parent 7cb1981 commit 5c0da0c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Source/ACE.Server/Managers/HouseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,18 @@ private static void HandleRentPaid(PlayerHouse playerHouse)

player.SaveBiotaToDatabase();

var clearedInventoryStatus = "";
if (playerHouse.House.HouseStatus == HouseStatus.Active)
{
// clear out slumlord inventory
var slumlord = playerHouse.House.SlumLord;
slumlord.ClearInventory();

slumlord.SaveBiotaToDatabase();
clearedInventoryStatus = "and cleared ";
}

log.DebugFormat("[HOUSE] HouseManager.HandleRentPaid({0}): rent payment successful!", playerHouse.PlayerName);
log.DebugFormat($"[HOUSE] HouseManager.HandleRentPaid({0}): rent payment successfully collected {clearedInventoryStatus}from SlumLord!", playerHouse.PlayerName);

// re-add item to queue
AddRentQueue(player, playerHouse.House);
Expand Down Expand Up @@ -450,7 +452,7 @@ public static void HandleEviction(House house, uint playerGuid, bool multihouse
var nextRentTime = house.GetRentDue(purchaseTime);
player.HouseRentTimestamp = (int)nextRentTime;

log.DebugFormat("[HOUSE] HouseManager.HandleRentPaid({0}): house rent disabled via config", player.Name);
log.DebugFormat("[HOUSE] HouseManager.HandleEviction({0}): house rent disabled via config", player.Name);

// re-add item to queue
AddRentQueue(player, house);
Expand Down
6 changes: 6 additions & 0 deletions Source/ACE.Server/Network/Structure/HouseData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public void SetRentItems(List<WorldObject> rentItems)
/// </summary>
public void SetPaidItems(SlumLord slumlord)
{
if (slumlord.House?.HouseOwner != null)
{
foreach (var item in Buy)
item.Paid = item.Num;
}

if (slumlord.House?.HouseStatus == HouseStatus.InActive)
{
foreach (var item in Rent)
Expand Down
6 changes: 6 additions & 0 deletions Source/ACE.Server/Network/Structure/HouseProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public void SetRentItems(List<WorldObject> rentItems)
/// </summary>
public void SetPaidItems(SlumLord slumlord)
{
if (slumlord.House?.HouseOwner != null)
{
foreach (var item in Buy)
item.Paid = item.Num;
}

if (slumlord.House?.HouseStatus == HouseStatus.InActive)
{
foreach (var item in Rent)
Expand Down
2 changes: 2 additions & 0 deletions Source/ACE.Server/WorldObjects/House.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public static House Load(uint houseGuid, bool isBasement = false)

house.ChildLinks.Remove(house.SlumLord);
house.ChildLinks.Add(slumlord);

slumlord.ParentLink = house;
}
return house;
}
Expand Down
16 changes: 15 additions & 1 deletion Source/ACE.Server/WorldObjects/Player_House.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,17 @@ public void HandleActionRentHouse(uint slumlord_id, List<uint> item_ids)

var slumlord = FindObject(slumlord_id, SearchLocations.Landblock) as SlumLord;
if (slumlord == null)
{
log.Warn($"[HOUSE] {Name}.HandleActionRentHouse({slumlord_id:X8}): Could not find SlumLord in world.");
return;
}

if (slumlord.IsRentPaid())
{
//Session.Network.EnqueueSend(new GameEventWeenieError(Session, WeenieError.HouseRentFailed)); // WeenieError.HouseRentFailed == blank message
Session.Network.EnqueueSend(new GameMessageSystemChat("The maintenance has already been paid for this period.\nYou may not prepay next period's maintenance.", ChatMessageType.Broadcast));

log.Info($"[HOUSE] {Name}.HandleActionRentHouse({slumlord_id:X8}): The maintenance has already been paid for this period.");
return;
}

Expand All @@ -211,6 +216,8 @@ public void HandleActionRentHouse(uint slumlord_id, List<uint> item_ids)
if (ownerHouses.Count() > 1)
{
Session.Network.EnqueueSend(new GameMessageSystemChat("The owner of this house currently owns multiple houses. Maintenance cannot be paid until they only own 1 house.", ChatMessageType.Broadcast));

log.Info($"[HOUSE] {Name}.HandleActionRentHouse({slumlord_id:X8}): The owner of this house currently owns multiple houses. Maintenance cannot be paid until they only own 1 house.");
return;
}
}
Expand Down Expand Up @@ -275,7 +282,10 @@ public void HandleActionRentHouse(uint slumlord_id, List<uint> item_ids)
}

if (consumeItems.Count == 0)
{
log.Warn($"[HOUSE] {Name}.HandleActionRentHouse({slumlord_id:X8}): Nothing sent could be transferred to slumlord for rent.");
return;
}

foreach (var consumeItem in consumeItems)
TryConsumeItemForRent(slumlord, consumeItem);
Expand All @@ -292,7 +302,11 @@ public void HandleActionRentHouse(uint slumlord_id, List<uint> item_ids)

HandleActionQueryHouse();

Session.Network.EnqueueSend(new GameMessageSystemChat($"Maintenance {(slumlord.IsRentPaid() ? "" : "partially ")}paid.", ChatMessageType.Broadcast));
var maintenanceStatus = $"Maintenance {(slumlord.IsRentPaid() ? "" : "partially ")}paid.";

Session.Network.EnqueueSend(new GameMessageSystemChat(maintenanceStatus, ChatMessageType.Broadcast));

log.Info($"[HOUSE] {Name}.HandleActionRentHouse({slumlord_id:X8}): {maintenanceStatus}");
}

/// <summary>
Expand Down

0 comments on commit 5c0da0c

Please sign in to comment.