Fixes for SpeciesLibrary

This commit is contained in:
Deukhoofd 2021-06-26 14:09:38 +02:00
parent 26566a284b
commit ecea85c26a
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 17 additions and 10 deletions

View File

@ -6,11 +6,17 @@ namespace Pkmnlib.Generated
{
internal static class SpeciesLibrary
{
/// <param name="initialCapacity">long unsigned int</param>
/// <returns>const SpeciesLibrary *</returns>
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_SpeciesLibrary_Construct")]
internal static extern IntPtr Construct(ulong initialCapacity);
/// <param name="out">const PokemonSpecies * &</param>
/// <param name="p">const SpeciesLibrary *</param>
/// <param name="species">const PokemonSpecies *</param>
/// <returns>const PokemonSpecies *</returns>
/// <returns>unsigned char</returns>
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_SpeciesLibrary_FindPreEvolution")]
internal static extern IntPtr FindPreEvolution(IntPtr p, IntPtr species);
internal static extern byte FindPreEvolution(ref IntPtr @out, IntPtr p, IntPtr species);
}
}

View File

@ -67,11 +67,12 @@ namespace PkmnLibSharp.Library
public Species? FindPreEvolution(Species species)
{
var ptr = Pkmnlib.Generated.SpeciesLibrary.FindPreEvolution(Ptr, species.Ptr);
if (ptr == IntPtr.Zero) return null;
return TryResolvePointer(ptr, out Species? prevoSpecies)
var outPtr = IntPtr.Zero;
Pkmnlib.Generated.SpeciesLibrary.FindPreEvolution(ref outPtr, Ptr, species.Ptr).Assert();
if (outPtr == IntPtr.Zero) return null;
return TryResolvePointer(outPtr, out Species? prevoSpecies)
? prevoSpecies
: Constructor.Active.ConstructSpecies(ptr);
: Constructor.Active.ConstructSpecies(outPtr);
}
public IEnumerable<Species> GetEnumerator()
@ -93,7 +94,7 @@ namespace PkmnLibSharp.Library
}
public SpeciesLibrary(ulong initialCapacity) : base(
Creaturelib.Generated.SpeciesLibrary.Construct(initialCapacity))
Pkmnlib.Generated.SpeciesLibrary.Construct(initialCapacity))
{
}

BIN
PkmnLibSharp/Native/Linux/libpkmnLib.so (Stored with Git LFS)

Binary file not shown.

File diff suppressed because one or more lines are too long