Hi. So I just want to report a bug and the fix I made.
The bug:
When my household purchases an additional residential lot, the build/buy action in that purchased lot costs no money. This behavior does not appear on Vacation Homes and Purchased Community Lots/Venues.
After digging through Google, I found a thread at MTS: https://modthesims.info/t/614300, which one of the posters investigated that this bug does not appear in the game without AwesomeMod. I confirmed myself by taking out AwesomeMod, the bug disappeared.
Investigation:
I realized that AM has a feature that overrides the Build/Buy button, which indicates that the mod injects some additional code when transitioning from Live mode to Build/Buy mode. I identified the code in problem begins in Awesome.Main.OnEnterBuildBuy() method, which disable the family funds flag in the LotManager
private static void OnEnterBuildBuy()
{
Lot sActiveBuildBuyLot = LotManager.sActiveBuildBuyLot;
Navigation.ClearMaps(sActiveBuildBuyLot);
if (sActiveBuildBuyLot.Household == null && Household.ActiveHousehold != null
&& !RealEstate.GetOwningHouseholds(sActiveBuildBuyLot.LotId).Contains(Household.ActiveHousehold)
&& (!GameObject.IsBuildBuyRestrictedForStageSetup() || LotManage.IsSettingUpStageForNPC(sActiveBuildBuyLot)))
{
LotManager.sFamilyFundsDisabled = true;
}
MagicWand.UnhideParkingSpots();
}
In that method, the code checks if the household is the owner of the lot through the method Awesome.Economy.RealEstate.GetOwningHouseholds(). Below is the original code:
public static List<Household> GetOwningHouseholds(ulong oid)
{
List<Household> list = new List<Household>();
foreach (Household sHousehold in Household.sHouseholdList)
{
if (sHousehold.RealEstateManager == null)
{
continue;
}
foreach (PropertyData allProperty in sHousehold.RealEstateManager.AllProperties)
{
bool flag = false;
if (allProperty.IsFullOwner)
{
switch (allProperty.PropertyType)
{
case RealEstatePropertyType.VacationHome:
case RealEstatePropertyType.Venue:
case RealEstatePropertyType.Resort:
flag = allProperty.LotId == oid;
break;
default:
flag = allProperty.ObjectId.Value == oid;
break;
}
if (flag && !list.Contains(sHousehold))
{
list.Add(sHousehold);
}
}
}
}
return list;
}
The code checks the ownership of the lot, however it disregards the PrivateLot property type
public enum RealEstatePropertyType
{
None,
RabbitHole,
VacationHome,
Venue,
PrivateLot,
Resort
}
Fix:
Adding the RealEstatePropertyType.PrivateLot to the switch cases fix the problem. The game no longer grants free build-buy on a purchased residential home in the homeworld. I modified the assembly via dnSpy tools and try to run in game.