Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Proper in-combat detection because I'm a brainlet.
Browse files Browse the repository at this point in the history
  • Loading branch information
PunishedPineapple committed Apr 16, 2021
1 parent 4c1e1bf commit d04ccff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
24 changes: 1 addition & 23 deletions WaymarkPresetPlugin/MemoryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private static bool IsSafeToDirectPlacePreset()
return mPluginInterface != null &&
mPluginInterface.ClientState.LocalPlayer != null &&
mPluginInterface.ClientState.LocalPlayer.Address != IntPtr.Zero &&
!IsCharacterInCombat() &&
!mPluginInterface.ClientState.Condition[Dalamud.Game.ClientState.ConditionFlag.InCombat] &&
currentContentLinkType > 0 && currentContentLinkType < 4;
}

Expand Down Expand Up @@ -224,27 +224,6 @@ public static bool GetCurrentWaymarksAsPresetData( ref GamePreset rPresetData )
return false;
}

private static bool IsCharacterInCombat()
{
if( mPluginInterface.ClientState.LocalPlayer != null &&
mPluginInterface.ClientState.LocalPlayer.Address != IntPtr.Zero )
{
try
{
byte flags = Marshal.ReadByte( new IntPtr( mPluginInterface.ClientState.LocalPlayer.Address.ToInt64() + mCharacterStructCombatFlagsOffset.ToInt64() ) );
return ( flags & 2 ) > 0;
}
catch
{
// Default to assuming in-combat for safety.
return true;
}
}

// Default to assuming in-combat for safety.
return true;
}

private static bool InOverworldZone()
{
return mdGetCurrentContentFinderLinkType != null &&
Expand Down Expand Up @@ -285,7 +264,6 @@ private static void PlacePreset_ClientSide( GamePreset preset )
// Magic Numbers
public static readonly int MaxPresetSlotNum = 5;
private static readonly byte mFMARKERDATIndex = 0x11;
private static readonly IntPtr mCharacterStructCombatFlagsOffset = new IntPtr( 0x1980 );
private static IntPtr mClientSideWaymarksOffset = new IntPtr( 0x1B0 ); //*****TODO: Feels bad initializing this with a magic number. Not sure best thing to do.*****

// Misc.
Expand Down
6 changes: 3 additions & 3 deletions WaymarkPresetPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WaymarkPresetPlugin")]
[assembly: AssemblyCopyright("Copyright © PunishedPineapple 2020")]
[assembly: AssemblyCopyright("Copyright © PunishedPineapple 2020-2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.2")]
[assembly: AssemblyFileVersion("1.2.0.2")]
[assembly: AssemblyVersion("1.2.0.3")]
[assembly: AssemblyFileVersion("1.2.0.3")]
2 changes: 1 addition & 1 deletion WaymarkPresetPlugin/WaymarkPresetPlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Name": "Waymark Preset Plugin",
"Description": "Manage waymark presets. Use \"/pwaymark help\" for more information.",
"InternalName": "WaymarkPresetPlugin",
"AssemblyVersion": "1.2.0.2",
"AssemblyVersion": "1.2.0.3",
"RepoUrl": "https://github.com/PunishedPineapple/WaymarkPresetPlugin",
"ApplicableVersion": "any",
"Tags": [ "Waymark", "Marker", "Preset", "Tool" ],
Expand Down

0 comments on commit d04ccff

Please sign in to comment.