Rework misclibrary gettime to not segfault
This commit is contained in:
parent
c2d846c2f6
commit
a59f73b2f6
|
@ -11,22 +11,16 @@ namespace PkmnLibSharp.Battling
|
||||||
{
|
{
|
||||||
public class MiscLibrary : PointerWrapper
|
public class MiscLibrary : PointerWrapper
|
||||||
{
|
{
|
||||||
private delegate TimeOfDay GetTimeDelegate();
|
public delegate TimeOfDay GetTimeDelegate();
|
||||||
|
|
||||||
internal MiscLibrary(IntPtr ptr) : base(ptr)
|
internal MiscLibrary(IntPtr ptr) : base(ptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public MiscLibrary()
|
public MiscLibrary(GetTimeDelegate @delegate)
|
||||||
{
|
{
|
||||||
GetTimeDelegate getTime = GetTime;
|
Initialize(Pkmnlib.Generated.MiscLibrary.Construct(Marshal.GetFunctionPointerForDelegate(@delegate)));
|
||||||
Initialize(Pkmnlib.Generated.MiscLibrary.Construct(Marshal.GetFunctionPointerForDelegate(getTime)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual TimeOfDay GetTime()
|
|
||||||
{
|
|
||||||
return TimeOfDay.Morning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsCritical(IntPtr move, Pokemon target, byte hitNumber)
|
public bool IsCritical(IntPtr move, Pokemon target, byte hitNumber)
|
||||||
{
|
{
|
||||||
byte b = 0;
|
byte b = 0;
|
||||||
|
|
BIN
PkmnLibSharp/Native/Linux/libArbutils.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Linux/libArbutils.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Linux/libCreatureLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Linux/libCreatureLib.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Linux/libpkmnLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Linux/libpkmnLib.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Linux/libpkmnlib_ai.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Linux/libpkmnlib_ai.so (Stored with Git LFS)
Binary file not shown.
|
@ -24,12 +24,17 @@ namespace PkmnLibSharpTests.Battling
|
||||||
var scriptLibrary = new AngelScriptResolver();
|
var scriptLibrary = new AngelScriptResolver();
|
||||||
_cache = new BattleLibrary(BuildStatic(), new StatCalculator(), new DamageLibrary(),
|
_cache = new BattleLibrary(BuildStatic(), new StatCalculator(), new DamageLibrary(),
|
||||||
new ExperienceLibrary(),
|
new ExperienceLibrary(),
|
||||||
scriptLibrary, new MiscLibrary());
|
scriptLibrary, new MiscLibrary(GetTime));
|
||||||
scriptLibrary.Initialize(_cache);
|
scriptLibrary.Initialize(_cache);
|
||||||
return _cache;
|
return _cache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TimeOfDay GetTime()
|
||||||
|
{
|
||||||
|
return TimeOfDay.Morning;
|
||||||
|
}
|
||||||
|
|
||||||
private static PokemonLibrary BuildStatic()
|
private static PokemonLibrary BuildStatic()
|
||||||
{
|
{
|
||||||
var settings = new LibrarySettings(100, 4, 4096);
|
var settings = new LibrarySettings(100, 4, 4096);
|
||||||
|
|
Loading…
Reference in New Issue