Skip to content

Commit

Permalink
Merge pull request #4 from Drakansoul/fix-plugin
Browse files Browse the repository at this point in the history
Fix plugin
  • Loading branch information
Drakansoul authored Jul 8, 2024
2 parents 6389f6f + 4d2b77f commit d0dc907
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 54 deletions.
2 changes: 0 additions & 2 deletions DisPlacePlugin/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using Dalamud.Configuration;
using Dalamud.Plugin;
using DisPlacePlugin.Objects;

namespace DisPlacePlugin
{
Expand Down
4 changes: 1 addition & 3 deletions DisPlacePlugin/DalamudApi.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
global using Dalamud;
using Dalamud.Game;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
Expand Down
36 changes: 14 additions & 22 deletions DisPlacePlugin/DisPlacePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Game.Network;
using Dalamud.IoC;
using Dalamud.Logging;
using Dalamud.Game.Command;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.MJI;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using ImGuiScene;
using Lumina.Excel.GeneratedSheets;
using DisPlacePlugin.Objects;
using DisPlacePlugin.Util;
Expand Down Expand Up @@ -97,8 +84,8 @@ public void Initialize()

IsSaveLayoutHook = HookManager.Hook<UpdateLayoutDelegate>("40 53 48 83 ec 20 48 8b d9 48 8b 0d ?? ?? ?? ?? e8 ?? ?? ?? ?? 33 d2 48 8b c8 e8 ?? ?? ?? ?? 84 c0 75 ?? 38 83 ?? 01 00 00", IsSaveLayoutDetour);

SelectItemHook = HookManager.Hook<SelectItemDelegate>("48 89 5c 24 18 55 56 57 41 54 41 55 41 56 41 57 48 83 ec ??", SelectItemDetour);

SelectItemHook = HookManager.Hook<SelectItemDelegate>("E8 ?? ?? 00 00 48 8B CE E8 ?? ?? 00 00 48 8B ?? ?? ?? 48", SelectItemDetour);
UpdateYardObjHook = HookManager.Hook<UpdateYardDelegate>("48 89 74 24 18 57 48 83 ec 20 b8 dc 02 00 00 0f b7 f2 ??", UpdateYardObj);

GetGameObjectHook = HookManager.Hook<GetObjectDelegate>("48 89 5c 24 08 48 89 74 24 10 57 48 83 ec 20 0f b7 f2 33 db 0f 1f 40 00 0f 1f 84 00 00 00 00 00", GetGameObject);
Expand Down Expand Up @@ -142,7 +129,7 @@ private void UpdateYardObj(IntPtr objectList, ushort index)
{
UpdateYardObjHook.Original(objectList, index);
}

unsafe static public void SelectItemDetour(IntPtr housing, IntPtr item)
{
SelectItemHook.Original(housing, item);
Expand All @@ -153,7 +140,7 @@ unsafe static public void SelectItem(IntPtr item)
{
SelectItemDetour((IntPtr)Memory.Instance.HousingStructure, item);
}


public unsafe void PlaceItems()
{
Expand Down Expand Up @@ -183,7 +170,7 @@ public unsafe void PlaceItems()
Log($"{item.Name} is already correctly placed");
continue;
}

SetItemPosition(item);

if (Config.LoadInterval > 0)
Expand Down Expand Up @@ -218,15 +205,20 @@ unsafe public static void SetItemPosition(HousingItem rowItem)

if (rowItem.ItemStruct == IntPtr.Zero) return;

Log("Placing " + rowItem.Name);

var MemInstance = Memory.Instance;

logHousingDetour = true;
ApplyChange = true;

SelectItem(rowItem.ItemStruct);
//SelectItem(rowItem.ItemStruct);

var thisItem = MemInstance.HousingStructure->ActiveItem;
if (thisItem == null) {
DalamudApi.PluginLog.Error("Error occured while writing position! Item Was null");
return;
}

Log("Placing " + rowItem.Name);

Vector3 position = new Vector3(rowItem.X, rowItem.Y, rowItem.Z);
Vector3 rotation = new Vector3();
Expand Down
8 changes: 5 additions & 3 deletions DisPlacePlugin/Gui/ConfigurationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ private void LogLayoutMode()

private bool CheckModeForSave()
{
return true; // LOL, LMAO
/*
if (Memory.Instance.IsHousingMode()) return true;
LogError("Unable to save layouts outside of Layout mode");
LogLayoutMode();
return false;
*/
}

private bool CheckModeForLoad()
Expand Down Expand Up @@ -310,10 +313,9 @@ unsafe private void DrawGeneralSettings()

ImGui.Dummy(new Vector2(0, 15));

//bool noFloors = Memory.Instance.GetCurrentTerritory() != Memory.HousingArea.Indoors || Memory.Instance.GetIndoorHouseSize().Equals("Apartment");
bool noFloors = Memory.Instance.GetCurrentTerritory() != Memory.HousingArea.Indoors || Memory.Instance.GetIndoorHouseSize().Equals("Apartment");

//if (!noFloors)
if(false)
if (!noFloors)
{

ImGui.Text("Selected Floors");
Expand Down
7 changes: 2 additions & 5 deletions DisPlacePlugin/Memory.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Game;
using Dalamud.Logging;
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.MJI;
using Lumina.Excel.GeneratedSheets;
Expand Down Expand Up @@ -342,8 +338,9 @@ public unsafe void WritePosition(Vector3 newPosition)
try
{
var item = HousingStructure->ActiveItem;
if (item == null)
if (item == null) {
return;
}

// Set the position.
item->Position = newPosition;
Expand Down
5 changes: 0 additions & 5 deletions DisPlacePlugin/Objects/Structs.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.MJI;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Lumina.Excel.GeneratedSheets;
using static FFXIVClientStructs.FFXIV.Client.Game.InventoryItem;
using static DisPlacePlugin.Utils;

namespace DisPlacePlugin
{
Expand Down
7 changes: 1 addition & 6 deletions DisPlacePlugin/Util/HookManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using Dalamud.Game;
using Dalamud.Hooking;
using Dalamud.Logging;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DisPlacePlugin
{
Expand Down
2 changes: 0 additions & 2 deletions DisPlacePlugin/Util/HookWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Plugin;

namespace DisPlacePlugin
{
Expand Down
6 changes: 1 addition & 5 deletions DisPlacePlugin/Util/Plots.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace DisPlacePlugin.Util
{
Expand Down
1 change: 0 additions & 1 deletion DisPlacePlugin/Util/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Logging;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using DisPlacePlugin.Objects;
Expand Down

0 comments on commit d0dc907

Please sign in to comment.