Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
(+1)

OK, I've fixed the bug 3 different ways and I think what's happening is that occasionally one region entirely contains another. The function register(shape) only checks whether an existing region has points outside the shape, not whether the new shape has points outside an existing region. Comparing the sizes of the two regions can show them to be not duplicates (and skips a lot of comparisons), or the comparison can be done symmetrically to notice that shape contains points outside the existing region.