kwsch / pkNX

Pokémon (Nintendo Switch) ROM Editor & Randomizer
https://projectpokemon.org/home/forums/topic/48647-pknx-nintendo-switch-rom-editor-randomizer/
GNU General Public License v3.0
352 stars 108 forks source link

Trainer randomizer - Using "RandomMoves" causes array index out of bounds #43

Closed BSoD38 closed 4 years ago

BSoD38 commented 4 years ago

Using the RandomMoves option for MoveRandType on the Trainer Randomizer causes the editor to throw an unhandled array index out of bounds exception.

Other options seem to work fine.

Exception text (it's in french, but it's basically array index out of bounds) :

System.IndexOutOfRangeException: L'index se trouve en dehors des limites du tableau.
   à pkNX.Randomization.MoveRandomizer.<>c__DisplayClass15_0.<IsMovesetMeetingRequirements>b__0(Int32 move)
   à System.Linq.Enumerable.Count[TSource](IEnumerable`1 source, Func`2 predicate)
   à pkNX.Randomization.MoveRandomizer.IsMovesetMeetingRequirements(Int32[] moves, Int32[] types, Int32 count)
   à pkNX.Randomization.MoveRandomizer.GetRandomMoveset(Int32[] Types, Int32 movecount)
   à pkNX.Randomization.MoveRandomizer.GetRandomMoveset(Int32 index, Int32 movecount)
   à pkNX.Randomization.TrainerRandomizer.RandomizeEntryMoves(TrainerPoke pk)
   à pkNX.Randomization.TrainerRandomizer.UpdatePKMFromSettings(TrainerPoke pk)
   à pkNX.Randomization.TrainerRandomizer.Execute()
   à pkNX.WinForms.BTTE.B_Randomize_Click(Object sender, EventArgs e) dans D:\dev\pknx\pkNX.WinForms\Subforms\BTTE.cs:ligne 558
   à System.Windows.Forms.Control.OnClick(EventArgs e)
   à System.Windows.Forms.Button.OnClick(EventArgs e)
   à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   à System.Windows.Forms.Control.WndProc(Message& m)
   à System.Windows.Forms.ButtonBase.WndProc(Message& m)
   à System.Windows.Forms.Button.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

This happens with commit 19ec807.

kwsch commented 4 years ago

Duplicate with https://github.com/kwsch/pkNX/issues/23 which was incorrectly closed via an unrelated pull request.