Skip to content

Commit

Permalink
update for 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakansoul committed Nov 21, 2024
1 parent f8435f1 commit 3afe172
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 146 deletions.
10 changes: 5 additions & 5 deletions DisPlacePlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Author": "Drakansoul",
"Name": "DisPlace Plugin",
"InternalName": "DisPlacePlugin",
"AssemblyVersion":"3.7.2",
"AssemblyVersion":"3.7.3",
"Punchline": "Automatically save & load furniture layouts in ANY house.",
"Description": "Automatically save & load the positions of house furniture. Copy other housing layouts. Import/export layouts from the MakePlace program.",
"ApplicableVersion": "any",
Expand All @@ -15,13 +15,13 @@
"drakansoul",
"displace"
],
"DalamudApiLevel": 10,
"DalamudApiLevel": 11,
"LoadPriority": 0,
"IconUrl": "https://raw.githubusercontent.com/Drakansoul/DisPlaced/master/icon.png",
"DownloadCount": 0,
"DownloadLinkInstall": "https://github.com/Drakansoul/DisPlaced/releases/download/v3.7.2/DisPlacePlugin.zip",
"DownloadLinkTesting": "https://github.com/Drakansoul/DisPlaced/releases/download/v3.7.2/DisPlacePlugin.zip",
"DownloadLinkUpdate": "https://github.com/Drakansoul/DisPlaced/releases/download/v3.7.2/DisPlacePlugin.zip",
"DownloadLinkInstall": "https://github.com/Drakansoul/DisPlaced/releases/download/v3.7.3/DisPlacePlugin.zip",
"DownloadLinkTesting": "https://github.com/Drakansoul/DisPlaced/releases/download/v3.7.3/DisPlacePlugin.zip",
"DownloadLinkUpdate": "https://github.com/Drakansoul/DisPlaced/releases/download/v3.7.3/DisPlacePlugin.zip",
"_isDip17Plugin": false,
"_Dip17Channel": null
}]
10 changes: 8 additions & 2 deletions DisPlacePlugin.sln
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30204.135
# Visual Studio Version 17
VisualStudioVersion = 17.10.35013.160
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DisPlacePlugin", "DisPlacePlugin\DisPlacePlugin.csproj", "{479ADEA9-780A-4A8E-98A1-82C0399176E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Debug|x64.ActiveCfg = Debug|x64
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Debug|x64.Build.0 = Debug|x64
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Release|Any CPU.Build.0 = Release|Any CPU
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Release|x64.ActiveCfg = Release|x64
{479ADEA9-780A-4A8E-98A1-82C0399176E4}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
33 changes: 13 additions & 20 deletions DisPlacePlugin/DisPlacePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Dalamud.Game.Command;
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.Game;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using DisPlacePlugin.Objects;
using DisPlacePlugin.Util;
using System;
Expand All @@ -10,8 +9,7 @@
using System.Numerics;
using System.Threading;
using static DisPlacePlugin.Memory;
using HousingFurniture = Lumina.Excel.GeneratedSheets.HousingFurniture;
using Lumina.Excel;
using HousingFurniture = Lumina.Excel.Sheets.HousingFurniture;

namespace DisPlacePlugin
{
Expand Down Expand Up @@ -90,7 +88,7 @@ public DisPlacePlugin(IDalamudPluginInterface pi)
Memory.Instance.SetPlaceAnywhere(true);
LayoutManager = new SaveLayoutManager(this, Config);

DalamudApi.PluginLog.Info("DisPlace Plugin v3.7.2 initialized");
DalamudApi.PluginLog.Info("DisPlace Plugin v3.7.3 initialized");
}
public void Initialize()
{
Expand All @@ -107,7 +105,7 @@ public void Initialize()

GetObjectFromIndexHook = HookManager.Hook<GetActiveObjectDelegate>("81 fa 90 01 00 00 75 08 48 8b 81 88 0c 00 00 c3 0f b7 81 90 0c 00 00 3b d0 72 03 33 c0 c3", GetObjectFromIndex);

GetYardIndexHook = HookManager.Hook<GetIndexDelegate>("48 89 6c 24 18 56 48 83 ec 20 0f b6 ?? 0f b6 ?? ?? ?? ?? ?? ?? ?? ??", GetYardIndex);
GetYardIndexHook = HookManager.Hook<GetIndexDelegate>("48 89 5C 24 ?? ?? 48 83 ec 20 0f b6 ?? 0f b6 ?? 84 ??", GetYardIndex);

MaybePlaceh = HookManager.Hook<MaybePlaced>("40 55 56 57 48 8D AC 24 70 FF FF FF 48 81 EC 90", MaybePlace); // MaybePlace0
ResetItemPlacementh = HookManager.Hook<ResetItemPlacementd>("48 89 5C 24 08 57 48 83 EC 20 48 83 79 18 00 0F", Hc1); // reset item to previous position on failed placement
Expand Down Expand Up @@ -573,13 +571,8 @@ public unsafe void GetPlotLocation()
DalamudApi.PluginLog.Debug($"Housing plot: {plotNumber}");
}
var territoryId = Memory.Instance.GetTerritoryTypeId();
TerritoryType row = null;
try {
row = DalamudApi.DataManager.GetExcelSheet<TerritoryType>().GetRow(territoryId);
} catch (Exception e) {
LogError($"Error: {e.Message}", e.StackTrace);
}
if (row == null)
TerritoryType row = DalamudApi.DataManager.GetExcelSheet<TerritoryType>().GetRow(territoryId);
if (row.Equals(null))
{
LogError("Plugin Cannot identify territory");
return;
Expand Down Expand Up @@ -617,9 +610,9 @@ public unsafe void LoadExterior()
{
uint furnitureKey = gameObject.housingRowId;
var furniture = DalamudApi.DataManager.GetExcelSheet<HousingYardObject>().GetRow(furnitureKey);
Item item = furniture?.Item?.Value;
Item? item = furniture.Item.Value;
if (item == null) continue;
if (item.RowId == 0) continue;
if (item.Equals(0)) continue;

/*
I could probably do this better if I was fully rested and wanted to do vector math properly but I'm just going to do it the easy way. Drakansoul is very tired.
Expand Down Expand Up @@ -648,7 +641,7 @@ public unsafe void LoadExterior()
}


var housingItem = new HousingItem(item, gameObject);
var housingItem = new HousingItem(item.Value, gameObject);
housingItem.ItemStruct = (IntPtr)gameObject.Item;

var location = new Vector3(housingItem.X, housingItem.Y, housingItem.Z);
Expand Down Expand Up @@ -700,9 +693,9 @@ public unsafe void LoadInterior()
uint furnitureKey = gameObject.housingRowId;

var furniture = DalamudApi.DataManager.GetExcelSheet<HousingFurniture>().GetRow(furnitureKey);
Item item = furniture?.Item?.Value;
Item item = furniture.Item.Value;

if (item == null) continue;
if (item.Equals(null)) continue;
if (item.RowId == 0) continue;

if (!IsSelectedFloor(gameObject.Y)) continue;
Expand Down Expand Up @@ -736,9 +729,9 @@ public unsafe void LoadIsland()
{
uint furnitureKey = gameObject.housingRowId;
var furniture = DalamudApi.DataManager.GetExcelSheet<HousingYardObject>().GetRow(furnitureKey);
Item item = furniture?.Item?.Value;
Item item = furniture.Item.Value;

if (item == null) continue;
if (item.Equals(null)) continue;
if (item.RowId == 0) continue;

var housingItem = new HousingItem(item, gameObject);
Expand Down
4 changes: 2 additions & 2 deletions DisPlacePlugin/DisPlacePlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Dalamud.NET.Sdk/11.0.0">

<PropertyGroup>
<DalamudLibPath>$(AppData)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<PluginVersion>3.7.2</PluginVersion>
<PluginVersion>3.7.3</PluginVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
10 changes: 5 additions & 5 deletions DisPlacePlugin/Gui/ConfigurationWindow.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using DisPlacePlugin.Objects;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -361,7 +361,7 @@ private void DrawRow(int i, HousingItem housingItem, bool showSetPosition = true


var stain = DalamudApi.DataManager.GetExcelSheet<Stain>().GetRow(housingItem.Stain);
var colorName = stain?.Name;
var colorName = stain.Name;

if (housingItem.Stain != 0)
{
Expand All @@ -378,7 +378,7 @@ private void DrawRow(int i, HousingItem housingItem, bool showSetPosition = true
else if (housingItem.MaterialItemKey != 0)
{
var item = DalamudApi.DataManager.GetExcelSheet<Item>().GetRow(housingItem.MaterialItemKey);
if (item != null)
if (!item.Equals(null))
{
if (!housingItem.DyeMatch) ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.5f, 0.5f, 0.5f, 1));

Expand Down Expand Up @@ -447,7 +447,7 @@ private void DrawFixtureList(List<Fixture> fixtureList)


var item = DalamudApi.DataManager.GetExcelSheet<Item>().GetRow(fixture.itemId);
if (item != null)
if (!item.Equals(null))
{
DrawIcon(item.Icon, new Vector2(20, 20));
ImGui.SameLine();
Expand Down Expand Up @@ -526,7 +526,7 @@ private void DrawItemList(List<HousingItem> itemList, bool isUnused = false)
var displayName = housingItem.Name;

var item = DalamudApi.DataManager.GetExcelSheet<Item>().GetRow(housingItem.ItemKey);
if (item != null)
if (!item.Equals(null))
{
DrawIcon(item.Icon, new Vector2(20, 20));
ImGui.SameLine();
Expand Down
44 changes: 25 additions & 19 deletions DisPlacePlugin/HousingData.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud.Data;
using Dalamud.Logging;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace DisPlacePlugin
{
public class HousingData
{
private readonly Dictionary<uint, HousingFurniture> _furnitureDict;
private readonly Dictionary<uint, Item> _itemDict;
private readonly Dictionary<uint, Item?> _itemDict;
private readonly Dictionary<uint, Stain> _stainDict;

private readonly Dictionary<uint, Dictionary<uint, CommonLandSet>> _territoryToLandSetDict;
Expand All @@ -33,14 +31,14 @@ private HousingData()

_territoryToLandSetDict = new Dictionary<uint, Dictionary<uint, CommonLandSet>>();

for (uint i = 0; i < sheet.RowCount && i < terriKeys.Length; i++)
for (uint i = 0; i < sheet.Count && i < terriKeys.Length; i++)
{

var row = sheet.GetRow(i);
var rowDict = new Dictionary<uint, CommonLandSet>();
for (var j = 0; j < row.LandSets.Length; j++)
for (var j = 0; j < row.LandSet.Count; j++)
{
var cset = CommonLandSet.FromExd(row.LandSets[j], j);
var cset = CommonLandSet.FromExd(row.LandSet[j], j);
rowDict[cset.PlacardId] = cset;
}

Expand All @@ -50,12 +48,20 @@ private HousingData()
var unitedExteriorSheet = DalamudApi.DataManager.GetExcelSheet<HousingUnitedExterior>();
_unitedDict = new Dictionary<uint, uint>();
foreach (var row in unitedExteriorSheet)
foreach (var item in row.Item)
_unitedDict[item.Row] = row.RowId;
{
_unitedDict[row.Roof.RowId] = row.RowId;
_unitedDict[row.Walls.RowId] = row.RowId;
_unitedDict[row.Windows.RowId] = row.RowId;
_unitedDict[row.Door.RowId] = row.RowId;
_unitedDict[row.OptionalRoof.RowId] = row.RowId;
_unitedDict[row.OptionalWall.RowId] = row.RowId;
_unitedDict[row.OptionalSignboard.RowId] = row.RowId;
_unitedDict[row.Fence.RowId] = row.RowId;
}

_itemDict = DalamudApi.DataManager.GetExcelSheet<Item>()
.Where(item => item.AdditionalData != 0 && (item.ItemSearchCategory.Row == 65 || item.ItemSearchCategory.Row == 66))
.ToDictionary(row => row.AdditionalData, row => row);
.Where(item => item.AdditionalData.RowId != 0 && (item.ItemSearchCategory.RowId == 65 || item.ItemSearchCategory.RowId == 66))
.ToDictionary(row => row.AdditionalData.RowId, row => (Item?) row);

_stainDict = DalamudApi.DataManager.GetExcelSheet<Stain>().ToDictionary(row => row.RowId, row => row);
_furnitureDict = DalamudApi.DataManager.GetExcelSheet<HousingFurniture>().ToDictionary(row => row.RowId, row => row);
Expand All @@ -82,12 +88,12 @@ private HousingData()
var id = row.RowId;

if (id < 1000) continue;
else if (id > 1000 && id < 2000) _painting.TryAdd(row.Unknown0, row.Item.Row);
else if (id > 2000 && id < 3000) _wallpaper.TryAdd(row.Unknown0, row.Item.Row);
else if (id > 3000 && id < 4000) _smallFishprint.TryAdd(row.Unknown0, row.Item.Row);
else if (id > 4000 && id < 5000) _mediumFishprint.TryAdd(row.Unknown0, row.Item.Row);
else if (id > 5000 && id < 6000) _largeFishprint.TryAdd(row.Unknown0, row.Item.Row);
else if (id > 6000 && id < 7000) _extraLargeFishprint.TryAdd(row.Unknown0, row.Item.Row);
else if (id > 1000 && id < 2000) _painting.TryAdd(row.Unknown0, row.Item.RowId);
else if (id > 2000 && id < 3000) _wallpaper.TryAdd(row.Unknown0, row.Item.RowId);
else if (id > 3000 && id < 4000) _smallFishprint.TryAdd(row.Unknown0, row.Item.RowId);
else if (id > 4000 && id < 5000) _mediumFishprint.TryAdd(row.Unknown0, row.Item.RowId);
else if (id > 5000 && id < 6000) _largeFishprint.TryAdd(row.Unknown0, row.Item.RowId);
else if (id > 6000 && id < 7000) _extraLargeFishprint.TryAdd(row.Unknown0, row.Item.RowId);

}
}
Expand All @@ -110,7 +116,7 @@ public bool TryGetFurniture(uint id, out HousingFurniture furniture)
return _furnitureDict.TryGetValue(id, out furniture);
}

public bool IsUnitedExteriorPart(uint id, out Item item)
public bool IsUnitedExteriorPart(uint id, out Item? item)
{
item = null;
if (!_unitedDict.TryGetValue(id, out var unitedId))
Expand All @@ -126,7 +132,7 @@ public bool TryGetLandSetDict(uint id, out Dictionary<uint, CommonLandSet> dict)
return _territoryToLandSetDict.TryGetValue(id, out dict);
}

public bool TryGetItem(uint id, out Item item)
public bool TryGetItem(uint id, out Item? item)
{
return _itemDict.TryGetValue(id, out item);
}
Expand Down
55 changes: 0 additions & 55 deletions DisPlacePlugin/HousingLandSet.cs

This file was deleted.

6 changes: 3 additions & 3 deletions DisPlacePlugin/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.MJI;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using static DisPlacePlugin.DisPlacePlugin;

namespace DisPlacePlugin
Expand Down Expand Up @@ -82,7 +82,7 @@ public string GetIndoorHouseSize()
var territoryId = Memory.Instance.GetTerritoryTypeId();
var row = DalamudApi.DataManager.GetExcelSheet<TerritoryType>().GetRow(territoryId);

if (row == null) return null;
if (row.Equals(null)) return null;

var placeName = row.Name.ToString();
var sizeName = placeName.Substring(1, 3);
Expand Down Expand Up @@ -282,7 +282,7 @@ public enum HousingArea
public unsafe HousingArea GetCurrentTerritory() // this gets called every window draw for some reason, should probably looke to refactor to only call this when something needs to be changed or might have been updated.
{
var territoryRow = DalamudApi.DataManager.GetExcelSheet<TerritoryType>().GetRow(GetTerritoryTypeId());
if (territoryRow == null || territoryRow.Name.ToString().Equals("r1i5")) // blacklist company workshop from editing since it's not actually a housing area
if (territoryRow.Equals(null) || territoryRow.Name.ToString().Equals("r1i5")) // blacklist company workshop from editing since it's not actually a housing area
{
return HousingArea.None;
}
Expand Down
Loading

0 comments on commit 3afe172

Please sign in to comment.