NateTheGreatt/bitECS

Setting world size larger than default blows up once the default size is reached.

luetkemj opened this issue ยท 7 comments

I'm building a standard multilevel dungeon roguelike. Each level creates around 3500 entities. If the default world size is left alone, at level 27 I get a very clear error message:

bitECS - max entities of 100,000 reached, increase with setDefaultSize function.

If I increase the limit to 1,000,000 I get a different error when I reach the original default of 100,000 entities.

Uncaught TypeError: Cannot read properties of undefined (reading 'fill')

Seems like some of the internals are still limited to the default world size.

For the sake of completeness I tried setting the default to 1,000 and instead get the correct error upon reaching 1,000 entities:

bitECS - max entities of 1,000 reached, increase with setDefaultSize function.

How To Repro:

Clone project and check out the world-size-bug-repro branch of my repo here: https://github.com/luetkemj/pixitest

Install deps
npm i

Start dev server:
npm start

Go to localhost:8080 in your favorite browser.

Your character @ starts on a stair case > just press and hold the > key until you get to the 27th floor or the game blows up. Default size is set to 1,000,000 on ln18 src/index.js.

I might suggest making a world per level, or bumping the max entities to something higher. Bitecs can handle millions of entities with no issues.

Thanks for the quick reply :)

bumping the max entities to something higher

I thought that's what setDefaultSize did? If it wasn't clear above, I set the defaultSize to 1,000,000 but get a fatal error after adding only 100,000 entities to the world. 100,000 is the original default size.

I might suggest making a world per level

Ideally, yes! That was the idea behind my first attempt at a multi-level dungeon, but on trying to save off and restore levels I ran into a different bug (#67)

Are you calling setDefaultSize before creating your world? If so that sounds like another bug that @NateTheGreatt will have to look into. I know he's in the middle of a refactor at the moment.

Are you calling setDefaultSize before creating your world?

Yep, it's the first thing I do after initial imports.

Thanks

@luetkemj did you or can you try the latest version of bitECS and let me know if the error still occurs? 0.3.34 is the latest version. seems like your branch is using an old version of 0.3.21. just want to make sure it's not already fixed ๐Ÿ™‚

@NateTheGreatt bug is fixed in 0.3.34 thanks!

awesome ๐Ÿ˜„ i'll close this issue then