AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 286 forks source link

IndexOutOfRangeException thrown if Tileset is switched on painted Tilemap #763

Open cowmanjoe opened 5 years ago

cowmanjoe commented 5 years ago

Summary

An IndexOutOfRange exception is thrown if the selected Tilemap's Tileset is switched. This exception only occurs if the Tileset has been painted on with Tiles that have a higher index than the new Tileset's maximum index. I also noticed that sometimes the tile pallette is not updated with the new Tileset.

How to reproduce

Workaround

Analysis

ilexp commented 5 years ago

Tagging this as Help Wanted and Good First Issue, since I'm suspecting this might be an easy fix, once the location and root cause of the error are identified.

SirePi commented 4 years ago

Tried to reproduce, but can't trigger the error.

Some dirty, non-existing tiles can be observed when changing to a different tileset with a different number of tiles, but I believe it can be considered in the realm of "expected behavior", given the operation that is being performed.

@AdamsLair/duality-core can any of you try to see if they can reproduce this? otherwise I'd be considering closing the issue.

streepje8 commented 5 months ago

Reproduced the issue, the error only occurs when editing after the swap (causing the update function to be called).

I added in a simple bounds check and created a pull request This is my first time helping an opensource project so I hope I did everything properly!