Engine Limits

DCurrent

Site Owner, OpenBOR Project Leader
Staff member
Hey guys, one of the things I've been doing as part of my property project is to try and decrease the memory footprint. It's not easy - the engine is already very optimal in most aspects. To squeeze out every last byte, I've been replacing a lot of internal variables with smaller types. This in turn results in smaller limits, albeit still academic.

One easy example is frames. Strictly speaking, OpenBOR does not actually have "frames" the way you think of them. There's just a set of arrayed properties on the animation strcture that taken together make up what is visually a frame on the screen. Previously the controlling integer values for each of those arrayed properties was a standard int, meaning they could range from -2,147,483,648 to 2,147,483,647. Standard practice for some good reasons, but in our case wasteful and leads to shortcut hacks I've been cleaning up. They are now a unsigned short int, making the range 0 to 65,535. Enough to put every single frame of a SFIII character in one animation and still have 64,000 or so left over. I think you'll be OK. :)

The important part is that it costs 2 bytes instead of 4. That's nothing alone, but multiplied by every animation for every entity it starts to make a difference. Doing the same thing for certain properties that exist per frame, or multiple per frame, really adds up. Bigger the module, the more it helps. Thus far I've taken one of my own projects from 83MB to 77MB.

Anyway, as I go, I'm putting these new (and old) limits on a single wiki page just so you can see them.

DC
 
Now that's what im talking about.  Love to see any memory management optimisation great work DC.

Will you also be looking into the character limit of text boxes right now its 128 but if more adventure or story heavy mods turn up this limit really hurts.  I thought of a work around using a seperate textbox for each individual letter but its long winded way of working.
 
Great, i would decrease attack types and remaps , these are big numbers, definitely over anything anyone could ever do realistically and practitally speaking.
Entities in play is probably the one that would be exceeded first if someone would try to make particles..
 
They're different animals...

bWWd said:
Great, i would decrease attack types and remaps , these are big numbers, definitely over anything anyone could ever do realistically and practitally speaking.

65,535 is as low as we can get. It's not an arbitrary limit you can just pull out of the sky, it has to do with the number of bits that comprise the number. The maximum range is always 2eBITS. That's why 8bit images are 256 colors, the color table is (2e8) = 256, 0 indexed from 0 to 255.

You might ask then, why not use 8bit numbers? 255 would be fine for a lot of things like color sets or active text objects, right? Not so much. There's no such thing as an 8bit variable unless you manually set the bit allocation, which completely breaks portability and incurs a massive speed penalty. Thus the smallest viable type is 16bit (2 bytes), the short int. We're actually lucky our compiler doesn't just allocate 4 bytes anyway, as many compilers will happily do.

As for the unsigned part, normally any numeric variable range is in both directions, because they're signed by default. So a short int ends up being 32,768 to 32,767 (one less on the positive side for 0). That's where the unsigned option comes in. It tells the compiler you want all possible values to be positive, giving you a range of 0 to 65,535.

Entities in play is probably the one that would be exceeded first if someone would try to make particles..

That one IS an arbitrary limit, set by yours truly. It's a sanity check to prevent the engine from crashing (a real crash, not an intentional shutdown) due to uncontrolled entity spawns. It was 1000 until recently. I need to make sure increasing further won't slow the engine down. If not, I'll be happy to run it up to something unreachable like 10K or so.

DC
 
Entities in play is probably the one that would be exceeded first if someone would try to make particles..
Depends, I don't think so. This would happen only if the coder uses it on a non-organized way.
I use particles on my mod and I never get even close to that previous limit of 1000.
 
Back
Top Bottom