haven1433 / HexManiacAdvance

A tool for editing tables, text, scripts, images, and other data in Pokemon GBA games
MIT License
236 stars 55 forks source link

Error every time a new trainer is created #210

Closed CrypticPoptartz closed 5 months ago

CrypticPoptartz commented 7 months ago

This error occurs every time I drag a new trainer out of the ribbon, but I've been able to create several trainers before this. I found out I should be using v1.0 after getting 50% done with my hack, so if it's related to that, just ignore.

Notes from crash.log:

Version Number: 0.5.6
Release Version
3/24/2024 10:06:29 AM
General Information:
Current tab count: 2
Current selected tab: 1
---
Tab is ViewPort for Pokemon - FireRed Version (USA, Europe) (Rev 1).gba
Game Code: BPRE1
Data Length: 0x1000000
Pokemon Count: 0
---
Tab is map for (0-13)
Size: 28x14
Events: 1-2-0-12
---
Exception Information:
System.ArgumentOutOfRangeException
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

   at HavenSoft.HexManiac.Core.ViewModels.Map.EventTemplate.CreateTrainer(ObjectEventViewModel objectEventModel, ModelDelta token) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Map\EventTemplate.cs:line 0
   at HavenSoft.HexManiac.Core.ViewModels.Map.EventTemplate.ApplyTemplate(ObjectEventViewModel objectEventModel, ModelDelta token) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Map\EventTemplate.cs:line 171
   at HavenSoft.HexManiac.Core.ViewModels.Map.MapEditorViewModel.CreateEventForCreationInteraction(EventCreationType type) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Map\MapEditorViewModel.cs:line 1038
   at HavenSoft.HexManiac.Core.ViewModels.Map.MapEditorViewModel.EventMove(Double x, Double y) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Map\MapEditorViewModel.cs:line 918
   at HavenSoft.HexManiac.Core.ViewModels.Map.MapEditorViewModel.PrimaryMove(Double x, Double y) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Map\MapEditorViewModel.cs:line 764
   at HavenSoft.HexManiac.WPF.Controls.MapTab.ButtonMove(Object sender, MouseEventArgs e) in D:\root\GitHub\HexManiac\src\HexManiac.WPF\Controls\MapTab.xaml.cs:line 199
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

-------------------------------------------
CrypticPoptartz commented 7 months ago

I'm still able to edit existing, unused trainers to continue my hack, so this may be low priority.

haven1433 commented 5 months ago

I think this is happening because HexManiacAdvance was unable to find your trainer stats table, which means it doesn't know which type each pokemon is. This makes it difficult to generate trainers that prefer a specific type of pokemon.

I've added some code that will just make the trainer use any pokemon if the type information cannot be found. It'll be available in 0.5.7.