From b1f134c2a1643cee0639ff765b0a3bda5793c11f Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 24 Aug 2020 19:52:14 +0200 Subject: [PATCH] Clear array passed to PokemonParty to assert dominance and take ownership of it. --- PkmnLibSharp/Battling/PokemonParty.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PkmnLibSharp/Battling/PokemonParty.cs b/PkmnLibSharp/Battling/PokemonParty.cs index dbe33b3..97f1352 100644 --- a/PkmnLibSharp/Battling/PokemonParty.cs +++ b/PkmnLibSharp/Battling/PokemonParty.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using PkmnLibSharp.Utilities; namespace PkmnLibSharp.Battling @@ -14,9 +15,12 @@ namespace PkmnLibSharp.Battling public PokemonParty(byte size = 6) : base(Creaturelib.Generated.CreatureParty.ConstructWithSize(size)) {} - public PokemonParty(Pokemon[] pokemon) : base( + public PokemonParty(Pokemon?[] pokemon) : base( Creaturelib.Generated.CreatureParty.ConstructFromArray(pokemon.ArrayPtr(), (ulong) pokemon.Length)) - {} + { + for (var index = 0; index < pokemon.Length; index++) + pokemon[index] = null; + } public virtual Pokemon this[int i] => GetAtIndex((ulong) i);