Skip to content

Commit

Permalink
Fixed type return bug in CDestructable, CItem and CUnit.
Browse files Browse the repository at this point in the history
  • Loading branch information
TinkerWorX committed Dec 11, 2013
1 parent 7382d79 commit cfeb60c
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 48 deletions.
32 changes: 16 additions & 16 deletions TinkerWorX.SharpCraft.Game/Core/CDestructable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ namespace TinkerWorX.SharpCraft.Game.Core
[StructLayout(LayoutKind.Sequential, Size = 0x88)]
unsafe public struct CDestructable
{
// The first function in GetDestructableX, GetDestructableY.
// int __fastcall sub_6F3BE010(int a1)
// We use __thiscall as a cheat for doing a fastcall with only one argument.
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
[return: MarshalAs(UnmanagedType.LPStruct)]
private delegate CDestructable sub_6F3BE010Prototype(JassDestructable destructable);

private static sub_6F3BE010Prototype sub_6F3BE010 = (sub_6F3BE010Prototype)Marshal.GetDelegateForFunctionPointer(WarcraftIII.Module + 0x3BE010, typeof(sub_6F3BE010Prototype));

public static CDestructable FromHandle(JassDestructable destructable)
{
return sub_6F3BE010(destructable);
}



public IntPtr VTable;
public IntPtr field0004;
public IntPtr field0008;
Expand Down Expand Up @@ -68,6 +52,22 @@ public CDestructablePtr AsSafe()
[StructLayout(LayoutKind.Sequential)]
public struct CDestructablePtr
{
// The first function in GetDestructableX, GetDestructableY.
// int __fastcall sub_6F3BE010(int a1)
// We use __thiscall as a cheat for doing a fastcall with only one argument.
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
[return: MarshalAs(UnmanagedType.LPStruct)]
private delegate CDestructablePtr sub_6F3BE010Prototype(JassDestructable destructable);

private static sub_6F3BE010Prototype sub_6F3BE010 = (sub_6F3BE010Prototype)Marshal.GetDelegateForFunctionPointer(WarcraftIII.Module + 0x3BE010, typeof(sub_6F3BE010Prototype));

public static CDestructablePtr FromHandle(JassDestructable destructable)
{
return sub_6F3BE010(destructable);
}



private IntPtr pointer;

public CDestructablePtr(IntPtr pointer)
Expand Down
32 changes: 16 additions & 16 deletions TinkerWorX.SharpCraft.Game/Core/CItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ namespace TinkerWorX.SharpCraft.Game.Core
[StructLayout(LayoutKind.Sequential, Size = 0xF8)]
unsafe public struct CItem
{
// The first function in GetItemX, GetItemY.
// int __fastcall sub_6F3BEB50(int a1)
// We use __thiscall as a cheat for doing a fastcall with only one argument.
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
[return: MarshalAs(UnmanagedType.LPStruct)]
private delegate CItem sub_6F3BEB50Prototype(JassItem item);

private static sub_6F3BEB50Prototype sub_6F3BEB50 = (sub_6F3BEB50Prototype)Marshal.GetDelegateForFunctionPointer(WarcraftIII.Module + 0x3BEB50, typeof(sub_6F3BEB50Prototype));

public static CItem FromHandle(JassItem item)
{
return sub_6F3BEB50(item);
}



public IntPtr VTable;
public IntPtr field0004;
public IntPtr field0008;
Expand Down Expand Up @@ -96,6 +80,22 @@ public CItemPtr AsSafe()
[StructLayout(LayoutKind.Sequential)]
public struct CItemPtr
{
// The first function in GetItemX, GetItemY.
// int __fastcall sub_6F3BEB50(int a1)
// We use __thiscall as a cheat for doing a fastcall with only one argument.
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
[return: MarshalAs(UnmanagedType.LPStruct)]
private delegate CItemPtr sub_6F3BEB50Prototype(JassItem item);

private static sub_6F3BEB50Prototype sub_6F3BEB50 = (sub_6F3BEB50Prototype)Marshal.GetDelegateForFunctionPointer(WarcraftIII.Module + 0x3BEB50, typeof(sub_6F3BEB50Prototype));

public static CItemPtr FromHandle(JassItem item)
{
return sub_6F3BEB50(item);
}



private IntPtr pointer;

public CItemPtr(IntPtr pointer)
Expand Down
32 changes: 16 additions & 16 deletions TinkerWorX.SharpCraft.Game/Core/CUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ namespace TinkerWorX.SharpCraft.Game.Core
[StructLayout(LayoutKind.Sequential, Size = 0x310)]
unsafe public struct CUnit
{
// The first function in GetUnitX, GetUnitY.
// int __fastcall sub_6F3BDCB0(int a1)
// We use __thiscall as a cheat for doing a fastcall with only one argument.
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
[return: MarshalAs(UnmanagedType.LPStruct)]
private delegate CUnit sub_6F3BDCB0Prototype(JassUnit unit);

private static sub_6F3BDCB0Prototype sub_6F3BDCB0 = (sub_6F3BDCB0Prototype)Marshal.GetDelegateForFunctionPointer(WarcraftIII.Module + 0x3BDCB0, typeof(sub_6F3BDCB0Prototype));

public static CUnit FromHandle(JassUnit unit)
{
return sub_6F3BDCB0(unit);
}



public IntPtr VTable;
public IntPtr field0004;
public IntPtr field0008;
Expand Down Expand Up @@ -230,6 +214,22 @@ public CUnitPtr AsSafe()
[StructLayout(LayoutKind.Sequential)]
public struct CUnitPtr
{
// The first function in GetUnitX, GetUnitY.
// int __fastcall sub_6F3BDCB0(int a1)
// We use __thiscall as a cheat for doing a fastcall with only one argument.
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
[return: MarshalAs(UnmanagedType.LPStruct)]
private delegate CUnitPtr sub_6F3BDCB0Prototype(JassUnit unit);

private static sub_6F3BDCB0Prototype sub_6F3BDCB0 = (sub_6F3BDCB0Prototype)Marshal.GetDelegateForFunctionPointer(WarcraftIII.Module + 0x3BDCB0, typeof(sub_6F3BDCB0Prototype));

public static CUnitPtr FromHandle(JassUnit unit)
{
return sub_6F3BDCB0(unit);
}



private IntPtr pointer;

public CUnitPtr(IntPtr pointer)
Expand Down
6 changes: 6 additions & 0 deletions TinkerWorX.SharpCraft.Game/Jass/JassDestructable.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using TinkerWorX.SharpCraft.Game.Core;

namespace TinkerWorX.SharpCraft.Game.Jass
{
Expand All @@ -13,6 +14,11 @@ public JassDestructable(IntPtr handle)
this.Handle = handle;
}

public CDestructablePtr ToCDestructable()
{
return CDestructablePtr.FromHandle(this);
}

public override String ToString()
{
return this.Handle.ToString();
Expand Down
6 changes: 6 additions & 0 deletions TinkerWorX.SharpCraft.Game/Jass/JassItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using TinkerWorX.SharpCraft.Game.Core;

namespace TinkerWorX.SharpCraft.Game.Jass
{
Expand All @@ -13,6 +14,11 @@ public JassItem(IntPtr handle)
this.Handle = handle;
}

public CItemPtr ToCItem()
{
return CItemPtr.FromHandle(this);
}

public override String ToString()
{
return this.Handle.ToString();
Expand Down
6 changes: 6 additions & 0 deletions TinkerWorX.SharpCraft.Game/Jass/JassUnit.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using TinkerWorX.SharpCraft.Game.Core;

namespace TinkerWorX.SharpCraft.Game.Jass
{
Expand Down Expand Up @@ -111,6 +112,11 @@ public JassUnit(IntPtr handle)
this.Handle = handle;
}

public CUnitPtr ToCUnit()
{
return CUnitPtr.FromHandle(this);
}

public Single GetX()
{
return _GetUnitX(this);
Expand Down

0 comments on commit cfeb60c

Please sign in to comment.