Skip to content

Commit

Permalink
fix: crash when viewing housing info from non-placard
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Apr 20, 2022
1 parent c6530de commit daa43a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AutoSweep.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyName>autoSweep</AssemblyName>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
25 changes: 17 additions & 8 deletions Paissa/LotteryObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public unsafe class LotteryObserver {

private delegate void HandlePlacardSaleInfoDelegate(
void* agentBase,
byte isUnowned,
HousingType housingType,
ushort territoryTypeId,
byte wardId,
byte plotId,
short a6,
short apartmentNumber,
IntPtr placardSaleInfoPtr,
long a8
);
Expand All @@ -36,25 +36,27 @@ public void Dispose() {

public void OnPlacardSaleInfo(
void* agentBase,
byte isUnowned,
HousingType housingType,
ushort territoryTypeId,
byte wardId,
byte plotId,
short a6,
short apartmentNumber,
IntPtr placardSaleInfoPtr,
long a8
) {
PlacardSaleInfoHook!.Original(agentBase, isUnowned, territoryTypeId, wardId, plotId, a6, placardSaleInfoPtr, a8);
PlacardSaleInfoHook!.Original(agentBase, housingType, territoryTypeId, wardId, plotId, apartmentNumber, placardSaleInfoPtr, a8);

// if the plot is owned, ignore it
if (isUnowned == 0) return;
if (housingType != HousingType.UnownedHouse) return;
if (placardSaleInfoPtr == IntPtr.Zero) return;

PlacardSaleInfo saleInfo = PlacardSaleInfo.Read(placardSaleInfoPtr);

PluginLog.LogDebug(
$"Got PlacardSaleInfo: PurchaseType={saleInfo.PurchaseType}, TenantType={saleInfo.TenantType}, available={saleInfo.AvailabilityType}, until={saleInfo.PhaseEndsAt}, numEntries={saleInfo.EntryCount}");
PluginLog.LogDebug($"unknown1={saleInfo.Unknown1}, unknown2={saleInfo.Unknown2}, unknown3={BitConverter.ToString(saleInfo.Unknown3)}");
PluginLog.LogDebug($"isUnowned={isUnowned}, territoryTypeId={territoryTypeId}, wardId={wardId}, plotId={plotId}; a6={a6}, a8={a8}");
PluginLog.LogDebug(
$"housingType={housingType}, territoryTypeId={territoryTypeId}, wardId={wardId}, plotId={plotId}, apartmentNumber={apartmentNumber}, placardSaleInfoPtr={placardSaleInfoPtr}, a8={a8}");

// get information about the world from the clientstate
World world = plugin.ClientState.LocalPlayer?.CurrentWorld.GameData;
Expand All @@ -67,4 +69,11 @@ long a8
plugin.PaissaClient.PostLotteryInfo(world.RowId, territoryTypeId, wardId, plotId, saleInfo);
}
}

public enum HousingType : byte {
OwnedHouse = 0,
UnownedHouse = 1,
FreeCompanyApartment = 2,
Apartment = 3
}
}

0 comments on commit daa43a9

Please sign in to comment.