Out of Range error?

AdventureIslands

  • *
  • Posts: 728
This wasn't happening in the Stable build of Stencyl, so I am guessing this is OpenFL related.

when you pause Tiny Dangerous Dungeons, it opens a pause menu actor that displays you collected items as well as the world map. When pausing, it creates item and map icons depending on if you have found them or not. The small black squares on the map indicate hidden items, and if you have found the item, it doesn't spawn on the map anymore and the item's icon appears to the inventory. Unpausing the game kills the inventory/map screen and all the item and map icons.

However, when unpausing the game, this weird error message pops up. I did some testing and it only shows up when the small map squares are killed. It's weird, because those actors don't have anything else on them besides make self always simulate and anchor self to screen. They don't interact with anything at all.

Here's image of the inventory screen actor's event. I noticed that on the last part of it, if I only have 4 or less Create MapIcon blocks, like the nameless one, Glove, Knives and Boot, the pausing works normally, but the moment I add more, like Key1, the error pops up when unpausing the game.

« Last Edit: November 19, 2013, 03:04:55 pm by AdventureIslands »

rob1221

  • *
  • Posts: 9473
It looks like a bug with removing anchored actors.  If you remove the anchor blocks, does the error still appear?

AdventureIslands

  • *
  • Posts: 728
I removed the anchoring and now they are killed properly like they should, although without anchoring they don't move with rest of the pause graphics now, of course. Can you fix the anchoring?

rob1221

  • *
  • Posts: 9473
In Engine.hx, I see this line:
Code: [Select]
hudActors = new IntHashTable<Actor>(16);
Replace that 16 with a number higher than your number of anchored actors and see if that solves the problem.

AdventureIslands

  • *
  • Posts: 728
I'm having trouble finding it, where is engine.hx located?

rob1221

  • *
  • Posts: 9473
plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx

AdventureIslands

  • *
  • Posts: 728
I increased the number to 32 and it seems to be working now, the error message is not showing up and the actors are being killed like they should.

rob1221

  • *
  • Posts: 9473
I increased the limit to 64.  I'm not familiar with IntHashTable, so maybe Jon knows of a better solution.

Jon

  • *
  • Posts: 17524
The data structure shouldn't be size restricted like that.

Docs for that are here.

https://github.com/polygonal/ds/blob/master/src/de/polygonal/ds/IntHashTable.hx

My expectation is that if you pass in say, 16, it will auto-resize once that limit is reached.

I'm bringing this up because this same expectation will affect a lot more than just this fringe case, so we ought to look into it more.

rob1221

  • *
  • Posts: 9473
I see this section of code:
Code: [Select]
//Clean up HUD actors
if(!hudActors.isEmpty())
{
for(a in hudActors)
{
if(a.dead || a.recycled)
{
hudActors.clr(a.ID);
}
}
}

Is it safe to call clr (I guess that removes?) on an IntHashTable while iterating through it?

Jon

  • *
  • Posts: 17524
Yes, clr is a remove operation on the first instance.

I suppose we could play it safe and do a 2-pass, but it's been this way all along.