Scripts in OpenBOR use a ton of memory, far more than they should. This is one of the engine's major shortcomings. But there are ways to mitigate this issue.
It's common to use the same animationscript for several models in a game. There's nothing inherently wrong with this practice; code reuse is good! But every time you load a model using that animationscript, OpenBOR recompiles it and gives it its own storage. In other words, if you have 20 characters using the same animationscript, the contents of that animationscript will be stored in memory 20 times!
There's an easy way around this, though. I'll demonstrate using magggas' fantastic, recently released
Double Dragon Reloaded. 113 models in the game all use the animationscript
. So let's rename
to
and create a new file
with this one line inside of it:
Code:
#import "data/scripts/ani0020_actual.h"
The
directive ensures that the script is only compiled and stored in memory once, instead of 113 times. And that's all! No further changes are needed. Just this one change brings the memory usage of Double Dragon Reloaded down from 118.6 MB to 52.5 MB, according to the Windows system monitor.
You can also do this with other kinds of scripts used by several models, with the caveat that script types other than animationscript have a
function, which the engine won't recognize if it's imported. The workaround is to rename
to
in
and then have this in
:
Code:
#import "data/scripts/scriptname_actual.c"
void main()
{
actual_main();
}
Or, if your main() function is already small, you can just move all of the other functions to the new file and leave main() where it is.