Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pallet Resolution for Multiple Pages Causes Error #100

Closed
eliptus opened this issue Nov 25, 2022 · 3 comments
Closed

Pallet Resolution for Multiple Pages Causes Error #100

eliptus opened this issue Nov 25, 2022 · 3 comments

Comments

@eliptus
Copy link
Contributor

eliptus commented Nov 25, 2022

Whenever I attempt to import an image with multiple pages, if I select any pallet resolution option other than Cautious, I get this error.

Notes from crash.log:

Version Number:0.4.5
Release Version
11/26/2022 5:35:12 AM
General Information:
Current tab count: 2
Current selected tab: 1
Tab is ViewPort for Pokemon - Radical Red - v3.1.gba
Game Code: BPRE0
Data Length: 0x2000000
Pokemon Count: 823
---
Tab is ViewPort for Moemon - Mega Fire Red - v1.2b.gba
Game Code: BPRE0
Data Length: 0x2000000
Pokemon Count: 412
---
Exception Information:
System.IndexOutOfRangeException
Index was outside the bounds of the array.
   at HavenSoft.HexManiac.Core.ViewModels.Tools.SpriteTool.WriteSpritesAndPalette(ISpriteRun spriteRun, IPaletteRun paletteRun, Int16[][] images, IReadOnlyList`1 usablePalPages) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Tools\SpriteTool.cs:line 0
   at HavenSoft.HexManiac.Core.ViewModels.Tools.SpriteTool.ImportTallSpriteAndPalette(IFileSystem fileSystem, Int16[] image, ISpriteRun spriteRun, IPaletteRun paletteRun) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Tools\SpriteTool.cs:line 944
   at HavenSoft.HexManiac.Core.ViewModels.Tools.SpriteTool.ImportSpriteAndPalette(IFileSystem fileSystem) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Tools\SpriteTool.cs:line 727
   at HavenSoft.HexManiac.Core.ViewModels.Tools.SpriteTool.<.ctor>b__158_8(Object arg) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Tools\SpriteTool.cs:line 568
   at HavenSoft.HexManiac.Core.ViewModels.Tools.SpriteElementViewModel.ExecuteSpriteToolCommand(IFileSystem fs, ICommand command) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Tools\SpriteElementViewModel.cs:line 153
   at HavenSoft.HexManiac.Core.ViewModels.Tools.SpriteElementViewModel.ExecuteImportImage(IFileSystem fs) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\Tools\SpriteElementViewModel.cs:line 102
   at HavenSoft.HexManiac.Core.ViewModels.ViewModelCore.<>c__DisplayClass14_0`1.<StubCommand>b__0(Object arg) in D:\root\GitHub\HexManiac\src\HexManiac.Core\ViewModels\ViewModelCore.cs:line 138
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Primitives.ToggleButton.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   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)

-------------------------------------------
@eliptus
Copy link
Contributor Author

eliptus commented Nov 26, 2022

This override is what's causing the truncation of the newPalettes array, which eventually results in the out-of-bounds:

if (spriteRun.Pages == expectedPalettePages) expectedPalettePages = 1; // handle the Castform case

Not yet sure what the solution is, though.

@eliptus
Copy link
Contributor Author

eliptus commented Nov 26, 2022

In case it's not clear, the intent in the import that causes this is to import four sprites with four different palettes, opting to Ignore the existing palettes.

@haven1433
Copy link
Owner

Fixed in fix castform multisprite import logic, thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants